fee is always calculated from fee_rate & weight of tx and that's done after the creation of tx -> thus it's rational to take fee_rate instead of fee in the parameters.
[ ] check whether it's feasible to spend given amount.
when send_amount= SendAmount::Amount , then we directly consider the given amount as utxo output value and we do not check whether it's feasible to send that amount or not.
If the change amount i.e (remaining= total_input_value- fee-amount - amount) > minimal_dust_amt -> then a change utxo is created while deducting fee from remaining.
[ ] Take
fee_rate
instead offee
:fee_rate
&weight of tx
and that's done after the creation of tx -> thus it's rational to takefee_rate
instead offee
in the parameters.[ ] check whether it's feasible to spend given amount.
when
send_amount= SendAmount::Amount
, then we directly consider the given amount as utxo output value and we do not check whether it's feasible to send that amount or not.If the change amount i.e
(remaining= total_input_value- fee-amount - amount) > minimal_dust_amt
-> then a change utxo is created while deducting fee from remaining.But there are two edges :
amount ~= total_input_value && amount> total_input_value:
remaining < minimal_dust_amt
-> no fee deducted.(total_input_value < amount)
-> panic occurs due to overflow