mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
convert existing xrpl library into a lerna monorepo
This commit is contained in:
27
packages/xrpl/src/utils/signPaymentChannelClaim.ts
Normal file
27
packages/xrpl/src/utils/signPaymentChannelClaim.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import binary from 'ripple-binary-codec'
|
||||
import keypairs from 'ripple-keypairs'
|
||||
|
||||
import { xrpToDrops } from './xrpConversion'
|
||||
|
||||
/**
|
||||
* Sign a payment channel claim.
|
||||
*
|
||||
* @param channel - Channel identifier specified by the paymentChannelClaim.
|
||||
* @param amount - Amount specified by the paymentChannelClaim.
|
||||
* @param privateKey - Private Key to sign paymentChannelClaim with.
|
||||
* @returns True if the channel is valid.
|
||||
* @category Utilities
|
||||
*/
|
||||
function signPaymentChannelClaim(
|
||||
channel: string,
|
||||
amount: string,
|
||||
privateKey: string,
|
||||
): string {
|
||||
const signingData = binary.encodeForSigningClaim({
|
||||
channel,
|
||||
amount: xrpToDrops(amount),
|
||||
})
|
||||
return keypairs.sign(signingData, privateKey)
|
||||
}
|
||||
|
||||
export default signPaymentChannelClaim
|
||||
Reference in New Issue
Block a user