@@ -854,21 +854,13 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
854854 case Event (cmd : CMD_SPLICE , d : DATA_NORMAL ) =>
855855 if (d.commitments.params.remoteParams.initFeatures.hasFeature(Features .SplicePrototype )) {
856856 d.spliceStatus match {
857- case SpliceStatus .NoSplice if d.commitments.params.useQuiescence =>
857+ case SpliceStatus .NoSplice =>
858858 startSingleTimer(QuiescenceTimeout .toString, QuiescenceTimeout (peer), nodeParams.channelConf.quiescenceTimeout)
859859 if (d.commitments.localIsQuiescent) {
860860 stay() using d.copy(spliceStatus = SpliceStatus .InitiatorQuiescent (cmd)) sending Stfu (d.channelId, initiator = true )
861861 } else {
862862 stay() using d.copy(spliceStatus = SpliceStatus .QuiescenceRequested (cmd))
863863 }
864- case SpliceStatus .NoSplice if ! d.commitments.params.useQuiescence =>
865- initiateSplice(cmd, d) match {
866- case Left (f) =>
867- cmd.replyTo ! RES_FAILURE (cmd, f)
868- stay()
869- case Right (spliceInit) =>
870- stay() using d.copy(spliceStatus = SpliceStatus .SpliceRequested (cmd, spliceInit)) sending spliceInit
871- }
872864 case _ =>
873865 log.warning(" cannot initiate splice, another one is already in progress" )
874866 cmd.replyTo ! RES_FAILURE (cmd, InvalidSpliceAlreadyInProgress (d.channelId))
@@ -886,62 +878,53 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
886878 stay()
887879
888880 case Event (msg : Stfu , d : DATA_NORMAL ) =>
889- if (d.commitments.params.useQuiescence) {
890- if (d.commitments.remoteIsQuiescent) {
891- d.spliceStatus match {
892- case SpliceStatus .NoSplice =>
893- startSingleTimer(QuiescenceTimeout .toString, QuiescenceTimeout (peer), nodeParams.channelConf.quiescenceTimeout)
894- if (d.commitments.localIsQuiescent) {
895- stay() using d.copy(spliceStatus = SpliceStatus .NonInitiatorQuiescent ) sending Stfu (d.channelId, initiator = false )
896- } else {
897- stay() using d.copy(spliceStatus = SpliceStatus .ReceivedStfu (msg))
898- }
899- case SpliceStatus .QuiescenceRequested (cmd) =>
900- // We could keep track of our splice attempt and merge it with the remote splice instead of cancelling it.
901- // But this is an edge case that should rarely occur, so it's probably not worth the additional complexity.
902- log.warning(" our peer initiated quiescence before us, cancelling our splice attempt" )
903- cmd.replyTo ! RES_FAILURE (cmd, ConcurrentRemoteSplice (d.channelId))
881+ if (d.commitments.remoteIsQuiescent) {
882+ d.spliceStatus match {
883+ case SpliceStatus .NoSplice =>
884+ startSingleTimer(QuiescenceTimeout .toString, QuiescenceTimeout (peer), nodeParams.channelConf.quiescenceTimeout)
885+ if (d.commitments.localIsQuiescent) {
886+ stay() using d.copy(spliceStatus = SpliceStatus .NonInitiatorQuiescent ) sending Stfu (d.channelId, initiator = false )
887+ } else {
904888 stay() using d.copy(spliceStatus = SpliceStatus .ReceivedStfu (msg))
905- case SpliceStatus .InitiatorQuiescent (cmd) =>
906- // if both sides send stfu at the same time, the quiescence initiator is the channel opener
907- if (! msg.initiator || d.commitments.params.localParams.isChannelOpener) {
908- initiateSplice(cmd, d) match {
909- case Left (f) =>
910- cmd.replyTo ! RES_FAILURE (cmd, f)
911- context.system.scheduler.scheduleOnce(2 second, peer, Peer .Disconnect (remoteNodeId))
912- stay() using d.copy(spliceStatus = SpliceStatus .NoSplice ) sending Warning (d.channelId, f.getMessage)
913- case Right (spliceInit) =>
914- stay() using d.copy(spliceStatus = SpliceStatus .SpliceRequested (cmd, spliceInit)) sending spliceInit
915- }
916- } else {
917- log.warning(" concurrent stfu received and our peer is the channel initiator, cancelling our splice attempt" )
918- cmd.replyTo ! RES_FAILURE (cmd, ConcurrentRemoteSplice (d.channelId))
919- stay() using d.copy(spliceStatus = SpliceStatus .NonInitiatorQuiescent )
889+ }
890+ case SpliceStatus .QuiescenceRequested (cmd) =>
891+ // We could keep track of our splice attempt and merge it with the remote splice instead of cancelling it.
892+ // But this is an edge case that should rarely occur, so it's probably not worth the additional complexity.
893+ log.warning(" our peer initiated quiescence before us, cancelling our splice attempt" )
894+ cmd.replyTo ! RES_FAILURE (cmd, ConcurrentRemoteSplice (d.channelId))
895+ stay() using d.copy(spliceStatus = SpliceStatus .ReceivedStfu (msg))
896+ case SpliceStatus .InitiatorQuiescent (cmd) =>
897+ // if both sides send stfu at the same time, the quiescence initiator is the channel opener
898+ if (! msg.initiator || d.commitments.params.localParams.isChannelOpener) {
899+ initiateSplice(cmd, d) match {
900+ case Left (f) =>
901+ cmd.replyTo ! RES_FAILURE (cmd, f)
902+ context.system.scheduler.scheduleOnce(2 second, peer, Peer .Disconnect (remoteNodeId))
903+ stay() using d.copy(spliceStatus = SpliceStatus .NoSplice ) sending Warning (d.channelId, f.getMessage)
904+ case Right (spliceInit) =>
905+ stay() using d.copy(spliceStatus = SpliceStatus .SpliceRequested (cmd, spliceInit)) sending spliceInit
920906 }
921- case _ =>
922- log.warning(" ignoring duplicate stfu" )
923- stay()
924- }
925- } else {
926- log.warning(" our peer sent stfu but is not quiescent" )
927- // NB: we use a small delay to ensure we've sent our warning before disconnecting.
928- context.system.scheduler.scheduleOnce(2 second, peer, Peer .Disconnect (remoteNodeId))
929- stay() using d.copy(spliceStatus = SpliceStatus .NoSplice ) sending Warning (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
907+ } else {
908+ log.warning(" concurrent stfu received and our peer is the channel initiator, cancelling our splice attempt" )
909+ cmd.replyTo ! RES_FAILURE (cmd, ConcurrentRemoteSplice (d.channelId))
910+ stay() using d.copy(spliceStatus = SpliceStatus .NonInitiatorQuiescent )
911+ }
912+ case _ =>
913+ log.warning(" ignoring duplicate stfu" )
914+ stay()
930915 }
931916 } else {
932- log.warning(" ignoring stfu because both peers do not advertise quiescence" )
933- stay()
917+ log.warning(" our peer sent stfu but is not quiescent" )
918+ // NB: we use a small delay to ensure we've sent our warning before disconnecting.
919+ context.system.scheduler.scheduleOnce(2 second, peer, Peer .Disconnect (remoteNodeId))
920+ stay() using d.copy(spliceStatus = SpliceStatus .NoSplice ) sending Warning (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
934921 }
935922
936923 case Event (_ : QuiescenceTimeout , d : DATA_NORMAL ) => handleQuiescenceTimeout(d)
937924
938- case Event (_ : SpliceInit , d : DATA_NORMAL ) if d.spliceStatus == SpliceStatus .NoSplice && d.commitments.params.useQuiescence =>
939- log.info(" rejecting splice attempt: quiescence not negotiated" )
940- stay() using d.copy(spliceStatus = SpliceStatus .SpliceAborted ) sending TxAbort (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
941-
942925 case Event (msg : SpliceInit , d : DATA_NORMAL ) =>
943926 d.spliceStatus match {
944- case SpliceStatus .NoSplice | SpliceStatus . NonInitiatorQuiescent =>
927+ case SpliceStatus .NonInitiatorQuiescent =>
945928 if (! d.commitments.isQuiescent) {
946929 log.info(" rejecting splice request: channel not quiescent" )
947930 stay() using d.copy(spliceStatus = SpliceStatus .SpliceAborted ) sending TxAbort (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
@@ -993,6 +976,9 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
993976 stay() using d.copy(spliceStatus = SpliceStatus .SpliceInProgress (cmd_opt = None , sessionId, txBuilder, remoteCommitSig = None )) sending spliceAck
994977 }
995978 }
979+ case SpliceStatus .NoSplice =>
980+ log.info(" rejecting splice attempt: quiescence not negotiated" )
981+ stay() using d.copy(spliceStatus = SpliceStatus .SpliceAborted ) sending TxAbort (d.channelId, InvalidSpliceNotQuiescent (d.channelId).getMessage)
996982 case SpliceStatus .SpliceAborted =>
997983 log.info(" rejecting splice attempt: our previous tx_abort was not acked" )
998984 stay() sending Warning (d.channelId, InvalidSpliceTxAbortNotAcked (d.channelId).getMessage)
0 commit comments