1

Given an address (i.e. 1BnPVV5Tt25cxbDg6DqoxJunjSL8reCGz6), how can I calculate its scriptPubKey in order to build a transaction?

Murch
  • 75,206
  • 34
  • 186
  • 622
user2298995
  • 193
  • 3
  • 14

1 Answers1

2

I assume you want to integrate it into a P2PKH tx. You would have to base58decode the address, and then remove the checksum and the network byte. Then you can integrate it into a P2PKH tx in the std. way:

76 A9 14 <20 Bytes> 88 AC

I have two references with some code examples in C and python, that helped me at the time, when I had the same question :-)

https://bitcointalk.org/index.php?topic=1543429.0

https://bitcointalk.org/index.php?topic=1026.0

and some online "play tools" to verify:

http://gobittest.appspot.com/Address

http://lenschulwitz.com/base58

pebwindkraft
  • 5,086
  • 2
  • 13
  • 34