try to sweep p2pk outputs from old type WIF privkeys #3125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #2857
Now that the most widely used server implementation, ElectrumX, with version 1.2, properly separates P2PK and P2PKH scripts, we can implement a way for users to spend P2PK outputs.
In this PR, I propose enabling the
sweep
functionality to redeem these coins. Unfortunately, the WIF format for private keys gives no hint if P2PK scripts are to be used. What I do, is search for both P2PK and P2PKH scripts whenever an "old type" (pre-segwit) WIF is swept from. Thecompressed
byte is assumed to be correct, the same boolean is used for both script types.I think the fact that (in some sense) duplicate queries are sent to servers (hence e.g. increasing load/bandwidth), can be overlooked, given sweeping is a rare operation. IMHO it is more important for users to be able to access these coins than to avoid looking up both script types at all costs. So while it might not be desirable to always subscribe to both script types (say) in an imported wallet, this one-time cost can be afforded.
I've tested this on regtest with ElectrumX 1.2.