How to convert scriptPubKey bytes to Bitcoin address?
How to convert scriptPubKey bytes to Bitcoin address?
I am currently trying myself in parsing the blockchain using pyblockchain. My problem is that I am not able to encode the scriptPubKey correctly - although I don't know what I could possibly do wrong.
Below you can see how I traverse the blockchain:
from blockchain.reader import BlockchainFileReader import hashlib import base58 block_reader = BlockchainFileReader('/media/Data/btc/blocks/blk00325.dat') count = 0 for block in block_reader: count +=1 for t in block.transactions: for outp in t.outputs: addr = base58.b58encode(outp.script_pub_key) if addr.startswith('1'): print(addr) if count >= 5: break
If I, in my Jupyter notebook, take a look at outp, I'll find for
outp.script_pub_key >> b'v\xa9\x14\x1e\xbev\x83\xceJd\xad\xc9\x17\xe9\xb1\x93\x7f\x12&Q\xcb\xab\xa1\x88\xac'
this:
base58.b58encode(outp.script_pub_key) >> 'pkJBVCg6k54E7ZiP7cvxbCvtN9aY9zEcgK'
and this is not a valid bitcoin address.
Apparently, bitcoin addresses are supposed to be encoded i Base58Check - however, that does not work either:
base58.b58encode_check(outp.script_pub_key) >> '6PSJQapdQn8VeG9SBuZdH8q2ysyP4ND6dmspzLZb'
So what am I doing wrong here?
http://ift.tt/2ATxh7h
How To Convert Scriptpubkey Bytes To Bitcoin Address? >>>>> Download Now
ReplyDelete>>>>> Download Full
How To Convert Scriptpubkey Bytes To Bitcoin Address? >>>>> Download LINK
>>>>> Download Now
How To Convert Scriptpubkey Bytes To Bitcoin Address? >>>>> Download Full
>>>>> Download LINK F6