feat: add p2pk_signing_keys to SendOptions#1750
Open
vnprc wants to merge 2 commits intocashubtc:mainfrom
Open
Conversation
Add `p2pk_signing_keys: Vec<SecretKey>` to `SendOptions` so wallets holding P2PK-locked proofs can spend them through the standard `prepare_send` / `confirm` flow without manually calling `swap()`. - Extract `sign_proofs()` into `wallet/util.rs` with four unit tests - Refactor `receive/saga/mod.rs` to call `sign_proofs()` (no behaviour change) - Sign `proofs_to_swap` in `send/saga/mod.rs::confirm()` before swap - Add `p2pk_signing_keys` to cdk-ffi `SendOptions` struct and both `From` conversions (was previously hardcoded to `Vec::new()`) - Fix CHANGELOG `## Added` heading level to `### Added` - Add integration test `test_p2pk_send_options_signing_keys` covering the full prepare_send / confirm flow with P2PK-locked input proofs
… conditions When a wallet holds P2PK-locked proofs whose total exactly equals the requested send amount, prepare_send short-circuits: all proofs go to proofs_to_send and proofs_to_swap is empty. Since confirm only signs proofs_to_swap, signing is skipped and the locked proofs flow out in the token unchanged, causing the recipient to get NUT11 errors. Fix by shadowing force_swap to true in internal_prepare when p2pk_signing_keys is non-empty, ensuring all proofs go through a real swap that signs and unlocks them before building the token. Add a regression test covering the exact-denomination case.
Contributor
|
I think this is partly getting fixed here: #1466 This would not be a complete fix but I think it's more or less where you want to take it. |
Contributor
Author
|
oh cool! |
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
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.
Summary
Wallets that hold P2PK-locked proofs (received from another party, or minted with spending conditions) currently have no way to spend them through the standard prepare_send / confirm flow — they must manually call swap() and handle signing themselves. This PR closes that gap.
Changes:
p2pk_signing_keys: Vec<SecretKey>toSendOptions(defaults to empty, fully backward-compatible)receive/saga/mod.rsinto a newsign_proofs()utility inwallet/util.rs, and call it from both the receive and send sagassign_proofs(&mut proofs_to_swap, &opts.p2pk_signing_keys)inPreparedSend::confirm()before the swap, so the mint accepts the spendSendOptionsstruct and bothFromconversions (matching the existingReceiveOptionspattern)Usage
Test plan
wallet/util.rs: correct key signs, wrong key is a no-op, plain proof is a no-op, empty key vec is a no-optest_p2pk_send_options_signing_keys: funds a wallet, swaps clean proofs for P2PK-locked proofs via the raw mint API, then exercises the full prepare_send / confirm flow with signing keys — verifies the recipient receives the correct amount