breadwallet / breadwallet-core

SPV bitcoin C library
MIT License
274 stars 324 forks source link

Modifying derivation path producing unexpected keys #43

Closed Robco87 closed 5 years ago

Robco87 commented 5 years ago

I am attempting to support bip 49. I seem to be correctly deriving keys, but the address does not match what I am expecting.

Leveraging this site for comparison. https://iancoleman.io/bip39/

My test seed is abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about With a darivation path of m/49'/0'/0'/0

The first public and private keys are correct and matching whats in the test site, but the address is correct instead of the address: 37VucYSaXLCAsxYyAPfbSi9eh4iEcbShgf

I get: 1PkaFBUcyAccDp2Xo2K8MqduVMgMB792r2

Is there something else that needs to be changed to get the correct address?

EBGToo commented 5 years ago

Core addresses are P2PKH and start with 1.... Your 3... address is a P2SH address. Note that Core also supports 'segwit' using P2WPKH addresses.

To see the P2PKH address go to iancoleman at the BIP32 tab and enter m/49'/0'/0'/0 at BIP32 Derivation Path

Robco87 commented 5 years ago

Ok, this makes more sense now. Is there any way to create a p2SH in Core?

EBGToo commented 5 years ago

There is not an existing interface.

Robco87 commented 5 years ago

Ok, then just to confirm looking through the code in BRAdreess, there is some code related to scripts. It this for the recieving side?

EBGToo commented 5 years ago

We only support base58 p2pkh, and bech32 p2wpkh. There are interfaces in BRAddress, and perhaps others, that likely allow you to create a valid p2sh address if that is what you need.