1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 06:21:42 +01:00

make wallet resolution independent of wake-up config

This commit is contained in:
pm47 2025-02-19 10:42:18 +01:00
parent 194f67365f
commit d32c269781
No known key found for this signature in database
GPG key ID: E434ED292E85643A

View file

@ -285,25 +285,25 @@ class NodeRelay private(nodeParams: NodeParams,
/** The next node may be a mobile wallet directly connected to us: in that case, we'll need to wake them up before relaying the payment. */
private def attemptWakeUpIfRecipientIsWallet(upstream: Upstream.Hot.Trampoline, recipient: Recipient, nextPayload: IntermediatePayload.NodeRelay, nextPacket_opt: Option[OnionRoutingPacket]): Behavior[Command] = {
if (nodeParams.peerWakeUpConfig.enabled) {
val forwardNodeIdFailureAdapter = context.messageAdapter[Register.ForwardNodeIdFailure[Peer.GetPeerInfo]](_ => WrappedPeerInfo(isPeer = false, remoteFeatures_opt = None))
val peerInfoAdapter = context.messageAdapter[Peer.PeerInfoResponse] {
case _: Peer.PeerNotFound => WrappedPeerInfo(isPeer = false, remoteFeatures_opt = None)
case info: Peer.PeerInfo => WrappedPeerInfo(isPeer = true, info.features)
val forwardNodeIdFailureAdapter = context.messageAdapter[Register.ForwardNodeIdFailure[Peer.GetPeerInfo]](_ => WrappedPeerInfo(isPeer = false, remoteFeatures_opt = None))
val peerInfoAdapter = context.messageAdapter[Peer.PeerInfoResponse] {
case _: Peer.PeerNotFound => WrappedPeerInfo(isPeer = false, remoteFeatures_opt = None)
case info: Peer.PeerInfo => WrappedPeerInfo(isPeer = true, info.features)
}
register ! Register.ForwardNodeId(forwardNodeIdFailureAdapter, recipient.nodeId, Peer.GetPeerInfo(Some(peerInfoAdapter)))
Behaviors.receiveMessagePartial {
rejectExtraHtlcPartialFunction orElse {
case info: WrappedPeerInfo =>
val walletNodeId_opt = if (info.isPeer && info.remoteFeatures_opt.exists(_.hasFeature(Features.WakeUpNotificationClient))) {
Some(recipient.nodeId)
} else {
None
}
walletNodeId_opt match {
case Some(walletNodeId) if nodeParams.peerWakeUpConfig.enabled => attemptWakeUp(upstream, walletNodeId, recipient, nextPayload, nextPacket_opt)
case _ => relay(upstream, recipient, None, None, nextPayload, nextPacket_opt)
}
}
register ! Register.ForwardNodeId(forwardNodeIdFailureAdapter, recipient.nodeId, Peer.GetPeerInfo(Some(peerInfoAdapter)))
Behaviors.receiveMessagePartial {
rejectExtraHtlcPartialFunction orElse {
case info: WrappedPeerInfo =>
if (info.isPeer && info.remoteFeatures_opt.exists(_.hasFeature(Features.WakeUpNotificationClient))) {
attemptWakeUp(upstream, recipient.nodeId, recipient, nextPayload, nextPacket_opt)
} else {
relay(upstream, recipient, None, None, nextPayload, nextPacket_opt)
}
}
}
} else {
relay(upstream, recipient, None, None, nextPayload, nextPacket_opt)
}
}