Skip to content

feat(core): Support P2PK payment request sends#309

Open
igbopharaoh wants to merge 4 commits into
cashubtc:masterfrom
igbopharaoh:feat/payment-req-for-p2pk
Open

feat(core): Support P2PK payment request sends#309
igbopharaoh wants to merge 4 commits into
cashubtc:masterfrom
igbopharaoh:feat/payment-req-for-p2pk

Conversation

@igbopharaoh

@igbopharaoh igbopharaoh commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

This pull request adds payer-side NUT-18 P2PK payment request support using cashu-ts NUT-10/NUT-11 normalization. #286

Problem

Coco could parse and pay normal payment requests, but P2PK requests needed explicit NUT-11 mint support checks, locked-output send preparation, and clear failure behavior for malformed or unsupported spending conditions before funds move.

Summary

  • Adds normalized P2PK payment request requirements, NUT-11 payable-mint filtering, and prepare-time NUT-11 assertions.
  • Routes payment request P2PK sends through the general P2PK send handler with structured cashu-ts options.
  • Keeps HTTP/inband/Nostr delivery semantics unchanged and documents the new payer-side behavior.
  • Adds adapter contract coverage for structured send method persistence.

Verification

  • bun run --filter='@cashu/coco-core' test -- test/unit/PaymentRequestService.test.ts
  • bun run --filter='@cashu/coco-core' test -- test/unit/P2pkSendHandler.test.ts test/unit/SendOpsApi.test.ts test/unit/MintService.test.ts
  • bun run --filter='@cashu/coco-core' test:unit
  • bun run typecheck
  • bun run docs:build
  • git diff --check

Changeset

  • Added .changeset/p2pk-payment-requests.md.

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cfb2822

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@cashu/coco-core Major
@cashu/coco-adapter-tests Major
@cashu/coco-indexeddb Major
@cashu/coco-expo-sqlite Major
@cashu/coco-sql-storage Major
@cashu/coco-sqlite Major
@cashu/coco-sqlite-bun Major
@cashu/coco-react Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@igbopharaoh igbopharaoh force-pushed the feat/payment-req-for-p2pk branch 2 times, most recently from f1d158e to 0292b92 Compare July 10, 2026 10:03

@Egge21M Egge21M left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you fr taking this on. The direction is great and this is almost good to go. There are a could docs missing and an issue with how cashu-ts' P2PKOptions behave currently. Please take a look at the comments

Comment thread packages/core/operations/send/SendMethodHandler.ts
Comment thread packages/core/services/PaymentRequestService.ts
Comment thread packages/core/services/MintService.ts
) {
if (
spendingCondition?.kind === 'P2PK' &&
!(await this.mintService.supportsNut(mintUrl, 11))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This can throw if a single mint is offline and take the whole call with it. I think we should catch single mint failures and simply exclude them from the request.

@igbopharaoh

Copy link
Copy Markdown
Contributor Author

Thank you fr taking this on. The direction is great and this is almost good to go. There are a could docs missing and an issue with how cashu-ts' P2PKOptions behave currently. Please take a look at the comments

Thanks for the review, I'll attend to all the comments now

@igbopharaoh igbopharaoh force-pushed the feat/payment-req-for-p2pk branch from 9d203c7 to 4d5c474 Compare July 13, 2026 15:41
@igbopharaoh igbopharaoh marked this pull request as draft July 13, 2026 16:07
@igbopharaoh igbopharaoh force-pushed the feat/payment-req-for-p2pk branch from 4d5c474 to ef343f3 Compare July 13, 2026 17:02
@igbopharaoh igbopharaoh marked this pull request as ready for review July 13, 2026 17:06

@Egge21M Egge21M left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the quick changes. Unfortunately I did find one more issue, which is a bit of a gotcha introduced by CTS.

}
| {
/** Full NUT-11 P2PK options accepted by cashu-ts output builders. */
options: P2PKOptions;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cashu-TS lets you add a hashLock on a P2PK construction, which turns the resulting data into HTLC (NUT-14) data. HTLC is out-of-scope for now, so we should make sure that consumers can't add it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great, addressing it now

@igbopharaoh igbopharaoh force-pushed the feat/payment-req-for-p2pk branch from ef343f3 to cfb2822 Compare July 13, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants