@@ -37,10 +37,9 @@ import fr.acinq.eclair.payment.send.MultiPartPaymentLifecycle.{PreimageReceived,
37
37
import fr .acinq .eclair .payment .send .PaymentInitiator .SendPaymentConfig
38
38
import fr .acinq .eclair .payment .send .PaymentLifecycle .SendPaymentToNode
39
39
import fr .acinq .eclair .payment .send ._
40
+ import fr .acinq .eclair .reputation .Reputation
41
+ import fr .acinq .eclair .reputation .ReputationRecorder .GetConfidence
40
42
import fr .acinq .eclair .router .Router .{ChannelHop , HopRelayParams , Route , RouteParams }
41
- import fr .acinq .eclair .reputation .ReputationRecorder
42
- import fr .acinq .eclair .reputation .ReputationRecorder .GetTrampolineConfidence
43
- import fr .acinq .eclair .router .Router .RouteParams
44
43
import fr .acinq .eclair .router .{BalanceTooLow , RouteNotFound }
45
44
import fr .acinq .eclair .wire .protocol .PaymentOnion .IntermediatePayload
46
45
import fr .acinq .eclair .wire .protocol ._
@@ -70,29 +69,27 @@ object NodeRelay {
70
69
private case class WrappedResolvedPaths (resolved : Seq [ResolvedPath ]) extends Command
71
70
private case class WrappedPeerInfo (remoteFeatures_opt : Option [Features [InitFeature ]]) extends Command
72
71
private case class WrappedOnTheFlyFundingResponse (result : Peer .ProposeOnTheFlyFundingResponse ) extends Command
73
- private case class WrappedConfidence (confidence : Double ) extends Command
74
72
// @formatter:on
75
73
76
74
trait OutgoingPaymentFactory {
77
75
def spawnOutgoingPayFSM (context : ActorContext [NodeRelay .Command ], cfg : SendPaymentConfig , multiPart : Boolean ): ActorRef
78
76
}
79
77
80
- case class SimpleOutgoingPaymentFactory (nodeParams : NodeParams , router : ActorRef , register : ActorRef ) extends OutgoingPaymentFactory {
78
+ case class SimpleOutgoingPaymentFactory (nodeParams : NodeParams , router : ActorRef , register : ActorRef , reputationRecorder_opt : Option [typed. ActorRef [ GetConfidence ]] ) extends OutgoingPaymentFactory {
81
79
val paymentFactory : PaymentInitiator .SimplePaymentFactory = PaymentInitiator .SimplePaymentFactory (nodeParams, router, register)
82
80
83
81
override def spawnOutgoingPayFSM (context : ActorContext [Command ], cfg : SendPaymentConfig , multiPart : Boolean ): ActorRef = {
84
82
if (multiPart) {
85
83
context.toClassic.actorOf(MultiPartPaymentLifecycle .props(nodeParams, cfg, publishPreimage = true , router, paymentFactory))
86
84
} else {
87
- context.toClassic.actorOf(PaymentLifecycle .props(nodeParams, cfg, router, register))
85
+ context.toClassic.actorOf(PaymentLifecycle .props(nodeParams, cfg, router, register, reputationRecorder_opt ))
88
86
}
89
87
}
90
88
}
91
89
92
90
def apply (nodeParams : NodeParams ,
93
91
parent : typed.ActorRef [NodeRelayer .Command ],
94
92
register : ActorRef ,
95
- reputationRecorder_opt : Option [typed.ActorRef [GetTrampolineConfidence ]],
96
93
relayId : UUID ,
97
94
nodeRelayPacket : NodeRelayPacket ,
98
95
outgoingPaymentFactory : OutgoingPaymentFactory ,
@@ -116,7 +113,7 @@ object NodeRelay {
116
113
case _ : IncomingPaymentPacket .RelayToNonTrampolinePacket => None
117
114
case _ : IncomingPaymentPacket .RelayToBlindedPathsPacket => None
118
115
}
119
- new NodeRelay (nodeParams, parent, register, reputationRecorder_opt, relayId, paymentHash, nodeRelayPacket.outerPayload.paymentSecret, context, outgoingPaymentFactory, router)
116
+ new NodeRelay (nodeParams, parent, register, relayId, paymentHash, nodeRelayPacket.outerPayload.paymentSecret, context, outgoingPaymentFactory, router)
120
117
.receiving(Queue .empty, nodeRelayPacket.innerPayload, nextPacket_opt, incomingPaymentHandler)
121
118
}
122
119
}
@@ -205,7 +202,6 @@ object NodeRelay {
205
202
class NodeRelay private (nodeParams : NodeParams ,
206
203
parent : akka.actor.typed.ActorRef [NodeRelayer .Command ],
207
204
register : ActorRef ,
208
- reputationRecorder_opt : Option [typed.ActorRef [GetTrampolineConfidence ]],
209
205
relayId : UUID ,
210
206
paymentHash : ByteVector32 ,
211
207
paymentSecret : ByteVector32 ,
@@ -343,33 +339,23 @@ class NodeRelay private(nodeParams: NodeParams,
343
339
context.log.debug(" relaying trampoline payment (amountIn={} expiryIn={} amountOut={} expiryOut={} isWallet={})" , upstream.amountIn, upstream.expiryIn, amountOut, expiryOut, walletNodeId_opt.isDefined)
344
340
// We only make one try when it's a direct payment to a wallet.
345
341
val maxPaymentAttempts = if (walletNodeId_opt.isDefined) 1 else nodeParams.maxPaymentAttempts
346
- val totalFee = upstream.amountIn - payloadOut.outgoingAmount(upstream.amountIn)
347
- reputationRecorder_opt match {
348
- case Some (reputationRecorder) => reputationRecorder ! GetTrampolineConfidence (context.messageAdapter(confidence => WrappedConfidence (confidence.value)), upstream, totalFee)
349
- case None => context.self ! WrappedConfidence ((upstream.received.map(_.add.endorsement).min + 0.5 ) / 8 )
350
- }
351
- Behaviors .receiveMessagePartial {
352
- rejectExtraHtlcPartialFunction orElse {
353
- case WrappedConfidence (confidence) =>
354
- val paymentCfg = SendPaymentConfig (relayId, relayId, None , paymentHash, recipient.nodeId, upstream, None , None , storeInDb = false , publishEvent = false , recordPathFindingMetrics = true , confidence)
355
- val routeParams = computeRouteParams(nodeParams, upstream.amountIn, upstream.expiryIn, amountOut, expiryOut)
356
- // If the next node is using trampoline, we assume that they support MPP.
357
- val useMultiPart = recipient.features.hasFeature(Features .BasicMultiPartPayment ) || packetOut_opt.nonEmpty
358
- val payFsmAdapters = {
359
- context.messageAdapter[PreimageReceived ](WrappedPreimageReceived )
360
- context.messageAdapter[PaymentSent ](WrappedPaymentSent )
361
- context.messageAdapter[PaymentFailed ](WrappedPaymentFailed )
362
- }.toClassic
363
- val payment = if (useMultiPart) {
364
- SendMultiPartPayment (payFsmAdapters, recipient, maxPaymentAttempts, routeParams)
365
- } else {
366
- SendPaymentToNode (payFsmAdapters, recipient, maxPaymentAttempts, routeParams)
367
- }
368
- val payFSM = outgoingPaymentFactory.spawnOutgoingPayFSM(context, paymentCfg, useMultiPart)
369
- payFSM ! payment
370
- sending(upstream, recipient, walletNodeId_opt, recipientFeatures_opt, payloadOut, TimestampMilli .now(), fulfilledUpstream = false )
371
- }
342
+ val paymentCfg = SendPaymentConfig (relayId, relayId, None , paymentHash, recipient.nodeId, upstream, None , None , storeInDb = false , publishEvent = false , recordPathFindingMetrics = true )
343
+ val routeParams = computeRouteParams(nodeParams, upstream.amountIn, upstream.expiryIn, amountOut, expiryOut)
344
+ // If the next node is using trampoline, we assume that they support MPP.
345
+ val useMultiPart = recipient.features.hasFeature(Features .BasicMultiPartPayment ) || packetOut_opt.nonEmpty
346
+ val payFsmAdapters = {
347
+ context.messageAdapter[PreimageReceived ](WrappedPreimageReceived )
348
+ context.messageAdapter[PaymentSent ](WrappedPaymentSent )
349
+ context.messageAdapter[PaymentFailed ](WrappedPaymentFailed )
350
+ }.toClassic
351
+ val payment = if (useMultiPart) {
352
+ SendMultiPartPayment (payFsmAdapters, recipient, maxPaymentAttempts, routeParams)
353
+ } else {
354
+ SendPaymentToNode (payFsmAdapters, recipient, maxPaymentAttempts, routeParams)
372
355
}
356
+ val payFSM = outgoingPaymentFactory.spawnOutgoingPayFSM(context, paymentCfg, useMultiPart)
357
+ payFSM ! payment
358
+ sending(upstream, recipient, walletNodeId_opt, recipientFeatures_opt, payloadOut, TimestampMilli .now(), fulfilledUpstream = false )
373
359
}
374
360
375
361
/**
@@ -434,7 +420,7 @@ class NodeRelay private(nodeParams: NodeParams,
434
420
case r : BlindedRecipient => r.blindedHops.headOption
435
421
}
436
422
val dummyRoute = Route (amountOut, Seq (dummyHop), finalHop_opt)
437
- OutgoingPaymentPacket .buildOutgoingPayment(Origin .Hot (ActorRef .noSender, upstream), paymentHash, dummyRoute, recipient, 1.0 ) match {
423
+ OutgoingPaymentPacket .buildOutgoingPayment(Origin .Hot (ActorRef .noSender, upstream), paymentHash, dummyRoute, recipient, 1.0 , Reputation .maxEndorsement ) match {
438
424
case Left (f) =>
439
425
context.log.warn(" could not create payment onion for on-the-fly funding: {}" , f.getMessage)
440
426
rejectPayment(upstream, translateError(nodeParams, failures, upstream, nextPayload))
0 commit comments