-
Notifications
You must be signed in to change notification settings - Fork 182
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
Add Legacy P2PKH Signing #567
Conversation
Initial copy from Seedsigner+Satochip
Initial copy from Seedsigner+Satochip fork
…eedsigner into add-p2pkh-signing
elif script_type == SettingsConstants.TAPROOT: | ||
return f"m/86'/{network_path}/0'" | ||
else: | ||
raise Exception("Unexpected script type") | ||
|
||
elif wallet_type == SettingsConstants.MULTISIG: | ||
if script_type == SettingsConstants.NATIVE_SEGWIT: | ||
return f"m/48'/{network_path}/0'/2'" | ||
if script_type == SettingsConstants.LEGACY_P2PKH: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??? Does this belong?
Wasn't sure, but now I see that "legacy" is not just meant as p2pkh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The native segwit block got moved down, basically just trying to be mostly consistent in terms of the code logic reflecting the BIP numbers (So older types with smaller BIP numbers start fist and then iterate through the BIPs in order of their release, so legacy first, Taproot last)
Wow, seeing this a bit late Sunday evening. Will take another look in the morning. |
I have tested tx signing with both legacy p2pkh single-sig and legacy p2sh multi-sig. For both tests, I exported the relevant psbt from sparrow wallet, successfully signed with this SeedSigner code change, loaded the signed psbt back into sparrow wallet, and broadcast the valid transaction. The only feature I found not working was exporting multi-sig xpub for the p2pkh (m/45') from SeedSigner into Sparrow wallet. Everything looks ok until Sparrow complains that p2sh was not sent as a possible tag (I ran into this with testing Electrum legacy multi-sig as well). It is fixed by adding the tag 400 (p2sh) for the hdkey to the outputs in src/seedsigner/models/encode_qr.py.
and later down also adding this when len(ur_outputs) is 0, i.e. derivation parsing didn't yield anything. This allows p2sh for electrum legacy seeds to work as well and covers all the bases with this addition:
I was able to find the tag map here for the descriptions of the tag numbers: |
Single-sig: I've tested this for single-sig legacy p2pkh w/o problems, worked great! Multisig: I think labeling for legacy multisig should read "Legacy p2sh" instead of p2pkh? I had problems as well setting up the sparrow wallet, so more work here is needed (or more effort on my part. I didn't try BamaHodl's recommended solution above but I suspect it would have helped). I hope to discuss this before release 0.8.0 as another already-merged pr is related. |
Just added it in and can confirm that it behaves properly when exporting multisig xpubs to Sparrow. Thanks @BamaHodl and @jdlcdl You are right that multisig is using P2SH, but as it stands, the script type label is set project-wide in the settings-definition.py, so perhaps just drop the explicit script type (So just call it "Legacy") It would be do-able to have it change the display name of the menu item for Legacy script type when exporting for Multisig, but that seems to be a messy way to do things... |
I'm late seeing this, but I have now tested both single-sig p2pkh and multisig p2sh exporting for both wallets, address explorer shows that addresses match, and can sign PSBTs. As of 05f5f0e: this is working for me. TO BE RESOLVED
|
"Nested Segwit" for P2SH-P2WSH (multisig) / P2SH-P2WPKH (single sig) and "Legacy" for P2SH (multisig) / P2PKH (single sig) would be my vote. This is what Sparrow Wallet uses. |
Made the tweak. It's certainly the cleanest solution. |
For my part, as of 4f6456b ACK tested p.s. pre-ack on the next pr/commit that alters "LEGACY_P2PKH" to "LEGACY" constant system-wide. |
Remove duplicate UTXO addition
I wonder if the above was an error taking both versions of a previous conflict. Now this pr is in conflict with 'dev' leaving a very similar looking situation in ._get_policy() I suspect you'll want the "dev" version which is indented. Note: 2 lines above the conflict is the |
I'll have a chance to have a proper look at it later on today. I'll also go through and add some relevant tests into the test_decodepsbtqr, as this is basically where the testing for PSBT parsing like this is happening. |
tACK |
@@ -277,16 +277,15 @@ def _get_policy(scope, scriptpubkey, xpubs): | |||
elif "p2sh" in script_type and scope.redeem_script is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a "p2sh" == script_type
for native segwit single-sig? I think this was corrected in 572, making sure nothing snuck back in.
I confirm that this conflict was properly resolved.
Description
Add support for Legacy P2PKH script type for both single and miltisig seeds.
This pull request is categorized as a:
Checklist
pytest
and made sure all unit tests pass before sumbitting the PRIf you modified or added functionality/workflow, did you add new unit tests?
I have tested this PR on the following platforms/os:
Note: Keep your changes limited in scope; if you uncover other issues or improvements along the way, ideally submit those as a separate PR. The more complicated the PR the harder to review, test, and merge.