Ethereum: How to convert PSBT transaction (base64) to raw/serialized…
Transformation from the Base64 PSBT transaction in the raw/served hexie
In this article, we will examine the PSBT Base64 conversion procedure (binary programming) in its raw and served format (HEX). We will use Bitcoin Core CLI as our set of tools.
preliminary requirements
- Knowing with Bitcoin and his blockchain architecture.
- Understanding the PSBT and Base64 coding standard.
Step 1: Transt Base64 PSBT Transaction in RAW
To convert Base64 coded by the PSBT transaction, we must use the “PSBT” command line provides the Bitcoin core. For this purpose, “Konwerttopsbt” is used. Here is an example of how to use it:
`Bash
Bitcoincore-Clli Converttopsbt
Replace
A real PSBT transaction with coded Base64, as can be seen in the exit of the Bitcoin core.
STEP 2: Transform a strict transaction into serialized hexagonal
After transforming PSBT transactions from the RAW format, we must change it into its series (HEX). For this purpose, we can re -use a tool such as “PSBT” or use the “Cointool” library.
Here is an example of a conversion of a strict transaction from Bitcoin Core Cli:
`Bash
Bitcoincore-cli Cointool
Replace
Step 3: Compare and check
To make sure that the conversion process is correct, we can compare coded by PSBT Base64 with its served series (HEX):
Bash
Bitcoincore-Clli Cointool
This command will produce a strict transaction from the original coded Base64 transaction.
Example exit
Here is an example of the output of the upper steps using a fictitious PSBT transaction as an entry:
`Panenetext
PSBT transaction with Base64
PSBT ("1.3.0", {{{
"Coding": "Base64",
"Scriptsig": ["010100100000000000000000000000"],
"Blocknumber": "100,000",
"Transactidex": "500000"
AND)
In conversion
Here is a simple Python script for conversion from Base64 to RAW, followed by a served hex:
`Python
Base64 import
Import json
Def Base64_TO_TSB (Base64_transation):
Use the PSBT command line tool provided by Bitcoin Core
output = Bitcoincore-Clli Converttopsbt (Base64_transation)
Return Json.LADS (Exit)
Def tsb_to_raw (tsb_json, coding = "basase64"):
Use the Coiintool library to convert from RAW to a hexagon
If coding == "raw":
Return Cointool (TSB_JSON, "Hex2raw")
Elif coding == "hex":
Return Cointool (TSB_JSON, "Hex2raw")
Example of use
Base64_transation = "PSBT (\" 1.3.0 \ ", {\" coding \ ": \" base64 \ ", \" scriptsig \ ": [\" 01010000000000000000000000000 \ "," blocknumba \ ":, \" transcationDex \ " ": \" 500000 \ "})"
Tsb_json = base64_to_tsb (Base64_transation)
Raw_hex = tsb_to_raw (tsb_json, coding = "hex")
Print (raw_hex)
exit:
In this example of the code, we first transform coded by PSBT Base64 into a Python dictionary using “json.lylads ()`. Then we use the “Cointool” library to transform it from the RAW format into a hexagon. The result is printed as raw and served (HEX) transactions.
Application
The transformation between the Base64 and raw/series (HEX) format in the bitcoin core includes two stages: first, transformation of PSBT transactions from Base64 to RAW; Secondly, the transformation of raw transactions into its series. This procedure can be achieved using various tools and libraries provided by Bitcoin Core Cli.