fromRaw static method

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

Implementation

static (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.$2;
  Uint8List lockScript = txoutputraw.sublist(cursor, cursor + vi.$1);
  cursor += vi.$1;
  return (
    TxOutput(
        amount: BigInt.from(value),
        scriptPubKey: Script.fromRaw(
            hexData: bytesToHex(lockScript), hasSegwit: hasSegwit)),
    cursor
  );
}