contractcourt: add verbose logging in resolvers

We now put the outpoint in the resolvers's logging so it's easier to
debug.
This commit is contained in:
yyforyongyu
2024-06-20 21:56:52 +08:00
parent 0bab6b3419
commit 1f2cfc6a60
6 changed files with 44 additions and 31 deletions

View File

@@ -82,6 +82,7 @@ func newTimeoutResolver(res lnwallet.OutgoingHtlcResolution,
}
h.initReport()
h.initLogger(fmt.Sprintf("%T(%v)", h, h.outpoint()))
return h
}
@@ -93,23 +94,25 @@ func (h *htlcTimeoutResolver) isTaproot() bool {
)
}
// outpoint returns the outpoint of the HTLC output we're attempting to sweep.
func (h *htlcTimeoutResolver) outpoint() wire.OutPoint {
// The primary key for this resolver will be the outpoint of the HTLC
// on the commitment transaction itself. If this is our commitment,
// then the output can be found within the signed timeout tx,
// otherwise, it's just the ClaimOutpoint.
if h.htlcResolution.SignedTimeoutTx != nil {
return h.htlcResolution.SignedTimeoutTx.TxIn[0].PreviousOutPoint
}
return h.htlcResolution.ClaimOutpoint
}
// ResolverKey returns an identifier which should be globally unique for this
// particular resolver within the chain the original contract resides within.
//
// NOTE: Part of the ContractResolver interface.
func (h *htlcTimeoutResolver) ResolverKey() []byte {
// The primary key for this resolver will be the outpoint of the HTLC
// on the commitment transaction itself. If this is our commitment,
// then the output can be found within the signed timeout tx,
// otherwise, it's just the ClaimOutpoint.
var op wire.OutPoint
if h.htlcResolution.SignedTimeoutTx != nil {
op = h.htlcResolution.SignedTimeoutTx.TxIn[0].PreviousOutPoint
} else {
op = h.htlcResolution.ClaimOutpoint
}
key := newResolverID(op)
key := newResolverID(h.outpoint())
return key[:]
}
@@ -1038,6 +1041,7 @@ func newTimeoutResolverFromReader(r io.Reader, resCfg ResolverConfig) (
}
h.initReport()
h.initLogger(fmt.Sprintf("%T(%v)", h, h.outpoint()))
return h, nil
}