Skip to content

Commit b8cf5ae

Browse files
committed
lnwallet: for rbf coop close, log the close tx
1 parent b94ce6f commit b8cf5ae

File tree

7 files changed

+11
-21
lines changed

7 files changed

+11
-21
lines changed

lnwallet/chancloser/chancloser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (m *mockChannel) RemoteUpfrontShutdownScript() lnwire.DeliveryAddress {
189189

190190
func (m *mockChannel) CreateCloseProposal(fee btcutil.Amount,
191191
localScript, remoteScript []byte,
192-
_ ...lnwallet.ChanCloseOpt) (input.Signature, *chainhash.Hash,
192+
_ ...lnwallet.ChanCloseOpt) (input.Signature, *wire.MsgTx,
193193
btcutil.Amount, error) {
194194

195195
if m.chanType.IsTaproot() {

lnwallet/chancloser/interface.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package chancloser
33
import (
44
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
55
"github.com/btcsuite/btcd/btcutil"
6-
"github.com/btcsuite/btcd/chaincfg/chainhash"
76
"github.com/btcsuite/btcd/wire"
87
"github.com/lightningnetwork/lnd/channeldb"
98
"github.com/lightningnetwork/lnd/fn/v2"
@@ -100,7 +99,7 @@ type Channel interface { //nolint:interfacebloat
10099
localDeliveryScript []byte, remoteDeliveryScript []byte,
101100
closeOpt ...lnwallet.ChanCloseOpt,
102101
) (
103-
input.Signature, *chainhash.Hash, btcutil.Amount, error)
102+
input.Signature, *wire.MsgTx, btcutil.Amount, error)
104103

105104
// CompleteCooperativeClose persistently "completes" the cooperative
106105
// close by producing a fully signed co-op close transaction.

lnwallet/chancloser/mock.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ type mockCloseSigner struct {
153153
func (m *mockCloseSigner) CreateCloseProposal(fee btcutil.Amount,
154154
localScript []byte, remoteScript []byte,
155155
closeOpt ...lnwallet.ChanCloseOpt) (
156-
input.Signature, *chainhash.Hash, btcutil.Amount, error) {
156+
input.Signature, *wire.MsgTx, btcutil.Amount, error) {
157157

158158
args := m.Called(fee, localScript, remoteScript, closeOpt)
159159

160-
return args.Get(0).(input.Signature), args.Get(1).(*chainhash.Hash),
160+
return args.Get(0).(input.Signature), args.Get(1).(*wire.MsgTx),
161161
args.Get(2).(btcutil.Amount), args.Error(3)
162162
}
163163

lnwallet/chancloser/rbf_coop_states.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/btcsuite/btcd/btcec/v2"
77
"github.com/btcsuite/btcd/btcutil"
88
"github.com/btcsuite/btcd/chaincfg"
9-
"github.com/btcsuite/btcd/chaincfg/chainhash"
109
"github.com/btcsuite/btcd/wire"
1110
"github.com/lightningnetwork/lnd/chainntnfs"
1211
"github.com/lightningnetwork/lnd/channeldb"
@@ -223,7 +222,7 @@ type CloseSigner interface {
223222
localDeliveryScript []byte, remoteDeliveryScript []byte,
224223
closeOpt ...lnwallet.ChanCloseOpt,
225224
) (
226-
input.Signature, *chainhash.Hash, btcutil.Amount, error)
225+
input.Signature, *wire.MsgTx, btcutil.Amount, error)
227226

228227
// CompleteCooperativeClose persistently "completes" the cooperative
229228
// close by producing a fully signed co-op close transaction.

lnwallet/chancloser/rbf_coop_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
1414
"github.com/btcsuite/btcd/btcutil"
1515
"github.com/btcsuite/btcd/chaincfg"
16-
"github.com/btcsuite/btcd/chaincfg/chainhash"
1716
"github.com/btcsuite/btcd/mempool"
1817
"github.com/btcsuite/btcd/txscript"
1918
"github.com/btcsuite/btcd/wire"
@@ -52,18 +51,11 @@ var (
5251
remoteSig = sigMustParse(remoteSigBytes)
5352
remoteWireSig = mustWireSig(&remoteSig)
5453

55-
localTxid = newChainHash(bytes.Repeat([]byte{0x01}, 32))
56-
remoteTxid = newChainHash(bytes.Repeat([]byte{0x02}, 32))
54+
localTx = wire.MsgTx{Version: 2}
5755

5856
closeTx = wire.NewMsgTx(2)
5957
)
6058

61-
func newChainHash(b []byte) chainhash.Hash {
62-
var h chainhash.Hash
63-
copy(h[:], b)
64-
return h
65-
}
66-
6759
func sigMustParse(sigBytes []byte) ecdsa.Signature {
6860
sig, err := ecdsa.ParseSignature(sigBytes)
6961
if err != nil {
@@ -386,7 +378,7 @@ func (r *rbfCloserTestHarness) expectNewCloseSig(
386378
r.signer.On(
387379
"CreateCloseProposal", fee, localScript, remoteScript,
388380
mock.Anything,
389-
).Return(&localSig, &localTxid, closeBalance, nil)
381+
).Return(&localSig, &localTx, closeBalance, nil)
390382
}
391383

392384
func (r *rbfCloserTestHarness) waitForMsgSent() {

lnwallet/chancloser/rbf_coop_transitions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ func (s *ShutdownPending) ProcessEvent(event ProtocolEvent, env *Environment,
308308
}
309309

310310
// If the channel is *already* flushed, and the close is
311-
// already in progress, then we can skip the flushing state and
312311
// go straight into negotiation, as this is the RBF loop.
312+
// already in progress, then we can skip the flushing state and
313313
var eventsToEmit fn.Option[protofsm.EmittedEvent[ProtocolEvent]]
314314
finalBalances := env.ChanObserver.FinalBalances().UnwrapOr(
315315
unknownBalance,

lnwallet/channel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8264,7 +8264,7 @@ func WithCustomLockTime(lockTime uint32) ChanCloseOpt {
82648264
// returned.
82658265
func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
82668266
localDeliveryScript []byte, remoteDeliveryScript []byte,
8267-
closeOpts ...ChanCloseOpt) (input.Signature, *chainhash.Hash,
8267+
closeOpts ...ChanCloseOpt) (input.Signature, *wire.MsgTx,
82688268
btcutil.Amount, error) {
82698269

82708270
lc.Lock()
@@ -8364,8 +8364,8 @@ func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
83648364
}
83658365
}
83668366

8367-
closeTXID := closeTx.TxHash()
8368-
return sig, &closeTXID, ourBalance, nil
8367+
return sig, closeTx, ourBalance, nil
8368+
83698369
}
83708370

83718371
// CompleteCooperativeClose completes the cooperative closure of the target

0 commit comments

Comments
 (0)