lnwallet: for rbf coop close, log the close tx
This commit is contained in:
7 files changed
+11
-21
No files matched your search
@@ -189,7 +189,7 @@ func (m *mockChannel) RemoteUpfrontShutdownScript() lnwire.DeliveryAddress {
|
||||
|
||||
func (m *mockChannel) CreateCloseProposal(fee btcutil.Amount,
|
||||
localScript, remoteScript []byte,
|
||||
_ ...lnwallet.ChanCloseOpt) (input.Signature, *chainhash.Hash,
|
||||
_ ...lnwallet.ChanCloseOpt) (input.Signature, *wire.MsgTx,
|
||||
btcutil.Amount, error) {
|
||||
|
||||
if m.chanType.IsTaproot() {
|
||||
|
||||
@@ -3,7 +3,6 @@ package chancloser
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
@@ -100,7 +99,7 @@ type Channel interface { //nolint:interfacebloat
|
||||
localDeliveryScript []byte, remoteDeliveryScript []byte,
|
||||
closeOpt ...lnwallet.ChanCloseOpt,
|
||||
) (
|
||||
input.Signature, *chainhash.Hash, btcutil.Amount, error)
|
||||
input.Signature, *wire.MsgTx, btcutil.Amount, error)
|
||||
|
||||
// CompleteCooperativeClose persistently "completes" the cooperative
|
||||
// close by producing a fully signed co-op close transaction.
|
||||
|
||||
@@ -153,11 +153,11 @@ type mockCloseSigner struct {
|
||||
func (m *mockCloseSigner) CreateCloseProposal(fee btcutil.Amount,
|
||||
localScript []byte, remoteScript []byte,
|
||||
closeOpt ...lnwallet.ChanCloseOpt) (
|
||||
input.Signature, *chainhash.Hash, btcutil.Amount, error) {
|
||||
input.Signature, *wire.MsgTx, btcutil.Amount, error) {
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
@@ -223,7 +222,7 @@ type CloseSigner interface {
|
||||
localDeliveryScript []byte, remoteDeliveryScript []byte,
|
||||
closeOpt ...lnwallet.ChanCloseOpt,
|
||||
) (
|
||||
input.Signature, *chainhash.Hash, btcutil.Amount, error)
|
||||
input.Signature, *wire.MsgTx, btcutil.Amount, error)
|
||||
|
||||
// CompleteCooperativeClose persistently "completes" the cooperative
|
||||
// close by producing a fully signed co-op close transaction.
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"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"
|
||||
@@ -52,18 +51,11 @@ var (
|
||||
remoteSig = sigMustParse(remoteSigBytes)
|
||||
remoteWireSig = mustWireSig(&remoteSig)
|
||||
|
||||
localTxid = newChainHash(bytes.Repeat([]byte{0x01}, 32))
|
||||
remoteTxid = newChainHash(bytes.Repeat([]byte{0x02}, 32))
|
||||
localTx = wire.MsgTx{Version: 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 {
|
||||
sig, err := ecdsa.ParseSignature(sigBytes)
|
||||
if err != nil {
|
||||
@@ -386,7 +378,7 @@ func (r *rbfCloserTestHarness) expectNewCloseSig(
|
||||
r.signer.On(
|
||||
"CreateCloseProposal", fee, localScript, remoteScript,
|
||||
mock.Anything,
|
||||
).Return(&localSig, &localTxid, closeBalance, nil)
|
||||
).Return(&localSig, &localTx, closeBalance, nil)
|
||||
}
|
||||
|
||||
func (r *rbfCloserTestHarness) waitForMsgSent() {
|
||||
|
||||
@@ -308,8 +308,8 @@ func (s *ShutdownPending) ProcessEvent(event ProtocolEvent, env *Environment,
|
||||
}
|
||||
|
||||
// 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.
|
||||
// already in progress, then we can skip the flushing state and
|
||||
var eventsToEmit fn.Option[protofsm.EmittedEvent[ProtocolEvent]]
|
||||
finalBalances := env.ChanObserver.FinalBalances().UnwrapOr(
|
||||
unknownBalance,
|
||||
|
||||
+3
-3
@@ -8264,7 +8264,7 @@ func WithCustomLockTime(lockTime uint32) ChanCloseOpt {
|
||||
// returned.
|
||||
func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
|
||||
localDeliveryScript []byte, remoteDeliveryScript []byte,
|
||||
closeOpts ...ChanCloseOpt) (input.Signature, *chainhash.Hash,
|
||||
closeOpts ...ChanCloseOpt) (input.Signature, *wire.MsgTx,
|
||||
btcutil.Amount, error) {
|
||||
|
||||
lc.Lock()
|
||||
@@ -8364,8 +8364,8 @@ func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
|
||||
}
|
||||
}
|
||||
|
||||
closeTXID := closeTx.TxHash()
|
||||
return sig, &closeTXID, ourBalance, nil
|
||||
return sig, closeTx, ourBalance, nil
|
||||
|
||||
}
|
||||
|
||||
// CompleteCooperativeClose completes the cooperative closure of the target
|
||||
|
||||
Reference in new issue
Block a user