serialize method

List<int> serialize()

Returns a buffer containing the serialized bytearray for this TransactionInput

Implementation

List<int> serialize() {

    if (_unlockingScriptBuilder == null) return Uint8List(0);

    var writer = ByteDataWriter();

    writer.write(HEX.decode(_prevTxnId!).reversed.toList(), copy: true);

    writer.writeUint32(_prevTxnOutputIndex!, Endian.little);

    var scriptBytes = _unlockingScriptBuilder!.getScriptSig().buffer;

    // varIntWriter(scriptBytes.length).toList()
    var scriptSize = VarInt.fromInt(scriptBytes.length);
    writer.write(scriptSize.encode(), copy: true);
    writer.write(scriptBytes, copy: true);

    writer.writeUint32(sequenceNumber, Endian.little);

    return writer.toBytes().toList();
}