1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-23 06:35:11 +01:00

updated proto file

This commit is contained in:
pm47 2016-01-22 17:14:45 +01:00
parent 5b643c5f10
commit 4e740606af
3 changed files with 25 additions and 13 deletions

View file

@ -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}"
}

View file

@ -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)

View file

@ -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;