multi: switch to lock time from sequence for coop close v2
This commit is contained in:
5 files changed
+18
-41
No files matched your search
@@ -1430,31 +1430,6 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
|
||||
closeHarness.assertNoStateTransitions()
|
||||
})
|
||||
|
||||
// If the remote party sends us a signature with a final sequence, then
|
||||
// we'll error out as it can't be RBF'd
|
||||
t.Run("recv_offer_final_sequence", func(t *testing.T) {
|
||||
closeHarness := newCloser(t, &harnessCfg{
|
||||
initialState: fn.Some[ProtocolState](startingState),
|
||||
})
|
||||
defer closeHarness.stopAndAssert()
|
||||
|
||||
// We should fail as they sent a non final sequence.
|
||||
closeHarness.expectFailure(ErrNonFinalSequence)
|
||||
|
||||
// We'll send an offer with something beyond the max RBF value,
|
||||
// this should fail.
|
||||
feeOffer := &OfferReceivedEvent{
|
||||
SigMsg: lnwire.ClosingComplete{
|
||||
FeeSatoshis: absoluteFee,
|
||||
Sequence: mempool.MaxRBFSequence + 1,
|
||||
},
|
||||
}
|
||||
closeHarness.chanCloser.SendEvent(feeOffer)
|
||||
|
||||
// We shouldn't have transitioned to a new state.
|
||||
closeHarness.assertNoStateTransitions()
|
||||
})
|
||||
|
||||
// If our balance, is dust, then the remote party should send a
|
||||
// signature that doesn't include our output.
|
||||
t.Run("recv_offer_err_closer_no_closee", func(t *testing.T) {
|
||||
@@ -1559,7 +1534,7 @@ func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
|
||||
feeOffer := &OfferReceivedEvent{
|
||||
SigMsg: lnwire.ClosingComplete{
|
||||
FeeSatoshis: absoluteFee,
|
||||
Sequence: sequence,
|
||||
LockTime: 10,
|
||||
ClosingSigs: lnwire.ClosingSigs{
|
||||
CloserAndClosee: newSigTlv[tlv.TlvType3]( //nolint:ll
|
||||
remoteWireSig,
|
||||
|
||||
@@ -716,7 +716,9 @@ func (l *LocalCloseStart) ProcessEvent(event ProtocolEvent, env *Environment,
|
||||
Msgs: []lnwire.Message{&lnwire.ClosingComplete{
|
||||
ChannelID: env.ChanID,
|
||||
FeeSatoshis: absoluteFee,
|
||||
Sequence: mempool.MaxRBFSequence,
|
||||
// TODO(roasbeef): thread thru proper height
|
||||
// value
|
||||
LockTime: mempool.MaxRBFSequence,
|
||||
ClosingSigs: closingSigs,
|
||||
}},
|
||||
}}
|
||||
@@ -862,18 +864,11 @@ func (l *RemoteCloseStart) ProcessEvent(event ProtocolEvent, env *Environment,
|
||||
// To start, we'll perform some basic validation of the sig
|
||||
// message they've sent. We'll validate that the remote party
|
||||
// actually has enough fees to pay the closing fees.
|
||||
switch {
|
||||
case !l.RemoteCanPayFees(msg.SigMsg.FeeSatoshis):
|
||||
if !l.RemoteCanPayFees(msg.SigMsg.FeeSatoshis) {
|
||||
return nil, fmt.Errorf("%w: %v vs %v",
|
||||
ErrRemoteCannotPay,
|
||||
msg.SigMsg.FeeSatoshis,
|
||||
l.RemoteBalance.ToSatoshis())
|
||||
|
||||
// The sequence they send can't be the max sequence, as that would
|
||||
// prevent RBF.
|
||||
case msg.SigMsg.Sequence > mempool.MaxRBFSequence:
|
||||
return nil, fmt.Errorf("%w: %v", ErrNonFinalSequence,
|
||||
msg.SigMsg.Sequence)
|
||||
}
|
||||
|
||||
// With the basic sanity checks out of the way, we'll now
|
||||
@@ -908,7 +903,7 @@ func (l *RemoteCloseStart) ProcessEvent(event ProtocolEvent, env *Environment,
|
||||
}
|
||||
|
||||
chanOpts := []lnwallet.ChanCloseOpt{
|
||||
lnwallet.WithCustomSequence(msg.SigMsg.Sequence),
|
||||
lnwallet.WithCustomSequence(mempool.MaxRBFSequence),
|
||||
}
|
||||
|
||||
chancloserLog.Infof("responding to close w/ local_addr=%x, "+
|
||||
|
||||
Reference in new issue
Block a user