diff --git a/itest/lnd_psbt_test.go b/itest/lnd_psbt_test.go index cd93fa0c0..2d4118599 100644 --- a/itest/lnd_psbt_test.go +++ b/itest/lnd_psbt_test.go @@ -649,16 +649,51 @@ func runPsbtChanFundingSingleStep(ht *lntest.HarnessTest, carol, // testSignPsbt tests that the SignPsbt RPC works correctly. func testSignPsbt(ht *lntest.HarnessTest) { - runSignPsbtSegWitV0P2WKH(ht, ht.Alice) - runSignPsbtSegWitV0NP2WKH(ht, ht.Alice) - runSignPsbtSegWitV1KeySpendBip86(ht, ht.Alice) - runSignPsbtSegWitV1KeySpendRootHash(ht, ht.Alice) - runSignPsbtSegWitV1ScriptSpend(ht, ht.Alice) + psbtTestRunners := []struct { + name string + runner func(*lntest.HarnessTest, *node.HarnessNode) + }{ + { + name: "sign psbt segwit v0 P2WPKH", + runner: runSignPsbtSegWitV0P2WKH, + }, + { + name: "sign psbt segwit v0 P2WSH", + runner: runSignPsbtSegWitV0NP2WKH, + }, + { + name: "sign psbt segwit v1 key spend bip86", + runner: runSignPsbtSegWitV1KeySpendBip86, + }, + { + name: "sign psbt segwit v1 key spend root hash", + runner: runSignPsbtSegWitV1KeySpendRootHash, + }, + { + name: "sign psbt segwit v1 script spend", + runner: runSignPsbtSegWitV1ScriptSpend, + }, + { + // The above tests all make sure we can sign for keys + // that aren't in the wallet. But we also want to make + // sure we can fund and then sign PSBTs from our + // wallet. + name: "fund and sign psbt", + runner: runFundAndSignPsbt, + }, + } - // The above tests all make sure we can sign for keys that aren't in - // the wallet. But we also want to make sure we can fund and then sign - // PSBTs from our wallet. - runFundAndSignPsbt(ht, ht.Alice) + for _, tc := range psbtTestRunners { + succeed := ht.Run(tc.name, func(t *testing.T) { + st := ht.Subtest(t) + tc.runner(st, st.Alice) + }) + + // Abort the test if failed. + if !succeed { + return + } + } } // runSignPsbtSegWitV0P2WKH tests that the SignPsbt RPC works correctly for a diff --git a/sweep/walletsweep.go b/sweep/walletsweep.go index 8eb3764a1..733855068 100644 --- a/sweep/walletsweep.go +++ b/sweep/walletsweep.go @@ -246,6 +246,8 @@ func CraftSweepAllTx(feeRate, maxFeeRate chainfee.SatPerKWeight, // knows of. Otherwise, it may be possible for a new funding flow to // lock an output while we fetch the set of unspent witnesses. err := coinSelectLocker.WithCoinSelectLock(func() error { + log.Trace("[WithCoinSelectLock] entered the lock") + // Now that we can be sure that no other coin selection // operations are going on, we can grab a clean snapshot of the // current UTXO state of the wallet. @@ -256,10 +258,15 @@ func CraftSweepAllTx(feeRate, maxFeeRate chainfee.SatPerKWeight, return err } + log.Trace("[WithCoinSelectLock] finished fetching UTXOs") + // We'll now lock each UTXO to ensure that other callers don't // attempt to use these UTXOs in transactions while we're // crafting out sweep all transaction. for _, utxo := range utxos { + log.Tracef("[WithCoinSelectLock] leasing utxo: %v", + utxo.OutPoint) + _, _, _, err = outputLeaser.LeaseOutput( chanfunding.LndInternalLockID, utxo.OutPoint, chanfunding.DefaultLockDuration, @@ -269,6 +276,8 @@ func CraftSweepAllTx(feeRate, maxFeeRate chainfee.SatPerKWeight, } } + log.Trace("[WithCoinSelectLock] exited the lock") + allOutputs = append(allOutputs, utxos...) return nil