sign method
Signs the transaction with the given keypair for a specific network.
Adds a signature to this transaction using the provided signer keypair.
The signature is computed over the transaction hash for the specified network.
Multiple signatures can be added by calling this method multiple times with
different signers.
Parameters:
signerThe KeyPair to sign with (must have the private key)networkThe Network passphrase (e.g., Network.TESTNET or Network.PUBLIC)
Security notes:
- Always verify you're signing for the correct network
- Never reuse signatures across different networks
- The transaction hash includes the network passphrase to prevent replay attacks
Example:
transaction.sign(sourceKeyPair, Network.TESTNET);
// For multi-sig, add additional signatures
transaction.sign(secondKeyPair, Network.TESTNET);
Implementation
void sign(KeyPair signer, Network network) {
_mSignatures.add(signer.signDecorated(this.hash(network)));
}