Skip to content

Commit ab71028

Browse files
guggeroRoasbeef
authored andcommitted
tapchannel: use limit spewer only
This fixes an issue of an infinite loop when attempting to spew a proof structure.
1 parent 9000263 commit ab71028

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

tapchannel/aux_closer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/btcsuite/btcd/btcutil"
1111
"github.com/btcsuite/btcd/txscript"
1212
"github.com/btcsuite/btcd/wire"
13-
"github.com/davecgh/go-spew/spew"
1413
"github.com/lightninglabs/taproot-assets/address"
1514
"github.com/lightninglabs/taproot-assets/asset"
1615
"github.com/lightninglabs/taproot-assets/fn"
@@ -250,7 +249,8 @@ func (a *AuxChanCloser) AuxCloseOutputs(
250249
}
251250

252251
log.Tracef("Decoded local_shutdown=%v, remote_shutdown=%v",
253-
spew.Sdump(localShutdown), spew.Sdump(remoteShutdown))
252+
limitSpewer.Sdump(localShutdown),
253+
limitSpewer.Sdump(remoteShutdown))
254254

255255
// To start with, we'll now create the allocations for the asset
256256
// outputs. We track the amount that'll go to the anchor assets, so we
@@ -570,7 +570,7 @@ func (a *AuxChanCloser) ShutdownBlob(
570570
return none, err
571571
}
572572

573-
log.Infof("Constructed shutdown record: %v", spew.Sdump(records))
573+
log.Infof("Constructed shutdown record: %v", limitSpewer.Sdump(records))
574574

575575
return lfn.Some[lnwire.CustomRecords](records), nil
576576
}

tapchannel/aux_funding_controller.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/btcsuite/btcd/btcutil/psbt"
2020
"github.com/btcsuite/btcd/chaincfg/chainhash"
2121
"github.com/btcsuite/btcd/wire"
22-
"github.com/davecgh/go-spew/spew"
2322
"github.com/lightninglabs/taproot-assets/address"
2423
"github.com/lightninglabs/taproot-assets/asset"
2524
"github.com/lightninglabs/taproot-assets/commitment"
@@ -522,7 +521,7 @@ func (p *pendingAssetFunding) unlockAssetInputs(ctx context.Context,
522521
coinSelect tapfreighter.CoinSelector) error {
523522

524523
log.Debugf("unlocking asset inputs: %v",
525-
spew.Sdump(p.lockedAssetInputs))
524+
limitSpewer.Sdump(p.lockedAssetInputs))
526525

527526
err := coinSelect.ReleaseCoins(ctx, p.lockedAssetInputs...)
528527
if err != nil {
@@ -936,7 +935,8 @@ func (f *FundingController) anchorVPackets(fundedPkt *tapsend.FundedPsbt,
936935
func (f *FundingController) signAndFinalizePsbt(ctx context.Context,
937936
pkt *psbt.Packet) (*wire.MsgTx, error) {
938937

939-
log.Debugf("Signing and finalizing PSBT w/ lnd: %v", spew.Sdump(pkt))
938+
log.Debugf("Signing and finalizing PSBT w/ lnd: %v",
939+
limitSpewer.Sdump(pkt))
940940

941941
// By default, the wallet won't try to finalize output it sees are watch
942942
// only (like the asset input), so we'll have it sign ourselves first.
@@ -945,7 +945,7 @@ func (f *FundingController) signAndFinalizePsbt(ctx context.Context,
945945
return nil, fmt.Errorf("unable to sign PSBT: %w", err)
946946
}
947947

948-
log.Debugf("Signed PSBT: %v", spew.Sdump(signedPkt))
948+
log.Debugf("Signed PSBT: %v", limitSpewer.Sdump(signedPkt))
949949

950950
finalizedPkt, err := f.cfg.ChainWallet.SignAndFinalizePsbt(
951951
ctx, signedPkt,
@@ -954,7 +954,7 @@ func (f *FundingController) signAndFinalizePsbt(ctx context.Context,
954954
return nil, fmt.Errorf("unable to finalize PSBT: %w", err)
955955
}
956956

957-
log.Debugf("Finalized PSBT: %v", spew.Sdump(signedPkt))
957+
log.Debugf("Finalized PSBT: %v", limitSpewer.Sdump(signedPkt))
958958

959959
// Extra the tx manually, then perform some manual sanity checks to
960960
// make sure things are ready for broadcast.
@@ -1056,7 +1056,8 @@ func (f *FundingController) completeChannelFunding(ctx context.Context,
10561056
// with lnd that we arrived at the proper TxOut.
10571057
fundingPsbt.UnsignedTx.TxOut[0].Value = int64(fundingReq.ChanAmt)
10581058

1059-
log.Debugf("Funding PSBT pre funding: %s", spew.Sdump(fundingPsbt))
1059+
log.Debugf("Funding PSBT pre funding: %s",
1060+
limitSpewer.Sdump(fundingPsbt))
10601061

10611062
// With the PSBT template created, we'll now ask lnd to fund the PSBT.
10621063
// This'll add yet another output (lnd's change output) to the
@@ -1068,7 +1069,8 @@ func (f *FundingController) completeChannelFunding(ctx context.Context,
10681069
return nil, fmt.Errorf("unable to fund PSBT: %w", err)
10691070
}
10701071

1071-
log.Infof("Funding PSBT post funding: %s", spew.Sdump(finalFundedPsbt))
1072+
log.Infof("Funding PSBT post funding: %s",
1073+
limitSpewer.Sdump(finalFundedPsbt))
10721074

10731075
// If we fail at any step in the process, we want to make sure we
10741076
// unlock the inputs, so we'll add them to funding state now.
@@ -1111,7 +1113,7 @@ func (f *FundingController) completeChannelFunding(ctx context.Context,
11111113
}
11121114

11131115
log.Debugf("Submitting finalized PSBT to lnd for verification: %s",
1114-
spew.Sdump(finalFundedPsbt.Pkt))
1116+
limitSpewer.Sdump(finalFundedPsbt.Pkt))
11151117

11161118
// At this point, we're nearly done, we'll now present the final PSBT
11171119
// to lnd to verification. If this passes, then we're clear to
@@ -1650,7 +1652,7 @@ func (f *FundingController) chanFunder() {
16501652
}
16511653

16521654
log.Infof("Returning funding desc: %v",
1653-
spew.Sdump(fundingDesc))
1655+
limitSpewer.Sdump(fundingDesc))
16541656

16551657
req.resp <- lfn.Some(*fundingDesc)
16561658

tapchannel/aux_invoice_manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"sync"
77

8-
"github.com/davecgh/go-spew/spew"
98
"github.com/lightninglabs/lndclient"
109
"github.com/lightninglabs/taproot-assets/address"
1110
"github.com/lightninglabs/taproot-assets/fn"
@@ -254,7 +253,8 @@ func (s *AuxInvoiceManager) priceFromQuote(rfqID rfqmsg.ID) (
254253
acceptedSellQuotes := s.cfg.RfqManager.LocalAcceptedSellQuotes()
255254

256255
log.Tracef("Currently available quotes: buy %v, sell %v",
257-
spew.Sdump(acceptedBuyQuotes), spew.Sdump(acceptedSellQuotes))
256+
limitSpewer.Sdump(acceptedBuyQuotes),
257+
limitSpewer.Sdump(acceptedSellQuotes))
258258

259259
buyQuote, isBuy := acceptedBuyQuotes[rfqID.Scid()]
260260
sellQuote, isSell := acceptedSellQuotes[rfqID.Scid()]

tapchannel/aux_leaf_signer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/btcsuite/btcd/btcutil/psbt"
1010
"github.com/btcsuite/btcd/txscript"
1111
"github.com/btcsuite/btcd/wire"
12-
"github.com/davecgh/go-spew/spew"
1312
"github.com/lightninglabs/taproot-assets/address"
1413
"github.com/lightninglabs/taproot-assets/asset"
1514
"github.com/lightninglabs/taproot-assets/commitment"
@@ -649,7 +648,7 @@ func (v *schnorrSigValidator) ValidateWitnesses(newAsset *asset.Asset,
649648
if !ok {
650649
return fmt.Errorf("%w: no prev asset for "+
651650
"input_prev_id=%v", vm.ErrNoInputs,
652-
spew.Sdump(witness.PrevID))
651+
limitSpewer.Sdump(witness.PrevID))
653652
}
654653

655654
var (

tapchannel/aux_sweeper.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/btcsuite/btcd/btcutil"
1616
"github.com/btcsuite/btcd/txscript"
1717
"github.com/btcsuite/btcd/wire"
18-
"github.com/davecgh/go-spew/spew"
1918
"github.com/lightninglabs/taproot-assets/address"
2019
"github.com/lightninglabs/taproot-assets/asset"
2120
"github.com/lightninglabs/taproot-assets/fn"
@@ -375,7 +374,7 @@ func (a *AuxSweeper) signSweepVpackets(vPackets []*tappsbt.VPacket,
375374
vIn.TaprootLeafScript[0].ControlBlock = ctrlBlock
376375

377376
log.Debugf("signing vPacket for input=%v",
378-
spew.Sdump(vIn.PrevID))
377+
limitSpewer.Sdump(vIn.PrevID))
379378

380379
// With everything set, we can now sign the new leaf we'll
381380
// sweep into.
@@ -1235,7 +1234,7 @@ func (a *AuxSweeper) importCommitScriptKeys(req lnwallet.ResolutionReq) error {
12351234
return fmt.Errorf("unknown close type: %v", req.CloseType)
12361235
}
12371236

1238-
log.Debugf("Importing script_keys=%v", spew.Sdump(keysToImport))
1237+
log.Debugf("Importing script_keys=%v", limitSpewer.Sdump(keysToImport))
12391238

12401239
ctxb := context.Background()
12411240
for _, key := range keysToImport {
@@ -1268,7 +1267,8 @@ func (a *AuxSweeper) importOutputScriptKeys(desc tapscriptSweepDescs) error {
12681267
},
12691268
}
12701269

1271-
log.Debugf("Importing script_keys=%v", spew.Sdump(scriptKey))
1270+
log.Debugf("Importing script_keys=%v",
1271+
limitSpewer.Sdump(scriptKey))
12721272

12731273
return a.cfg.AddrBook.InsertScriptKey(ctxb, scriptKey, true)
12741274
}
@@ -1327,7 +1327,7 @@ func importOutputProofs(scid lnwire.ShortChannelID,
13271327
}
13281328

13291329
log.Infof("Fetching funding input proof, locator=%v",
1330-
spew.Sdump(inputProofLocator))
1330+
limitSpewer.Sdump(inputProofLocator))
13311331

13321332
// First, we'll make a courier to use in fetching the proofs we
13331333
// need.
@@ -1360,7 +1360,7 @@ func importOutputProofs(scid lnwire.ShortChannelID,
13601360
}
13611361

13621362
log.Infof("All proofs fetched, importing locator=%v",
1363-
spew.Sdump(inputProofLocator))
1363+
limitSpewer.Sdump(inputProofLocator))
13641364

13651365
// Before we combine the proofs below, we'll be sure to update
13661366
// the transition proof to include the proper block+merkle proof
@@ -1832,7 +1832,8 @@ func (a *AuxSweeper) resolveContract(
18321832
}
18331833

18341834
log.Infof("Sweeping %v asset outputs (second_level=%v): %v",
1835-
len(assetOutputs), needsSecondLevel, spew.Sdump(assetOutputs))
1835+
len(assetOutputs), needsSecondLevel,
1836+
limitSpewer.Sdump(assetOutputs))
18361837

18371838
// With the sweep desc constructed above, we'll create vPackets for each
18381839
// of the local assets, then sign them all.
@@ -2270,7 +2271,8 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
22702271
// TODO(roasbeef): need to handle replacement -- will porter just
22712272
// upsert in place?
22722273

2273-
log.Infof("Register broadcast of sweep_tx=%v", spew.Sdump(sweepTx))
2274+
log.Infof("Register broadcast of sweep_tx=%v",
2275+
limitSpewer.Sdump(sweepTx))
22742276

22752277
// In order to properly register the sweep, we'll need to first extra a
22762278
// unified set of vPackets from the specified inputs.
@@ -2431,7 +2433,8 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
24312433
}
24322434
}
24332435

2434-
log.Infof("Proofs generated for sweep_tx=%v", spew.Sdump(sweepTx))
2436+
log.Infof("Proofs generated for sweep_tx=%v",
2437+
limitSpewer.Sdump(sweepTx))
24352438

24362439
// With the output commitments re-created, we have all we need to log
24372440
// and ship the transaction.

0 commit comments

Comments
 (0)