mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-18 19:25:48 +00:00
31 lines
956 B
TypeScript
31 lines
956 B
TypeScript
import { encodeForSigningClaim } from '@transia/ripple-binary-codec'
|
|
import { verify } from '@transia/ripple-keypairs'
|
|
|
|
import { xrpToDrops } from './xrpConversion'
|
|
|
|
/**
|
|
* Verify the signature of a payment channel claim.
|
|
*
|
|
* @param channel - Channel identifier specified by the paymentChannelClaim.
|
|
* @param amount - Amount specified by the paymentChannelClaim.
|
|
* @param signature - Signature produced from signing paymentChannelClaim.
|
|
* @param publicKey - Public key that signed the paymentChannelClaim.
|
|
* @returns True if the channel is valid.
|
|
* @category Utilities
|
|
*/
|
|
// eslint-disable-next-line max-params -- Needs 4 params
|
|
function verifyPaymentChannelClaim(
|
|
channel: string,
|
|
amount: string,
|
|
signature: string,
|
|
publicKey: string,
|
|
): boolean {
|
|
const signingData = encodeForSigningClaim({
|
|
channel,
|
|
amount: xrpToDrops(amount),
|
|
})
|
|
return verify(signingData, signature, publicKey)
|
|
}
|
|
|
|
export default verifyPaymentChannelClaim
|