Extract output address from raw script in bitcoin protocol

Extract output address from raw script in bitcoin protocol

I'm working on bitcoin protocol and exactly i want to extract raw script from output script to gain address from tx messages.

for common scripts, like scripts start with 0x76(means OP_DUP), we can access to address with these steps:

  1. add zeros to start of raw script.
  2. hash with sha256.
  3. hashed with sha256 again.
  4. grab the first 4 bytes of this result and stick them on the end of the raw script with leading zeros
  5. then encode with base58.
  6. at the end, add "1" to start of last output to gain output address.

these steps are suitable for common scripts, but for scripts like this

410498361908359fec5adaa624428484e7d117f36f811c7c471f4f1c7dd8184c20b32f0e2590c8d70906ebd585da2ae14ea942e4088891139379b434a26173754750ac

which is means:

PUSH(0x41) 0498361908359fec5adaa624428484e7d117f36f811c7c471f4f1c7dd8184c20b32f0e2590c8d70906ebd585da2ae14ea942e4088891139379b434a26173754750 ac

it didn't work and the generated output isn't valid.

https://ift.tt/2jh4sdI

Comments

Popular posts from this blog

Bitcoin Core errors with database block

Bitfinex & Market Synergy To Offer Institutional Calibre Cryptocurrency Connectivity