# Gavin Andresen # 2011-08-14 23:36:56 # https://bitcointalk.org/index.php?topic=37126.msg456222#msg456222 RE: negative account balances: @p{par} There is (was?) a patch proposed with an RPC call to prepare a send transaction, which would lock the inputs involved and return the transaction fee and a transaction id. And commit/reject RPC calls, which take the transaction id and either commit it or rejects it. That's the only really right way to estimate transaction fees before sending. I haven't reviewed the patch, and I don't think it has been thoroughly tested; there might be denial-of-service attacks possible or odd edge cases (e.g. could one customer who decides to go to lunch while the "this transaction will cost you 0.0005 BTC, OK/Cancel?" dialog is open tie up the entire wallet's balance, making sends fail for everybody?) @p{par} There's also an estimatetxfee patch, but the problem is that between the time you estimate the tx fee and the time the send happens the state of the wallet might change, making the estimate wrong. @p{par} The real question is why should customer A pay a transaction fee just because customer B funded their account with tons of tiny transactions? If customer A puts 1,000 bitcoins in their account and pays 0 fee, they're going to be pretty upset at you if you charge them to withdraw @p{(bf}THEIR@p{bf)} money from the account. @p{par} For ClearCoin, I just treated transaction fees as a cost of doing business, and refunded customer accounts when a send resulted in a transaction fee (via the RPC move method from a special FEES account that I pre-funded to cover transaction fees). @p{par} So sends look like: @p{brk} sendfrom "account" @p{lt}to@s{gt} @p{lt}amount@s{gt} @p{brk} ... return txid @p{brk} gettransaction @p{lt}txid@s{gt} @p{brk} ... return txinfo @p{brk} if txinfo says a fee was paid: @p{brk} move "FEES" "account" @p{lt}amount-of-fee-paid@s{gt} @p{par} @p{brk} RE: static addresses @p{par} I don't follow. You mean have one address per account? You could call getaddressesbyaccount and the return the first address or (if empty array) return getaccountaddress? Or if you create an account when a user signs up for your service, call getaccountaddress and then you KNOW that getaddressesbyaccount will return at least one address. @p{brk}