Skip to content

Commit 38e86a1

Browse files
committed
sweepbatcher: log tx weight in addition to feerate
Also log fee before applying clampBatchFee. This is useful to debug fee ralated issues.
1 parent 3d5b7db commit 38e86a1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

sweepbatcher/sweep_batch.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,11 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) {
727727

728728
weightEstimate.AddP2TROutput()
729729

730-
fee = b.rbfCache.FeeRate.FeeForWeight(weightEstimate.Weight())
730+
weight := weightEstimate.Weight()
731+
feeForWeight := b.rbfCache.FeeRate.FeeForWeight(weight)
731732

732733
// Clamp the calculated fee to the max allowed fee amount for the batch.
733-
fee = clampBatchFee(fee, batchAmt)
734+
fee = clampBatchFee(feeForWeight, batchAmt)
734735

735736
// Add the batch transaction output, which excludes the fees paid to
736737
// miners.
@@ -761,8 +762,9 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) {
761762
}
762763

763764
b.log.Infof("attempting to publish non-coop tx=%v with feerate=%v, "+
764-
"totalfee=%v, sweeps=%d, destAddr=%s", batchTx.TxHash(),
765-
b.rbfCache.FeeRate, fee, len(batchTx.TxIn), address)
765+
"weight=%v, feeForWeight=%v, fee=%v, sweeps=%d, destAddr=%s",
766+
batchTx.TxHash(), b.rbfCache.FeeRate, weight, feeForWeight, fee,
767+
len(batchTx.TxIn), address)
766768

767769
b.debugLogTx("serialized non-coop sweep", batchTx)
768770

@@ -857,10 +859,11 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount,
857859

858860
weightEstimate.AddP2TROutput()
859861

860-
fee = b.rbfCache.FeeRate.FeeForWeight(weightEstimate.Weight())
862+
weight := weightEstimate.Weight()
863+
feeForWeight := b.rbfCache.FeeRate.FeeForWeight(weight)
861864

862865
// Clamp the calculated fee to the max allowed fee amount for the batch.
863-
fee = clampBatchFee(fee, batchAmt)
866+
fee = clampBatchFee(feeForWeight, batchAmt)
864867

865868
// Add the batch transaction output, which excludes the fees paid to
866869
// miners.
@@ -905,8 +908,9 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount,
905908
}
906909

907910
b.log.Infof("attempting to publish coop tx=%v with feerate=%v, "+
908-
"totalfee=%v, sweeps=%d, destAddr=%s", batchTx.TxHash(),
909-
b.rbfCache.FeeRate, fee, len(batchTx.TxIn), address)
911+
"weight=%v, feeForWeight=%v, fee=%v, sweeps=%d, destAddr=%s",
912+
batchTx.TxHash(), b.rbfCache.FeeRate, weight, feeForWeight, fee,
913+
len(batchTx.TxIn), address)
910914

911915
b.debugLogTx("serialized coop sweep", batchTx)
912916

0 commit comments

Comments
 (0)