Skip to content

Commit ebd15f2

Browse files
committed
tapgarden: bump feerate to min relay fee
If the fee estimation returns a fee rate lower than the min relay fee, we should use the min relay fee instead. This commit implements this behavior for the minting transaction.
1 parent bfa9735 commit ebd15f2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tapgarden/planter.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,32 @@ func (c *ChainPlanter) fundGenesisPsbt(ctx context.Context,
571571
batchKey[:], feeRate.FeePerKVByte().String())
572572
}
573573

574+
minRelayFee, err := c.cfg.Wallet.MinRelayFee(ctx)
575+
if err != nil {
576+
return nil, fmt.Errorf("unable to obtain minrelayfee: %w", err)
577+
}
578+
579+
// If the fee rate is below the minimum relay fee, we'll
580+
// bump it up.
581+
if feeRate < minRelayFee {
582+
switch {
583+
// If a fee rate was manually assigned for this batch, we err
584+
// out, otherwise we silently bump the feerate.
585+
case manualFeeRate != nil:
586+
// This case should already have been handled by the
587+
// `checkFeeRateSanity` of `rpcserver.go`. We check here
588+
// again to be safe.
589+
return nil, fmt.Errorf("feerate does not meet "+
590+
"minrelayfee: (fee_rate=%s, minrelayfee=%s)",
591+
feeRate.String(), minRelayFee.String())
592+
default:
593+
log.Infof("Bump fee rate for batch %x to meet "+
594+
"minrelayfee from %s to %s", batchKey[:],
595+
feeRate.String(), minRelayFee.String())
596+
feeRate = minRelayFee
597+
}
598+
}
599+
574600
fundedGenesisPkt, err := c.cfg.Wallet.FundPsbt(
575601
ctx, genesisPkt, 1, feeRate, -1,
576602
)

0 commit comments

Comments
 (0)