@@ -853,21 +853,13 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
853
853
case Event (cmd : CMD_SPLICE , d : DATA_NORMAL ) =>
854
854
if (d.commitments.params.remoteParams.initFeatures.hasFeature(Features .Splicing )) {
855
855
d.spliceStatus match {
856
- case SpliceStatus .NoSplice if d.commitments.params.useQuiescence =>
856
+ case SpliceStatus .NoSplice =>
857
857
startSingleTimer(QuiescenceTimeout .toString, QuiescenceTimeout (peer), nodeParams.channelConf.quiescenceTimeout)
858
858
if (d.commitments.localIsQuiescent) {
859
859
stay() using d.copy(spliceStatus = SpliceStatus .InitiatorQuiescent (cmd)) sending Stfu (d.channelId, initiator = true )
860
860
} else {
861
861
stay() using d.copy(spliceStatus = SpliceStatus .QuiescenceRequested (cmd))
862
862
}
863
- case SpliceStatus .NoSplice if ! d.commitments.params.useQuiescence =>
864
- initiateSplice(cmd, d) match {
865
- case Left (f) =>
866
- cmd.replyTo ! RES_FAILURE (cmd, f)
867
- stay()
868
- case Right (spliceInit) =>
869
- stay() using d.copy(spliceStatus = SpliceStatus .SpliceRequested (cmd, spliceInit)) sending spliceInit
870
- }
871
863
case _ =>
872
864
log.warning(" cannot initiate splice, another one is already in progress" )
873
865
cmd.replyTo ! RES_FAILURE (cmd, InvalidSpliceAlreadyInProgress (d.channelId))
@@ -885,62 +877,53 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
885
877
stay()
886
878
887
879
case Event (msg : Stfu , d : DATA_NORMAL ) =>
888
- if (d.commitments.params.useQuiescence) {
889
- if (d.commitments.remoteIsQuiescent) {
890
- d.spliceStatus match {
891
- case SpliceStatus .NoSplice =>
892
- startSingleTimer(QuiescenceTimeout .toString, QuiescenceTimeout (peer), nodeParams.channelConf.quiescenceTimeout)
893
- if (d.commitments.localIsQuiescent) {
894
- stay() using d.copy(spliceStatus = SpliceStatus .NonInitiatorQuiescent ) sending Stfu (d.channelId, initiator = false )
895
- } else {
896
- stay() using d.copy(spliceStatus = SpliceStatus .ReceivedStfu (msg))
897
- }
898
- case SpliceStatus .QuiescenceRequested (cmd) =>
899
- // We could keep track of our splice attempt and merge it with the remote splice instead of cancelling it.
900
- // But this is an edge case that should rarely occur, so it's probably not worth the additional complexity.
901
- log.warning(" our peer initiated quiescence before us, cancelling our splice attempt" )
902
- cmd.replyTo ! RES_FAILURE (cmd, ConcurrentRemoteSplice (d.channelId))
880
+ if (d.commitments.remoteIsQuiescent) {
881
+ d.spliceStatus match {
882
+ case SpliceStatus .NoSplice =>
883
+ startSingleTimer(QuiescenceTimeout .toString, QuiescenceTimeout (peer), nodeParams.channelConf.quiescenceTimeout)
884
+ if (d.commitments.localIsQuiescent) {
885
+ stay() using d.copy(spliceStatus = SpliceStatus .NonInitiatorQuiescent ) sending Stfu (d.channelId, initiator = false )
886
+ } else {
903
887
stay() using d.copy(spliceStatus = SpliceStatus .ReceivedStfu (msg))
904
- case SpliceStatus .InitiatorQuiescent (cmd) =>
905
- // if both sides send stfu at the same time, the quiescence initiator is the channel opener
906
- if (! msg.initiator || d.commitments.params.localParams.isChannelOpener) {
907
- initiateSplice(cmd, d) match {
908
- case Left (f) =>
909
- cmd.replyTo ! RES_FAILURE (cmd, f)
910
- context.system.scheduler.scheduleOnce(2 second, peer, Peer .Disconnect (remoteNodeId))
911
- stay() using d.copy(spliceStatus = SpliceStatus .NoSplice ) sending Warning (d.channelId, f.getMessage)
912
- case Right (spliceInit) =>
913
- stay() using d.copy(spliceStatus = SpliceStatus .SpliceRequested (cmd, spliceInit)) sending spliceInit
914
- }
915
- } else {
916
- log.warning(" concurrent stfu received and our peer is the channel initiator, cancelling our splice attempt" )
917
- cmd.replyTo ! RES_FAILURE (cmd, ConcurrentRemoteSplice (d.channelId))
918
- stay() using d.copy(spliceStatus = SpliceStatus .NonInitiatorQuiescent )
888
+ }
889
+ case SpliceStatus .QuiescenceRequested (cmd) =>
890
+ // We could keep track of our splice attempt and merge it with the remote splice instead of cancelling it.
891
+ // But this is an edge case that should rarely occur, so it's probably not worth the additional complexity.
892
+ log.warning(" our peer initiated quiescence before us, cancelling our splice attempt" )
893
+ cmd.replyTo ! RES_FAILURE (cmd, ConcurrentRemoteSplice (d.channelId))
894
+ stay() using d.copy(spliceStatus = SpliceStatus .ReceivedStfu (msg))
895
+ case SpliceStatus .InitiatorQuiescent (cmd) =>
896
+ // if both sides send stfu at the same time, the quiescence initiator is the channel opener
897
+ if (! msg.initiator || d.commitments.params.localParams.isChannelOpener) {
898
+ initiateSplice(cmd, d) match {
899
+ case Left (f) =>
900
+ cmd.replyTo ! RES_FAILURE (cmd, f)
901
+ context.system.scheduler.scheduleOnce(2 second, peer, Peer .Disconnect (remoteNodeId))
902
+ stay() using d.copy(spliceStatus = SpliceStatus .NoSplice ) sending Warning (d.channelId, f.getMessage)
903
+ case Right (spliceInit) =>
904
+ stay() using d.copy(spliceStatus = SpliceStatus .SpliceRequested (cmd, spliceInit)) sending spliceInit
919
905
}
920
- case _ =>
921
- log.warning(" ignoring duplicate stfu" )
922
- stay()
923
- }
924
- } else {
925
- log.warning(" our peer sent stfu but is not quiescent" )
926
- // NB: we use a small delay to ensure we've sent our warning before disconnecting.
927
- context.system.scheduler.scheduleOnce(2 second, peer, Peer .Disconnect (remoteNodeId))
928
- stay() using d.copy(spliceStatus = SpliceStatus .NoSplice ) sending Warning (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
906
+ } else {
907
+ log.warning(" concurrent stfu received and our peer is the channel initiator, cancelling our splice attempt" )
908
+ cmd.replyTo ! RES_FAILURE (cmd, ConcurrentRemoteSplice (d.channelId))
909
+ stay() using d.copy(spliceStatus = SpliceStatus .NonInitiatorQuiescent )
910
+ }
911
+ case _ =>
912
+ log.warning(" ignoring duplicate stfu" )
913
+ stay()
929
914
}
930
915
} else {
931
- log.warning(" ignoring stfu because both peers do not advertise quiescence" )
932
- stay()
916
+ log.warning(" our peer sent stfu but is not quiescent" )
917
+ // NB: we use a small delay to ensure we've sent our warning before disconnecting.
918
+ context.system.scheduler.scheduleOnce(2 second, peer, Peer .Disconnect (remoteNodeId))
919
+ stay() using d.copy(spliceStatus = SpliceStatus .NoSplice ) sending Warning (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
933
920
}
934
921
935
922
case Event (_ : QuiescenceTimeout , d : DATA_NORMAL ) => handleQuiescenceTimeout(d)
936
923
937
- case Event (_ : SpliceInit , d : DATA_NORMAL ) if d.spliceStatus == SpliceStatus .NoSplice && d.commitments.params.useQuiescence =>
938
- log.info(" rejecting splice attempt: quiescence not negotiated" )
939
- stay() using d.copy(spliceStatus = SpliceStatus .SpliceAborted ) sending TxAbort (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
940
-
941
924
case Event (msg : SpliceInit , d : DATA_NORMAL ) =>
942
925
d.spliceStatus match {
943
- case SpliceStatus .NoSplice | SpliceStatus . NonInitiatorQuiescent =>
926
+ case SpliceStatus .NonInitiatorQuiescent =>
944
927
if (! d.commitments.isQuiescent) {
945
928
log.info(" rejecting splice request: channel not quiescent" )
946
929
stay() using d.copy(spliceStatus = SpliceStatus .SpliceAborted ) sending TxAbort (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
@@ -981,6 +964,9 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
981
964
txBuilder ! InteractiveTxBuilder .Start (self)
982
965
stay() using d.copy(spliceStatus = SpliceStatus .SpliceInProgress (cmd_opt = None , sessionId, txBuilder, remoteCommitSig = None )) sending spliceAck
983
966
}
967
+ case SpliceStatus .NoSplice =>
968
+ log.info(" rejecting splice attempt: quiescence not negotiated" )
969
+ stay() using d.copy(spliceStatus = SpliceStatus .SpliceAborted ) sending TxAbort (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
984
970
case SpliceStatus .SpliceAborted =>
985
971
log.info(" rejecting splice attempt: our previous tx_abort was not acked" )
986
972
stay() sending Warning (d.channelId, InvalidSpliceTxAbortNotAcked (d.channelId).getMessage)
0 commit comments