contractcourt: fix taproot coop close db record bug

In this commit, we fix an issue with co-op closes for taproot channels. Before this commit, we'd think that the remote party broadcasted a state very far in the future, and try to execute DLP. The wallet would properly credit the settled funds, but we'd mark the close in the DB as a force close.

To fix this, we also watch for the RBF sequence number we use in this scenario.
This commit is contained in:
Olaoluwa Osuntokun 2024-05-29 19:57:45 +02:00 committed by Oliver Gugger
parent e7747442d3
commit 3262c45266
No known key found for this signature in database
GPG key ID: 8E4256593F177720

View file

@ -11,6 +11,7 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/mempool"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
@ -714,7 +715,10 @@ func (c *chainWatcher) closeObserver(spendNtfn *chainntnfs.SpendEvent) {
// sequence number that's finalized. This won't happen with
// regular commitment transactions due to the state hint
// encoding scheme.
if commitTxBroadcast.TxIn[0].Sequence == wire.MaxTxInSequenceNum {
switch commitTxBroadcast.TxIn[0].Sequence {
case wire.MaxTxInSequenceNum:
fallthrough
case mempool.MaxRBFSequence:
// TODO(roasbeef): rare but possible, need itest case
// for
err := c.dispatchCooperativeClose(commitSpend)