mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 18:43:42 +02:00
lnrpc+rpcserver: add remote reserve to openchannel request
This commit is contained in:
41
rpcserver.go
41
rpcserver.go
@ -1910,6 +1910,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
||||
remoteCsvDelay := uint16(in.RemoteCsvDelay)
|
||||
maxValue := lnwire.MilliSatoshi(in.RemoteMaxValueInFlightMsat)
|
||||
maxHtlcs := uint16(in.RemoteMaxHtlcs)
|
||||
remoteChanReserve := btcutil.Amount(in.RemoteChanReserveSat)
|
||||
|
||||
globalFeatureSet := r.server.featureMgr.Get(feature.SetNodeAnn)
|
||||
|
||||
@ -1937,6 +1938,13 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
||||
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
|
||||
// channel size. If the funding amount is above the soft-limit, then
|
||||
// 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
|
||||
// be used to consume updates of the state of the pending channel.
|
||||
return &funding.InitFundingMsg{
|
||||
TargetPubkey: nodePubKey,
|
||||
ChainHash: *r.cfg.ActiveNetParams.GenesisHash,
|
||||
LocalFundingAmt: localFundingAmt,
|
||||
BaseFee: channelBaseFee,
|
||||
FeeRate: channelFeeRate,
|
||||
PushAmt: lnwire.NewMSatFromSatoshis(remoteInitialBalance),
|
||||
MinHtlcIn: minHtlcIn,
|
||||
FundingFeePerKw: feeRate,
|
||||
Private: in.Private,
|
||||
RemoteCsvDelay: remoteCsvDelay,
|
||||
MinConfs: minConfs,
|
||||
ShutdownScript: script,
|
||||
MaxValueInFlight: maxValue,
|
||||
MaxHtlcs: maxHtlcs,
|
||||
MaxLocalCsv: uint16(in.MaxLocalCsv),
|
||||
ChannelType: channelType,
|
||||
TargetPubkey: nodePubKey,
|
||||
ChainHash: *r.cfg.ActiveNetParams.GenesisHash,
|
||||
LocalFundingAmt: localFundingAmt,
|
||||
BaseFee: channelBaseFee,
|
||||
FeeRate: channelFeeRate,
|
||||
PushAmt: lnwire.NewMSatFromSatoshis(remoteInitialBalance),
|
||||
MinHtlcIn: minHtlcIn,
|
||||
FundingFeePerKw: feeRate,
|
||||
Private: in.Private,
|
||||
RemoteCsvDelay: remoteCsvDelay,
|
||||
RemoteChanReserve: remoteChanReserve,
|
||||
MinConfs: minConfs,
|
||||
ShutdownScript: script,
|
||||
MaxValueInFlight: maxValue,
|
||||
MaxHtlcs: maxHtlcs,
|
||||
MaxLocalCsv: uint16(in.MaxLocalCsv),
|
||||
ChannelType: channelType,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user