-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor and test psbt::derive_sp
#27
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
Open
nymius
wants to merge
13
commits into
bitcoindevkit:master
Choose a base branch
from
nymius:refactor/psbt-derive-sp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…e alias Add supporting types for derive_sp refactoring: - SpkWithSecret type alias for (ScriptBuf, SecretKey) tuple - DataForPartialSecret struct to encapsulate input collection data - Default implementation for DataForPartialSecret No functional changes; preparation for function extraction.
Previously, PSBT `get_key` errors weren’t captured in `SpSendError`, making failed key lookups hard to diagnose. This commit introduces a new `KeyError` variant to represent any failure from the `K: GetKey` provider and updates `SpSendError`’s `Display` impl with a generic error message. Note: the `GetKey` error type lacks a `Display` implementation, so the underlying error can’t be shown; `KeyError` serves as a marker for private‐key retrieval failures.
Introduce two new variants to the SpSendError enum: - MissingDerivations: For cases where the PSBT lacks required key derivations. - MissingOutputs: For scenarios where output counts do not match expectations. These errors enable more precise handling of derivation and output validation issues in the send process, without altering existing behavior. This is a pure addition to improve error granularity for future refactors and fixes. No breaking changes; existing code remains unaffected.
The create_silentpayment_scriptpubkeys API no longer returns a Result since it cannot fail on its own. - create_silentpayment_scriptpubkeys never produces an error internally, so returning Result was misleading - eliminates needless panic points and clarifies that failure cannot occur at this stage - streamlines code paths and makes error propagation more consistent elsewhere
Extract prevout script retrieval logic into a standalone function. This separates the logic for getting script_pubkey from either witness_utxo or non_witness_utxo into its own function without changing behavior. No changes in derive_sp logic.
Extract taproot private key derivation logic into a standalone function. This separates the taproot key handling including parity adjustment and tap tweaking into its own function.
…e_sp Extract non-taproot private key derivation logic into a standalone function. This separates the BIP32 and public key-based key retrieval logic.
Extract transaction input building logic into a standalone function. This isolates the logic for constructing a complete TxIn with witness from PSBT input data.
Extract input data collection logic into a standalone function. This separates the logic for gathering scripts with secrets and finding the lexicographically minimum outpoint.
Extract PSBT output update logic into a standalone function. This separates the logic to update PSBT outputs with silent payment data.
Replace inline logic in derive_sp with calls to extracted functions. This completes the refactoring by using collect_input_data and update_outputs.
4a49ab0
to
0662119
Compare
0662119
to
8e43b8d
Compare
Reviewed and tested 👍 - LGTM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Splits
psbt::derive_sp
in small logical units and adds unit tests.Fixes #8 .
Checklists
just p
(fmt, clippy and test) before committing