Having worked on a few sites using bitcoind, a recurring pain point for me (and apparently many others) has been the inability to know the fee prior to sending. This is particulary troublesome because the fee can vary wildly as a percentage of the send total, and business rules may preclude sending when a fee is higher than a given percentage.
It's sort of like if you walk into Western Union or Money Gram, and ask how much it will cost to send money. They say, don't worry about it.... it's kinda complicated to figure out so just leave us your credit card and you can look at your statement later to find out how much we charged you. They don't do that because people would not accept it. We like to know up front, or at least be able to set limits.
Often when sending bitcoin it may be desirable to wait until the fee is less -- either because the coins have aged, or we have restructured our inputs, or we are sending a larger total resulting in a smaller percentage fee.
In other words, the fee itself can be an important factor in decision making whether to send a transaction.
I understand it may be difficult or problematic to implement a getsendfee() type of API because the fee could change, etc.
However I know that for my own use cases, it would be very helpful to be able to set a fee limit. So that sendtoaddress or sendmany would succeed if the fee is below the limit and fail if over.
So the APIs could be:
sendtoaddress "bitcoinaddress" amount ( "comment" "comment-to" "max-fee" )
sendmany "fromaccount" {"address":amount,...} ( minconf "comment" "max-fee" )
where max-fee can be either:
a) a fixed amount, eg: 0.001
b) a percentage amount, eg: 1%
If the transaction would exceed max-fee then an error is thrown. Applications can catch that error and optionally try again with a different combination of amount and max-fee. At least the app knows the fee was insufficient and can act accordingly.
Use cases for this functionality1. A merchant or other bitcoin receiving website maintains a hot wallet and regularly sweeps to cold-storage.
Owner wishes to wait until either:
a) enough funds have accumulated and coins aged sufficiently to send with 0 fee.
b) funds total passes a given threshold, and will then accept up to a 1% fee.
c) funds total passes a higher threshold and will then accept up to a 3% fee.
etc.
2. A mining pool or other agent needs to send to many recipients.
Agent wishes to wait until enough funds have accumulated and coins aged sufficiently to send with 0 fee.
Agent will send to individuals sooner if requested, but will deduct max_fee amount from their payment to cover the send fee.
But what about floating fees and txconfirmtarget?At first I was hoping that floating fees would remove this pain point, but it doesn't really seem like it does. According to Gavin:
There is a new option that lets you control how quickly you’d like your transactions to confirm: txconfirmtarget. The default value is 1, meaning “I’d like my transactions to be sent with enough fee or priority so they are very likely to be included in the next block.” Set it to 6 and it will take on average six blocks for your transactions to get their first confirmation.
Now that sounds pretty fuzzy to me. I don't see how I can use that capability to enforce a business rule that we don't send unless fees are below X percentage. If it is possible, please enlighten me.
So... what do you think? good idea or bad? and how easy or hard to implement correctly?
I'd be glad to a crack at this and submit a patch, but only if there is some amount of consensus that it is desirable functionality and reasonably straight-forward to implement.