为什么 BLOCKCHAIN.COM API 只返回收件人 BASE58 地址并省略 BECH32s? [英] Why does BLOCKCHAIN.COM API only return recipient BASE58 addresses and omits BECH32s?

查看:26
本文介绍了为什么 BLOCKCHAIN.COM API 只返回收件人 BASE58 地址并省略 BECH32s?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bc1q6z469jfm4s8u47h7g0e26wwkvja9rygdqpeykd 地址在那里可见.如何通过API访问?

不可访问的地址具有 BECH32 格式,而可访问的地址具有 BASE58(我通过单击网站上的地址获得的信息).我能够检索收件人地址的那些交易具有 BASE58 格式.

关于区块的链接.

Blochchain.com API 尚不完全支持 bech32 地址.

因此您可以使用其他提供商,例如 Blockstream 或 Blockchair.

或者您也可以从 P2WPKH 脚本中获取地址.例如使用 BitcoinLib(免责声明:我的图书馆):

from bitcoinlib.transactions import script_deserializefrom bitcoinlib.keys 导入地址锁定脚本 = '0014d0aba2c93bac0fcafafe43f2ad39d664ba51910d'scr = script_deserialize(locking_script)a = 地址(hashed_data=scr['hashes'][0], script_type=scr['script_type'])打印(地址)

Following this post, I am trying to access all transactions within the #630873 block in the bitcoin blockchain.

import requests

r = requests.get('https://blockchain.info/block-height/630873?format=json')
data = r.json()

When inspecting the (0-indexed) 4th transaction within this block (via data['blocks'][0]['tx'][4]['out']), I get this:

[{'n': 0,
  'script': '0014d0aba2c93bac0fcafafe43f2ad39d664ba51910d',
  'spent': False,
  'tx_index': 0,
  'type': 0,
  'value': 19571491},
 {'addr': '1A7tWftaGHohhGcJMVkkm4zAYnF53KjRnU',
  'n': 1,
  'script': '76a9146406a0a47d4ed716f6ddf2eeca20c725932763f188ac',
  'spending_outpoints': [{'n': 0, 'tx_index': 0}],
  'spent': True,
  'tx_index': 0,
  'type': 0,
  'value': 3928145371}]

Only the addr of the second recipient of this transaction is included. On the blockchain.com website this transaction looks like:

The bc1q6z469jfm4s8u47h7g0e26wwkvja9rygdqpeykd address is visible there. How to access it through the API?

The unaccessible address has BECH32 format, while the accessible one has BASE58 (which information I get by clicking on the address on the website). Those transactions which I was able to retrieve the reciepient address, had BASE58 format.

Link to the block I am talking about..

解决方案

The Blochchain.com API does not fully support bech32 addresses yet.

So you could use another provider such as Blockstream or Blockchair.

Or you can also derive the addresses from the P2WPKH script. For example using BitcoinLib (Disclaimer: my library):

from bitcoinlib.transactions import script_deserialize
from bitcoinlib.keys import Address

locking_script = '0014d0aba2c93bac0fcafafe43f2ad39d664ba51910d'
scr = script_deserialize(locking_script)
a = Address(hashed_data=scr['hashes'][0], script_type=scr['script_type'])
print(a.address)

这篇关于为什么 BLOCKCHAIN.COM API 只返回收件人 BASE58 地址并省略 BECH32s?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆