Transaction via Blockchain API using Multiple recipients

689 Views Asked by At

Im trying to send bitcoins using Blockchain.info API to both adresses in 'recipes':

recipes ={'1Pd9gXJ8EqyGrqMKVevQWNjjF4B4dcSykf':10000,'14gVMjoCbjaGU3s9EQghVxYTAJgkmqqtHV':10000}

My request looks like:

url_multi = 'https://blockchain.info/nl/merchant/MYKEY/sendmany?password=MYPASSWORD&recipients='+recipes+'&fee=15000'

requests.get(url_multi)

I managed to send txs to single adresses using the examples in the documentation. However, sending to multiple adresses at once requires a dict according to the PHP-example.

In Python, the following Typerror gets returned; TypeError: cannot concatenate 'str' and 'dict' objects

How do I add multiple recipients to the request without using a dict?

1

There are 1 best solutions below

0
On

recipes should have been a JSON object instead. So I converted it before adding it to the URL. Works fine now.

x = json.dumps(recipes) 

url_multi = 'https://blockchain.info/nl/merchant/MYKEY/sendmany?password=MYPASSWORD&recipients='+x+'&fee=15000'

requests.get(url_multi)

I suck sometimes ;(