Open kewde opened 7 years ago
Maybe spending the dust amount as a fee would clear this up (warn the user before doing so)? i.e. Take all the inputs and calculate fee = max widthdraw (with largest fee possible) ... on spend send the max withdraw amount + (relevant fee + extra dust) to miner. That should leave you with 0 balance.
That was initially what I planned on doing, seems like the easiest way to translate it into code too. Small recursive function, constantly lowering the amount untill it can fit both the amount and the fee (and then include the dust as fee).
Okay, so I'm modifying EstimateAnonFee() and creating a new EstimateAnonFeeIncluded() which will do a while loop of EstimateAnonFee, deducting the fee from the amount to spend until it is below max amount.
I'm currently lowering nMaxAmount in steps of TX_MIN_ANON_FEE, which is the lowest barrier to spend something which seems like a foolproof step to me.
When trying to spend the full amount of SDT, it often ends up being a messy procedure with lots of trial and error.
When you lower the amount to accommodate for the fee, it often increases the transaction size causing it to require a larger fee. It's a vicious cycle that eventually stops.