From 77f2d8a572e37270d32542dd26bc770a21b3deb6 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 1 Sep 2025 16:26:39 -0700 Subject: [PATCH] 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. --- contractcourt/chain_watcher.go | 9 +++++---- contractcourt/htlc_timeout_resolver.go | 3 +-- contractcourt/utxonursery.go | 3 +-- sweep/sweeper.go | 5 ++--- watchtower/lookout/justice_descriptor.go | 3 +-- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/contractcourt/chain_watcher.go b/contractcourt/chain_watcher.go index f07b3e87b..9c566fd6b 100644 --- a/contractcourt/chain_watcher.go +++ b/contractcourt/chain_watcher.go @@ -588,10 +588,10 @@ func newChainSet(chanState *channeldb.OpenChannel) (*chainSet, error) { log.Tracef("ChannelPoint(%v): local_commit_type=%v, local_commit=%v", chanState.FundingOutpoint, chanState.ChanType, - spew.Sdump(localCommit)) + lnutils.SpewLogClosure(localCommit)) log.Tracef("ChannelPoint(%v): remote_commit_type=%v, remote_commit=%v", chanState.FundingOutpoint, chanState.ChanType, - spew.Sdump(remoteCommit)) + lnutils.SpewLogClosure(remoteCommit)) // Fetch the current known commit height for the remote party, and // 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, "+ "remote_pending_commit=%v", chanState.FundingOutpoint, chanState.ChanType, - spew.Sdump(remoteChainTip.Commitment)) + lnutils.SpewLogClosure(remoteChainTip.Commitment)) htlcs := remoteChainTip.Commitment.Htlcs commitSet.HtlcSets[RemotePendingHtlcSet] = htlcs @@ -995,7 +995,8 @@ func (c *chainWatcher) dispatchCooperativeClose(commitSpend *chainntnfs.SpendDet broadcastTx := commitSpend.SpendingTx 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 // ours. diff --git a/contractcourt/htlc_timeout_resolver.go b/contractcourt/htlc_timeout_resolver.go index 5b8536398..6beafc399 100644 --- a/contractcourt/htlc_timeout_resolver.go +++ b/contractcourt/htlc_timeout_resolver.go @@ -10,7 +10,6 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/fn/v2" @@ -167,7 +166,7 @@ func (h *htlcTimeoutResolver) claimCleanUp( log.Infof("%T(%v): extracting preimage! remote party spent "+ "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 // them to spend using the second-level success transaction. diff --git a/contractcourt/utxonursery.go b/contractcourt/utxonursery.go index d962ff1da..af4a8cd96 100644 --- a/contractcourt/utxonursery.go +++ b/contractcourt/utxonursery.go @@ -12,7 +12,6 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/fn/v2" @@ -964,7 +963,7 @@ func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) erro !errors.Is(err, lnwallet.ErrMempoolFee) { utxnLog.Errorf("Unable to broadcast baby tx: "+ - "%v, %v", err, spew.Sdump(baby.timeoutTx)) + "%v, %v", err, lnutils.SpewLogClosure(baby.timeoutTx)) return err } diff --git a/sweep/sweeper.go b/sweep/sweeper.go index 2b9bad082..e2163f637 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -9,7 +9,6 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainio" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/fn/v2" @@ -626,7 +625,7 @@ func (s *UtxoSweeper) removeConflictSweepDescendants( // all the transactions that are descendants of outputs created // by the sweepTx and the sweepTx itself. 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) if err != nil { @@ -1435,7 +1434,7 @@ func (s *UtxoSweeper) handleInputSpent(spend *chainntnfs.SpendDetail) { log.Debugf("Attempting to remove descendant txns invalidated "+ "by (txid=%v): %v", spendingTx.TxHash(), - spew.Sdump(spendingTx)) + lnutils.SpewLogClosure(spendingTx)) err := s.removeConflictSweepDescendants(inputsSpent) if err != nil { diff --git a/watchtower/lookout/justice_descriptor.go b/watchtower/lookout/justice_descriptor.go index 1d84e6cc5..e4a095a25 100644 --- a/watchtower/lookout/justice_descriptor.go +++ b/watchtower/lookout/justice_descriptor.go @@ -9,7 +9,6 @@ import ( "github.com/btcsuite/btcd/btcutil/txsort" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnutils" @@ -197,7 +196,7 @@ func (p *JusticeDescriptor) assembleJusticeTxn(txWeight lntypes.WeightUnit, } if err := vm.Execute(); err != nil { log.Debugf("Failed to validate justice transaction: %s", - spew.Sdump(justiceTxn)) + lnutils.SpewLogClosure(justiceTxn)) return nil, fmt.Errorf("error validating TX: %w", err) } }