1
0
mirror of https://github.com/ACINQ/eclair.git synced 2024-11-20 02:27:32 +01:00

Use proper closing type in ChannelClosed event (#977)

There was actually a change introduced by #944 where we used
`ClosingType.toString` instead of manually defining types, causing a
regression in the audit database.
This commit is contained in:
Pierre-Marie Padiou 2019-05-09 09:43:25 +02:00 committed by GitHub
parent de5a7827bd
commit 7b874f23d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -1319,12 +1319,12 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
// and we also send events related to fee
Closing.networkFeePaid(tx, d1) map { case (fee, desc) => feePaid(fee, tx, desc, d.channelId) }
// then let's see if any of the possible close scenarii can be considered done
val closeType_opt = Closing.isClosed(d1, Some(tx))
val closingType_opt = Closing.isClosed(d1, Some(tx))
// finally, if one of the unilateral closes is done, we move to CLOSED state, otherwise we stay (note that we don't store the state)
closeType_opt match {
case Some(closeType) =>
log.info(s"channel closed (type=$closeType)")
context.system.eventStream.publish(ChannelClosed(self, d.channelId, closeType.toString, d.commitments))
closingType_opt match {
case Some(closingType) =>
log.info(s"channel closed (type=$closingType)")
context.system.eventStream.publish(ChannelClosed(self, d.channelId, closingType, d.commitments))
goto(CLOSED) using store(d1)
case None =>
stay using store(d1)

View File

@ -21,6 +21,7 @@ import fr.acinq.bitcoin.Crypto.PublicKey
import fr.acinq.bitcoin.{ByteVector32, Satoshi, Transaction}
import fr.acinq.eclair.ShortChannelId
import fr.acinq.eclair.channel.Channel.ChannelError
import fr.acinq.eclair.channel.Helpers.Closing.ClosingType
import fr.acinq.eclair.wire.{ChannelAnnouncement, ChannelUpdate}
/**
@ -58,4 +59,4 @@ case class ChannelPersisted(channel: ActorRef, remoteNodeId: PublicKey, channelI
case class LocalCommitConfirmed(channel: ActorRef, remoteNodeId: PublicKey, channelId: ByteVector32, refundAtBlock: Long) extends ChannelEvent
case class ChannelClosed(channel: ActorRef, channelId: ByteVector32, closeType: String, commitments: Commitments)
case class ChannelClosed(channel: ActorRef, channelId: ByteVector32, closingType: ClosingType, commitments: Commitments)

View File

@ -20,6 +20,7 @@ import akka.actor.{Actor, ActorLogging, Props}
import fr.acinq.bitcoin.ByteVector32
import fr.acinq.eclair.NodeParams
import fr.acinq.eclair.channel.Channel.{LocalError, RemoteError}
import fr.acinq.eclair.channel.Helpers.Closing.{LocalClose, MutualClose, RecoveryClose, RemoteClose, RevokedClose}
import fr.acinq.eclair.channel._
import fr.acinq.eclair.db.{AuditDb, ChannelLifecycleEvent}
@ -61,7 +62,14 @@ class Auditor(nodeParams: NodeParams) extends Actor with ActorLogging {
}
case e: ChannelClosed =>
db.add(ChannelLifecycleEvent(e.channelId, e.commitments.remoteParams.nodeId, e.commitments.commitInput.txOut.amount.toLong, e.commitments.localParams.isFunder, !e.commitments.announceChannel, e.closeType))
val event = e.closingType match {
case MutualClose => "mutual"
case LocalClose => "local"
case RemoteClose => "remote"
case RecoveryClose => "recovery"
case RevokedClose => "revoked"
}
db.add(ChannelLifecycleEvent(e.channelId, e.commitments.remoteParams.nodeId, e.commitments.commitInput.txOut.amount.toLong, e.commitments.localParams.isFunder, !e.commitments.announceChannel, event))
}