1

I am learning how transactions are coded in the blockchain, so I used a python script to compute bitcoin address from public key. This works with the public key: 03416fe9ba17be8fe3f88011923135e83c6a0666fcb575de6ab337c7d6c8f41a5f

within the sigscript if this transaction: https://www.blockchain.com/btc/tx/56beef8afe5a4b5b41225211e62c3e7bce5747c4c8dcdd982173e8496687794b I correctly get the corresponding address:

15nrxBDLts1tEbowH1dLm5z84RVas7USmP

I tried with the same python code to check where is the public key of the first input of this transaction: https://www.blockchain.com/btc/tx/01e7c525a5759cde1d04d2e9a363424053ace3ff1d2dde9cd1b368493254bd0d

I tried to check if I get the address of this input: 34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo Unfortunately, I didn't manage to end with this address when I use the second field of the witness of this input, which should be the public key of the address I am trying to get (the one starting with 34xp): 02a720e54e39b28434a4c55462718b4584db973331a834141b8cad7e52c317f695

SHA256+RIPEMD160+b58encode on this data doesn't correspond to the address above (the one starting with 34xp), and I didn't figured out why, and where is the public key of this address in this transaction input. Could anyone please give me a clue about it?

1 Answer 1

1

I found my answer in this post: Find sender's public key in SegWit Transaction

Without witness:

address = base58check( 0x00 + hash160(publicKey) )

With witness:

address = base58check( 0x05 + hash160( 0x00 + 0x14 + hash160(publicKey) ) )

With:

  • "+" operator is concatenation
  • hash160() is SHA256 + RIPEMD160
  • publicKey is the second element of the witness (the one I correctly identified in my question above), or the second element of sigscript if no witness

Well note that this is not a global rule, but the rule for the transactions I mentioned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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