SolanaTransaction.deserialize constructor
Deserializes a Solana transaction from a serialized buffer.
Implementation
factory SolanaTransaction.deserialize(List<int> serializedTransaction,
{bool verifySignatures = false}) {
final emptySignatureBytes = List<int>.unmodifiable(
List<int>.filled(SolanaTransactionConstant.signatureLengthInBytes, 0));
final message =
SolanaTransactionUtils.deserializeTransaction(serializedTransaction);
final transaction = SolanaTransaction._(
List.generate(message.item1.header.numRequiredSignatures,
(index) => List<int>.unmodifiable(emptySignatureBytes)),
message: message.item1);
final signerPubkeys = message.item1.accountKeys
.sublist(0, message.item1.header.numRequiredSignatures);
for (int i = 0; i < message.item2.length; i++) {
if (BytesUtils.bytesEqual(
emptySignatureBytes, message.item2.elementAt(i))) {
continue;
}
transaction.addSignature(
signerPubkeys.elementAt(i), message.item2.elementAt(i),
/// Supports only versioned Transaction legacy or V0.
/// Older Transactions may fail.
verifySignature: verifySignatures);
}
return transaction;
}