fromRaw static method
Implementation
static Tuple2<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.item2;
Uint8List unlockingScript = txInputRaw.sublist(cursor, cursor + vi.item1);
cursor += vi.item1;
Uint8List sequenceNumberData = txInputRaw.sublist(cursor, cursor + 4);
cursor += 4;
return Tuple2(
TxInput(
txId: bytesToHex(inpHash),
txIndex: int.parse(bytesToHex(outputN), radix: 16),
sig: Script.fromRaw(
hexData: bytesToHex(unlockingScript), hasSegwit: hasSegwit),
sq: sequenceNumberData),
cursor);
}