Skip to content

Commit 75d7641

Browse files
committed
sweepbatcher: add more debug logging
1 parent 13e8c29 commit 75d7641

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

sweepbatcher/sweep_batch.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sweepbatcher
33
import (
44
"bytes"
55
"context"
6+
"encoding/hex"
67
"fmt"
78
"math"
89
"sync"
@@ -700,9 +701,11 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) {
700701
batchTx.TxIn[i].Witness = witness
701702
}
702703

703-
b.log.Debugf("attempting to publish non-coop tx with feerate=%v, "+
704-
"totalfee=%v, sweeps=%v, destAddr=%s", b.rbfCache.FeeRate, fee,
705-
len(batchTx.TxIn), address.String())
704+
b.log.Infof("attempting to publish non-coop tx=%v with feerate=%v, "+
705+
"totalfee=%v, sweeps=%d, destAddr=%s", batchTx.TxHash(),
706+
b.rbfCache.FeeRate, fee, len(batchTx.TxIn), address)
707+
708+
b.debugLogTx("serialized non-coop sweep", batchTx)
706709

707710
err = b.wallet.PublishTransaction(
708711
ctx, batchTx, labels.LoopOutBatchSweepSuccess(b.id),
@@ -846,9 +849,11 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount,
846849
return fee, err, false
847850
}
848851

849-
b.log.Debugf("attempting to publish coop tx with feerate=%v, "+
850-
"totalfee=%v, sweeps=%v, destAddr=%s", b.rbfCache.FeeRate, fee,
851-
len(batchTx.TxIn), address.String())
852+
b.log.Infof("attempting to publish coop tx=%v with feerate=%v, "+
853+
"totalfee=%v, sweeps=%d, destAddr=%s", batchTx.TxHash(),
854+
b.rbfCache.FeeRate, fee, len(batchTx.TxIn), address)
855+
856+
b.debugLogTx("serialized coop sweep", batchTx)
852857

853858
err = b.wallet.PublishTransaction(
854859
ctx, batchTx, labels.LoopOutBatchSweepSuccess(b.id),
@@ -866,6 +871,17 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount,
866871
return fee, nil, true
867872
}
868873

874+
func (b *batch) debugLogTx(msg string, tx *wire.MsgTx) {
875+
// Serialize the transaction and convert to hex string.
876+
buf := bytes.NewBuffer(make([]byte, 0, tx.SerializeSize()))
877+
if err := tx.Serialize(buf); err != nil {
878+
b.log.Errorf("failed to serialize tx for debug log: %v", err)
879+
return
880+
}
881+
882+
b.log.Debugf("%s: %s", msg, hex.EncodeToString(buf.Bytes()))
883+
}
884+
869885
// coopSignBatchTx collects the necessary signatures from the server in order
870886
// to cooperatively sweep the funds.
871887
func (b *batch) coopSignBatchTx(ctx context.Context, packet *psbt.Packet,

0 commit comments

Comments
 (0)