-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add option to set remote channel reservation in open channel #2708
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
36be46a
proto: Add remote_chan_reserve_sat field to OpenChannelRequest
roeierez 8461b69
fundingmanager: Enable configurable channel reservation on open channel
roeierez d732e18
lncli: Add lncli support to determine remote channel reservation.
roeierez 47e12be
fundingmanager: add validation for channel reserve
roeierez d9c3f5d
fundingmanager: add tests for remote chanel reserve
roeierez 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 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2580,6 +2580,7 @@ func TestFundingManagerCustomChannelParameters(t *testing.T) { | |
| const minHtlcIn = 1234 | ||
| const maxValueInFlight = 50000 | ||
| const fundingAmt = 5000000 | ||
| const chanReserve = 100000 | ||
|
|
||
| // We will consume the channel updates as we go, so no buffering is | ||
| // needed. | ||
|
|
@@ -2593,17 +2594,18 @@ func TestFundingManagerCustomChannelParameters(t *testing.T) { | |
| // workflow. | ||
| errChan := make(chan error, 1) | ||
| initReq := &InitFundingMsg{ | ||
| Peer: bob, | ||
| TargetPubkey: bob.privKey.PubKey(), | ||
| ChainHash: *fundingNetParams.GenesisHash, | ||
| LocalFundingAmt: localAmt, | ||
| PushAmt: lnwire.NewMSatFromSatoshis(pushAmt), | ||
| Private: false, | ||
| MaxValueInFlight: maxValueInFlight, | ||
| MinHtlcIn: minHtlcIn, | ||
| RemoteCsvDelay: csvDelay, | ||
| Updates: updateChan, | ||
| Err: errChan, | ||
| Peer: bob, | ||
| TargetPubkey: bob.privKey.PubKey(), | ||
| ChainHash: *fundingNetParams.GenesisHash, | ||
| LocalFundingAmt: localAmt, | ||
| PushAmt: lnwire.NewMSatFromSatoshis(pushAmt), | ||
| Private: false, | ||
| MaxValueInFlight: maxValueInFlight, | ||
| MinHtlcIn: minHtlcIn, | ||
| RemoteCsvDelay: csvDelay, | ||
| Updates: updateChan, | ||
| Err: errChan, | ||
| RemoteChanReserve: chanReserve, | ||
| } | ||
|
|
||
| alice.fundingMgr.InitFundingWorkflow(initReq) | ||
|
|
@@ -2648,6 +2650,12 @@ func TestFundingManagerCustomChannelParameters(t *testing.T) { | |
| maxValueInFlight, openChannelReq.MaxValueInFlight) | ||
| } | ||
|
|
||
| // Check that the custom remoteChanReserve value is sent. | ||
| if openChannelReq.ChannelReserve != chanReserve { | ||
| t.Fatalf("expected OpenChannel to have chanReserve %v, got %v", | ||
| chanReserve, openChannelReq.ChannelReserve) | ||
| } | ||
|
|
||
| chanID := openChannelReq.PendingChannelID | ||
|
|
||
| // Let Bob handle the init message. | ||
|
|
@@ -3095,6 +3103,50 @@ func TestFundingManagerRejectPush(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| // TestFundingManagerInvalidChanReserve ensures proper validation is done on | ||
| // remoteChanReserve parameter sent to open channel. | ||
| func TestFundingManagerInvalidChanReserve(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| testInvalidChanReserve := func(chanReserve btcutil.Amount) { | ||
| alice, bob := setupFundingManagers(t) | ||
| defer tearDownFundingManagers(t, alice, bob) | ||
|
|
||
| // Create a funding request and start the workflow. | ||
| updateChan := make(chan *lnrpc.OpenStatusUpdate) | ||
| errChan := make(chan error, 1) | ||
| initReq := &InitFundingMsg{ | ||
| Peer: bob, | ||
| TargetPubkey: bob.privKey.PubKey(), | ||
| ChainHash: *fundingNetParams.GenesisHash, | ||
| LocalFundingAmt: 500000, | ||
| PushAmt: lnwire.NewMSatFromSatoshis(10), | ||
| Private: false, | ||
| Updates: updateChan, | ||
| RemoteChanReserve: chanReserve, | ||
| Err: errChan, | ||
| } | ||
|
|
||
| alice.fundingMgr.InitFundingWorkflow(initReq) | ||
|
|
||
| // Alice should have sent the OpenChannel message to Bob. | ||
| select { | ||
| case <-alice.msgChan: | ||
| t.Fatalf("init funding workflow should fail with invalid chan"+ | ||
| "reserve %v", chanReserve) | ||
| case <-initReq.Err: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should assert on the expected error here. |
||
| case <-time.After(time.Second * 5): | ||
| t.Fatalf("alice did not send OpenChannel message") | ||
| } | ||
| } | ||
|
|
||
| // Test channel reserve below dust | ||
| testInvalidChanReserve(300) | ||
|
|
||
| // test channel reserve above capacity | ||
| testInvalidChanReserve(500000) | ||
| } | ||
|
|
||
| // TestFundingManagerMaxConfs ensures that we don't accept a funding proposal | ||
| // that proposes a MinAcceptDepth greater than the maximum number of | ||
| // confirmations we're willing to accept. | ||
|
|
||
Oops, something went wrong.
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.
We already have a similar check in
CommitConstraints, though that doesn't check against the capacity.