shadowproject / shadow

ShadowCore integration/staging tree
MIT License
95 stars 62 forks source link

[Bug] Calculating private transaction fees. #66

Open kewde opened 7 years ago

kewde commented 7 years ago

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.

dasource commented 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.

kewde commented 7 years ago

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).

kewde commented 7 years ago

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.

kewde commented 7 years ago

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.