rpcserver: parse channel fees into InitFundingMsg

This commit is contained in:
Slyghtning 2022-09-10 12:04:48 -04:00
parent e87412bd63
commit 1e030c2d48

View file

@ -1922,12 +1922,21 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
// satoshis) does not exceed the amount the local party has requested
// for funding.
//
// TODO(roasbeef): incorporate base fee?
if remoteInitialBalance >= localFundingAmt {
return nil, fmt.Errorf("amount pushed to remote peer for " +
"initial state must be below the local funding amount")
}
// Determine if the user provided channel fees
// and if so pass them on to the funding workflow.
var channelBaseFee, channelFeeRate *uint64
if in.UseBaseFee {
channelBaseFee = &in.BaseFee
}
if in.UseFeeRate {
channelFeeRate = &in.FeeRate
}
// 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.
@ -2086,6 +2095,8 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
TargetPubkey: nodePubKey,
ChainHash: *r.cfg.ActiveNetParams.GenesisHash,
LocalFundingAmt: localFundingAmt,
BaseFee: channelBaseFee,
FeeRate: channelFeeRate,
PushAmt: lnwire.NewMSatFromSatoshis(remoteInitialBalance),
MinHtlcIn: minHtlcIn,
FundingFeePerKw: feeRate,