Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (this.hasMultiSigners()) {
return this;
}
const prev_sig = this.tx_json.TxnSignature;
delete this.tx_json.TxnSignature;
const hash = this.signingHash();
// If the hash is the same, we can re-use the previous signature
if (prev_sig && hash === this.previousSigningHash) {
this.tx_json.TxnSignature = prev_sig;
return this;
}
const keypair = deriveKeypair(secret || this._secret);
this.tx_json.TxnSignature = sign(new Buffer(this.signingData(), 'hex'),
keypair.privateKey);
this.previousSigningHash = hash;
return this;
};
function computeSignature(tx, privateKey, signAs) {
const signingData = signAs ?
binary.encodeForMultisigning(tx, signAs) : binary.encodeForSigning(tx);
return rippleKeypairs.sign(signingData, privateKey);
}
function computeSignature(tx: Object, privateKey: string, signAs: ?string) {
const signingData = signAs ?
binary.encodeForMultisigning(tx, signAs) : binary.encodeForSigning(tx)
return keypairs.sign(signingData, privateKey)
}
function signPaymentChannelClaim(
channel: string,
amount: string,
privateKey: string
): string {
validate.signPaymentChannelClaim({channel, amount, privateKey})
const signingData = binary.encodeForSigningClaim({
channel: channel,
amount: xrpToDrops(amount)
})
return keypairs.sign(signingData, privateKey)
}
function computeSignature(tx: object, privateKey: string, signAs?: string) {
const signingData = signAs
? binaryCodec.encodeForMultisigning(tx, signAs)
: binaryCodec.encodeForSigning(tx)
return keypairs.sign(signingData, privateKey)
}