gpt4 book ai didi

python - 区 block 链信息钱包支票付款

转载 作者:太空宇宙 更新时间:2023-11-03 14:22:46 29 4
gpt4 key购买 nike

我正在尝试创建付款账单并通过电报机器人发送给我的客户:我正在使用区 block 链 API V2-https://blockchain.info/api/api 接收。我的代码是:

xpub='***'
keyk='02e57f1***'
url='https://api.blockchain.info/v2/receive?xpub='+str(xpub)+'&callback=https%3A%2F%2Fdoors03.ru&key='+keyk
x=requests.get(url)
r=x.json()
r=r['address']

r - 是一个已创建的地址。我正在将其发送给我的客户(顺便问一下,有什么方法可以发送准确的付款金额的地址)。我想检查是否收到付款后:

data={ "Content-Type": "text/plain","key":keyk,"addr":r,"callback":"https%3A%2F%2Fdoors03.ru","onNotification":"KEEP", "op":"RECEIVE"}
r = requests.post(url, data=data)

这是响应 - u'{\n "message": "Internal handlers error"\n}'

我做错了什么?如何查看付款情况?如何发送包含btc或ethereum精确总和的地址?

最佳答案

Sorry, i don't have enough reputation to post a comment, so this isthe only option i have. @egorkh have you solved this problem? Maybeyou have received explanation from blockchain.info support? I havesent them a question about that, but they are answering for too long.

更新:最后,我找到了解决方案。

就我而言,“内部处理程序错误”消息的原因在于对其 API 的错误解释。

由于他们没有在他们的 java-api 中实现 balance_update 请求,所以我自己做了,但我的方式是错误的。

我已经输入了这个参数:

{"key":keyk,"addr":r,"callback":"https%3A%2F%2Fdoors03.ru","onNotification":"KEEP", "op":"RECEIVE"}

作为 post 参数,就像他们在 api 中提供的其他方法一样。在这些方法中,参数是 URLEncoded,就像您对回调链接所做的那样。但是...

在此 HTML 请求中,它们必须以 json 格式的纯文本形式发送,无需任何特殊编码,如下所示:

Map<String, String> params = new HashMap<String, String>();
params.put("addr", address);
params.put("callback", callbackUrl);
params.put("key", apiCode);
params.put("onNotification", keepOnNotification? "KEEP" : "DELETE");
params.put("confs", Integer.toString(confirmationCount));
params.put("op", StringUtils.isBlank(operationType) ? "ALL" : operationType);

//parse parameters map to json string(that's optional: you can write it directly as string)
String body = new Gson().toJson(params);

if (requestMethod.equals("POST")) {
byte[] postBytes = body.getBytes("UTF-8");
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "text/plain");
conn.setRequestProperty("Content-Length", String.valueOf(postBytes.length));
conn.getOutputStream().write(postBytes);
conn.getOutputStream().close();
}

错误的主要原因可能是您将“Content-Type”:“text/plain”放入数据对象(可能还有编码的回调网址)

关于python - 区 block 链信息钱包支票付款,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47837442/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com