I'm using the json API. I need to keep all the account balances positive: I call
getbalance first, check if it has enough bitcoins to proceed, and then
This approach causes two problems.
Problem 1 is that this is not an atomic operation, so after the first
getbalance the balance could actually be changed.
Problem 2 only happens with
sendfrom: there might be a transaction fee, hence if the user sends his entire balance, he'll have a negative balance due to that.
Solution to Problem 2 would be to know in advance the transaction fee: I noticed (though I didn't try) I can set it with
settxfee, but I found no call to get it, is there?
While I could implement some external lock mechanism to solve Problem 1, I'd rather use a bitcoind native method, though I get it does not exist, does it? Hacking the
sendfrom function to have it check the balance before sending would be enough, I guess?