From 4e740606affc2c13dc0a37077fb82186aca464a2 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 22 Jan 2016 17:14:45 +0100 Subject: [PATCH] updated proto file --- .../acinq/eclair/channel/ChannelState.scala | 14 ++++++------- .../fr/acinq/eclair/channel/Scripts.scala | 4 ++-- .../src/main/protobuf/lightning.proto | 20 +++++++++++++++---- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/eclair-demo/src/main/scala/fr/acinq/eclair/channel/ChannelState.scala b/eclair-demo/src/main/scala/fr/acinq/eclair/channel/ChannelState.scala index a54204dd4..1c776c6f0 100644 --- a/eclair-demo/src/main/scala/fr/acinq/eclair/channel/ChannelState.scala +++ b/eclair-demo/src/main/scala/fr/acinq/eclair/channel/ChannelState.scala @@ -31,7 +31,7 @@ case class ChannelState(us: ChannelOneSide, them: ChannelOneSide) { * @param htlc * @return */ - def htlc_receive(htlc: update_add_htlc): ChannelState = this.copy(them = them.copy(pay = them.pay - htlc.amount), us = us.copy(htlcs = us.htlcs :+ htlc)) + def htlc_receive(htlc: update_add_htlc): ChannelState = this.copy(them = them.copy(pay = them.pay - htlc.amountMsat), us = us.copy(htlcs = us.htlcs :+ htlc)) /** * Update our state when we receive an htlc @@ -39,7 +39,7 @@ case class ChannelState(us: ChannelOneSide, them: ChannelOneSide) { * @param htlc * @return */ - def htlc_send(htlc: update_add_htlc): ChannelState = this.copy(them = them.copy(htlcs = them.htlcs :+ htlc), us = us.copy(pay = us.pay - htlc.amount)) + def htlc_send(htlc: update_add_htlc): ChannelState = this.copy(them = them.copy(htlcs = them.htlcs :+ htlc), us = us.copy(pay = us.pay - htlc.amountMsat)) /** * We remove an existing htlc (can be because of a timeout, or a routing failure) @@ -52,12 +52,12 @@ case class ChannelState(us: ChannelOneSide, them: ChannelOneSide) { // TODO not optimized val htlc = us.htlcs.find(_.rHash == rHash).get // we were the receiver of this htlc - this.copy(them = them.copy(pay = them.pay + htlc.amount), us = us.copy(htlcs = us.htlcs.filterNot(_ == htlc))) + this.copy(them = them.copy(pay = them.pay + htlc.amountMsat), us = us.copy(htlcs = us.htlcs.filterNot(_ == htlc))) } else if (them.htlcs.find(_.rHash == rHash).isDefined) { // TODO not optimized val htlc = them.htlcs.find(_.rHash == rHash).get // we were the sender of this htlc - this.copy(them = them.copy(htlcs = them.htlcs.filterNot(_ == htlc)), us = us.copy(pay = us.pay + htlc.amount)) + this.copy(them = them.copy(htlcs = them.htlcs.filterNot(_ == htlc)), us = us.copy(pay = us.pay + htlc.amountMsat)) } else throw new RuntimeException(s"could not find corresponding htlc (rHash=$rHash)") } @@ -66,14 +66,14 @@ case class ChannelState(us: ChannelOneSide, them: ChannelOneSide) { // TODO not optimized val htlc = us.htlcs.find(_.rHash == bin2sha256(Crypto.sha256(r))).get // we were the receiver of this htlc - this.copy(us = us.copy(pay = us.pay + htlc.amount, htlcs = us.htlcs.filterNot(_ == htlc))) + this.copy(us = us.copy(pay = us.pay + htlc.amountMsat, htlcs = us.htlcs.filterNot(_ == htlc))) } else if (them.htlcs.find(_.rHash == bin2sha256(Crypto.sha256(r))).isDefined) { // TODO not optimized val htlc = them.htlcs.find(_.rHash == bin2sha256(Crypto.sha256(r))).get // we were the sender of this htlc - this.copy(them = them.copy(pay = them.pay + htlc.amount, htlcs = them.htlcs.filterNot(_ == htlc))) + this.copy(them = them.copy(pay = them.pay + htlc.amountMsat, htlcs = them.htlcs.filterNot(_ == htlc))) } else throw new RuntimeException(s"could not find corresponding htlc (r=$r)") } - def prettyString(): String = s"pay_us=${us.pay} htlcs_us=${us.htlcs.map(_.amount).sum} pay_them=${them.pay} htlcs_them=${them.htlcs.map(_.amount).sum} total=${us.pay + us.htlcs.map(_.amount).sum + them.pay + them.htlcs.map(_.amount).sum}" + def prettyString(): String = s"pay_us=${us.pay} htlcs_us=${us.htlcs.map(_.amountMsat).sum} pay_them=${them.pay} htlcs_them=${them.htlcs.map(_.amountMsat).sum} total=${us.pay + us.htlcs.map(_.amountMsat).sum + them.pay + them.htlcs.map(_.amountMsat).sum}" } diff --git a/eclair-demo/src/main/scala/fr/acinq/eclair/channel/Scripts.scala b/eclair-demo/src/main/scala/fr/acinq/eclair/channel/Scripts.scala index 39165a1ef..454c7c981 100644 --- a/eclair-demo/src/main/scala/fr/acinq/eclair/channel/Scripts.scala +++ b/eclair-demo/src/main/scala/fr/acinq/eclair/channel/Scripts.scala @@ -111,10 +111,10 @@ object Scripts { lockTime = 0) val sendOuts = channelState.them.htlcs.map(htlc => { - TxOut(htlc.amount, pay2sh(scriptPubKeyHtlcSend(ourFinalKey, theirFinalKey, htlc.amount, htlc.expiry, theirDelay, htlc.rHash, htlc.revocationHash))) + TxOut(htlc.amountMsat, pay2sh(scriptPubKeyHtlcSend(ourFinalKey, theirFinalKey, htlc.amountMsat, htlc.expiry, theirDelay, htlc.rHash, htlc.revocationHash))) }) val receiveOuts = channelState.us.htlcs.map(htlc => { - TxOut(htlc.amount, pay2sh(scriptPubKeyHtlcReceive(ourFinalKey, theirFinalKey, htlc.amount, htlc.expiry, theirDelay, htlc.rHash, htlc.revocationHash))) + TxOut(htlc.amountMsat, pay2sh(scriptPubKeyHtlcReceive(ourFinalKey, theirFinalKey, htlc.amountMsat, htlc.expiry, theirDelay, htlc.rHash, htlc.revocationHash))) }) val tx1 = tx.copy(txOut = tx.txOut ++ sendOuts ++ receiveOuts) permuteOutputs(tx1) diff --git a/lightning-types/src/main/protobuf/lightning.proto b/lightning-types/src/main/protobuf/lightning.proto index 7100eaf9d..912833628 100644 --- a/lightning-types/src/main/protobuf/lightning.proto +++ b/lightning-types/src/main/protobuf/lightning.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + // The outer layer handles encryption, authentication and message // boundaries. @@ -49,6 +51,14 @@ message funding { // Packet Types // +// Set channel params. +message authenticate { + // Which node this is. + required bitcoin_pubkey node_id = 1; + // Signature of your session key. */ + required signature session_sig = 2; +}; + // Set channel params. message open_channel { // Relative locktime for outputs going to us. @@ -105,15 +115,15 @@ message update { // Hash for which I will supply preimage to revoke this. required sha256_hash revocation_hash = 1; // Change in current payment to-me (implies reverse to-you). - required sint64 delta = 2; + required sint64 delta_msat = 2; } // Start a new commitment tx to add an HTLC me -> you. message update_add_htlc { // Hash for which I will supply preimage to revoke this commitment tx. required sha256_hash revocation_hash = 1; - // Amount for htlc - required uint32 amount = 2; + // Amount for htlc (millisatoshi) + required uint32 amount_msat = 2; // Hash for HTLC R value. required sha256_hash r_hash = 3; // Time at which HTLC expires (absolute) @@ -195,7 +205,7 @@ message close_channel_complete { message close_channel_ack { } -// This means we're going to hang up; it's to help diagnose only! +// This means we're going to hang up; it's to help diagnose only! message error { optional string problem = 1; } @@ -203,6 +213,8 @@ message error { // This is the union which defines all of them message pkt { oneof pkt { + // Start of connection + authenticate auth = 50; // Opening open_channel open = 20; open_anchor open_anchor = 21;