From 38e86a1b0f28dc645a21d3016415da9cd619de3a Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Mon, 24 Jun 2024 21:48:22 -0300 Subject: [PATCH] sweepbatcher: log tx weight in addition to feerate Also log fee before applying clampBatchFee. This is useful to debug fee ralated issues. --- sweepbatcher/sweep_batch.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sweepbatcher/sweep_batch.go b/sweepbatcher/sweep_batch.go index 6c85cb7..1455de1 100644 --- a/sweepbatcher/sweep_batch.go +++ b/sweepbatcher/sweep_batch.go @@ -727,10 +727,11 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) { weightEstimate.AddP2TROutput() - fee = b.rbfCache.FeeRate.FeeForWeight(weightEstimate.Weight()) + weight := weightEstimate.Weight() + feeForWeight := b.rbfCache.FeeRate.FeeForWeight(weight) // Clamp the calculated fee to the max allowed fee amount for the batch. - fee = clampBatchFee(fee, batchAmt) + fee = clampBatchFee(feeForWeight, batchAmt) // Add the batch transaction output, which excludes the fees paid to // miners. @@ -761,8 +762,9 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) { } b.log.Infof("attempting to publish non-coop tx=%v with feerate=%v, "+ - "totalfee=%v, sweeps=%d, destAddr=%s", batchTx.TxHash(), - b.rbfCache.FeeRate, fee, len(batchTx.TxIn), address) + "weight=%v, feeForWeight=%v, fee=%v, sweeps=%d, destAddr=%s", + batchTx.TxHash(), b.rbfCache.FeeRate, weight, feeForWeight, fee, + len(batchTx.TxIn), address) b.debugLogTx("serialized non-coop sweep", batchTx) @@ -857,10 +859,11 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount, weightEstimate.AddP2TROutput() - fee = b.rbfCache.FeeRate.FeeForWeight(weightEstimate.Weight()) + weight := weightEstimate.Weight() + feeForWeight := b.rbfCache.FeeRate.FeeForWeight(weight) // Clamp the calculated fee to the max allowed fee amount for the batch. - fee = clampBatchFee(fee, batchAmt) + fee = clampBatchFee(feeForWeight, batchAmt) // Add the batch transaction output, which excludes the fees paid to // miners. @@ -905,8 +908,9 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount, } b.log.Infof("attempting to publish coop tx=%v with feerate=%v, "+ - "totalfee=%v, sweeps=%d, destAddr=%s", batchTx.TxHash(), - b.rbfCache.FeeRate, fee, len(batchTx.TxIn), address) + "weight=%v, feeForWeight=%v, fee=%v, sweeps=%d, destAddr=%s", + batchTx.TxHash(), b.rbfCache.FeeRate, weight, feeForWeight, fee, + len(batchTx.TxIn), address) b.debugLogTx("serialized coop sweep", batchTx)