Skip to content

NIP-47 Add Hold Invoice Support#1913

Merged
vitorpamplona merged 18 commits intonostr-protocol:masterfrom
frnandu:nip-47-hold-invoices
Feb 3, 2026
Merged

NIP-47 Add Hold Invoice Support#1913
vitorpamplona merged 18 commits intonostr-protocol:masterfrom
frnandu:nip-47-hold-invoices

Conversation

@frnandu
Copy link
Contributor

@frnandu frnandu commented May 7, 2025

Rendered

This PR introduces support for hold invoices in the Nostr Wallet Connect (NIP-47) protocol.

Hold invoices enable more advanced payment workflows where the receiver must explicitly settle or cancel the invoice using the preimage. This allows for enhanced control and coordination in payment flows, such as conditional payments or escrow-like behavior.

Summary of Changes:

  • New RPC methods:

    • make_hold_invoice: Create a hold invoice using a pre-generated preimage and its payment hash.
    • settle_hold_invoice: Settle a hold invoice by providing the original preimage.
    • cancel_hold_invoice: Cancel a hold invoice using its payment hash.
  • New notification:

    • hold_invoice_accepted: Emitted when a payer accepts a hold invoice (i.e., locks in payment).
  • Extended example flow: A new section documents the end-to-end process for using hold invoices, including invoice creation, settlement, and cancellation.

Motivation:

Hold invoices are a key feature in Lightning-based applications that require more complex transaction logic, such as:

  • Pay-to-unlock content
  • Marketplace escrow systems
  • Payment gating and tokenized actions

This addition expands the versatility and usability of NWC while maintaining backward compatibility with existing methods.

Implementations and usages:

Copy link
Contributor

@Semisol Semisol left a comment

Choose a reason for hiding this comment

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

see review

@rolznz
Copy link
Contributor

rolznz commented May 8, 2025

Implemented in Alby JS SDK: getAlby/js-sdk#382

frnandu and others added 3 commits May 21, 2025 09:48
Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
@daywalker90
Copy link

Have you seen my reviews? I never get replies to these, i have a feeling github is shadowbanning me.

@frnandu
Copy link
Contributor Author

frnandu commented Jul 31, 2025

@daywalker90
Copy link

I've implemented this PR for CLN in my nip47 plugin here daywalker90/cln-nip47#4 with the necessary changes to the library i use here rust-nostr/nostr#1019 and the necessary changes to my holdinvoice plugin here: daywalker90/holdinvoice#2

Everything looks good to me so far. Is there a client other than myself to test this with already?

yukibtc added a commit to rust-nostr/nostr that referenced this pull request Aug 4, 2025
Implements nostr-protocol/nips#1913

Pull-Request: #1019
Acked-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
@frnandu
Copy link
Contributor Author

frnandu commented Oct 23, 2025

Everything looks good to me so far. Is there a client other than myself to test this with already?

You can try https://github.com/relaystr/ndk there is even a demo app .apk in the releases

Copy link
Contributor

@Semisol Semisol left a comment

Choose a reason for hiding this comment

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

LGTM. We should specify that all preimages and hashes are encoded as hex in the spec.

@frnandu
Copy link
Contributor Author

frnandu commented Nov 2, 2025

LGTM. We should specify that all preimages and hashes are encoded as hex in the spec.

NIP-47 originally doesn't have such thing specified there.
Are you saying change it globally?

@frnandu frnandu requested a review from Semisol February 3, 2026 18:15
@frnandu
Copy link
Contributor Author

frnandu commented Feb 3, 2026

@vitorpamplona can we merge this?

@vitorpamplona vitorpamplona merged commit 01838f3 into nostr-protocol:master Feb 3, 2026
@vitorpamplona
Copy link
Collaborator

NIP-47 is getting very big. Can we do a review and make sure everything on the NIP is being actually used? A PR removing some rare stuff would be welcome.

@frnandu
Copy link
Contributor Author

frnandu commented Feb 3, 2026

I think the only unused stuff is the multi_* methods, right @rolznz ?

@rolznz rolznz mentioned this pull request Feb 4, 2026
@rolznz
Copy link
Contributor

rolznz commented Feb 4, 2026

#2210

Copy link

@varo0000000 varo0000000 left a comment

Choose a reason for hiding this comment

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

{
"id": "df467db0a9f9ec77ffe6f561811714ccaa2e26051c20f58f33c3d66d6c2b4d1c",
"pubkey": "c04ccd5c82fc1ea3499b9c6a5c0a7ab627fbe00a0116110d4c750faeaecba1e2",
"created_at": 1713883677,
"kind": 13194,
"tags": [
[ "encryption", "nip44_v2 nip04" ],
[
"notifications",
"payment_received payment_sent"
]
],
"content": "pay_invoice pay_keysend get_balance get_info make_invoice lookup_invoice list_transactions multi_pay_invoice multi_pay_keysend sign_message notifications",
"sig": "31f57b369459b5306a5353aa9e03be7fbde169bc881c3233625605dd12f53548179def16b9fe1137e6465d7e4d5bb27ce81fd6e75908c46b06269f4233c845d8"
}

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.

6 participants