mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 03:35:49 +00:00
28 lines
765 B
TypeScript
28 lines
765 B
TypeScript
import { encodeForSigningClaim } from '@transia/ripple-binary-codec'
|
|
import { sign } from '@transia/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 = encodeForSigningClaim({
|
|
channel,
|
|
amount: xrpToDrops(amount),
|
|
})
|
|
return sign(signingData, privateKey)
|
|
}
|
|
|
|
export default signPaymentChannelClaim
|