3

I am experiencing some major issues which I honestly can't understand. When I am generating a wallet from Electrum the public key looks like this: xpub661MyMwAqRbcG8Zah6TcX3QpP5yJApaXcyLK8CJcZkuYjczivsHxVL5qm9cw8BYLYehgFeddK5WrxhntpcvqJKTVg96dUVL9P7hZ7Kcvqvd

When I am generating a wallet address from bitcoin core rpc, the public key looks like this: 037acd3408dfb612a69204c5f5bafe2a326646398cdd16c85fedd65a4e96a28278

When I am trying to create a multisig address in the core using this type of public keys, I get errror: xpub661MyMwAqRbcG8Zah6TcX3QpP5yJApaXcyLK8CJcZkuYjczivsHxVL5qm9cw8BYLYehgFeddK5WrxhntpcvqJKTVg96dUVL9P7hZ7Kcvqvd

When I am trying to create a multisig address in the core ( via PHP ) using this type of public keys, it works: 037acd3408dfb612a69204c5f5bafe2a326646398cdd16c85fedd65a4e96a28278

I am super confused.

I am developing a multisig system for bitcoin, but it seems that I can't do it, since the clients will almost always use this type of public key generated from Electrum: xpub661MyMwAqRbcG8Zah6TcX3QpP5yJApaXcyLK8CJcZkuYjczivsHxVL5qm9cw8BYLYehgFeddK5WrxhntpcvqJKTVg96dUVL9P7hZ7Kcvqvd

Is there any type of conversion way in PHP from this type of public key: xpub661MyMwAqRbcG8Zah6TcX3QpP5yJApaXcyLK8CJcZkuYjczivsHxVL5qm9cw8BYLYehgFeddK5WrxhntpcvqJKTVg96dUVL9P7hZ7Kcvqvd to this type: 037acd3408dfb612a69204c5f5bafe2a326646398cdd16c85fedd65a4e96a28278 ? I am trying to understand what I am doing wrong

Thank you for your time, and hope to get an answer!

4

The electrum public key xpub661MyMwAqRbcG8Zah6TcX3QpP5yJApaXcyLK8CJcZkuYjczivsHxVL5qm9cw8BYLYehgFeddK5WrxhntpcvqJKTVg96dUVL9P7hZ7Kcvqvd is a BIP32 extended public key. This can be used to derive child addresses.

The Bitcoin-Core public key 037acd3408dfb612a69204c5f5bafe2a326646398cdd16c85fedd65a4e96a28278 is a hex representation of the compressed form of a public key.

In order to convert to from the extended to compressed format, all you need to do is decode from Base58Check and grab the last 33 bytes (32 for private keys). I'm sure there's an implementation in PHP for Base58Check decoding. See BIP32 - Extended Key Serialization:

$ printf "xpub661MyMwAqRbcG8Zah6TcX3QpP5yJApaXcyLK8CJcZkuYjczivsHxVL5qm9cw8BYLYehgFeddK5WrxhntpcvqJKTVg96dUVL9P7hZ7Kcvqvd" | base58 -dc | xxd -p 0488b21e0000000000000000009f8b20f34eceef6ea60d35db00446763f7 dc76bd60ec8cf6fd63dc912499cbd4039edccce0e93f436a283947412378 8b33a28ed7ad7cffc3a130889f232344ad1c

The last 33 bytes represent the hex version of the compressed public key (last 32 bytes for private keys).

039edccce0e93f436a2839474123788b33a28ed7ad7cffc3a130889f232344ad1c

  • Thak you for your answer! – L. Mark Nov 6 '18 at 12:30
  • @L.Mark you're welcome! – JBaczuk Nov 6 '18 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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