Skip to content

Commit

Permalink
fixup! Refactor Payment classes. The PaymentOptions embeds the amount…
Browse files Browse the repository at this point in the history
… and expiry and additional tlvs. The PaymentInitiator translates payment parameters before forwarding to PaymentLifecycle. This make it easier to add new payment capabilities before the PaymentLifecycle layer (AMP, Loop, Trampoline, etc).
  • Loading branch information
t-bast committed Aug 2, 2019
1 parent b48c559 commit cd4d100
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions eclair-core/src/main/scala/fr/acinq/eclair/Eclair.scala
Expand Up @@ -37,7 +37,7 @@ import fr.acinq.eclair.wire.{ChannelAnnouncement, ChannelUpdate, NodeAddress, No
import scodec.bits.ByteVector

import scala.concurrent.duration._
import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.concurrent.{ExecutionContext, Future}

case class GetInfoResponse(nodeId: PublicKey, alias: String, chainHash: ByteVector32, blockHeight: Int, publicAddresses: Seq[NodeAddress])

Expand All @@ -54,7 +54,6 @@ object TimestampQueryFilters {
}
}


trait Eclair {

def connect(target: Either[NodeURI, PublicKey])(implicit timeout: Timeout): Future[String]
Expand Down Expand Up @@ -112,7 +111,7 @@ trait Eclair {

class EclairImpl(appKit: Kit) extends Eclair {

implicit val ec: ExecutionContextExecutor = appKit.system.dispatcher
implicit val ec: ExecutionContext = appKit.system.dispatcher

override def connect(target: Either[NodeURI, PublicKey])(implicit timeout: Timeout): Future[String] = target match {
case Left(uri) => (appKit.switchboard ? Peer.Connect(uri)).mapTo[String]
Expand Down
Expand Up @@ -223,13 +223,13 @@ object PaymentLifecycle {
// The final htlc expiry in number of blocks.
val finalExpiry: Long
}
case class LegacyPayload(finalAmountMsat: Long, finalCltvExpiry: Long) extends PaymentOptions {
case class LegacyPayload(finalAmountMsat: Long, finalCltvExpiryDelta: Long) extends PaymentOptions {
// We add one block in order to not have our htlc fail when a new block has just been found.
override val finalExpiry = Globals.blockCount.get() + finalCltvExpiry + 1
override val finalExpiry = Globals.blockCount.get() + finalCltvExpiryDelta + 1
}
case class TlvPayload(finalAmountMsat: Long, finalCltvExpiry: Long, records: Seq[OnionTlv] = Nil) extends PaymentOptions {
case class TlvPayload(finalAmountMsat: Long, finalCltvExpiryDelta: Long, records: Seq[OnionTlv] = Nil) extends PaymentOptions {
// We add one block in order to not have our htlc fail when a new block has just been found.
override val finalExpiry = Globals.blockCount.get() + finalCltvExpiry + 1
override val finalExpiry = Globals.blockCount.get() + finalCltvExpiryDelta + 1
}

sealed trait Data
Expand Down

0 comments on commit cd4d100

Please sign in to comment.