autopilot+funding+rpc+invoices: complete migration to lazy debug logging

In this commit, we complete the migration to lnutils.SpewLogClosure for
the remaining application-layer components. This includes the autopilot
channel management system, the funding manager, the RPC server, and the
invoice storage subsystem.
This commit is contained in:
Olaoluwa Osuntokun committed 2025-09-05 18:20:52 -07:00
1 parent 2cc4079a0e
commit f77cd51671
4 files changed
+17 -13

No files matched your search

+8 -5
View File
@@ -11,8 +11,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
) )
@@ -443,7 +443,7 @@ func (a *Agent) controller(ctx context.Context) {
case *chanOpenUpdate: case *chanOpenUpdate:
log.Debugf("New channel successfully opened, "+ log.Debugf("New channel successfully opened, "+
"updating state with: %v", "updating state with: %v",
spew.Sdump(update.newChan)) lnutils.SpewLogClosure(update.newChan))
newChan := update.newChan newChan := update.newChan
a.chanStateMtx.Lock() a.chanStateMtx.Lock()
@@ -460,7 +460,9 @@ func (a *Agent) controller(ctx context.Context) {
case *chanCloseUpdate: case *chanCloseUpdate:
log.Debugf("Applying closed channel "+ log.Debugf("Applying closed channel "+
"updates: %v", "updates: %v",
spew.Sdump(update.closedChans)) lnutils.SpewLogClosure(
update.closedChans),
)
a.chanStateMtx.Lock() a.chanStateMtx.Lock()
for _, closedChan := range update.closedChans { for _, closedChan := range update.closedChans {
@@ -515,7 +517,8 @@ func (a *Agent) controller(ctx context.Context) {
} }
a.pendingMtx.Lock() a.pendingMtx.Lock()
log.Debugf("Pending channels: %v", spew.Sdump(a.pendingOpens)) log.Debugf("Pending channels: %v",
lnutils.SpewLogClosure(a.pendingOpens))
a.pendingMtx.Unlock() a.pendingMtx.Unlock()
// With all the updates applied, we'll obtain a set of the // With all the updates applied, we'll obtain a set of the
@@ -699,7 +702,7 @@ func (a *Agent) openChans(ctx context.Context, availableFunds btcutil.Amount,
} }
log.Infof("Attempting to execute channel attachment "+ log.Infof("Attempting to execute channel attachment "+
"directives: %v", spew.Sdump(chanCandidates)) "directives: %v", lnutils.SpewLogClosure(chanCandidates))
// Before proceeding, check to see if we have any slots // Before proceeding, check to see if we have any slots
// available to open channels. If there are any, we will attempt // available to open channels. If there are any, we will attempt
+4 -3
View File
@@ -18,7 +18,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/chanacceptor" "github.com/lightningnetwork/lnd/chanacceptor"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
@@ -992,7 +991,9 @@ func (f *Manager) failFundingFlow(peer lnpeer.Peer, cid *chanIdentifier,
} }
log.Debugf("Sending funding error to peer (%x): %v", log.Debugf("Sending funding error to peer (%x): %v",
peer.IdentityKey().SerializeCompressed(), spew.Sdump(errMsg)) peer.IdentityKey().SerializeCompressed(),
lnutils.SpewLogClosure(errMsg))
if err := peer.SendMessage(false, errMsg); err != nil { if err := peer.SendMessage(false, errMsg); err != nil {
log.Errorf("unable to send error message to peer %v", err) log.Errorf("unable to send error message to peer %v", err)
} }
@@ -1012,7 +1013,7 @@ func (f *Manager) sendWarning(peer lnpeer.Peer, cid *chanIdentifier,
log.Debugf("Sending funding warning to peer (%x): %v", log.Debugf("Sending funding warning to peer (%x): %v",
peer.IdentityKey().SerializeCompressed(), peer.IdentityKey().SerializeCompressed(),
spew.Sdump(errMsg), lnutils.SpewLogClosure(errMsg),
) )
if err := peer.SendMessage(false, errMsg); err != nil { if err := peer.SendMessage(false, errMsg); err != nil {
+2 -2
View File
@@ -10,10 +10,10 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/record" "github.com/lightningnetwork/lnd/record"
"github.com/lightningnetwork/lnd/sqldb" "github.com/lightningnetwork/lnd/sqldb"
@@ -409,7 +409,7 @@ func getInvoiceByRef(ctx context.Context,
// In case the reference is ambiguous, meaning it matches more // In case the reference is ambiguous, meaning it matches more
// than one invoice, we'll return an error. // than one invoice, we'll return an error.
return sqlc.Invoice{}, fmt.Errorf("ambiguous invoice ref: "+ return sqlc.Invoice{}, fmt.Errorf("ambiguous invoice ref: "+
"%s: %s", ref.String(), spew.Sdump(rows)) "%s: %s", ref.String(), lnutils.SpewLogClosure(rows))
case err != nil: case err != nil:
return sqlc.Invoice{}, fmt.Errorf("unable to fetch invoice: %w", return sqlc.Invoice{}, fmt.Errorf("unable to fetch invoice: %w",
+3 -3
View File
@@ -33,7 +33,6 @@ import (
"github.com/btcsuite/btcwallet/waddrmgr" "github.com/btcsuite/btcwallet/waddrmgr"
"github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wallet"
"github.com/btcsuite/btcwallet/wallet/txauthor" "github.com/btcsuite/btcwallet/wallet/txauthor"
"github.com/davecgh/go-spew/spew"
proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/build"
@@ -1526,7 +1525,8 @@ func (r *rpcServer) SendCoins(ctx context.Context,
} }
rpcsLog.Debugf("Sweeping coins from wallet to addr=%v, "+ rpcsLog.Debugf("Sweeping coins from wallet to addr=%v, "+
"with tx=%v", in.Addr, spew.Sdump(sweepTxPkg.SweepTx)) "with tx=%v", in.Addr,
lnutils.SpewLogClosure(sweepTxPkg.SweepTx))
// As our sweep transaction was created, successfully, we'll // As our sweep transaction was created, successfully, we'll
// now attempt to publish it, cancelling the sweep pkg to // now attempt to publish it, cancelling the sweep pkg to
@@ -1612,7 +1612,7 @@ func (r *rpcServer) SendMany(ctx context.Context,
} }
rpcsLog.Infof("[sendmany] outputs=%v, sat/kw=%v", rpcsLog.Infof("[sendmany] outputs=%v, sat/kw=%v",
spew.Sdump(in.AddrToAmount), int64(feePerKw)) lnutils.SpewLogClosure(in.AddrToAmount), int64(feePerKw))
var txid *chainhash.Hash var txid *chainhash.Hash