feat(cashu): Track D — dispute resolution via P_M signature delivery#771
feat(cashu): Track D — dispute resolution via P_M signature delivery#771AndreaDiazCorreia wants to merge 1 commit into
Conversation
Implement the Cashu escrow dispute path in admin_settle and admin_cancel. This is the only place the daemon signs with its P_M arbitrator key. - Add `cashu` crate (v0.16, no default features) for NUT-11 token parsing and Schnorr signing - Add `CashuSettings` to config and `is_cashu_mode()` helper on Settings - New `src/cashu/mod.rs`: `sign_with_pm(token_str, secret_key)` parses a cashuA/cashuB token and returns one `CashuProofSignature` per proof, signed with the daemon's P_M secp256k1 key (NUT-11 SIG_INPUTS) - `admin_settle`: if the order has a Cashu escrow token, branch into `cashu_admin_settle` — signs proofs, transitions to Status::SettledByAdmin, delivers `Action::CashuPmSignature` to the buyer, notifies solver and seller; skips do_payment() and bond resolution (mutually exclusive) - `admin_cancel`: if the order has a Cashu escrow token, branch into `cashu_admin_cancel` — signs proofs, transitions to Status::CanceledByAdmin, delivers `Action::CashuPmSignature` to the seller, notifies all parties; skips ln_client.cancel_hold_invoice() and bond resolution - Update all Settings struct literals in tests to include `cashu: None` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 405c035624
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| order_updated | ||
| .update(pool) | ||
| .await | ||
| .map_err(|e| MostroInternalErr(ServiceError::DbAccessError(e.to_string())))?; |
There was a problem hiding this comment.
Guard Cashu cancel with the dispute status
When admin-cancel races with admin-settle for the same Cashu dispute, this unconditional update() can overwrite a terminal status that another resolver just wrote and then continue to enqueue Mostro's P_M signature for the seller. Since the Cashu settle branch uses WHERE status = Dispute before sending its signature, the cancel branch needs the same compare-and-swap behavior; otherwise a concurrent resolution can leak P_M signatures to both sides and make the disputed ecash redeemable by the wrong party or by whichever client reaches the mint first.
Useful? React with 👍 / 👎.
Implement the Cashu escrow dispute path in admin_settle and admin_cancel. This is the only place the daemon signs with its P_M arbitrator key.
cashucrate (v0.16, no default features) for NUT-11 token parsing and Schnorr signingCashuSettingsto config andis_cashu_mode()helper on Settingssrc/cashu/mod.rs:sign_with_pm(token_str, secret_key)parses a cashuA/cashuB token and returns oneCashuProofSignatureper proof, signed with the daemon's P_M secp256k1 key (NUT-11 SIG_INPUTS)admin_settle: if the order has a Cashu escrow token, branch intocashu_admin_settle— signs proofs, transitions to Status::SettledByAdmin, deliversAction::CashuPmSignatureto the buyer, notifies solver and seller; skips do_payment() and bond resolution (mutually exclusive)admin_cancel: if the order has a Cashu escrow token, branch intocashu_admin_cancel— signs proofs, transitions to Status::CanceledByAdmin, deliversAction::CashuPmSignatureto the seller, notifies all parties; skips ln_client.cancel_hold_invoice() and bond resolutioncashu: None