Why does BLOCKCHAIN.COM API only return recipient BASE58 addresses and omits BECH32s?

2024/9/22 7:01:27

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

import requestsr = 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:

enter image description here

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..

Answer

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 Addresslocking_script = '0014d0aba2c93bac0fcafafe43f2ad39d664ba51910d'
scr = script_deserialize(locking_script)
a = Address(hashed_data=scr['hashes'][0], script_type=scr['script_type'])
print(a.address)
https://en.xdnf.cn/q/119162.html

Related Q&A

rename columns according to list

I have 3 lists of data frames and I want to add a suffix to each column according to whether it belongs to a certain list of data frames. its all in order, so the first item in the suffix list should b…

How to send a pdf file from Flask to ReactJS

How can I send a file from Flask to ReactJS? I have already code that in the frontend, the user upload a file and then that file goes to the Flask server, then in the flask server the file is modify, …

How to draw cover on each tile in memory in pygame

I am a beginner in pygame and I am not a English native speaker.My assignment is coding a game called Memory. This game contains 8 pairs pictures and an cover exists on each pictures. This week, our as…

Compare 2 Excel files and output an Excel file with differences

Assume for simplicity that the data files look like this, sorted on ID:ID | Data1 | Data2 | Data3 | Data4 199 | Tim | 55 | work | $55 345 | Joe | 45 | work | $34 356 | Sam |…

Problem to show data dynamically table in python flask

I want to show a table in the html using python flask framework. I have two array. One for column heading and another for data record. The length of the column heading and data record are dynamic. I ca…

RuntimeError: generator raised StopIteration

I am in a course and try to find my problem. I cant understand why if I enter something other than 9 digits, the if should raise the StopIteration and then I want it to go to except and print it out. W…

split list elements into sub-elements in pandas dataframe

I have a dataframe as:-Filtered_data[defence possessed russia china,factors driving china modernise] [force bolster pentagon,strike capabilities pentagon congress detailing china] [missiles warheads, d…

Image does not display on Pyqt [duplicate]

This question already has an answer here:Why Icon and images are not shown when I execute Python QT5 code?(1 answer)Closed 2 years ago.I am using Pyqt5, python3.9, and windows 11. I am trying to add a…

Expand the following dictionary into following list

how to generate the following list from the following dictionary d = {2: 4, 3: 1, 5: 3}f = [2**1,2**2, 2**3, 2**4, 3**1, 5**1, 5**2, 5**3, 2**1 * 3, 2**2 * 3, 2**3 * 3, 2**4 * 3, 5**1 * 3, 5**2 * 3, 5*…

how can I improve the accuracy rate of the below trained model using CNN

I have trained a model using python detect the colors of the gemstone and have built a CNN.Herewith Iam attaching the code of mine.(Referred https://www.kaggle.com) import os import matplotlib.pyplot a…