lnrpc+rpcserver: add remote reserve to openchannel request
This commit is contained in:
1 parent
6467b0ee12
commit
b6a24b52fe
4 files changed
+1935
-1900
No files matched your search
+1898
-1884
File diff suppressed because it is too large.
Load diff
@@ -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 {
|
||||||
|
|||||||
@@ -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."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+25
-16
@@ -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.
|
||||||
@@ -2092,22 +2100,23 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
|||||||
// open a new channel. A stream is returned in place, this stream will
|
// open a new channel. A stream is returned in place, this stream will
|
||||||
// be used to consume updates of the state of the pending channel.
|
// be used to consume updates of the state of the pending channel.
|
||||||
return &funding.InitFundingMsg{
|
return &funding.InitFundingMsg{
|
||||||
TargetPubkey: nodePubKey,
|
TargetPubkey: nodePubKey,
|
||||||
ChainHash: *r.cfg.ActiveNetParams.GenesisHash,
|
ChainHash: *r.cfg.ActiveNetParams.GenesisHash,
|
||||||
LocalFundingAmt: localFundingAmt,
|
LocalFundingAmt: localFundingAmt,
|
||||||
BaseFee: channelBaseFee,
|
BaseFee: channelBaseFee,
|
||||||
FeeRate: channelFeeRate,
|
FeeRate: channelFeeRate,
|
||||||
PushAmt: lnwire.NewMSatFromSatoshis(remoteInitialBalance),
|
PushAmt: lnwire.NewMSatFromSatoshis(remoteInitialBalance),
|
||||||
MinHtlcIn: minHtlcIn,
|
MinHtlcIn: minHtlcIn,
|
||||||
FundingFeePerKw: feeRate,
|
FundingFeePerKw: feeRate,
|
||||||
Private: in.Private,
|
Private: in.Private,
|
||||||
RemoteCsvDelay: remoteCsvDelay,
|
RemoteCsvDelay: remoteCsvDelay,
|
||||||
MinConfs: minConfs,
|
RemoteChanReserve: remoteChanReserve,
|
||||||
ShutdownScript: script,
|
MinConfs: minConfs,
|
||||||
MaxValueInFlight: maxValue,
|
ShutdownScript: script,
|
||||||
MaxHtlcs: maxHtlcs,
|
MaxValueInFlight: maxValue,
|
||||||
MaxLocalCsv: uint16(in.MaxLocalCsv),
|
MaxHtlcs: maxHtlcs,
|
||||||
ChannelType: channelType,
|
MaxLocalCsv: uint16(in.MaxLocalCsv),
|
||||||
|
ChannelType: channelType,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user