rpcserver+fundingmanager: thread remote_max_htlcs to channel opening
This commit is contained in:
parent
9e73683c45
commit
a4031f500b
@ -855,6 +855,11 @@ type OpenChannelParams struct {
|
|||||||
// MinHtlc is the htlc_minimum_msat value set when opening the channel.
|
// MinHtlc is the htlc_minimum_msat value set when opening the channel.
|
||||||
MinHtlc lnwire.MilliSatoshi
|
MinHtlc lnwire.MilliSatoshi
|
||||||
|
|
||||||
|
// RemoteMaxHtlcs is the remote_max_htlcs value set when opening the
|
||||||
|
// channel, restricting the number of concurrent HTLCs the remote party
|
||||||
|
// can add to a commitment.
|
||||||
|
RemoteMaxHtlcs uint16
|
||||||
|
|
||||||
// FundingShim is an optional funding shim that the caller can specify
|
// FundingShim is an optional funding shim that the caller can specify
|
||||||
// in order to modify the channel funding workflow.
|
// in order to modify the channel funding workflow.
|
||||||
FundingShim *lnrpc.FundingShim
|
FundingShim *lnrpc.FundingShim
|
||||||
@ -893,6 +898,7 @@ func (n *NetworkHarness) OpenChannel(ctx context.Context,
|
|||||||
MinConfs: minConfs,
|
MinConfs: minConfs,
|
||||||
SpendUnconfirmed: p.SpendUnconfirmed,
|
SpendUnconfirmed: p.SpendUnconfirmed,
|
||||||
MinHtlcMsat: int64(p.MinHtlc),
|
MinHtlcMsat: int64(p.MinHtlc),
|
||||||
|
RemoteMaxHtlcs: uint32(p.RemoteMaxHtlcs),
|
||||||
FundingShim: p.FundingShim,
|
FundingShim: p.FundingShim,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4848,9 +4848,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
const bobRemoteMaxHtlcs = 100
|
const bobRemoteMaxHtlcs = 100
|
||||||
|
|
||||||
// Create two fresh nodes and open a channel between them.
|
// Create two fresh nodes and open a channel between them.
|
||||||
alice, err := net.NewNode("Alice", []string{
|
alice, err := net.NewNode("Alice", nil)
|
||||||
fmt.Sprintf("--default-remote-max-htlcs=%v", aliceRemoteMaxHtlcs),
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create new node: %v", err)
|
t.Fatalf("unable to create new node: %v", err)
|
||||||
}
|
}
|
||||||
@ -4889,6 +4887,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
lntest.OpenChannelParams{
|
lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
MinHtlc: customizedMinHtlc,
|
MinHtlc: customizedMinHtlc,
|
||||||
|
RemoteMaxHtlcs: aliceRemoteMaxHtlcs,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1742,6 +1742,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
|||||||
minHtlcIn := lnwire.MilliSatoshi(in.MinHtlcMsat)
|
minHtlcIn := lnwire.MilliSatoshi(in.MinHtlcMsat)
|
||||||
remoteCsvDelay := uint16(in.RemoteCsvDelay)
|
remoteCsvDelay := uint16(in.RemoteCsvDelay)
|
||||||
maxValue := lnwire.MilliSatoshi(in.RemoteMaxValueInFlightMsat)
|
maxValue := lnwire.MilliSatoshi(in.RemoteMaxValueInFlightMsat)
|
||||||
|
maxHtlcs := uint16(in.RemoteMaxHtlcs)
|
||||||
|
|
||||||
globalFeatureSet := r.server.featureMgr.Get(feature.SetNodeAnn)
|
globalFeatureSet := r.server.featureMgr.Get(feature.SetNodeAnn)
|
||||||
|
|
||||||
@ -1774,6 +1775,13 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
|||||||
"channel size is: %v SAT", int64(minChanFundingSize))
|
"channel size is: %v SAT", int64(minChanFundingSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent users from submitting a max-htlc value that would exceed the
|
||||||
|
// protocol maximum.
|
||||||
|
if maxHtlcs > input.MaxHTLCNumber/2 {
|
||||||
|
return nil, fmt.Errorf("remote-max-htlcs (%v) cannot be "+
|
||||||
|
"greater than %v", maxHtlcs, input.MaxHTLCNumber/2)
|
||||||
|
}
|
||||||
|
|
||||||
// Then, we'll extract the minimum number of confirmations that each
|
// Then, we'll extract the minimum number of confirmations that each
|
||||||
// output we use to fund the channel's funding transaction should
|
// output we use to fund the channel's funding transaction should
|
||||||
// satisfy.
|
// satisfy.
|
||||||
@ -1862,6 +1870,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
|||||||
minConfs: minConfs,
|
minConfs: minConfs,
|
||||||
shutdownScript: script,
|
shutdownScript: script,
|
||||||
maxValueInFlight: maxValue,
|
maxValueInFlight: maxValue,
|
||||||
|
maxHtlcs: maxHtlcs,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user