Skip to content

feat(cashu): Track D — dispute resolution via P_M signature delivery#771

Draft
AndreaDiazCorreia wants to merge 1 commit into
feat/cashu-mostro-core-0.12from
feat/cashu-track-d-dispute-resolution
Draft

feat(cashu): Track D — dispute resolution via P_M signature delivery#771
AndreaDiazCorreia wants to merge 1 commit into
feat/cashu-mostro-core-0.12from
feat/cashu-track-d-dispute-resolution

Conversation

@AndreaDiazCorreia

Copy link
Copy Markdown
Member

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

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>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • develop

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 00b0ad74-dadb-4247-8d73-1985a3ea19ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cashu-track-d-dispute-resolution

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/app/admin_cancel.rs
Comment on lines +85 to +88
order_updated
.update(pool)
.await
.map_err(|e| MostroInternalErr(ServiceError::DbAccessError(e.to_string())))?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@grunch
grunch marked this pull request as draft July 1, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant