fromRaw static method

Tuple2<TxOutput, int> fromRaw({
  1. required String raw,
  2. required int cursor,
  3. bool hasSegwit = false,
})

Implementation

static Tuple2<TxOutput, int> fromRaw(
    {required String raw, required int cursor, bool hasSegwit = false}) {
  final txoutputraw = hexToBytes(raw);
  int value = ByteData.sublistView(txoutputraw, cursor, cursor + 8)
      .getInt64(0, Endian.little);
  cursor += 8;

  final vi = viToInt(txoutputraw.sublist(cursor, cursor + 9));
  cursor += vi.item2;
  Uint8List lockScript = txoutputraw.sublist(cursor, cursor + vi.item1);
  cursor += vi.item1;
  return Tuple2(
      TxOutput(
          amount: BigInt.from(value),
          scriptPubKey: Script.fromRaw(
              hexData: bytesToHex(lockScript), hasSegwit: hasSegwit)),
      cursor);
}