Pages:
Author

Topic: [1 BTC BOUNTY] A way to use sendmany - page 2. (Read 5169 times)

legendary
Activity: 1400
Merit: 1005
July 01, 2011, 12:26:39 AM
#11
Here is a solution in Python: I usually use the excellent Bitcoin Python Library "authproxy.py" by Jeff Garzik. Here is a version with a few improvements I added: http://pastebin.com/RZNMCGRe . Save this as authproxy.py .

Then you can use this code to use sendmany:

Code:
from authproxy import AuthServiceProxy, JSONRPCException

RPC_URL = "http://rpcuser:[email protected]:8332"

bitcoind = AuthServiceProxy(RPC_URL)

try:
    recipients = { '14Z1mazY4HfysZyMaKudFr63EwHqQT2njz': 50.0
                 , '147dRpRoYQxpf5WGnz7dipCcavtANRRfjt': 50.0
                 }
    bitcoind.sendmany("", recipients)
except JSONRPCException as e:
    print "Error: %s" % e.error['message']

You can try out the above code on an empty wallet. You should get an "account has insufficient funds" error.

If this code is to your satisfaction, I humbly request the bounty to go to this address: 1fYHRKUXnFfj7ZhjwMMNqddjcnkGtq4wA . :-)

Ok, you'll have to forgive me, because I know very little about python except for how to open one from the command line.  Tongue  What do I do with the library file?
legendary
Activity: 1400
Merit: 1005
June 30, 2011, 12:51:11 PM
#10
Provided codler's or jav's solution works for me, the bounty has been claimed.  If they both work, I will pay them each half of the bounty, since they are both good solutions.
full member
Activity: 191
Merit: 100
June 30, 2011, 12:49:06 PM
#9
Add this method in BitcoinClient class, I haven't tested but it should be like this.

Code:
  /**
   * Returns Transaction id (txid)
   *
   * @param string $fromAccount Account to send from
   * @param array $sendTo Key=address Value=amount
   * @param integer $minconf
   * @param string $comment
   * @return string Hexadecimal transaction ID on success.
   * @throws BitcoinClientException
   * @since 0.3.21
   * @author codler
   */
  public function sendmany($fromAccount, $sendTo, $minconf = 1, $comment=NULL) {
    if (!$fromAccount || empty($fromAccount))
      throw new BitcoinClientException("sendmany requires an account");
    if (!is_numeric($minconf) || $minconf < 0)
      throw new BitcoinClientException('sendmany requires a numeric minconf >= 0');
 
    if (!$comment)
      return $this->query("sendmany", $fromAccount, $sendTo, $minconf);
    return $this->query("sendmany", $fromAccount, $sendTo, $minconf, $comment);
  }
legendary
Activity: 1400
Merit: 1005
June 30, 2011, 12:37:27 PM
#8
Thanks jav.  I can't give that a try right at the moment (will have to wait about 12 hours before I get home and can try it), but hopefully that will work.  If it does, I'll send you your 1 BTC.

Codler, I wish, but there is no sendmany function built in to bitcoin-php.  The project was abandoned a couple of months back because the dev didn't have time to update it, and that was before sendmany was built in as an rpc command.

Unless, you have some php files I don't have...  in which case, let me know where you got them!

He's just using jsonRPCclient directly, which should work.
Sheesh, is it really that simple?  Well I hope to try it soon.  That would be great if it worked that cleanly.

Does anyone know if there is a practical maximum to the number of addresses I can put in a sendmany request?  I've read a couple of posts about bitcoind locking up around 30 addresses or so, but I'm not sure if that was just an initial bug, or if it still exists and I shouldn't try to send to more than that at the same time.
hero member
Activity: 588
Merit: 500
June 30, 2011, 12:14:14 PM
#7
Thanks jav.  I can't give that a try right at the moment (will have to wait about 12 hours before I get home and can try it), but hopefully that will work.  If it does, I'll send you your 1 BTC.

Codler, I wish, but there is no sendmany function built in to bitcoin-php.  The project was abandoned a couple of months back because the dev didn't have time to update it, and that was before sendmany was built in as an rpc command.

Unless, you have some php files I don't have...  in which case, let me know where you got them!

He's just using jsonRPCclient directly, which should work.
legendary
Activity: 1400
Merit: 1005
June 30, 2011, 11:16:49 AM
#6
Thanks jav.  I can't give that a try right at the moment (will have to wait about 12 hours before I get home and can try it), but hopefully that will work.  If it does, I'll send you your 1 BTC.

Codler, I wish, but there is no sendmany function built in to bitcoin-php.  The project was abandoned a couple of months back because the dev didn't have time to update it, and that was before sendmany was built in as an rpc command.

Unless, you have some php files I don't have...  in which case, let me know where you got them!

I don't know what bitcoin-php is. Could you link bitcoin-php? Maybe I can implement it.
Sure thing:  http://www.nostate.com/3962/bitcoin-php-a-php-library-for-bitcoin/
full member
Activity: 191
Merit: 100
June 30, 2011, 11:02:29 AM
#5
Thanks jav.  I can't give that a try right at the moment (will have to wait about 12 hours before I get home and can try it), but hopefully that will work.  If it does, I'll send you your 1 BTC.

Codler, I wish, but there is no sendmany function built in to bitcoin-php.  The project was abandoned a couple of months back because the dev didn't have time to update it, and that was before sendmany was built in as an rpc command.

Unless, you have some php files I don't have...  in which case, let me know where you got them!

I don't know what bitcoin-php is. Could you link bitcoin-php? Maybe I can implement it.
legendary
Activity: 1400
Merit: 1005
June 30, 2011, 10:44:54 AM
#4
Thanks jav.  I can't give that a try right at the moment (will have to wait about 12 hours before I get home and can try it), but hopefully that will work.  If it does, I'll send you your 1 BTC.

Codler, I wish, but there is no sendmany function built in to bitcoin-php.  The project was abandoned a couple of months back because the dev didn't have time to update it, and that was before sendmany was built in as an rpc command.

Unless, you have some php files I don't have...  in which case, let me know where you got them!
full member
Activity: 191
Merit: 100
June 30, 2011, 07:27:18 AM
#3
Isn't it just do like this?

Code:
require_once 'jsonRPCClient.php';
$bitcoin = new jsonRPCClient('http://user:[email protected]:8332/');
$fromAccount = "";
// {address:amount,...}
$sendTo = array(
  '1NRo5XtmfDWfwiN2fY9A7kj9rs1rx3jJok' => 1,
  '19u9uMbEdCRTyrLszCEiJCAzNJURUTaS4T' => 1,
);

echo "
\n";
echo "txid: ".$bitcoin->sendmany($fromAccount, $sendTo)."\n";
echo "
";
jav
sr. member
Activity: 249
Merit: 251
June 30, 2011, 03:36:49 AM
#2
Here is a solution in Python: I usually use the excellent Bitcoin Python Library "authproxy.py" by Jeff Garzik. Here is a version with a few improvements I added: http://pastebin.com/RZNMCGRe . Save this as authproxy.py .

Then you can use this code to use sendmany:

Code:
from authproxy import AuthServiceProxy, JSONRPCException

RPC_URL = "http://rpcuser:[email protected]:8332"

bitcoind = AuthServiceProxy(RPC_URL)

try:
    recipients = { '14Z1mazY4HfysZyMaKudFr63EwHqQT2njz': 50.0
                 , '147dRpRoYQxpf5WGnz7dipCcavtANRRfjt': 50.0
                 }
    bitcoind.sendmany("", recipients)
except JSONRPCException as e:
    print "Error: %s" % e.error['message']

You can try out the above code on an empty wallet. You should get an "account has insufficient funds" error.

If this code is to your satisfaction, I humbly request the bounty to go to this address: 1fYHRKUXnFfj7ZhjwMMNqddjcnkGtq4wA . :-)
legendary
Activity: 1400
Merit: 1005
June 30, 2011, 02:46:19 AM
#1
I just want to send BTC to a list of addresses I have.  Really, it's a simple request, and I thought it would have a simple answer, but I can find no simple answer.

bitcoin-php does not have the sendmany function in its library, and I have been unable to successfully add it.  I just don't know enough about json formatting and how to go back and forth between the two.

So, I will pay 1 BTC for a script, preferably in php, but acceptable in python or curl as well, that will allow me to quickly and easily send BTC to a list of addresses and amounts.
Pages:
Jump to: