@@ -3,6 +3,7 @@ package sweepbatcher
3
3
import (
4
4
"bytes"
5
5
"context"
6
+ "encoding/hex"
6
7
"fmt"
7
8
"math"
8
9
"sync"
@@ -700,9 +701,11 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) {
700
701
batchTx .TxIn [i ].Witness = witness
701
702
}
702
703
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 )
706
709
707
710
err = b .wallet .PublishTransaction (
708
711
ctx , batchTx , labels .LoopOutBatchSweepSuccess (b .id ),
@@ -846,9 +849,11 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount,
846
849
return fee , err , false
847
850
}
848
851
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 )
852
857
853
858
err = b .wallet .PublishTransaction (
854
859
ctx , batchTx , labels .LoopOutBatchSweepSuccess (b .id ),
@@ -866,6 +871,17 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount,
866
871
return fee , nil , true
867
872
}
868
873
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
+
869
885
// coopSignBatchTx collects the necessary signatures from the server in order
870
886
// to cooperatively sweep the funds.
871
887
func (b * batch ) coopSignBatchTx (ctx context.Context , packet * psbt.Packet ,
0 commit comments