plugins: nwc: sync with spec, fix some bugs#10505
Merged
SomberNight merged 6 commits intospesmilo:masterfrom Mar 3, 2026
Merged
plugins: nwc: sync with spec, fix some bugs#10505SomberNight merged 6 commits intospesmilo:masterfrom
SomberNight merged 6 commits intospesmilo:masterfrom
Conversation
It got removed from the spec so we don't need to support it anymore. nostr-protocol/nips#2210
NIP-47 now defines how client/server should communicate their supported encryption schemes. For backwards compatibility its not strictly neccessary to implement this but it seems cleaner to explicitly handle it.
SomberNight
reviewed
Mar 3, 2026
SomberNight
reviewed
Mar 3, 2026
Keep track of the spent amount in msat instead of sat to prevent issues due to rounding. The budget is still specified in sat.
Increase the payment budget before attempting the payment and decrease again if the payment fails. This prevents a race where multiple concurrent payments could pass the budget check before the budget is incremented through any of the other payments. A lock around the budget is not suitable either as then one long stuck payment (hold invoice) would render the budget inaccessible for all other payment attempts.
NIP-47 got extended to include an optional 'state' field in responses. Implementing this acutally fixes an issue of Alby Go showing succeeded payments as failed that appeared recently.
these changes deserve a new version
SomberNight
reviewed
Mar 3, 2026
Comment on lines
+819
to
+821
| if not self.budget_allows_spend(request_pub, msat_requested=amount_msat or invoice.get_amount_msat()): | ||
| return self.get_error_response("QUOTA_EXCEEDED", "Payment exceeds daily limit") | ||
| budget_item = self.add_to_budget(request_pub, amount_msat=amount_msat or invoice.get_amount_msat()) |
Member
There was a problem hiding this comment.
note: I think it would be a safer API if budget_allows_spend and add_to_budget were combined to a single method. could be done in a follow-up if you agree
Member
There was a problem hiding this comment.
but as long as there is no await between the two calls, and no multi-threading here, it does not functionally matter
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.
Syncs the NWC plugin with changes to the NIP-47 specification and makes the handling of payment budgets more reliable.