lnwallet: for rbf coop close, log the close tx

This commit is contained in:
Olaoluwa Osuntokun committed 2024-12-10 23:07:02 +01:00
1 parent b94ce6fa08
commit b8cf5ae98f
7 files changed
+11 -21

No files matched your search

+1 -1
View File
@@ -189,7 +189,7 @@ func (m *mockChannel) RemoteUpfrontShutdownScript() lnwire.DeliveryAddress {
func (m *mockChannel) CreateCloseProposal(fee btcutil.Amount, func (m *mockChannel) CreateCloseProposal(fee btcutil.Amount,
localScript, remoteScript []byte, localScript, remoteScript []byte,
_ ...lnwallet.ChanCloseOpt) (input.Signature, *chainhash.Hash, _ ...lnwallet.ChanCloseOpt) (input.Signature, *wire.MsgTx,
btcutil.Amount, error) { btcutil.Amount, error) {
if m.chanType.IsTaproot() { if m.chanType.IsTaproot() {
+1 -2
View File
@@ -3,7 +3,6 @@ package chancloser
import ( import (
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2" "github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/fn/v2"
@@ -100,7 +99,7 @@ type Channel interface { //nolint:interfacebloat
localDeliveryScript []byte, remoteDeliveryScript []byte, localDeliveryScript []byte, remoteDeliveryScript []byte,
closeOpt ...lnwallet.ChanCloseOpt, closeOpt ...lnwallet.ChanCloseOpt,
) ( ) (
input.Signature, *chainhash.Hash, btcutil.Amount, error) input.Signature, *wire.MsgTx, btcutil.Amount, error)
// CompleteCooperativeClose persistently "completes" the cooperative // CompleteCooperativeClose persistently "completes" the cooperative
// close by producing a fully signed co-op close transaction. // close by producing a fully signed co-op close transaction.
+2 -2
View File
@@ -153,11 +153,11 @@ type mockCloseSigner struct {
func (m *mockCloseSigner) CreateCloseProposal(fee btcutil.Amount, func (m *mockCloseSigner) CreateCloseProposal(fee btcutil.Amount,
localScript []byte, remoteScript []byte, localScript []byte, remoteScript []byte,
closeOpt ...lnwallet.ChanCloseOpt) ( closeOpt ...lnwallet.ChanCloseOpt) (
input.Signature, *chainhash.Hash, btcutil.Amount, error) { input.Signature, *wire.MsgTx, btcutil.Amount, error) {
args := m.Called(fee, localScript, remoteScript, closeOpt) args := m.Called(fee, localScript, remoteScript, closeOpt)
return args.Get(0).(input.Signature), args.Get(1).(*chainhash.Hash), return args.Get(0).(input.Signature), args.Get(1).(*wire.MsgTx),
args.Get(2).(btcutil.Amount), args.Error(3) args.Get(2).(btcutil.Amount), args.Error(3)
} }
+1 -2
View File
@@ -6,7 +6,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
@@ -223,7 +222,7 @@ type CloseSigner interface {
localDeliveryScript []byte, remoteDeliveryScript []byte, localDeliveryScript []byte, remoteDeliveryScript []byte,
closeOpt ...lnwallet.ChanCloseOpt, closeOpt ...lnwallet.ChanCloseOpt,
) ( ) (
input.Signature, *chainhash.Hash, btcutil.Amount, error) input.Signature, *wire.MsgTx, btcutil.Amount, error)
// CompleteCooperativeClose persistently "completes" the cooperative // CompleteCooperativeClose persistently "completes" the cooperative
// close by producing a fully signed co-op close transaction. // close by producing a fully signed co-op close transaction.
+2 -10
View File
@@ -13,7 +13,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/mempool"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
@@ -52,18 +51,11 @@ var (
remoteSig = sigMustParse(remoteSigBytes) remoteSig = sigMustParse(remoteSigBytes)
remoteWireSig = mustWireSig(&remoteSig) remoteWireSig = mustWireSig(&remoteSig)
localTxid = newChainHash(bytes.Repeat([]byte{0x01}, 32)) localTx = wire.MsgTx{Version: 2}
remoteTxid = newChainHash(bytes.Repeat([]byte{0x02}, 32))
closeTx = wire.NewMsgTx(2) closeTx = wire.NewMsgTx(2)
) )
func newChainHash(b []byte) chainhash.Hash {
var h chainhash.Hash
copy(h[:], b)
return h
}
func sigMustParse(sigBytes []byte) ecdsa.Signature { func sigMustParse(sigBytes []byte) ecdsa.Signature {
sig, err := ecdsa.ParseSignature(sigBytes) sig, err := ecdsa.ParseSignature(sigBytes)
if err != nil { if err != nil {
@@ -386,7 +378,7 @@ func (r *rbfCloserTestHarness) expectNewCloseSig(
r.signer.On( r.signer.On(
"CreateCloseProposal", fee, localScript, remoteScript, "CreateCloseProposal", fee, localScript, remoteScript,
mock.Anything, mock.Anything,
).Return(&localSig, &localTxid, closeBalance, nil) ).Return(&localSig, &localTx, closeBalance, nil)
} }
func (r *rbfCloserTestHarness) waitForMsgSent() { func (r *rbfCloserTestHarness) waitForMsgSent() {
+1 -1
View File
@@ -308,8 +308,8 @@ func (s *ShutdownPending) ProcessEvent(event ProtocolEvent, env *Environment,
} }
// If the channel is *already* flushed, and the close is // If the channel is *already* flushed, and the close is
// already in progress, then we can skip the flushing state and
// go straight into negotiation, as this is the RBF loop. // go straight into negotiation, as this is the RBF loop.
// already in progress, then we can skip the flushing state and
var eventsToEmit fn.Option[protofsm.EmittedEvent[ProtocolEvent]] var eventsToEmit fn.Option[protofsm.EmittedEvent[ProtocolEvent]]
finalBalances := env.ChanObserver.FinalBalances().UnwrapOr( finalBalances := env.ChanObserver.FinalBalances().UnwrapOr(
unknownBalance, unknownBalance,
+3 -3
View File
@@ -8264,7 +8264,7 @@ func WithCustomLockTime(lockTime uint32) ChanCloseOpt {
// returned. // returned.
func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount, func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
localDeliveryScript []byte, remoteDeliveryScript []byte, localDeliveryScript []byte, remoteDeliveryScript []byte,
closeOpts ...ChanCloseOpt) (input.Signature, *chainhash.Hash, closeOpts ...ChanCloseOpt) (input.Signature, *wire.MsgTx,
btcutil.Amount, error) { btcutil.Amount, error) {
lc.Lock() lc.Lock()
@@ -8364,8 +8364,8 @@ func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
} }
} }
closeTXID := closeTx.TxHash() return sig, closeTx, ourBalance, nil
return sig, &closeTXID, ourBalance, nil
} }
// CompleteCooperativeClose completes the cooperative closure of the target // CompleteCooperativeClose completes the cooperative closure of the target