contractcourt+sweep+watchtower: use lnutils.SpewLogClosure for debug logging

In this commit, we update the contractcourt, sweep, and watchtower
packages to use lnutils.SpewLogClosure instead of directly calling
spew.Sdump in logging statements.
This commit is contained in:
Olaoluwa Osuntokun
2025-09-01 16:26:39 -07:00
parent 6e21bc5764
commit 77f2d8a572
5 changed files with 10 additions and 13 deletions

View File

@@ -588,10 +588,10 @@ func newChainSet(chanState *channeldb.OpenChannel) (*chainSet, error) {
log.Tracef("ChannelPoint(%v): local_commit_type=%v, local_commit=%v", log.Tracef("ChannelPoint(%v): local_commit_type=%v, local_commit=%v",
chanState.FundingOutpoint, chanState.ChanType, chanState.FundingOutpoint, chanState.ChanType,
spew.Sdump(localCommit)) lnutils.SpewLogClosure(localCommit))
log.Tracef("ChannelPoint(%v): remote_commit_type=%v, remote_commit=%v", log.Tracef("ChannelPoint(%v): remote_commit_type=%v, remote_commit=%v",
chanState.FundingOutpoint, chanState.ChanType, chanState.FundingOutpoint, chanState.ChanType,
spew.Sdump(remoteCommit)) lnutils.SpewLogClosure(remoteCommit))
// Fetch the current known commit height for the remote party, and // Fetch the current known commit height for the remote party, and
// their pending commitment chain tip if it exists. // their pending commitment chain tip if it exists.
@@ -619,7 +619,7 @@ func newChainSet(chanState *channeldb.OpenChannel) (*chainSet, error) {
log.Tracef("ChannelPoint(%v): remote_pending_commit_type=%v, "+ log.Tracef("ChannelPoint(%v): remote_pending_commit_type=%v, "+
"remote_pending_commit=%v", chanState.FundingOutpoint, "remote_pending_commit=%v", chanState.FundingOutpoint,
chanState.ChanType, chanState.ChanType,
spew.Sdump(remoteChainTip.Commitment)) lnutils.SpewLogClosure(remoteChainTip.Commitment))
htlcs := remoteChainTip.Commitment.Htlcs htlcs := remoteChainTip.Commitment.Htlcs
commitSet.HtlcSets[RemotePendingHtlcSet] = htlcs commitSet.HtlcSets[RemotePendingHtlcSet] = htlcs
@@ -995,7 +995,8 @@ func (c *chainWatcher) dispatchCooperativeClose(commitSpend *chainntnfs.SpendDet
broadcastTx := commitSpend.SpendingTx broadcastTx := commitSpend.SpendingTx
log.Infof("Cooperative closure for ChannelPoint(%v): %v", log.Infof("Cooperative closure for ChannelPoint(%v): %v",
c.cfg.chanState.FundingOutpoint, spew.Sdump(broadcastTx)) c.cfg.chanState.FundingOutpoint,
lnutils.SpewLogClosure(broadcastTx))
// If the input *is* final, then we'll check to see which output is // If the input *is* final, then we'll check to see which output is
// ours. // ours.

View File

@@ -10,7 +10,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/fn/v2"
@@ -167,7 +166,7 @@ func (h *htlcTimeoutResolver) claimCleanUp(
log.Infof("%T(%v): extracting preimage! remote party spent "+ log.Infof("%T(%v): extracting preimage! remote party spent "+
"HTLC with tx=%v", h, h.htlcResolution.ClaimOutpoint, "HTLC with tx=%v", h, h.htlcResolution.ClaimOutpoint,
spew.Sdump(commitSpend.SpendingTx)) lnutils.SpewLogClosure(commitSpend.SpendingTx))
// If this is the remote party's commitment, then we'll be looking for // If this is the remote party's commitment, then we'll be looking for
// them to spend using the second-level success transaction. // them to spend using the second-level success transaction.

View File

@@ -12,7 +12,6 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/fn/v2"
@@ -964,7 +963,7 @@ func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) erro
!errors.Is(err, lnwallet.ErrMempoolFee) { !errors.Is(err, lnwallet.ErrMempoolFee) {
utxnLog.Errorf("Unable to broadcast baby tx: "+ utxnLog.Errorf("Unable to broadcast baby tx: "+
"%v, %v", err, spew.Sdump(baby.timeoutTx)) "%v, %v", err, lnutils.SpewLogClosure(baby.timeoutTx))
return err return err
} }

View File

@@ -9,7 +9,6 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainio" "github.com/lightningnetwork/lnd/chainio"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/fn/v2"
@@ -626,7 +625,7 @@ func (s *UtxoSweeper) removeConflictSweepDescendants(
// all the transactions that are descendants of outputs created // all the transactions that are descendants of outputs created
// by the sweepTx and the sweepTx itself. // by the sweepTx and the sweepTx itself.
log.Debugf("Removing sweep txid=%v from wallet: %v", log.Debugf("Removing sweep txid=%v from wallet: %v",
sweepTx.TxHash(), spew.Sdump(sweepTx)) sweepTx.TxHash(), lnutils.SpewLogClosure(sweepTx))
err = s.cfg.Wallet.RemoveDescendants(sweepTx) err = s.cfg.Wallet.RemoveDescendants(sweepTx)
if err != nil { if err != nil {
@@ -1435,7 +1434,7 @@ func (s *UtxoSweeper) handleInputSpent(spend *chainntnfs.SpendDetail) {
log.Debugf("Attempting to remove descendant txns invalidated "+ log.Debugf("Attempting to remove descendant txns invalidated "+
"by (txid=%v): %v", spendingTx.TxHash(), "by (txid=%v): %v", spendingTx.TxHash(),
spew.Sdump(spendingTx)) lnutils.SpewLogClosure(spendingTx))
err := s.removeConflictSweepDescendants(inputsSpent) err := s.removeConflictSweepDescendants(inputsSpent)
if err != nil { if err != nil {

View File

@@ -9,7 +9,6 @@ import (
"github.com/btcsuite/btcd/btcutil/txsort" "github.com/btcsuite/btcd/btcutil/txsort"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnutils"
@@ -197,7 +196,7 @@ func (p *JusticeDescriptor) assembleJusticeTxn(txWeight lntypes.WeightUnit,
} }
if err := vm.Execute(); err != nil { if err := vm.Execute(); err != nil {
log.Debugf("Failed to validate justice transaction: %s", log.Debugf("Failed to validate justice transaction: %s",
spew.Sdump(justiceTxn)) lnutils.SpewLogClosure(justiceTxn))
return nil, fmt.Errorf("error validating TX: %w", err) return nil, fmt.Errorf("error validating TX: %w", err)
} }
} }