createUnsignedTransaction method

Transaction createUnsignedTransaction({
  1. required Address toAddress,
  2. required Amount amount,
  3. required Address changeAddress,
})

Implementation

Transaction createUnsignedTransaction({
  required Address toAddress,
  required Amount amount,
  required Address changeAddress,
}) {
  final selectedUtxos = _selectUtxos(
    spendAmount: amount.raw,
    feePerInput: kFeePerInput,
  );

  final changeAmount = _getChangeRaw(
    selectedUtxos: selectedUtxos,
    spendAmount: amount.raw,
    feePerInput: kFeePerInput,
  );

  final payments = <Address, Int64>{
    toAddress: amount.raw.toInt64(),
    if (changeAmount > kFeePerInput) changeAddress: changeAmount.toInt64(),
  };

  final unsignedTransaction = _createUnsignedTransaction(
    utxos: selectedUtxos,
    payments: payments,
  );

  return unsignedTransaction;
}