Bitcoin Forum

Economy => Service Discussion => Topic started by: p4u on May 08, 2014, 05:44:14 PM



Title: blockchain.info API, problem in sendmany
Post by: p4u on May 08, 2014, 05:44:14 PM
Hi.
I'm working on this https://github.com/p4u/blockchain.py
It is a blockchain.info python API (I did not find any code light and working). I've problems with the "sendManyPayment" method, I hope you can help me.

According to blockchain.info API specification (https://blockchain.info/es/api/blockchain_wallet_api):

Code:
https://blockchain.info/es/merchant/$guid/sendmany?password=$main_password&second_password=$second_password&recipients=$recipients&shared=$shared&fee=$fee 

    $main_password Your Main My wallet password
    $second_password Your second My Wallet password if double encryption is enabled.
    $recipients Is a JSON Object using Bitcoin Addresses as keys and the amounts to send as values (See below).
    $from Send from a specific Bitcoin Address (Optional)
    $shared "true" or "false" indicating whether the transaction should be sent through a shared wallet. Fees apply. (Optional)
    $fee Transaction fee value in satoshi (Must be greater than default fee) (Optional)
    $note A public note to include with the transaction (Optional)

{
    "1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh": 100000000,
    "12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT": 1500000000,
    "1dice6YgEVBf88erBFra9BHf6ZMoyvG88": 200000000
}

Recipients is a JSON object with the BTC address as key and the amount in Satoshi as value.

Sending the recipients dictionary as is, does not work:

Code:
RuntimeError: ERROR: Invalid Recipients JSON. Please make sure it is url encoded and consult the docs.

And trying to encode it by

Code:
data['recipients'] = urllib.parse.urlencode(recipients)

Does not work either.

Code:
RuntimeError: ERROR: Invalid Recipients JSON. Please make sure it is url encoded and consult the docs.

Do you have any experience with it? Do you know which kind of data are they expecting? Could it be that they use another url encode RFC?

Thanks!

EDIT: typo


Title: Re: blockchain.info API, problem in sendmany
Post by: p4u on May 08, 2014, 06:40:02 PM
I've made some advances.

This is the HTTP/post content I'm sending now with the last code of my github repository.

Quote
recipients=%7B%221KfC6Q1GLxSJm3QdMRqi745QN2nJ7JjsQC%22%3A%22182445.18%22%2C%22181rvCtNX5uPYkcDfpNrM9itC6LRdQBUYP%22%3A%22150000.0%22%7D

Now blockchain.info says:

Quote
RuntimeError: ERROR: java.lang.String cannot be cast to java.lang.Long

lol


Title: Re: blockchain.info API, problem in sendmany
Post by: p4u on May 09, 2014, 10:15:04 AM
Finally I found it. Seems that blockchain.info does not accept amounts in decimal format. They use "Satoshis" (I already knew that) but amount must be integer.

So, blockchain.py library is working fine :) Feel free to use it.


Title: Re: blockchain.info API, problem in sendmany
Post by: ExchangeCurrency on October 24, 2014, 04:18:04 AM
Hi,
i had alot of problems with this Bitcoin API too, specialy the callback URL
after 2 nights of Headaches,i finaly found the problem :p
this is a DEMO, who is interesting to integrate this LOVELY API on his website he can "Check before Buy" here is the link : http://ex-currency.com/btc/index.php
Payment Sent/Recieved/Confirmed IMMEDIATLY
the price of curiosity is 1 USD