6

Let's say it's pay day--I've accumulated a lot of bitcoins, and sent them all to a single address. I now want to pay a lot of addresses from this "pool" of coins, say anywhere between 100 and 10,000 addresses. What is the best way to do this in a way I can use with PHP, and with which client would be the best fit? I'm currently familiar with bitcoind and electrum.

The problems I see happening is:

  1. If I make them one after another, I would have to wait for a confirmation between each each transaction.
  2. If I somehow send them all in one transaction, I would need to a) mess with raw transactions, and b) possibly hit a limit on the transaction size.

Is it possible to do this without using raw transactions? And how do I check to see how many addresses I can send to at once without hitting the max transaction size? If I DO have to deal with raw transactions, is there any library in PHP that helps me build them easily?

Thank you.

timetofly
  • 201
  • 2
  • 9

2 Answers2

4

In Electrum you can use the CSV import feature to make bulk payments. It can accept either a CSV file or CSV entered into a text box. The rough format is:

ADDRESS, 0.12345
ADDRESS, 0.12314

This feature has been merged into the 1.9 version that is not released yet, but you can use it already.

https://github.com/spesmilo/electrum/pull/282

Example:

1PkeTTctdh2CvhW3fQLs93PWP9qupWV68X, 5
3NujXLC3LxNsmk2wr69CLBuXGfhXeenUyu, 5
1CNAnSb7d1XCA4AXBH2gip3mi8dNTQxzeo, 1
1LSBFJ1An9orRMU6Bz3NS1y3jr1eH9AexE, 1
16qRyDVZVpptJb4HZzv5rWkjqtJWVRjDep, 1
1PkeTTctdh2CvhW3fQLs93PWP9qupWV68X, 5
1Nnad832Zyob64wGbju49CC5RFbACAfCNZ, 1
1J2gFYBnf8K2wHJDndgr3iN1nPoZumHXap, 5

The amount is in the unit your Electrum is configured. In my case, for example, it is in mBTC. Be careful with this!

Felipe
  • 1,738
  • 3
  • 19
  • 33
rdymac
  • 1,437
  • 8
  • 10
  • Oh that is cool. How does it handle transactions that get too big for a single transaction--does it split them up? Any idea when this version is going to be released as stable? In the history panel, it looks like right clicking -> Details doesn't show the popup box anymore. – timetofly Sep 24 '13 at 15:15
  • I've been looking for someone who would know about the big transactions handling, will be asking. The release is around the corner. – rdymac Sep 27 '13 at 06:37
  • @user371699 Electrum's CSV import works the same as the Send function, so a bigger fee will be needed for a big single transaction. – rdymac Oct 16 '13 at 10:40
  • I believe there is still a size limit for every transaction in the protocol, something like 10KB? I wonder if Electrum knows this limit and splits it into multiple transactions? – timetofly Oct 16 '13 at 22:00
  • 1
    Quote: "It doesn't split txs. The limit is 100KB, so it shouldn't be an issue. Fee would probably be 1 BTC though" – rdymac Oct 17 '13 at 00:51
3

At least when you're using bitcoind, the best solution is using the sendmany RPC call, which allows you to create a single transaction that does many payouts. The transaction will be much smaller (in bytes) than the many single-payment transactions you had in mind (over 6 times, for 100 outputs), resulting in lower fees in total for the same effect.

Also, even if you'd use separate transactions for each (though I advise against that), there is no need to wait for confirmations between the different transactions, as the implementation allows sending 0-confirms transactions if they're from yourself.

Pieter Wuille
  • 105,497
  • 9
  • 194
  • 308