0

In raw transaction, bitcoin using bytes of the public key, like:

042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9

It takes a lot of bytes.

Technically, can we use bitcoin addresses (e.g.1MBngSqZbMydscpzSoehjP8kznMaHAzh9y ) instead to make the blocks smaller?

3

In raw transaction, bitcoin using bytes of the public key, like: 042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9

Technically the raw transaction contains the Script, which usually is written with Bitcoin script that is a stack-based language. It can contain the PubKey in the old scripts, like P2PK but the community is making a big effort to move the bitcoin users to use the script that contains the hash of the public key. The script like Pay-to-Public-Key-Hash (P2PKH) or pay-to-witness-public-key-hash (P2WPKH).

from the script, it is possible to calculate the address but not vice versa.

In conclusion, all the addresses have a conversion like:

  • P2PK, P2PKH: Start with 1.
  • P2SH: start with 3.
  • P2WSH, P2WPKH: Start with bc or with 3.

At this point, the answer should contain a resume of all the types of script and how the script is built, and also an introduction to the not standard script that is used extensively from the lightning network protocol.

But I think a very good summary is inside these two chapters of the Bitcoin book 'Transactions' and 'Advanced Transactions and Scripting', I can't do better

Update

I'm not a fan of theory, maybe you can use also this code example to understand how the script is converted on a Bitcoin address. Decompiler Bitcoin Script.

it is only an example of the conversion that could be done.

The usage of the example code is described inside the bash script run-decompiler.sh

An example with the following block is the following ./Decompiler 76a914536ffa992491508dca0354e52f32a3a7a679a53a88ac

With the following result

----------------------------------------| Results |-----------------------------------
                               ###  Script PAY TO PUBLIC KEY HASH  ###                            
  Raw Script PubKey: 76a914536ffa992491508dca0354e52f32a3a7a679a53a88ac

OP_DUP OP_HASH160 536ffa992491508dca0354e52f32a3a7a679a53a OP_EQUALVERIFY OP_CHECKSIG
                                                                                      
 The address: 18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX
 The Hash160 pubkey: 536ffa992491508dca0354e52f32a3a7a679a53a
 The P2PSH address: 39JC9tvQ5CANbfuPgUZ4Zdc227m5uQnMRB

 https://blockstream.info/address/18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX
______________________________________________________________________________________

See the result here https://blockstream.info/address/18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX

Please consider this example as an example of code, I developed this to understand how de script works. Can contains error. I will work to integrate this in my project and I will maintain this post update.

To answer at your comment that is

Thanks. I use you the code linked, the the result address codepad.org/nRJhvMC3 does not match the expected address blockchain.com/btc/block/1 So what's the usage of this Decompiler?

The decompiler takes the hex of the script and try to calculate the corresponding address if it is a standard script.

3
  • Thanks. I use you the code linked, the the result address codepad.org/nRJhvMC3 does not match the expected address blockchain.com/btc/block/1 So what's the usage of this Decompiler? – ntk138 Feb 28 at 12:32
  • Oh, I see, interesting, I have some bug in the P2PK deserialization, sorry you have right. I will fix it for the P2PK. if you run the script you have a complete summary where is contained the link to see the address information on an explorer. Sorry for the P2PK deserialization. I update the post with an example of how to use the code – vincenzopalazzo Feb 28 at 13:22
  • I fixed the bug with this commit github.com/vincenzopalazzo/decompiler-bitcoin-script/commit/… thanks so much and sorry, now you can see with the following command that you address if calculate the same ./Decompiler 410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac. Look here the result blockstream.info/address/12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX – vincenzopalazzo Feb 28 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.