-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
electrum compatibility and P2SH addresses #37
Comments
hi @melaxon . Thx for the report.
Good observation. The --preset, aka Path Preset is only an aid for choosing the bip32 path. It's not attempting to emulate a particular wallet in every regard.
I will need to look into this in more detail. It would be helpful if you can post an example YPRV or YPUB (without funds!) along with electrum and hd-wallet-derive derived value(s) that demonstrate the discrepancy.
maybe. It's been pretty solid though. |
ypub6Z5GQFUWdyxxA6cKP8ZKacJTvtpk6ao3P54tvvzPSPevYH752rYWW6REEd5u5R77VdmkcrzWJmDHGKwx3qRmA9m39T26FJg5LngyQKSnokw The address with index 15 contains 0.00022 BTC This key was used to generate addresses in my app. The addresses and public keys are identical with electrum
I cannot see pubkeyhash in electrum unfortunately. The function that calculates the "correct" pubkeyhashes:
|
ok, so what are the "correct" and "incorrect" pubkeyhash values you are seeing for index 0? (assuming that your fn_get_hash160() is producing correct results). |
address 0 address 15 |
examples of P2PKH: 1NR4KPhzQagzSUBGunPSuKbWN7vnS6r77Z Did not try bc1 yet |
bach32 is also okay |
hmm, I took a brief look at this. I was trying to compare with output from other tools, but I couldn't seem to find one supports ypub and also outputs the pubkeyhash. So, it's not immediately obvious which implementation is correct. The hd-wallet-derive code that gets the pubkeyhas is pretty straight-forward, ie:
So this is just calling into the Bitwasp bitcoin-php lib to do the heavy lifting. One would think that if pubkey is correct, then pubkeyhash should be also, but I haven't investigated further yet. |
Now I'm pretty sure that the problem resides is Bitwasp code. First, I will search through their PRs as the version of bitcoin-php you use is far not the latest one and maybe the problem is already solved in later releases. |
fwiw, I updated composer require to latest bitwasp release (1.0.4), found one issue, and determined that hd-wallet-derive still generates the "incorrect" pubkeyhash.
|
Hello I noticed 2 things when I run such commands:
./hd-wallet-derive.php -g --key="xprv......" --addr-type=p2sh-segwit --preset=electrum
./hd-wallet-derive.php -g --key="yprv......" --addr-type=p2sh-segwit --preset=electrum
The first one is meaningless for those who wish to generate the same addresses in Electrum because Electrum will never generate 3bitcoinaddres... addresses from XPRV (or XPUB). There is no such an option (currently)
The second command will generate the same addresses and public keys as Electrum does from given YPRV (or YPUB) but pubkeyhash seems to be WRONG (or maybe I'm wrong and missed something).
To get the address balance I inquire electrumx using this code:
In case of XPRV everything is okay. For YPRV, if I use pubkeyhashes generated by hd-wallet-derive ($array['pubkeyhash']) the balance is always zero. If I delete pubkeyhashes and calculate them with some function fn_get_hash160 it works smoothly.
I guess I have to look into Bitwasp code (?)
The text was updated successfully, but these errors were encountered: