Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Eildosa on June 17, 2018, 09:07:32 PM



Title: Where is the code that convert public key to address?
Post by: Eildosa on June 17, 2018, 09:07:32 PM
Hi,

I can't find where in the bitcoin core code is the public key -> address conversion code.
My C++ being very rusty it might be just in front of me.

If any of you know, I'm all ears :)

Thanks.

PS : I know how it is done, but I'd like to see the actual cpp code


Title: Re: Where is the code that convert public key to address?
Post by: achow101 on June 18, 2018, 02:45:27 AM
The addresses are encoded here: https://github.com/bitcoin/bitcoin/blob/da9a2f5cd9032ee22acc5c2dc175e6934f63132c/src/key_io.cpp#L19. The specific functions that do the encoding are https://github.com/bitcoin/bitcoin/blob/ad823178e85aa070e5ec62799c17c36210b0dd7a/src/base58.cpp#L133 and https://github.com/bitcoin/bitcoin/blob/1d4662f5dcf64bd8cbab7386616461b570e93e67/src/bech32.cpp#L146


Title: Re: Where is the code that convert public key to address?
Post by: Eildosa on June 18, 2018, 05:45:04 PM
Thank you very much :D