-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NWC] Add get_budget command for per-connection budget limits. #1504
Open
jklein24
wants to merge
6
commits into
nostr-protocol:master
Choose a base branch
from
jklein24:feat/get_budget
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
17cd5be
[NWC] Add get_budget command for per-connection budget limits.
jklein24 2109664
Suggested comment clarification
jklein24 1c96bc4
Add renewal_period
jklein24 9dd2256
Switch to used budget instead of remaining
jklein24 1a65d51
Remove explicit msats in names
jklein24 587be06
Add back msats comment
jklein24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rolznz and I were discussing on the alby-hub implementation what should happen if there's no budget set for a connection. My initial thinking was that absence of a budget would be represented by an empty struct return value. However, @rolznz suggests to respond with an error instead. Some tradeoff off the top of my head:
Empty response:
Error response
@rolznz wdyt of these tradeoffs? Anything I'm missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jklein24 if the app calls
get_info
it could know if it can callget_budget
or not. I think this is a good thing for the app to do first so it knows what methods it can call. What do you think?If it returned an empty response, would the developer check if
total_budget
is not empty? (e.g. in javascript:if (!!response.total_budget) { /* app has a budget */ }
? ) - if we go this way, should we add some note in this spec so developers more easily know what to do?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's true. In general, is the assumption that apps normally call get_info before doing things with a connection?
Yeah, agreed this is a little gross :-/. Either way we decide on this, we should definitely document it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is our recommendation. Because a wallet service could post an info event about what methods it supports, but the app connection itself could be different, based on what permissions the user selects when configuring the connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. I guess I can be convinced on the error instead. @shreyav @bsiaotickchong curious if either of you have thoughts on this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect if wallets/users using budgets are also mainly creating connections with budgets, on average it'd be faster to just call get_budget without having to wait for the get_info response every time. In this case I think the empty response for get_budget is preferable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Alby Hub + JS SDK currently implement the empty response option for the no budget case.