addSignature method
Add an externally created signature to a transaction. The pubkey must correspond to the
fee payer or a signer account in the transaction instructions (Message.accountKeys).
Implementation
void addSignature(final Pubkey pubkey, final Uint8List signature) {
check(
signature.length == nacl.signatureLength,
'Invalid signature length ${signature.length}',
);
final int numRequiredSignatures = message.header.numRequiredSignatures;
final List<Pubkey> signerPubkeys = message.accountKeys.sublist(
0,
numRequiredSignatures,
);
final int signerIndex = signerPubkeys.indexWhere(
(signerPubkey) => signerPubkey == pubkey,
);
check(signerIndex >= 0, 'Unknown transaction signer.');
signatures[signerIndex] = signature;
}