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) {
if (signature.length != nacl.signatureLength)
throw Exception('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);
if (signerIndex < 0) throw Exception('Unknown transaction signer.');
signatures[signerIndex] = signature;
}