transaction property

Transaction get transaction

Obtains the transaction with selected inputs and outputs including any change at a random location, ready to be signed. Throws InsufficientFunds if there is not enough input value to meet the output value and fee, or TransactionTooLarge if the resulting signed transaction would be too large.

Implementation

Transaction get transaction {
  if (!enoughFunds) throw InsufficientFunds();
  if (tooLarge) throw TransactionTooLarge();
  return Transaction(
    version: version,
    inputs: selected.map((candidate) => candidate.input),
    outputs: changeless ? recipients : insertRandom(
      recipients,
      Output.fromProgram(changeValue, changeProgram),
    ),
    locktime: locktime,
  );
}