Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: shark255 on December 11, 2013, 03:12:19 PM



Title: question about transferring money from many addresses bitcoind
Post by: shark255 on December 11, 2013, 03:12:19 PM
On many services - gambling and others - every user gets unique payment address.

According to this doc - https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list
i can do it with getnewaddress.
Also i can get total amount - getbalance.

And this command -
sendfrom    <fromaccount> <tobitcoinaddress> <amount> [minconf=1] [comment] [comment-to]

What is withdrawal logic ? It takes money from random addressess if only total amount allows to do its operation?


Title: Re: question about transferring money from many addresses bitcoind
Post by: cnk on December 13, 2013, 10:48:25 AM
What is withdrawal logic ? It takes money from random addressess if only total amount allows to do its operation?

bitcoind uses stochastic approximation to select a subset of unspent outputs to spend.
(actual code : https://github.com/bitcoin/bitcoin/blob/master/src/wallet.cpp#L1043-L1185)

There is an old thread about it here: https://bitcointalk.org/index.php?topic=29207.0