feat: add transaction signature verification
This commit is contained in:
committed by
Michael Vines
parent
fd00571b0a
commit
d9a271742f
@@ -411,6 +411,22 @@ export class Transaction {
|
||||
this.signatures[index].signature = Buffer.from(signature);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify signatures of a complete, signed Transaction
|
||||
*/
|
||||
verifySignatures(): boolean {
|
||||
let verified = true;
|
||||
const signData = this._getSignData();
|
||||
for (const {signature, publicKey} of this.signatures) {
|
||||
if (
|
||||
!nacl.sign.detached.verify(signData, signature, publicKey.toBuffer())
|
||||
) {
|
||||
verified = false;
|
||||
}
|
||||
}
|
||||
return verified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the Transaction in the wire format.
|
||||
*
|
||||
|
Reference in New Issue
Block a user