lnrpc+rpcserver: add remote reserve to openchannel request

This commit is contained in:
Roei Erez authored and Elle Mouton committed 2022-10-07 14:57:05 +02:00
1 parent 6467b0ee12
commit b6a24b52fe
4 files changed
+1919 -1884

No files matched your search

+1898 -1884
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -2217,6 +2217,13 @@ message OpenChannelRequest {
to use the default fee rate value specified in the config or 0. to use the default fee rate value specified in the config or 0.
*/ */
bool use_fee_rate = 24; bool use_fee_rate = 24;
/*
The number of satoshis we require the remote peer to reserve. This value,
if specified, must be above the dust limit and below 20% of the channel
capacity.
*/
uint64 remote_chan_reserve_sat = 25;
} }
message OpenStatusUpdate { message OpenStatusUpdate {
oneof update { oneof update {
+5
View File
@@ -5679,6 +5679,11 @@
"use_fee_rate": { "use_fee_rate": {
"type": "boolean", "type": "boolean",
"description": "If use_fee_rate is true the open channel announcement will update the\nchannel fee rate with the value specified in fee_rate. In the case of\na fee_rate of 0 use_fee_rate is needed downstream to distinguish whether\nto use the default fee rate value specified in the config or 0." "description": "If use_fee_rate is true the open channel announcement will update the\nchannel fee rate with the value specified in fee_rate. In the case of\na fee_rate of 0 use_fee_rate is needed downstream to distinguish whether\nto use the default fee rate value specified in the config or 0."
},
"remote_chan_reserve_sat": {
"type": "string",
"format": "uint64",
"description": "The number of satoshis we require the remote peer to reserve. This value,\nif specified, must be above the dust limit and below 20% of the channel\ncapacity."
} }
} }
}, },
+9
View File
@@ -1910,6 +1910,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
remoteCsvDelay := uint16(in.RemoteCsvDelay) remoteCsvDelay := uint16(in.RemoteCsvDelay)
maxValue := lnwire.MilliSatoshi(in.RemoteMaxValueInFlightMsat) maxValue := lnwire.MilliSatoshi(in.RemoteMaxValueInFlightMsat)
maxHtlcs := uint16(in.RemoteMaxHtlcs) maxHtlcs := uint16(in.RemoteMaxHtlcs)
remoteChanReserve := btcutil.Amount(in.RemoteChanReserveSat)
globalFeatureSet := r.server.featureMgr.Get(feature.SetNodeAnn) globalFeatureSet := r.server.featureMgr.Get(feature.SetNodeAnn)
@@ -1937,6 +1938,13 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
channelFeeRate = &in.FeeRate channelFeeRate = &in.FeeRate
} }
// Ensure that the remote channel reserve does not exceed 20% of the
// channel capacity.
if remoteChanReserve >= localFundingAmt/5 {
return nil, fmt.Errorf("remote channel reserve must be less " +
"than the %%20 of the channel capacity")
}
// Ensure that the user doesn't exceed the current soft-limit for // Ensure that the user doesn't exceed the current soft-limit for
// channel size. If the funding amount is above the soft-limit, then // channel size. If the funding amount is above the soft-limit, then
// we'll reject the request. // we'll reject the request.
@@ -2102,6 +2110,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
FundingFeePerKw: feeRate, FundingFeePerKw: feeRate,
Private: in.Private, Private: in.Private,
RemoteCsvDelay: remoteCsvDelay, RemoteCsvDelay: remoteCsvDelay,
RemoteChanReserve: remoteChanReserve,
MinConfs: minConfs, MinConfs: minConfs,
ShutdownScript: script, ShutdownScript: script,
MaxValueInFlight: maxValue, MaxValueInFlight: maxValue,