addOutput method

  1. @override
void addOutput({
  1. required Uint8List scriptPubKey,
  2. required BigInt value,
})
override

Implementation

@override
void addOutput({
  required Uint8List scriptPubKey,
  required BigInt value,
}) {
  _ensureSections();

  final outputKvs = <PsbtKeyValue>[];

  // PSBT_OUT_AMOUNT (0x03): 8-byte LE value
  final amountBytes = Uint8List(8);
  WireWriter(amountBytes).writeUInt64(value);
  outputKvs.add(PsbtKeyValue(
    key: Uint8List.fromList([PsbtOutputEntry.amount.keyType]),
    value: amountBytes,
  ));

  // PSBT_OUT_SCRIPT (0x04): scriptPubKey
  outputKvs.add(PsbtKeyValue(
    key: Uint8List.fromList([PsbtOutputEntry.script.keyType]),
    value: scriptPubKey,
  ));

  _sections.add(outputKvs);
  _outputCount++;
}