2015-10-07 1 views
0

Я пытаюсь отправить платеж с использованием API оплаты Blockchain.Info. Я использую библиотеку Python, найденную на GitHub здесь: https://github.com/gowness/pyblockchain/blob/master/pyblockchain.pyОтправка платежа с использованием API Blockchain.info - Ошибка выполнения: ОШИБКА: Для строки ввода: .001

При запуске кода ниже возникает следующая ошибка: RuntimeError: ERROR: для строки ввода: «.001» Кто-нибудь знает, что здесь происходит? Я запускаю Python 2.7. Как только я получил первоначальную отправку одной транзакции, я хотел бы посмотреть на отправку нескольких транзакций.

from __future__ import print_function 
from itertools import islice, imap 
import csv, requests, json, math 
from collections import defaultdict 
import requests 
import urllib 
import json 
from os.path import expanduser 
import configparser 

class Wallet: 
guid  = 'g' 
isAccount = 0 
isKey  = 0 
password1 = 'x' 
password2 = 'z' 
url   = '' 

def __init__(self, guid = 'g', password1 = 'x', password2 = 'z'): 

    if guid.count('-') > 0: 
     self.isAccount = 1 
     if password1 == '': # wallet guid's contain - 
      raise ValueError('No password with guid.') 
    else: 
     self.isKey = 1 

    self.guid = guid 
    self.url = 'https://blockchain.info/merchant/' + guid + '/' 

    self.password1 = password1 
    self.password2 = password2 

def Call(self, method, data = {}): 
    if self.password1 != '': 
     data['password'] = self.password1 
    if self.password2 != '': 
     data['second_password'] = self.password2 

    response = requests.post(self.url + method,params=data) 

    json = response.json() 
    if 'error' in json: 
     raise RuntimeError('ERROR: ' + json['error']) 

    return json 

def SendPayment(self, toaddr='TA', amount='0.001', fromaddr = 'FA', shared = 0, fee = 0.0001, note = 'test'): 
    data = {} 
    data['address'] = toaddr 
    data['amount'] = amount 
    data['fee'] = fee 


    if fromaddr != '': 
     data['from'] = fromaddr 

    if shared == 1: 
     data['shared'] = 'true' 

    if note != '': 
     data['note'] = note 

    response = self.Call('payment',data) 

    return 

def SendManyPayment(self, txs = {} , fromaddr = 'FA', shared = 0, fee = 0.0001, note = 'test'): 
    responses = {} 

    for tx in txs: 
     SendPayment(self, tx[0], tx[1] , fromaddr , shared , fee , note) 

    return 



print(Wallet().SendPayment()) 

ответ

0

У меня есть исправление, сумма платежа должна быть в Сатоши, а не BTC. Должно было сначала взглянуть на документы API более подробно;)

 Смежные вопросы

  • Нет связанных вопросов^_^