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

Merge branch 'wip-bolts' into wip-disconnect

This commit is contained in:
pm47 2017-02-17 16:30:06 +01:00
commit 2e3031fafd
6 changed files with 17 additions and 24 deletions

View file

@ -3,8 +3,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import java.lang.String?>
<?import javafx.scene.layout.*?>
<?import java.net.URL?>
<BorderPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minWidth="-Infinity"
prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8"
@ -43,8 +42,8 @@
<TableView fx:id="allNodesTable" minHeight="50.0" prefHeight="5000.0">
<columnResizePolicy><TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/></columnResizePolicy>
<columns>
<TableColumn fx:id="allNodesRGBColumn" minWidth="20.0" prefWidth="20.0" maxWidth="20.0" text=""/>
<TableColumn fx:id="allNodesAliasColumn" text="Alias"/>
<TableColumn fx:id="allNodesRGBColumn" minWidth="20.0" prefWidth="20.0" maxWidth="20.0" text="" sortable="false"/>
<TableColumn fx:id="allNodesAliasColumn" minWidth="80.0" prefWidth="180.0" maxWidth="300.0" text="Alias"/>
<TableColumn fx:id="allNodesIdColumn" text="Node Id"/>
</columns>
</TableView>
@ -61,7 +60,7 @@
<TableView fx:id="allChannelsTable" minHeight="50.0" prefHeight="5000.0">
<columnResizePolicy><TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/></columnResizePolicy>
<columns>
<TableColumn fx:id="allChannelsIdColumn" text="Channel Id"/>
<TableColumn fx:id="allChannelsIdColumn" minWidth="120.0" prefWidth="170.0" maxWidth="300.0" text="Channel Id"/>
<TableColumn fx:id="allChannelsNode1Column" text="Node 1"/>
<TableColumn fx:id="allChannelsNode2Column" text="Node 2"/>
</columns>

View file

@ -246,7 +246,7 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
val commitments = Commitments(params.localParams, params.remoteParams,
LocalCommit(0, localSpec, PublishableTxs(signedLocalCommitTx, Nil)), RemoteCommit(0, remoteSpec, remoteCommitTx.tx.txid, remoteFirstPerCommitmentPoint),
LocalChanges(Nil, Nil, Nil), RemoteChanges(Nil, Nil),
LocalChanges(Nil, Nil, Nil), RemoteChanges(Nil, Nil, Nil),
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
commitInput, ShaChain.init, channelId = 0) // TODO: we will compute the channelId at the next step, so we temporarily put 0
@ -278,7 +278,7 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
val commitments = Commitments(params.localParams, params.remoteParams,
LocalCommit(0, localSpec, PublishableTxs(signedLocalCommitTx, Nil)), remoteCommit,
LocalChanges(Nil, Nil, Nil), RemoteChanges(Nil, Nil),
LocalChanges(Nil, Nil, Nil), RemoteChanges(Nil, Nil, Nil),
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
commitInput, ShaChain.init, channelId = 0)
@ -463,10 +463,6 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
Try(Commitments.receiveCommit(d.commitments, msg)) match {
case Success((commitments1, revocation)) =>
remote ! revocation
// now that we have their sig, we should propagate the htlcs newly received
(commitments1.localCommit.spec.htlcs -- d.commitments.localCommit.spec.htlcs)
.filter(_.direction == IN)
.foreach(htlc => relayer ! htlc.add)
context.system.eventStream.publish(ChannelSignatureReceived(self, commitments1))
stay using d.copy(commitments = commitments1)
case Failure(cause) => handleLocalError(cause, d)
@ -477,6 +473,9 @@ class Channel(val r: ActorRef, val blockchain: ActorRef, router: ActorRef, relay
// => all our changes have been acked
Try(Commitments.receiveRevocation(d.commitments, msg)) match {
case Success(commitments1) =>
// we forward HTLCs only when they have been committed by both sides
// it always happen when we receive a revocation, because, we always sign our changes before they sign them
val newlySignedHtlcs = d.commitments.remoteChanges.signed.collect { case htlc: UpdateAddHtlc => relayer ! htlc}
stay using d.copy(commitments = commitments1)
case Failure(cause) => handleLocalError(cause, d)
}

View file

@ -13,7 +13,7 @@ import grizzled.slf4j.Logging
case class LocalChanges(proposed: List[UpdateMessage], signed: List[UpdateMessage], acked: List[UpdateMessage]) {
def all: List[UpdateMessage] = proposed ++ signed ++ acked
}
case class RemoteChanges(proposed: List[UpdateMessage], acked: List[UpdateMessage])
case class RemoteChanges(proposed: List[UpdateMessage], acked: List[UpdateMessage], signed: List[UpdateMessage])
case class Changes(ourChanges: LocalChanges, theirChanges: RemoteChanges)
case class HtlcTxAndSigs(txinfo: TransactionWithInputInfo, localSig: BinaryData, remoteSig: BinaryData)
case class PublishableTxs(commitTx: CommitTx, htlcTxsAndSigs: Seq[HtlcTxAndSigs])
@ -207,7 +207,7 @@ object Commitments extends Logging {
val commitments1 = commitments.copy(
remoteNextCommitInfo = Left((RemoteCommit(remoteCommit.index + 1, spec, remoteCommitTx.tx.txid, remoteNextPerCommitmentPoint), commitSig)),
localChanges = localChanges.copy(proposed = Nil, signed = localChanges.proposed),
remoteChanges = remoteChanges.copy(acked = Nil))
remoteChanges = remoteChanges.copy(acked = Nil, signed = remoteChanges.acked))
(commitments1, commitSig)
case Left(_) =>
throw new RuntimeException("cannot sign until next revocation hash is received")
@ -314,6 +314,7 @@ object Commitments extends Logging {
commitments.copy(
localChanges = localChanges.copy(signed = Nil, acked = localChanges.acked ++ localChanges.signed),
remoteChanges = remoteChanges.copy(signed = Nil),
remoteCommit = theirNextCommit,
remoteNextCommitInfo = Right(revocation.nextPerCommitmentPoint),
remotePerCommitmentSecrets = commitments.remotePerCommitmentSecrets.addHash(revocation.perCommitmentSecret, 0xFFFFFFFFFFFFL - commitments.remoteCommit.index))

View file

@ -26,11 +26,12 @@ class FxApp extends Application with Logging {
override def start(primaryStage: Stage): Unit = {
val icon = new Image(getClass.getResource("/gui/commons/images/eclair02.png").toExternalForm, false)
primaryStage.getIcons.add(icon)
val icon = new Image("/gui/commons/images/eclair02.png", true)
primaryStage.getIcons().add(icon)
val splashStage = new SplashStage()
splashStage.initOwner(primaryStage)
splashStage.getIcons.add(icon)
splashStage.show
new Thread(new Runnable {

View file

@ -20,9 +20,6 @@ class SplashStage() extends Stage() {
initStyle(StageStyle.TRANSPARENT)
setResizable(false)
val icon = new Image("/gui/commons/images/eclair02.png", false)
this.getIcons().add(icon)
// get fxml/controller
val splash = new FXMLLoader(getClass.getResource("/gui/splash/splash.fxml"))
val root = splash.load[Parent]

View file

@ -34,15 +34,11 @@ class LocalPaymentHandler extends Actor with ActorLogging {
case htlc: UpdateAddHtlc if h2r.contains(htlc.paymentHash) =>
val r = h2r(htlc.paymentHash)
sender ! CMD_SIGN
sender ! CMD_FULFILL_HTLC(htlc.id, r)
sender ! CMD_SIGN
sender ! CMD_FULFILL_HTLC(htlc.id, r, commit = true)
context.become(run(h2r - htlc.paymentHash))
case htlc: UpdateAddHtlc =>
sender ! CMD_SIGN
sender ! CMD_FAIL_HTLC(htlc.id, "unkown H")
sender ! CMD_SIGN
sender ! CMD_FAIL_HTLC(htlc.id, "unkown H", commit = true)
}