lnd: add max fee rate check to closechannel rpc
This commit is contained in:
7 files changed
+109
-12
No files matched your search
@@ -2878,6 +2878,15 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
maxFee := chainfee.SatPerKVByte(
|
||||
in.MaxFeePerVbyte * 1000,
|
||||
).FeePerKWeight()
|
||||
|
||||
// In case the max fee was specified, we check if it's less than
|
||||
// the initial fee rate and abort if it is.
|
||||
if maxFee != 0 && maxFee < feeRate {
|
||||
return fmt.Errorf("max_fee_per_vbyte (%v) is less "+
|
||||
"than the required fee rate (%v)", maxFee,
|
||||
feeRate)
|
||||
}
|
||||
|
||||
updateChan, errChan = r.server.htlcSwitch.CloseLink(
|
||||
chanPoint, contractcourt.CloseRegular, feeRate,
|
||||
maxFee, deliveryScript,
|
||||
@@ -2909,7 +2918,9 @@ out:
|
||||
case err := <-errChan:
|
||||
rpcsLog.Errorf("[closechannel] unable to close "+
|
||||
"ChannelPoint(%v): %v", chanPoint, err)
|
||||
|
||||
return err
|
||||
|
||||
case closingUpdate := <-updateChan:
|
||||
rpcClosingUpdate, err := createRPCCloseUpdate(
|
||||
closingUpdate,
|
||||
@@ -2948,6 +2959,7 @@ out:
|
||||
"txid(%v)", h)
|
||||
break out
|
||||
}
|
||||
|
||||
case <-r.quit:
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user