Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: cloverme on May 13, 2016, 03:10:40 AM



Title: Bitcoin client RPC/json sendmany
Post by: cloverme on May 13, 2016, 03:10:40 AM
I'd like to bundle some send transactions together programmatically to save on transaction fees.  It looks like the sendmany API call to via RPC will do this, but I have some questions if anyone has used this API call before. 

Is there an upward limit per sendmany transaction? 100, 255, 1000?

Any way to easily calculate the appropriate transaction fee for such a transaction?

Thanks in advance  ;)


Title: Re: Bitcoin client RPC/json sendmany
Post by: belcher on May 13, 2016, 12:08:47 PM
The upper limit will be set by the maximum size of transactions in blocks. If you look at the transactions from some exchanges, you'll see some of them are quite large and seem to confirm without any problems.

I believe sendmany uses the wallet transaction fees settings to automatically work out how much it should pay in miner fees.

It's best to play with this stuff in testnet first, because you can then just try it and see without any danger of losing valuable coins or paying too much or too little in fees.


Title: Re: Bitcoin client RPC/json sendmany
Post by: Patatas on May 13, 2016, 12:46:54 PM
Is there an upward limit per sendmany transaction? 100, 255, 1000?
As far as I know,there is no limit as such but considering the transaction size and the related fees ,you probably have to set your own limits.Doesn't it depends on the block-size as well ? Clear me if I missed something there.

Any way to easily calculate the appropriate transaction fee for such a transaction?
To describe in detail ,check this :
Quote
9
down vote
accepted
See GetMinFee() in main.h for the code which determines the minimum transaction fee.

The part you're describing is implemented as follows:

// Raise the price as the block approaches full
if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2)
{
    if (nNewBlockSize >= MAX_BLOCK_SIZE_GEN)
        return MAX_MONEY;
    nMinFee *= MAX_BLOCK_SIZE_GEN / (MAX_BLOCK_SIZE_GEN - nNewBlockSize);
}
where:

nBlockSize depends on who we are:
if we're a user making a new transaction, nBlockSize is 1
if we're a node deciding whether to relay an incoming transaction, nBlockSize is 1000
if we're a miner deciding which transactions to include in a new block, nBlockSize is the size of the block we're building before adding the new transaction
nNewBlockSize is the size of the block including the new transaction
MAX_BLOCK_SIZE_GEN is 500kB
MAX_MONEY is 21 million BTC (all the money in the world)
so it's saying:

if we're either deciding whether to relay or mine the transaction, and adding the transaction would make the block over 50% full:
never allow a transaction that makes the block 100% full
otherwise scale the fee up by a factor of 500kB / (500kB - nNewBlockSize)
Note: by rearranging the symbols, we get exactly what Meni wrote in his answer:

Fee = Normal fee / ((500kB - size) / 500kB) = Normal fee / (1 - size / 500kB)

Source : http://bitcoin.stackexchange.com/questions/3400/what-is-the-exact-formula-for-calculating-transaction-fees

The easy way could be taking the size of the transaction into consideration and assuming standard fee of 0.0001kb,you can do the math.


Title: Re: Bitcoin client RPC/json sendmany
Post by: cloverme on May 13, 2016, 04:17:23 PM
Thanks... Good ideas and information here.  8)

Yeah, I was planning on testing the functionality on testnet beforehand, I think I got enuff testnet coins to play with lol