From 68700f285fdb72cf5bd785e85ffac909a20944c5 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Padiou Date: Wed, 24 Feb 2021 18:13:02 +0100 Subject: [PATCH] Address all intellij warnings for Channel.scala (#1705) --- .../fr/acinq/eclair/channel/Channel.scala | 97 ++++++++++--------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala index 7ae6deb648..28198f32cf 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala @@ -47,33 +47,33 @@ import scala.util.{Failure, Success, Try} */ object Channel { - def props(nodeParams: NodeParams, wallet: EclairWallet, remoteNodeId: PublicKey, blockchain: ActorRef, relayer: ActorRef, origin_opt: Option[ActorRef]) = Props(new Channel(nodeParams, wallet, remoteNodeId, blockchain, relayer, origin_opt)) + def props(nodeParams: NodeParams, wallet: EclairWallet, remoteNodeId: PublicKey, blockchain: ActorRef, relayer: ActorRef, origin_opt: Option[ActorRef]): Props = Props(new Channel(nodeParams, wallet, remoteNodeId, blockchain, relayer, origin_opt)) // see /~https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#requirements val ANNOUNCEMENTS_MINCONF = 6 // /~https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#requirements - val MAX_FUNDING = 16777216 sat // = 2^24 + val MAX_FUNDING: Satoshi = 16777216 sat // = 2^24 val MAX_ACCEPTED_HTLCS = 483 // we don't want the counterparty to use a dust limit lower than that, because they wouldn't only hurt themselves we may need them to publish their commit tx in certain cases (backup/restore) - val MIN_DUSTLIMIT = 546 sat + val MIN_DUSTLIMIT: Satoshi = 546 sat // we won't exchange more than this many signatures when negotiating the closing fee val MAX_NEGOTIATION_ITERATIONS = 20 // this is defined in BOLT 11 - val MIN_CLTV_EXPIRY_DELTA = CltvExpiryDelta(18) - val MAX_CLTV_EXPIRY_DELTA = CltvExpiryDelta(7 * 144) // one week + val MIN_CLTV_EXPIRY_DELTA: CltvExpiryDelta = CltvExpiryDelta(18) + val MAX_CLTV_EXPIRY_DELTA: CltvExpiryDelta = CltvExpiryDelta(7 * 144) // one week // since BOLT 1.1, there is a max value for the refund delay of the main commitment tx - val MAX_TO_SELF_DELAY = CltvExpiryDelta(2016) + val MAX_TO_SELF_DELAY: CltvExpiryDelta = CltvExpiryDelta(2016) // as a fundee, we will wait that many blocks for the funding tx to confirm (funder will rely on the funding tx being double-spent) val FUNDING_TIMEOUT_FUNDEE = 2016 // pruning occurs if no new update has been received in two weeks (BOLT 7) - val REFRESH_CHANNEL_UPDATE_INTERVAL = 10 days + val REFRESH_CHANNEL_UPDATE_INTERVAL: FiniteDuration = 10 days case class BroadcastChannelUpdate(reason: BroadcastReason) @@ -111,6 +111,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId // we assume that the peer is the channel's parent private val peer = context.parent + //noinspection ActorMutableStateInspection // the last active connection we are aware of; note that the peer manages connections and asynchronously notifies // the channel, which means that if we get disconnected, the previous active connection will die and some messages will // be sent to dead letters, before the channel gets notified of the disconnection; knowing that this will happen, we @@ -752,7 +753,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId Commitments.sendCommit(d.commitments, keyManager) match { case Right((commitments1, commit)) => log.debug("sending a new sig, spec:\n{}", Commitments.specs2String(commitments1)) - val nextRemoteCommit = commitments1.remoteNextCommitInfo.left.get.nextRemoteCommit + val nextRemoteCommit = commitments1.remoteNextCommitInfo.swap.toOption.get.nextRemoteCommit val nextCommitNumber = nextRemoteCommit.index // we persist htlc data in order to be able to claim htlc outputs in case a revoked tx is published by our // counterparty, so only htlcs above remote's dust_limit matter @@ -770,7 +771,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId context.system.eventStream.publish(ChannelSignatureSent(self, commitments1)) // we expect a quick response from our peer setTimer(RevocationTimeout.toString, RevocationTimeout(commitments1.remoteCommit.index, peer), timeout = nodeParams.revocationTimeout, repeat = false) - handleCommandSuccess(c, d.copy(commitments = commitments1)) storing() sending commit acking (commitments1.localChanges.signed) + handleCommandSuccess(c, d.copy(commitments = commitments1)).storing().sending(commit).acking(commitments1.localChanges.signed) case Left(cause) => handleCommandError(cause, c) } case Left(waitForRevocation) => @@ -1105,7 +1106,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId context.system.eventStream.publish(ChannelSignatureSent(self, commitments1)) // we expect a quick response from our peer setTimer(RevocationTimeout.toString, RevocationTimeout(commitments1.remoteCommit.index, peer), timeout = nodeParams.revocationTimeout, repeat = false) - handleCommandSuccess(c, d.copy(commitments = commitments1)) storing() sending commit acking (commitments1.localChanges.signed) + handleCommandSuccess(c, d.copy(commitments = commitments1)).storing().sending(commit).acking(commitments1.localChanges.signed) case Left(cause) => handleCommandError(cause, c) } case Left(waitForRevocation) => @@ -1254,7 +1255,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId val remoteCommitPublished1 = d.remoteCommitPublished.map(remoteCommitPublished => Helpers.Closing.claimRemoteCommitTxOutputs(keyManager, commitments1, commitments1.remoteCommit, remoteCommitPublished.commitTx, nodeParams.onChainFeeConf.feeEstimator, nodeParams.onChainFeeConf.feeTargets)) val nextRemoteCommitPublished1 = d.nextRemoteCommitPublished.map(remoteCommitPublished => { require(commitments1.remoteNextCommitInfo.isLeft, "next remote commit must be defined") - val remoteCommit = commitments1.remoteNextCommitInfo.left.get.nextRemoteCommit + val remoteCommit = commitments1.remoteNextCommitInfo.swap.toOption.get.nextRemoteCommit Helpers.Closing.claimRemoteCommitTxOutputs(keyManager, commitments1, remoteCommit, remoteCommitPublished.commitTx, nodeParams.onChainFeeConf.feeEstimator, nodeParams.onChainFeeConf.feeTargets) }) @@ -1673,7 +1674,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId case Event(WatchEventSpent(BITCOIN_FUNDING_SPENT, tx), d: DATA_WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT) => handleRemoteSpentFuture(tx, d) }) - def errorStateHandler: StateFunction = { + private def errorStateHandler: StateFunction = { case Event(Symbol("nevermatches"), _) => stay // we can't define a state with no event handler, so we put a dummy one here } @@ -1847,7 +1848,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId /** * This function is used to return feedback to user at channel opening */ - def channelOpenReplyToUser(message: Either[ChannelOpenError, ChannelOpenResponse]): Unit = { + private def channelOpenReplyToUser(message: Either[ChannelOpenError, ChannelOpenResponse]): Unit = { val m = message match { case Left(LocalError(t)) => Status.Failure(t) case Left(RemoteError(e)) => Status.Failure(new RuntimeException(s"peer sent error: ascii='${e.toAscii}' bin=${e.data.toHex}")) @@ -1856,7 +1857,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId origin_opt.foreach(_ ! m) } - def handleCurrentFeerate(c: CurrentFeerates, d: HasCommitments) = { + private def handleCurrentFeerate(c: CurrentFeerates, d: HasCommitments) = { val networkFeeratePerKw = nodeParams.onChainFeeConf.getCommitmentFeerate(d.commitments.channelVersion, d.commitments.capacity, Some(c)) val currentFeeratePerKw = d.commitments.localCommit.spec.feeratePerKw val shouldUpdateFee = d.commitments.localParams.isFunder && nodeParams.onChainFeeConf.shouldUpdateFee(currentFeeratePerKw, networkFeeratePerKw) @@ -1880,7 +1881,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId * @param d the channel commtiments * @return */ - def handleOfflineFeerate(c: CurrentFeerates, d: HasCommitments) = { + private def handleOfflineFeerate(c: CurrentFeerates, d: HasCommitments) = { val networkFeeratePerKw = nodeParams.onChainFeeConf.getCommitmentFeerate(d.commitments.channelVersion, d.commitments.capacity, Some(c)) val currentFeeratePerKw = d.commitments.localCommit.spec.feeratePerKw // if the network fees are too high we risk to not be able to confirm our current commitment @@ -1900,13 +1901,13 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def handleFastClose(c: CloseCommand, channelId: ByteVector32) = { + private def handleFastClose(c: CloseCommand, channelId: ByteVector32) = { val replyTo = if (c.replyTo == ActorRef.noSender) sender else c.replyTo replyTo ! RES_SUCCESS(c, channelId) goto(CLOSED) } - def handleCommandSuccess(c: Command, newData: Data) = { + private def handleCommandSuccess(c: Command, newData: Data) = { val replyTo_opt = c match { case hasOptionalReplyTo: HasOptionalReplyToCommand => hasOptionalReplyTo.replyTo_opt case hasReplyTo: HasReplyToCommand => if (hasReplyTo.replyTo == ActorRef.noSender) Some(sender) else Some(hasReplyTo.replyTo) @@ -1917,7 +1918,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId stay using newData } - def handleAddHtlcCommandError(c: CMD_ADD_HTLC, cause: ChannelException, channelUpdate: Option[ChannelUpdate]) = { + private def handleAddHtlcCommandError(c: CMD_ADD_HTLC, cause: ChannelException, channelUpdate: Option[ChannelUpdate]) = { log.warning(s"${cause.getMessage} while processing cmd=${c.getClass.getSimpleName} in state=$stateName") val replyTo = if (c.replyTo == ActorRef.noSender) sender else c.replyTo replyTo ! RES_ADD_FAILED(c, cause, channelUpdate) @@ -1925,7 +1926,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId stay } - def handleCommandError(cause: ChannelException, c: Command) = { + private def handleCommandError(cause: ChannelException, c: Command) = { log.warning(s"${cause.getMessage} while processing cmd=${c.getClass.getSimpleName} in state=$stateName") val replyTo_opt = c match { case hasOptionalReplyTo: HasOptionalReplyToCommand => hasOptionalReplyTo.replyTo_opt @@ -1936,7 +1937,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId stay } - def watchFundingTx(commitments: Commitments, additionalKnownSpendingTxs: Set[ByteVector32] = Set.empty): Unit = { + private def watchFundingTx(commitments: Commitments, additionalKnownSpendingTxs: Set[ByteVector32] = Set.empty): Unit = { // TODO: should we wait for an acknowledgment from the watcher? val knownSpendingTxs = Set(commitments.localCommit.publishableTxs.commitTx.tx.txid, commitments.remoteCommit.txid) ++ commitments.remoteNextCommitInfo.left.toSeq.map(_.nextRemoteCommit.txid).toSet ++ additionalKnownSpendingTxs blockchain ! WatchSpent(self, commitments.commitInput.outPoint.txid, commitments.commitInput.outPoint.index.toInt, commitments.commitInput.txOut.publicKeyScript, BITCOIN_FUNDING_SPENT, knownSpendingTxs) @@ -1948,7 +1949,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId * When we are funder, we use this function to detect when our funding tx has been double-spent (by another transaction * that we made for some reason). If the funding tx has been double spent we can forget about the channel. */ - def checkDoubleSpent(fundingTx: Transaction): Unit = { + private def checkDoubleSpent(fundingTx: Transaction): Unit = { log.debug(s"checking status of funding tx txid=${fundingTx.txid}") wallet.doubleSpent(fundingTx).onComplete { case Success(true) => @@ -1959,7 +1960,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def handleGetFundingTx(getTxResponse: GetTxWithMetaResponse, waitingSinceBlock: Long, fundingTx_opt: Option[Transaction]) = { + private def handleGetFundingTx(getTxResponse: GetTxWithMetaResponse, waitingSinceBlock: Long, fundingTx_opt: Option[Transaction]) = { import getTxResponse._ tx_opt match { case Some(_) => () // the funding tx exists, nothing to do @@ -1986,7 +1987,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId stay } - def handleFundingPublishFailed(d: HasCommitments) = { + private def handleFundingPublishFailed(d: HasCommitments) = { log.error(s"failed to publish funding tx") val exc = ChannelFundingError(d.channelId) val error = Error(d.channelId, exc.getMessage) @@ -1996,7 +1997,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId goto(CLOSED) sending error } - def handleFundingTimeout(d: HasCommitments) = { + private def handleFundingTimeout(d: HasCommitments) = { log.warning(s"funding tx hasn't been confirmed in time, cancelling channel delay=$FUNDING_TIMEOUT_FUNDEE") val exc = FundingTxTimedout(d.channelId) val error = Error(d.channelId, exc.getMessage) @@ -2004,7 +2005,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId goto(CLOSED) sending error } - def handleRevocationTimeout(revocationTimeout: RevocationTimeout, d: HasCommitments) = { + private def handleRevocationTimeout(revocationTimeout: RevocationTimeout, d: HasCommitments) = { d.commitments.remoteNextCommitInfo match { case Left(waitingForRevocation) if revocationTimeout.remoteCommitNumber + 1 == waitingForRevocation.nextRemoteCommit.index => log.warning(s"waited for too long for a revocation to remoteCommitNumber=${revocationTimeout.remoteCommitNumber}, disconnecting") @@ -2014,7 +2015,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId stay } - def handleAddDisconnected(c: CMD_ADD_HTLC, d: DATA_NORMAL) = { + private def handleAddDisconnected(c: CMD_ADD_HTLC, d: DATA_NORMAL) = { log.info(s"rejecting htlc request in state=$stateName") // in order to reduce gossip spam, we don't disable the channel right away when disconnected // we will only emit a new channel_update with the disable flag set if someone tries to use that channel @@ -2033,7 +2034,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def handleNewBlock(c: CurrentBlockCount, d: HasCommitments) = { + private def handleNewBlock(c: CurrentBlockCount, d: HasCommitments) = { val timedOutOutgoing = d.commitments.timedOutOutgoingHtlcs(c.blockCount) val almostTimedOutIncoming = d.commitments.almostTimedOutIncomingHtlcs(c.blockCount, nodeParams.fulfillSafetyBeforeTimeout) if (timedOutOutgoing.nonEmpty) { @@ -2062,7 +2063,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def handleLocalError(cause: Throwable, d: Data, msg: Option[Any]) = { + private def handleLocalError(cause: Throwable, d: Data, msg: Option[Any]) = { cause match { case _: ForcedLocalCommit => log.warning(s"force-closing channel at user request") case _ => log.error(s"${cause.getMessage} while processing msg=${msg.getOrElse("n/a").getClass.getSimpleName} in state=$stateName") @@ -2085,7 +2086,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def handleRemoteError(e: Error, d: Data) = { + private def handleRemoteError(e: Error, d: Data) = { // see BOLT 1: only print out data verbatim if is composed of printable ASCII characters log.error(s"peer sent error: ascii='${e.toAscii}' bin=${e.data.toHex}") context.system.eventStream.publish(ChannelErrorOccurred(self, stateData.channelId, remoteNodeId, stateData, RemoteError(e), isFatal = true)) @@ -2100,7 +2101,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def handleMutualClose(closingTx: Transaction, d: Either[DATA_NEGOTIATING, DATA_CLOSING]) = { + private def handleMutualClose(closingTx: Transaction, d: Either[DATA_NEGOTIATING, DATA_CLOSING]) = { log.info(s"closing tx published: closingTxId=${closingTx.txid}") val nextData = d match { case Left(negotiating) => DATA_CLOSING(negotiating.commitments, fundingTx = None, waitingSinceBlock = nodeParams.currentBlockHeight, negotiating.closingTxProposed.flatten.map(_.unsignedTx), mutualClosePublished = closingTx :: Nil) @@ -2109,12 +2110,12 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId goto(CLOSING) using nextData storing() calling doPublish(closingTx) } - def doPublish(closingTx: Transaction): Unit = { + private def doPublish(closingTx: Transaction): Unit = { blockchain ! PublishAsap(closingTx) blockchain ! WatchConfirmed(self, closingTx, nodeParams.minDepthBlocks, BITCOIN_TX_CONFIRMED(closingTx)) } - def spendLocalCurrent(d: HasCommitments) = { + private def spendLocalCurrent(d: HasCommitments) = { val outdatedCommitment = d match { case _: DATA_WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT => true case closing: DATA_CLOSING if closing.futureRemoteCommitPublished.isDefined => true @@ -2139,7 +2140,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId /** * This helper method will publish txs only if they haven't yet reached minDepth */ - def publishIfNeeded(txs: Iterable[Transaction], irrevocablySpent: Map[OutPoint, ByteVector32]): Unit = { + private def publishIfNeeded(txs: Iterable[Transaction], irrevocablySpent: Map[OutPoint, ByteVector32]): Unit = { val (skip, process) = txs.partition(Closing.inputsAlreadySpent(_, irrevocablySpent)) process.foreach { tx => log.info(s"publishing txid=${tx.txid}") @@ -2151,7 +2152,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId /** * This helper method will watch txs only if they haven't yet reached minDepth */ - def watchConfirmedIfNeeded(txs: Iterable[Transaction], irrevocablySpent: Map[OutPoint, ByteVector32]): Unit = { + private def watchConfirmedIfNeeded(txs: Iterable[Transaction], irrevocablySpent: Map[OutPoint, ByteVector32]): Unit = { val (skip, process) = txs.partition(Closing.inputsAlreadySpent(_, irrevocablySpent)) process.foreach(tx => blockchain ! WatchConfirmed(self, tx, nodeParams.minDepthBlocks, BITCOIN_TX_CONFIRMED(tx))) skip.foreach(tx => log.info(s"no need to watch txid=${tx.txid}, it has already been confirmed")) @@ -2160,13 +2161,13 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId /** * This helper method will watch txs only if the utxo they spend hasn't already been irrevocably spent */ - def watchSpentIfNeeded(parentTx: Transaction, txs: Iterable[Transaction], irrevocablySpent: Map[OutPoint, ByteVector32]): Unit = { + private def watchSpentIfNeeded(parentTx: Transaction, txs: Iterable[Transaction], irrevocablySpent: Map[OutPoint, ByteVector32]): Unit = { val (skip, process) = txs.partition(Closing.inputsAlreadySpent(_, irrevocablySpent)) process.foreach(tx => blockchain ! WatchSpent(self, parentTx, tx.txIn.filter(_.outPoint.txid == parentTx.txid).head.outPoint.index.toInt, BITCOIN_OUTPUT_SPENT, hints = Set(tx.txid))) skip.foreach(tx => log.info(s"no need to watch txid=${tx.txid}, it has already been confirmed")) } - def doPublish(localCommitPublished: LocalCommitPublished): Unit = { + private def doPublish(localCommitPublished: LocalCommitPublished): Unit = { import localCommitPublished._ val publishQueue = List(commitTx) ++ claimMainDelayedOutputTx ++ htlcSuccessTxs ++ htlcTimeoutTxs ++ claimHtlcDelayedTxs @@ -2183,7 +2184,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId watchSpentIfNeeded(commitTx, watchSpentQueue, irrevocablySpent) } - def handleRemoteSpentCurrent(commitTx: Transaction, d: HasCommitments) = { + private def handleRemoteSpentCurrent(commitTx: Transaction, d: HasCommitments) = { log.warning(s"they published their current commit in txid=${commitTx.txid}") require(commitTx.txid == d.commitments.remoteCommit.txid, "txid mismatch") @@ -2197,7 +2198,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId goto(CLOSING) using nextData storing() calling doPublish(remoteCommitPublished) } - def handleRemoteSpentFuture(commitTx: Transaction, d: DATA_WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT) = { + private def handleRemoteSpentFuture(commitTx: Transaction, d: DATA_WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT) = { log.warning(s"they published their future commit (because we asked them to) in txid=${commitTx.txid}") d.commitments.channelVersion match { case v if v.paysDirectlyToWallet => @@ -2212,7 +2213,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def handleRemoteSpentNext(commitTx: Transaction, d: HasCommitments) = { + private def handleRemoteSpentNext(commitTx: Transaction, d: HasCommitments) = { log.warning(s"they published their next commit in txid=${commitTx.txid}") require(d.commitments.remoteNextCommitInfo.isLeft, "next remote commit must be defined") val remoteCommit = d.commitments.remoteNextCommitInfo.left.get.nextRemoteCommit @@ -2228,7 +2229,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId goto(CLOSING) using nextData storing() calling doPublish(remoteCommitPublished) } - def doPublish(remoteCommitPublished: RemoteCommitPublished): Unit = { + private def doPublish(remoteCommitPublished: RemoteCommitPublished): Unit = { import remoteCommitPublished._ val publishQueue = claimMainOutputTx ++ claimHtlcSuccessTxs ++ claimHtlcTimeoutTxs @@ -2245,7 +2246,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId watchSpentIfNeeded(commitTx, watchSpentQueue, irrevocablySpent) } - def handleRemoteSpentOther(tx: Transaction, d: HasCommitments) = { + private def handleRemoteSpentOther(tx: Transaction, d: HasCommitments) = { log.warning(s"funding tx spent in txid=${tx.txid}") Helpers.Closing.claimRevokedRemoteCommitTxOutputs(keyManager, d.commitments, tx, nodeParams.db.channels, nodeParams.onChainFeeConf.feeEstimator, nodeParams.onChainFeeConf.feeTargets) match { case Some(revokedCommitPublished) => @@ -2267,7 +2268,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def doPublish(revokedCommitPublished: RevokedCommitPublished): Unit = { + private def doPublish(revokedCommitPublished: RevokedCommitPublished): Unit = { import revokedCommitPublished._ val publishQueue = claimMainOutputTx ++ mainPenaltyTx ++ htlcPenaltyTxs ++ claimHtlcDelayedPenaltyTxs @@ -2284,7 +2285,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId watchSpentIfNeeded(commitTx, watchSpentQueue, irrevocablySpent) } - def handleInformationLeak(tx: Transaction, d: HasCommitments) = { + private def handleInformationLeak(tx: Transaction, d: HasCommitments) = { // this is never supposed to happen !! log.error(s"our funding tx ${d.commitments.commitInput.outPoint.txid} was spent by txid=${tx.txid} !!") val exc = FundingTxSpent(d.channelId, tx) @@ -2297,7 +2298,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId goto(ERR_INFORMATION_LEAK) calling doPublish(localCommitPublished) sending error } - def handleSync(channelReestablish: ChannelReestablish, d: HasCommitments): (Commitments, Queue[LightningMessage]) = { + private def handleSync(channelReestablish: ChannelReestablish, d: HasCommitments): (Commitments, Queue[LightningMessage]) = { var sendQueue = Queue.empty[LightningMessage] // first we clean up unacknowledged updates log.debug("discarding proposed OUT: {}", d.commitments.localChanges.proposed.map(Commitments.msg2String(_)).mkString(",")) @@ -2375,7 +2376,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId /** * This helper function runs the state's default event handlers, and react to exceptions by unilaterally closing the channel */ - def handleExceptions(s: StateFunction): StateFunction = { + private def handleExceptions(s: StateFunction): StateFunction = { case event if s.isDefinedAt(event) => try { s(event) @@ -2384,12 +2385,12 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } } - def feePaid(fee: Satoshi, tx: Transaction, desc: String, channelId: ByteVector32): Unit = Try { // this may fail with an NPE in tests because context has been cleaned up, but it's not a big deal + private def feePaid(fee: Satoshi, tx: Transaction, desc: String, channelId: ByteVector32): Unit = Try { // this may fail with an NPE in tests because context has been cleaned up, but it's not a big deal log.info(s"paid feeSatoshi=${fee.toLong} for txid=${tx.txid} desc=$desc") context.system.eventStream.publish(NetworkFeePaid(self, remoteNodeId, channelId, tx, fee, desc)) } - implicit def state2mystate(state: FSM.State[fr.acinq.eclair.channel.State, Data]): MyState = MyState(state) + implicit private def state2mystate(state: FSM.State[fr.acinq.eclair.channel.State, Data]): MyState = MyState(state) case class MyState(state: FSM.State[fr.acinq.eclair.channel.State, Data]) { @@ -2445,7 +2446,7 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId } - def send(msg: LightningMessage): Unit = { + private def send(msg: LightningMessage): Unit = { peer ! OutgoingMessage(msg, activeConnection) }