sweeper+lntest: remove conflicting tx

For anchor channels and neutrino backends we need to make sure
that sweeps of the same exclusive group are removed when one of
them is confirmed. Otherwise for neutrino backends those sweep
transaction are always rebroadcasted and are blocking funds in
the worst case scenario.
This commit is contained in:
ziggie
2023-07-01 12:27:42 +02:00
parent 2fee3f6efa
commit 2bc6b22a43
2 changed files with 83 additions and 34 deletions

View File

@@ -27,6 +27,7 @@ import (
"github.com/lightningnetwork/lnd/lntest/rpc"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)
@@ -693,6 +694,27 @@ func (h *HarnessTest) AssertStreamChannelForceClosed(hn *node.HarnessNode,
closingTxid := h.WaitForChannelCloseEvent(stream)
h.Miner.AssertTxInBlock(block, closingTxid)
// This makes sure that we do not have any lingering unconfirmed anchor
// cpfp transactions blocking some of our utxos. Especially important
// in case of a neutrino backend.
if anchors {
err := wait.NoError(func() error {
utxos := h.GetUTXOsUnconfirmed(
hn, lnwallet.DefaultAccountName,
)
total := len(utxos)
if total == 0 {
return nil
}
return fmt.Errorf("%s: assert %s failed: want %d "+
"got: %d", hn.Name(), "no unconfirmed cpfp "+
"achor sweep transactions", 0, total)
}, DefaultTimeout)
require.NoErrorf(hn, err, "expected no unconfirmed cpfp "+
"anchor sweep utxos")
}
// We should see zero waiting close channels and 1 pending force close
// channels now.
h.AssertNumWaitingClose(hn, 0)