Skip to content

Commit bade5a6

Browse files
committed
Address @sstone comments
1 parent f738b99 commit bade5a6

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

docs/release-notes/eclair-vnext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
### Simplified mutual close
88

9-
This release includes support for the latest [mutual close protocol](https://github.com/lightning/bolts/pull/1096).
9+
This release includes support for the latest [mutual close protocol](https://github.com/lightning/bolts/pull/1205).
1010
This protocol allows both channel participants to decide exactly how much fees they're willing to pay to close the channel.
1111
Each participant obtains a channel closing transaction where they are paying the fees.
1212

eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ object Helpers {
635635
case Success(OP_0 :: OP_PUSHDATA(pubkeyHash, _) :: Nil) if pubkeyHash.size == 20 => true
636636
case Success(OP_0 :: OP_PUSHDATA(scriptHash, _) :: Nil) if scriptHash.size == 32 => true
637637
case Success((OP_1 | OP_2 | OP_3 | OP_4 | OP_5 | OP_6 | OP_7 | OP_8 | OP_9 | OP_10 | OP_11 | OP_12 | OP_13 | OP_14 | OP_15 | OP_16) :: OP_PUSHDATA(program, _) :: Nil) if allowAnySegwit && 2 <= program.length && program.length <= 40 => true
638-
case Success(OP_RETURN :: _) if allowOpReturn => true
638+
case Success(OP_RETURN :: _) if allowOpReturn => scriptPubKey.length <= 83
639639
case _ => false
640640
}
641641
}

eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,8 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
751751
if (d.commitments.hasNoPendingHtlcsOrFeeUpdate) {
752752
// there are no pending signed changes, let's directly negotiate a closing transaction
753753
if (Features.canUseFeature(d.commitments.params.localParams.initFeatures, d.commitments.params.remoteParams.initFeatures, Features.SimpleClose)) {
754-
startSimpleClose(d.commitments, localShutdown, remoteShutdown, d.closingFeerates, sendList)
754+
val (d1, closingComplete_opt) = startSimpleClose(d.commitments, localShutdown, remoteShutdown, d.closingFeerates)
755+
goto(NEGOTIATING_SIMPLE) using d1 storing() sending sendList ++ closingComplete_opt.toSeq
755756
} else if (d.commitments.params.localParams.paysClosingFees) {
756757
// we pay the closing fees, so we initiate the negotiation by sending the first closing_signed
757758
val (closingTx, closingSigned) = MutualClose.makeFirstClosingTx(keyManager, d.commitments.latest, localShutdown.scriptPubKey, remoteShutdownScript, nodeParams.currentFeeratesForFundingClosing, nodeParams.onChainFeeConf, d.closingFeerates)
@@ -1535,7 +1536,8 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
15351536
context.system.eventStream.publish(ChannelSignatureReceived(self, commitments1))
15361537
if (commitments1.hasNoPendingHtlcsOrFeeUpdate) {
15371538
if (Features.canUseFeature(d.commitments.params.localParams.initFeatures, d.commitments.params.remoteParams.initFeatures, Features.SimpleClose)) {
1538-
startSimpleClose(d.commitments, localShutdown, remoteShutdown, d.closingFeerates, revocation :: Nil)
1539+
val (d1, closingComplete_opt) = startSimpleClose(d.commitments, localShutdown, remoteShutdown, d.closingFeerates)
1540+
goto(NEGOTIATING_SIMPLE) using d1 storing() sending revocation +: closingComplete_opt.toSeq
15391541
} else if (d.commitments.params.localParams.paysClosingFees) {
15401542
// we pay the closing fees, so we initiate the negotiation by sending the first closing_signed
15411543
val (closingTx, closingSigned) = MutualClose.makeFirstClosingTx(keyManager, commitments1.latest, localShutdown.scriptPubKey, remoteShutdown.scriptPubKey, nodeParams.currentFeeratesForFundingClosing, nodeParams.onChainFeeConf, closingFeerates)
@@ -1579,7 +1581,8 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
15791581
if (commitments1.hasNoPendingHtlcsOrFeeUpdate) {
15801582
log.debug("switching to NEGOTIATING spec:\n{}", commitments1.latest.specs2String)
15811583
if (Features.canUseFeature(d.commitments.params.localParams.initFeatures, d.commitments.params.remoteParams.initFeatures, Features.SimpleClose)) {
1582-
startSimpleClose(d.commitments, localShutdown, remoteShutdown, d.closingFeerates, Nil)
1584+
val (d1, closingComplete_opt) = startSimpleClose(d.commitments, localShutdown, remoteShutdown, d.closingFeerates)
1585+
goto(NEGOTIATING_SIMPLE) using d1 storing() sending closingComplete_opt.toSeq
15831586
} else if (d.commitments.params.localParams.paysClosingFees) {
15841587
// we pay the closing fees, so we initiate the negotiation by sending the first closing_signed
15851588
val (closingTx, closingSigned) = MutualClose.makeFirstClosingTx(keyManager, commitments1.latest, localShutdown.scriptPubKey, remoteShutdown.scriptPubKey, nodeParams.currentFeeratesForFundingClosing, nodeParams.onChainFeeConf, closingFeerates)

eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/CommonHandlers.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import fr.acinq.eclair.channel.Helpers.Closing.MutualClose
2323
import fr.acinq.eclair.channel._
2424
import fr.acinq.eclair.db.PendingCommandsDb
2525
import fr.acinq.eclair.io.Peer
26-
import fr.acinq.eclair.wire.protocol.{HtlcSettlementMessage, LightningMessage, Shutdown, UpdateMessage}
26+
import fr.acinq.eclair.wire.protocol.{ClosingComplete, HtlcSettlementMessage, LightningMessage, Shutdown, UpdateMessage}
2727
import scodec.bits.ByteVector
2828

2929
import scala.concurrent.duration.DurationInt
@@ -132,19 +132,19 @@ trait CommonHandlers {
132132
finalScriptPubKey
133133
}
134134

135-
def startSimpleClose(commitments: Commitments, localShutdown: Shutdown, remoteShutdown: Shutdown, closingFeerates: Option[ClosingFeerates], toSend: List[LightningMessage]) = {
135+
def startSimpleClose(commitments: Commitments, localShutdown: Shutdown, remoteShutdown: Shutdown, closingFeerates: Option[ClosingFeerates]): (DATA_NEGOTIATING_SIMPLE, Option[ClosingComplete]) = {
136136
val localScript = localShutdown.scriptPubKey
137137
val remoteScript = remoteShutdown.scriptPubKey
138138
val closingFeerate = closingFeerates.map(_.preferred).getOrElse(nodeParams.onChainFeeConf.getClosingFeerate(nodeParams.currentBitcoinCoreFeerates))
139139
MutualClose.makeSimpleClosingTx(nodeParams.currentBlockHeight, keyManager, commitments.latest, localScript, remoteScript, closingFeerate) match {
140140
case Left(f) =>
141141
log.warning("cannot create local closing txs, waiting for remote closing_complete: {}", f.getMessage)
142142
val d = DATA_NEGOTIATING_SIMPLE(commitments, closingFeerate, localScript, remoteScript, Nil, Nil)
143-
goto(NEGOTIATING_SIMPLE) using d storing() sending toSend
143+
(d, None)
144144
case Right((closingTxs, closingComplete)) =>
145145
log.debug("signing local mutual close transactions: {}", closingTxs)
146146
val d = DATA_NEGOTIATING_SIMPLE(commitments, closingFeerate, localScript, remoteScript, closingTxs :: Nil, Nil)
147-
goto(NEGOTIATING_SIMPLE) using d storing() sending toSend :+ closingComplete
147+
(d, Some(closingComplete))
148148
}
149149
}
150150

0 commit comments

Comments
 (0)