addOutput method
Returns a new Transaction with the output
added to the end of the
output list.
Implementation
Transaction addOutput(Output output) {
final modifiedInputs = inputs.asMap().map(
(i, input) => MapEntry(
i, input.filterSignatures(
(insig)
// Allow signatures that sign no outpus
=> insig.hashType.none
// Allow signatures that sign a single output which isn't the one
// being added
|| (insig.hashType.single && i != outputs.length),
),
),
).values;
return Transaction(
version: version,
inputs: modifiedInputs,
outputs: [...outputs, output],
locktime: locktime,
);
}