From 17cd5be19224f0b3cf1ea34239414fdfc819bfad Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Tue, 17 Sep 2024 20:40:08 -0700 Subject: [PATCH 1/6] [NWC] Add get_budget command for per-connection budget limits. This separates the notion of budget from `get_balance` so that permissions can be more appropriately controlled by the wallet. Budgets can be configured by users like how Alby supports, and client apps can query their remaining budget and when it will renew next. Breaking out a separate command for this purpose means that a user can let a client app see their own remaining budget without giving the app access to see their entire wallet balance. --- 47.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/47.md b/47.md index 983d2c954..5581beebe 100644 --- a/47.md +++ b/47.md @@ -373,6 +373,33 @@ Response: } ``` +### `get_budget` + +Budgets can be used to limit the amount of funds that can be spent by a connection in a given time period. +Budgets are optional and can be set by the user if their wallet supports it. Support for this command indicates +that the wallet supports user-configured budgets. The budget will be reset at the `renews_at` timestamp. + +Request: +```jsonc +{ + "method": "get_budget", + "params": { + } +} +``` + +Response: +```jsonc +{ + "result_type": "get_budget", + "result": { + "remaining_budget_msats": 10000, + "total_budget_msats": 100000, + "renews_at": 1693876973, // timestamp in seconds since epoch + } +} +``` + ### `get_info` Request: From 210966466b6c1dc11efe896e0b839533b4f42fda Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Wed, 18 Sep 2024 22:42:04 -0700 Subject: [PATCH 2/6] Suggested comment clarification Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com> --- 47.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/47.md b/47.md index 5581beebe..62fdec18c 100644 --- a/47.md +++ b/47.md @@ -395,7 +395,7 @@ Response: "result": { "remaining_budget_msats": 10000, "total_budget_msats": 100000, - "renews_at": 1693876973, // timestamp in seconds since epoch + "renews_at": 1693876973, // timestamp in seconds since epoch, optional. If not provided, the budget does not renew. } } ``` From 1c96bc45cf84e35ad35fce9385544f0778ffa062 Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Wed, 18 Sep 2024 22:46:48 -0700 Subject: [PATCH 3/6] Add renewal_period --- 47.md | 1 + 1 file changed, 1 insertion(+) diff --git a/47.md b/47.md index 62fdec18c..b19cc0273 100644 --- a/47.md +++ b/47.md @@ -396,6 +396,7 @@ Response: "remaining_budget_msats": 10000, "total_budget_msats": 100000, "renews_at": 1693876973, // timestamp in seconds since epoch, optional. If not provided, the budget does not renew. + "renewal_period": "monthly", // daily|weekly|monthly|yearly|never } } ``` From 9dd2256a2a34fb89e6f1b13589c57aaf116ccf13 Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Sun, 22 Sep 2024 21:32:42 -0700 Subject: [PATCH 4/6] Switch to used budget instead of remaining --- 47.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/47.md b/47.md index b19cc0273..4cc4d9ac5 100644 --- a/47.md +++ b/47.md @@ -393,7 +393,7 @@ Response: { "result_type": "get_budget", "result": { - "remaining_budget_msats": 10000, + "used_budget_msats": 10000, "total_budget_msats": 100000, "renews_at": 1693876973, // timestamp in seconds since epoch, optional. If not provided, the budget does not renew. "renewal_period": "monthly", // daily|weekly|monthly|yearly|never From 1a65d511dad0f6ab7acd0802c8a26d595e1cf8ee Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Sun, 22 Sep 2024 21:57:21 -0700 Subject: [PATCH 5/6] Remove explicit msats in names --- 47.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/47.md b/47.md index 4cc4d9ac5..1d88368c6 100644 --- a/47.md +++ b/47.md @@ -393,8 +393,8 @@ Response: { "result_type": "get_budget", "result": { - "used_budget_msats": 10000, - "total_budget_msats": 100000, + "used_budget": 10000, + "total_budget": 100000, "renews_at": 1693876973, // timestamp in seconds since epoch, optional. If not provided, the budget does not renew. "renewal_period": "monthly", // daily|weekly|monthly|yearly|never } From 587be067ed3eba7d410242df93e9c1b649c7ad84 Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Thu, 26 Sep 2024 10:13:32 -0700 Subject: [PATCH 6/6] Add back msats comment --- 47.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/47.md b/47.md index 1d88368c6..9c6fbdb10 100644 --- a/47.md +++ b/47.md @@ -393,8 +393,8 @@ Response: { "result_type": "get_budget", "result": { - "used_budget": 10000, - "total_budget": 100000, + "used_budget": 10000, // used budget amount in msats + "total_budget": 100000, // total budget amount in msats "renews_at": 1693876973, // timestamp in seconds since epoch, optional. If not provided, the budget does not renew. "renewal_period": "monthly", // daily|weekly|monthly|yearly|never }