1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-24 06:47:46 +01:00

Unified cltv expiry type to Long (#253)

This commit is contained in:
Dominique 2017-12-04 17:37:11 +01:00 committed by GitHub
parent 71f39a033b
commit 82c5b676e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -181,16 +181,16 @@ object PaymentLifecycle {
* - firstExpiry is the cltv expiry for the first htlc in the route * - firstExpiry is the cltv expiry for the first htlc in the route
* - a sequence of payloads that will be used to build the onion * - a sequence of payloads that will be used to build the onion
*/ */
def buildPayloads(finalAmountMsat: Long, finalExpiry: Int, hops: Seq[PaymentHop]): (Long, Int, Seq[PerHopPayload]) = def buildPayloads(finalAmountMsat: Long, finalExpiry: Long, hops: Seq[PaymentHop]): (Long, Long, Seq[PerHopPayload]) =
hops.reverse.foldLeft((finalAmountMsat, finalExpiry, PerHopPayload(0L, finalAmountMsat, finalExpiry) :: Nil)) { hops.reverse.foldLeft((finalAmountMsat, finalExpiry, PerHopPayload(0L, finalAmountMsat, finalExpiry) :: Nil)) {
case ((msat, expiry, payloads), hop) => case ((msat, expiry, payloads), hop) =>
(msat + hop.nextFee(msat), expiry + hop.cltvExpiryDelta, PerHopPayload(hop.shortChannelId, msat, expiry) +: payloads) (msat + hop.nextFee(msat), expiry + hop.cltvExpiryDelta, PerHopPayload(hop.shortChannelId, msat, expiry) +: payloads)
} }
// this is defined in BOLT 11 // this is defined in BOLT 11
val defaultMinFinalCltvExpiry = 9 val defaultMinFinalCltvExpiry:Long = 9L
def buildCommand(finalAmountMsat: Long, finalExpiry: Int, paymentHash: BinaryData, hops: Seq[Hop]): (CMD_ADD_HTLC, Seq[(BinaryData, PublicKey)]) = { def buildCommand(finalAmountMsat: Long, finalExpiry: Long, paymentHash: BinaryData, hops: Seq[Hop]): (CMD_ADD_HTLC, Seq[(BinaryData, PublicKey)]) = {
val (firstAmountMsat, firstExpiry, payloads) = buildPayloads(finalAmountMsat, finalExpiry, hops.drop(1)) val (firstAmountMsat, firstExpiry, payloads) = buildPayloads(finalAmountMsat, finalExpiry, hops.drop(1))
val nodes = hops.map(_.nextNodeId) val nodes = hops.map(_.nextNodeId)
// BOLT 2 requires that associatedData == paymentHash // BOLT 2 requires that associatedData == paymentHash

View file

@ -294,7 +294,7 @@ object LightningMessageCodecs {
("realm" | constant(ByteVector.fromByte(0))) :: ("realm" | constant(ByteVector.fromByte(0))) ::
("channel_id" | uint64) :: ("channel_id" | uint64) ::
("amt_to_forward" | uint64) :: ("amt_to_forward" | uint64) ::
("outgoing_cltv_value" | int32) :: // we use a signed int32, it is enough to store cltv for 40 000 years ("outgoing_cltv_value" | uint32) ::
("unused_with_v0_version_on_header" | ignore(8 * 12))).as[PerHopPayload] ("unused_with_v0_version_on_header" | ignore(8 * 12))).as[PerHopPayload]
} }

View file

@ -157,4 +157,4 @@ case class ChannelUpdate(signature: BinaryData,
case class PerHopPayload(channel_id: Long, case class PerHopPayload(channel_id: Long,
amtToForward: Long, amtToForward: Long,
outgoingCltvValue: Int) outgoingCltvValue: Long)