1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 14:22:39 +01:00

channel: use chanel id in outgoing error messages

This commit is contained in:
sstone 2017-02-25 21:31:17 +01:00
parent 1826fb6e6a
commit 071f705df4

View file

@ -249,7 +249,7 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
localNextHtlcId = 0L, remoteNextHtlcId = 0L, localNextHtlcId = 0L, remoteNextHtlcId = 0L,
remoteNextCommitInfo = Right(null), // TODO: we will receive their next per-commitment point in the next message, so we temporarily put an empty byte array, remoteNextCommitInfo = Right(null), // TODO: we will receive their next per-commitment point in the next message, so we temporarily put an empty byte array,
unackedMessages = Nil, unackedMessages = Nil,
commitInput, ShaChain.init, channelId = 0) // TODO: we will compute the channelId at the next step, so we temporarily put 0 commitInput, ShaChain.init, channelId = temporaryChannelId) // TODO: we will compute the channelId at the next step, so we temporarily put 0
context.system.eventStream.publish(ChannelIdAssigned(self, commitments.anchorId, Satoshi(params.fundingSatoshis))) context.system.eventStream.publish(ChannelIdAssigned(self, commitments.anchorId, Satoshi(params.fundingSatoshis)))
goto(WAIT_FOR_FUNDING_CONFIRMED) using DATA_WAIT_FOR_FUNDING_CONFIRMED(temporaryChannelId, params, commitments, None, Right(fundingSigned)) goto(WAIT_FOR_FUNDING_CONFIRMED) using DATA_WAIT_FOR_FUNDING_CONFIRMED(temporaryChannelId, params, commitments, None, Right(fundingSigned))
} }
@ -282,7 +282,7 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
localNextHtlcId = 0L, remoteNextHtlcId = 0L, localNextHtlcId = 0L, remoteNextHtlcId = 0L,
remoteNextCommitInfo = Right(null), // TODO: we will receive their next per-commitment point in the next message, so we temporarily put an empty byte array remoteNextCommitInfo = Right(null), // TODO: we will receive their next per-commitment point in the next message, so we temporarily put an empty byte array
unackedMessages = Nil, unackedMessages = Nil,
commitInput, ShaChain.init, channelId = 0) commitInput, ShaChain.init, channelId = temporaryChannelId)
context.system.eventStream.publish(ChannelIdAssigned(self, commitments.anchorId, Satoshi(params.fundingSatoshis))) context.system.eventStream.publish(ChannelIdAssigned(self, commitments.anchorId, Satoshi(params.fundingSatoshis)))
context.system.eventStream.publish(ChannelSignatureReceived(self, commitments)) context.system.eventStream.publish(ChannelSignatureReceived(self, commitments))
goto(WAIT_FOR_FUNDING_CONFIRMED) using DATA_WAIT_FOR_FUNDING_CONFIRMED(temporaryChannelId, params, commitments, None, Left(fundingCreated)) goto(WAIT_FOR_FUNDING_CONFIRMED) using DATA_WAIT_FOR_FUNDING_CONFIRMED(temporaryChannelId, params, commitments, None, Left(fundingCreated))
@ -310,8 +310,8 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
goto(WAIT_FOR_FUNDING_LOCKED) using DATA_WAIT_FOR_FUNDING_LOCKED(params, commitments.copy(channelId = channelId), fundingLocked) goto(WAIT_FOR_FUNDING_LOCKED) using DATA_WAIT_FOR_FUNDING_LOCKED(params, commitments.copy(channelId = channelId), fundingLocked)
// TODO: not implemented, maybe should be done with a state timer and not a blockchain watch? // TODO: not implemented, maybe should be done with a state timer and not a blockchain watch?
case Event(BITCOIN_FUNDING_TIMEOUT, _) => case Event(BITCOIN_FUNDING_TIMEOUT, d: DATA_WAIT_FOR_FUNDING_CONFIRMED) =>
remote ! Error(0, "Funding tx timed out".getBytes) remote ! Error(d.channelId, "Funding tx timed out".getBytes)
goto(CLOSED) goto(CLOSED)
case Event(WatchEventSpent(BITCOIN_FUNDING_SPENT, tx: Transaction), d: DATA_WAIT_FOR_FUNDING_CONFIRMED) if tx.txid == d.commitments.remoteCommit.txid => handleRemoteSpentCurrent(tx, d) case Event(WatchEventSpent(BITCOIN_FUNDING_SPENT, tx: Transaction), d: DATA_WAIT_FOR_FUNDING_CONFIRMED) if tx.txid == d.commitments.remoteCommit.txid => handleRemoteSpentCurrent(tx, d)
@ -934,7 +934,7 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
def handleLocalError(cause: Throwable, d: HasCommitments) = { def handleLocalError(cause: Throwable, d: HasCommitments) = {
log.error(cause, "") log.error(cause, "")
remote ! Error(0, cause.getMessage.getBytes) remote ! Error(d.channelId, cause.getMessage.getBytes)
spendLocalCurrent(d) spendLocalCurrent(d)
} }
@ -1052,7 +1052,7 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
Helpers.Closing.claimRevokedRemoteCommitTxOutputs(d.commitments, tx) match { Helpers.Closing.claimRevokedRemoteCommitTxOutputs(d.commitments, tx) match {
case Some(revokedCommitPublished) => case Some(revokedCommitPublished) =>
log.warning(s"txid=${tx.txid} was a revoked commitment, publishing the penalty tx") log.warning(s"txid=${tx.txid} was a revoked commitment, publishing the penalty tx")
remote ! Error(0, "Funding tx has been spent".getBytes) remote ! Error(d.channelId, "Funding tx has been spent".getBytes)
// TODO hardcoded mindepth + shouldn't we watch the claim tx instead? // TODO hardcoded mindepth + shouldn't we watch the claim tx instead?
blockchain ! WatchConfirmed(self, tx.txid, 3, BITCOIN_PENALTY_DONE) blockchain ! WatchConfirmed(self, tx.txid, 3, BITCOIN_PENALTY_DONE)
@ -1082,8 +1082,7 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
log.error(s"our funding tx ${ log.error(s"our funding tx ${
d.commitments.anchorId d.commitments.anchorId
} was spent !!") } was spent !!")
// TODO! channel id remote ! Error(d.channelId, "Funding tx has been spent".getBytes)
remote ! Error(0, "Funding tx has been spent".getBytes)
// TODO: not enough // TODO: not enough
val commitTx = d.commitments.localCommit.publishableTxs.commitTx.tx val commitTx = d.commitments.localCommit.publishableTxs.commitTx.tx
blockchain ! PublishAsap(commitTx) blockchain ! PublishAsap(commitTx)