-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
macaroons: initial implementation of macaroon based accounting #2390
Closed
Conversation
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
guggero
changed the title
Initial implementation of macaroon based accounting
macaroons: initial implementation of macaroon based accounting
Dec 31, 2018
guggero
force-pushed
the
macaroon-accounting
branch
2 times, most recently
from
December 31, 2018 12:50
1768f07
to
faa09f9
Compare
Roasbeef
added
enhancement
Improvements to existing features / behaviour
macaroons
P3
might get fixed, nice to have
labels
Jan 2, 2019
guggero
force-pushed
the
macaroon-accounting
branch
from
January 4, 2019 07:55
faa09f9
to
36d9124
Compare
guggero
force-pushed
the
macaroon-accounting
branch
2 times, most recently
from
February 22, 2019 11:03
15901d4
to
f23612e
Compare
guggero
force-pushed
the
macaroon-accounting
branch
2 times, most recently
from
April 17, 2019 13:27
e73261e
to
40dd237
Compare
guggero
force-pushed
the
macaroon-accounting
branch
from
May 26, 2019 12:51
40dd237
to
0c59b43
Compare
guggero
force-pushed
the
macaroon-accounting
branch
from
June 4, 2019 06:48
0c59b43
to
d062ebe
Compare
guggero
force-pushed
the
macaroon-accounting
branch
from
September 30, 2019 08:05
d062ebe
to
4b550d7
Compare
guggero
force-pushed
the
macaroon-accounting
branch
from
January 27, 2020 09:15
4b550d7
to
5226a34
Compare
Realized this probably shouldn't be built into lnd itself but some kind of wrapper library. Will continue working on this in a different context. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
Improvements to existing features / behaviour
macaroons
P3
might get fixed, nice to have
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.
In this PR we add a new accounting system to the macaroons package.
This first implementation only partially satisfies the features requested in #291 but further PRs will follow.
As we introduce it in this first PR, an account is a simple construct that has a balance and an optional expiration date. The balance represents satoshis that can be spent by the "owner" of the account.
Every invoice that is paid from/with an account reduces the balance of that account by the payment amount plus fees.
Once the balance of an account is 0, further payments will be refused from/with that account.
Applying an account to a macaroon is a restriction. The bearer of a macaroon that is locked to an account will only be able to spend at most as many satoshis as the account's balance.
If a macaroon is not locked to an account, there is no restriction.
Accounts only assert a maximum amount spendable. Having a certain account balance does not guarantee that the node has the channel liquidity to actually spend that amount.
There are three commands in
lncli
that can be used to manage accounts:createaccount balance [expiration_date]
Creates a new account with the given balance and the optional expiration date.listaccounts
Lists all accounts that are currently stored in the accountdatabase.
removeaccount id
Removes the account with the given ID.Example output of
listaccounts
:A new macaroon that is locked to an account can then be created using the
delegatemacaroon
command:lncli --macaroonpath /some/dir/payment.macaroon delegatemacaroon --save_to /some/dir/account.macaroon --account_id abcdef01abcdef01
Of course this only makes sense if we can create a macaroon that is only allowed to pay invoices, once #1160 is merged.
With this first version there are several limitations that will be addressed in further PRs:
SendPayment
,SendPaymentSync
,SendToRoute
andSendToRouteSync
) are currently checked for the account constraint. It can be discussed if theListAccounts
method should only show the current account when the macaroon is locked to an account.Depends on #1147 and #1152 (the first three commits of this PR will be removed as soon as these two PRs are merged to master).