feat(wallet): add Wallet::sign_psbt<K> wrapping bitcoin::Psbt::sign#438
feat(wallet): add Wallet::sign_psbt<K> wrapping bitcoin::Psbt::sign#438EliteCoder18 wants to merge 3 commits intobitcoindevkit:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #438 +/- ##
==========================================
+ Coverage 80.04% 80.07% +0.03%
==========================================
Files 24 24
Lines 5336 5345 +9
Branches 242 242
==========================================
+ Hits 4271 4280 +9
Misses 987 987
Partials 78 78
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Concept ACK. I've not had an extensive look at the implementation.
|
Add a thin wrapper method `sign_psbt` that delegates to `bitcoin::Psbt::sign`, passing the wallet's internal secp256k1 context. This allows users to sign PSBTs with their own `GetKey` implementor (e.g., `Xpriv` or hardware wallet adapters) without managing a separate secp256k1 context.
Add tests covering signing with a matching and non-matching `Xpriv`. - `test_sign_psbt_with_xpriv`: verifies that a matching key signs at least one input - `test_sign_psbt_with_wrong_key_signs_nothing`: verifies that an unrelated key returns Ok but produces no signatures
6694fbb to
ce3d189
Compare
|
@ValuedMammal Thanks for the feedback! I've updated the tests to use a base64 PSBT with pre-populated Would appreciate a review when you get a chance. |
Description
Related to #331
Adds
Wallet::sign_psbt<K>, a thin wrapper aroundbitcoin::Psbt::signthat passes the wallet's internal secp256k1 context to the caller'sGetKeyimplementor (e.g.Xpriv, a hardware wallet adapter).Without this, callers driving signing themselves via the bitcoin crate must construct their own
Secp256k1<All>— setup the wallet already owns.Notes to the reviewers
bitcoin::Psbt::signreadsbip32_derivationfields to locate child keys. A freshly built PSBT lacks these. Callers must first runwallet.sign(&mut psbt, SignOptions { try_finalize: false, ..Default::default() })to populate them. Documented in rustdoc.Wallet::signuses BDK's internal signer infrastructure (InputSigner/TransactionSigner).sign_psbtdelegates entirely tobitcoin::Psbt::sign; callers supply their ownGetKey. Both methods coexist without conflict.KeyMapWrappervariant (rust-miniscript#867) is postponed to 4.0 per maintainer direction.Changelog notice
Wallet::sign_psbt<K>wrapper aroundbitcoin::Psbt::signusing the wallet's internal secp256k1 context.Checklists
All Submissions:
just pbefore pushingNew Features: