简体   繁体   中英

Transaction via Blockchain API using Multiple recipients

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?

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 ;(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM