Skip to content

Commit

Permalink
multi: add trace log outputs
Browse files Browse the repository at this point in the history
This commit adds a couple of trace outputs that were helpful in finding
two bugs fixed in this series of commits.

We also increase the number of levels the spew logger is allowed to
print, so we can see a bit more. We need this limit to avoid endless
loops in self-referencing structs such as proofs.
  • Loading branch information
guggero committed Nov 27, 2024
1 parent 78bea04 commit 8076596
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions tapchannel/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,13 @@ func CreateAllocations(chanState lnwallet.AuxChanState, ourBalance,
// asset level, NOT for the BTC level.
tweakedTree := TweakHtlcTree(htlcTree, htlc.HtlcIndex)

log.Tracef("Tweaking HTLC script key with index %d: internal "+
"key %x -> %x, script key %x -> %x", htlc.HtlcIndex,
htlcTree.InternalKey.SerializeCompressed(),
tweakedTree.InternalKey.SerializeCompressed(),
schnorr.SerializePubKey(htlcTree.TaprootKey),
schnorr.SerializePubKey(tweakedTree.TaprootKey))

allocations = append(allocations, &Allocation{
Type: allocType,
Amount: rfqmsg.Sum(htlc.AssetBalances),
Expand Down Expand Up @@ -1288,6 +1295,13 @@ func createSecondLevelHtlcAllocations(chanType channeldb.ChannelType,
// the BTC level.
tweakedTree := TweakHtlcTree(htlcTree, htlcIndex)

log.Tracef("Tweaking second level HTLC script key with index %d: "+
"internal key %x -> %x, script key %x -> %x", htlcIndex,
htlcTree.InternalKey.SerializeCompressed(),
tweakedTree.InternalKey.SerializeCompressed(),
schnorr.SerializePubKey(htlcTree.TaprootKey),
schnorr.SerializePubKey(tweakedTree.TaprootKey))

allocations := []*Allocation{{
Type: SecondLevelHtlcAllocation,
// If we're making the second-level transaction just to sign,
Expand Down
2 changes: 1 addition & 1 deletion tapchannel/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var log = btclog.Disabled
// to 4 levels, so it can safely be used for things that contain an MS-SMT tree.
var limitSpewer = &spew.ConfigState{
Indent: " ",
MaxDepth: 5,
MaxDepth: 7,
}

// DisableLog disables all library log output. Logging output is disabled
Expand Down
4 changes: 4 additions & 0 deletions tapsend/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btclog"
"github.com/davecgh/go-spew/spew"
"github.com/lightninglabs/lndclient"
"github.com/lightninglabs/taproot-assets/address"
"github.com/lightninglabs/taproot-assets/asset"
Expand Down Expand Up @@ -974,6 +975,9 @@ func CreateTaprootSignature(vIn *tappsbt.VInput, virtualTx *wire.MsgTx,
"from virtual transaction packet")
}

log.Tracef("Signing virtual TX with descriptor %v",
spew.Sdump(spendDesc))

sig, err := txSigner.SignVirtualTx(&spendDesc, virtualTx, prevOut)
if err != nil {
return nil, err
Expand Down

0 comments on commit 8076596

Please sign in to comment.