mirror of
https://github.com/ACINQ/eclair.git
synced 2024-11-20 10:39:19 +01:00
PaymentSucceeded adds fee in amountMsat, and contains paymentHash (#466)
This commit is contained in:
parent
43128636ce
commit
8d387cee90
@ -20,7 +20,7 @@ case class SendPayment(amountMsat: Long, paymentHash: BinaryData, targetNodeId:
|
||||
case class CheckPayment(paymentHash: BinaryData)
|
||||
|
||||
sealed trait PaymentResult
|
||||
case class PaymentSucceeded(amountMsat: Long, paymentPreimage: BinaryData, route: Seq[Hop]) extends PaymentResult
|
||||
case class PaymentSucceeded(amountMsat: Long, paymentHash: BinaryData, paymentPreimage: BinaryData, route: Seq[Hop]) extends PaymentResult // note: the amount includes fees
|
||||
sealed trait PaymentFailure
|
||||
case class LocalFailure(t: Throwable) extends PaymentFailure
|
||||
case class RemoteFailure(route: Seq[Hop], e: ErrorPacket) extends PaymentFailure
|
||||
@ -72,7 +72,7 @@ class PaymentLifecycle(sourceNodeId: PublicKey, router: ActorRef, register: Acto
|
||||
case Event("ok", _) => stay()
|
||||
|
||||
case Event(fulfill: UpdateFulfillHtlc, WaitingForComplete(s, c, cmd, _, _, _, _, hops)) =>
|
||||
reply(s, PaymentSucceeded(c.amountMsat, fulfill.paymentPreimage, hops))
|
||||
reply(s, PaymentSucceeded(cmd.amountMsat, c.paymentHash, fulfill.paymentPreimage, hops))
|
||||
context.system.eventStream.publish(PaymentSent(MilliSatoshi(c.amountMsat), MilliSatoshi(cmd.amountMsat - c.amountMsat), cmd.paymentHash, fulfill.paymentPreimage))
|
||||
stop(FSM.Normal)
|
||||
|
||||
|
@ -136,7 +136,7 @@ class Relayer(nodeParams: NodeParams, register: ActorRef, paymentHandler: ActorR
|
||||
|
||||
case ForwardFulfill(fulfill, Local(None), add) =>
|
||||
// we sent the payment, but we probably restarted and the reference to the original sender was lost, we just publish the failure on the event stream
|
||||
context.system.eventStream.publish(PaymentSucceeded(add.amountMsat, fulfill.paymentPreimage, Nil))
|
||||
context.system.eventStream.publish(PaymentSucceeded(add.amountMsat, add.paymentHash, fulfill.paymentPreimage, Nil))
|
||||
|
||||
case ForwardFulfill(fulfill, Local(Some(sender)), _) =>
|
||||
sender ! fulfill
|
||||
|
@ -189,6 +189,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec {
|
||||
sender.send(paymentFSM, UpdateFulfillHtlc("00" * 32, 0, "42" * 32))
|
||||
|
||||
val paymentOK = sender.expectMsgType[PaymentSucceeded]
|
||||
assert(paymentOK.amountMsat > request.amountMsat)
|
||||
val PaymentSent(MilliSatoshi(request.amountMsat), feesPaid, request.paymentHash, paymentOK.paymentPreimage) = eventListener.expectMsgType[PaymentSent]
|
||||
assert(feesPaid.amount > 0)
|
||||
|
||||
|
@ -127,7 +127,6 @@ abstract class BaseRouterSpec extends TestkitBaseClass {
|
||||
val channels = sender.expectMsgType[Iterable[ChannelAnnouncement]]
|
||||
sender.send(router, 'updates)
|
||||
val updates = sender.expectMsgType[Iterable[ChannelUpdate]]
|
||||
println(nodes.size, channels.size, updates.size)
|
||||
nodes.size === 6 && channels.size === 4 && updates.size === 8
|
||||
}, max = 10 seconds, interval = 1 second)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user