Skip to content

Commit 2165a00

Browse files
committed
tapchannel: bump fee rate from 250 to 253 sat/kw
To avoid an error when the user specifies 1 sat/vByte (which is equal to 250 sat/kw), we simply bump it to match the default min relay fee rate of bitcoind. Otherwise 1 sat/vByte can really never be used.
1 parent 2c73f30 commit 2165a00

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tapchannel/aux_funding_controller.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ type pendingAssetFunding struct {
417417

418418
inputProofs []*proof.Proof
419419

420-
feeRate chainfee.SatPerVByte
420+
feeRate chainfee.SatPerKWeight
421421

422422
lockedInputs []wire.OutPoint
423423

@@ -1280,7 +1280,7 @@ func (f *FundingController) completeChannelFunding(ctx context.Context,
12801280
// This'll add yet another output (lnd's change output) to the
12811281
// template.
12821282
finalFundedPsbt, err := f.fundPsbt(
1283-
ctx, fundingPsbt, fundingState.feeRate.FeePerKWeight(),
1283+
ctx, fundingPsbt, fundingState.feeRate,
12841284
)
12851285
if err != nil {
12861286
return nil, fmt.Errorf("unable to fund PSBT: %w", err)
@@ -1619,7 +1619,15 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
16191619
return fmt.Errorf("unable to establish min_relay_fee: %w",
16201620
err)
16211621
}
1622-
if fundReq.FeeRate.FeePerKWeight() < minRelayFee {
1622+
1623+
// If the user specifies 1 sat/vByte, that result in 253 sat/kw, which
1624+
// is exactly 3 sat/kw lower than the default min relay fee. So we need
1625+
// to make sure we don't allow that.
1626+
feeRate := fundReq.FeeRate.FeePerKWeight()
1627+
if feeRate == chainfee.AbsoluteFeePerKwFloor {
1628+
feeRate = chainfee.FeePerKwFloor
1629+
}
1630+
if feeRate < minRelayFee {
16231631
return fmt.Errorf("fee rate %v too low, min_relay_fee: %v",
16241632
fundReq.FeeRate.FeePerKWeight(), minRelayFee)
16251633
}
@@ -1638,7 +1646,7 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
16381646
initiator: true,
16391647
amt: fundReq.AssetAmount,
16401648
pushAmt: fundReq.PushAmount,
1641-
feeRate: fundReq.FeeRate,
1649+
feeRate: feeRate,
16421650
fundingAckChan: make(chan bool, 1),
16431651
fundingFinalizedSignal: make(chan struct{}),
16441652
}

0 commit comments

Comments
 (0)