xrpl
Version:
A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser
27 lines (23 loc) • 800 B
text/typescript
import { encodeForSigningClaim } from 'ripple-binary-codec'
import { sign } from 'ripple-keypairs'
import { Wallet } from './index'
/**
* Creates a signature that can be used to redeem a specific amount of XRP from a payment channel.
*
* @param wallet - The account that will sign for this payment channel.
* @param channelId - An id for the payment channel to redeem XRP from.
* @param amount - The amount in drops to redeem.
* @returns A signature that can be used to redeem a specific amount of XRP from a payment channel.
* @category Utilities
*/
export function authorizeChannel(
wallet: Wallet,
channelId: string,
amount: string,
): string {
const signingData = encodeForSigningClaim({
channel: channelId,
amount,
})
return sign(signingData, wallet.privateKey)
}