TxOut.deserialize constructor

TxOut.deserialize(
  1. Uint8List data,
  2. int offset
)

Deserialize transaction output

Implementation

factory TxOut.deserialize(Uint8List data, int offset) {
  int pos = offset;

  // Value (8 bytes)
  final value = _bytesToUint64(data, pos);
  pos += 8;

  // Public key script length
  final buffer = ByteData.sublistView(data);
  final scriptLen = VarInt.read(buffer, pos);
  pos += VarInt.size(scriptLen);

  // Public key script
  final pkScript = data.sublist(pos, pos + scriptLen);

  return TxOut(
    value: value,
    pkScript: pkScript,
  );
}