watchtower: fix logging and add comments

This commit is contained in:
yyforyongyu
2025-06-26 17:51:00 +08:00
parent 6290edf146
commit bef90c6a84

View File

@@ -12,6 +12,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/watchtower/blob"
"github.com/lightningnetwork/lnd/watchtower/wtdb"
)
@@ -230,6 +231,9 @@ func (p *JusticeDescriptor) CreateJusticeTxn() (*wire.MsgTx, error) {
case input.P2WPKHSize:
weightEstimate.AddP2WKHOutput()
// NOTE: P2TR has the same size as P2WSH (34 bytes), their output sizes
// are also the same (43 bytes), so here we implicitly catch the P2TR
// output case.
case input.P2WSHSize:
weightEstimate.AddP2WSHOutput()
@@ -260,8 +264,9 @@ func (p *JusticeDescriptor) CreateJusticeTxn() (*wire.MsgTx, error) {
sweepInputs = append(sweepInputs, toLocalInput)
log.Debugf("Found to local witness output=%#v, stack=%v",
toLocalInput.txOut, toLocalInput.witness)
log.Debugf("Found to local witness output=%v, stack=%x",
lnutils.SpewLogClosure(toLocalInput.txOut),
toLocalInput.witness)
// If the justice kit specifies that we have to sweep the to-remote
// output, we'll also try to assemble the output and add it to weight
@@ -273,8 +278,9 @@ func (p *JusticeDescriptor) CreateJusticeTxn() (*wire.MsgTx, error) {
}
sweepInputs = append(sweepInputs, toRemoteInput)
log.Debugf("Found to remote witness output=%#v, stack=%v",
toRemoteInput.txOut, toRemoteInput.witness)
log.Debugf("Found to remote witness output=%v, stack=%x",
lnutils.SpewLogClosure(toRemoteInput.txOut),
toRemoteInput.witness)
// Get the weight for the to-remote witness and add that to the
// estimator.