fromRaw static method
Implementation
static (TxInput, int) fromRaw(
{required String raw, int cursor = 0, bool hasSegwit = false}) {
final txInputRaw = hexToBytes(raw);
Uint8List inpHash = Uint8List.fromList(
txInputRaw.sublist(cursor, cursor + 32).reversed.toList());
if (inpHash.isEmpty) {
throw ArgumentError(
"Input transaction hash not found. Probably malformed raw transaction");
}
Uint8List outputN = Uint8List.fromList(
txInputRaw.sublist(cursor + 32, cursor + 36).reversed.toList());
cursor += 36;
final vi = viToInt(txInputRaw.sublist(cursor, cursor + 9));
cursor += vi.$2;
Uint8List unlockingScript = txInputRaw.sublist(cursor, cursor + vi.$1);
cursor += vi.$1;
Uint8List sequenceNumberData = txInputRaw.sublist(cursor, cursor + 4);
cursor += 4;
return (
TxInput(
txId: bytesToHex(inpHash),
txIndex: int.parse(bytesToHex(outputN), radix: 16),
sig: Script.fromRaw(
hexData: bytesToHex(unlockingScript), hasSegwit: hasSegwit),
sq: sequenceNumberData),
cursor
);
}