1
0

onion_messages: guard onion message forwarding behind config option

EXPERIMENTAL_LN_FORWARD_PAYMENTS (default False)
This commit is contained in:
Sander van Grieken
2025-02-19 18:06:04 +01:00
parent c3c5aaab3d
commit ad6eb73dd3
2 changed files with 10 additions and 3 deletions

View File

@@ -758,5 +758,7 @@ class OnionMessageManager(Logger):
if processed_onion_packet.are_we_final:
self.on_onion_message_received(recipient_data, payload)
else:
elif self.network.config.EXPERIMENTAL_LN_FORWARD_PAYMENTS:
self.on_onion_message_forward(recipient_data, processed_onion_packet.next_packet, blinding, shared_secret)
else:
self.logger.info('onion_message dropped')

View File

@@ -8,6 +8,7 @@ import logging
import electrum_ecc as ecc
from electrum_ecc import ECPrivkey
from electrum import SimpleConfig
from electrum.lnmsg import decode_msg, OnionWireSerializer
from electrum.lnonion import (
OnionHopsDataSingle, OnionPacket,
@@ -16,15 +17,17 @@ from electrum.lnonion import (
HOPS_DATA_SIZE, InvalidPayloadSize)
from electrum.crypto import get_ecdh, privkey_to_pubkey
from electrum.lnutil import LnFeatures, Keypair
from electrum.onion_message import blinding_privkey, create_blinded_path, encrypt_onionmsg_tlv_hops_data, \
from electrum.onion_message import (
blinding_privkey, create_blinded_path, encrypt_onionmsg_tlv_hops_data,
OnionMessageManager, NoRouteFound, Timeout
)
from electrum.util import bfh, read_json_file, OldTaskGroup, get_asyncio_loop
from electrum.logging import console_stderr_handler
from . import ElectrumTestCase, test_lnpeer
from .test_lnpeer import PutIntoOthersQueueTransport, PeerInTests, keypair
TIME_STEP = 0.01 # run tests 100 x faster
TIME_STEP = 0.01 # run tests 100 x faster
OnionMessageManager.SLEEP_DELAY *= TIME_STEP
OnionMessageManager.REQUEST_REPLY_TIMEOUT *= TIME_STEP
OnionMessageManager.REQUEST_REPLY_RETRY_DELAY *= TIME_STEP
@@ -263,6 +266,8 @@ class MockNetwork:
def __init__(self):
self.asyncio_loop = get_asyncio_loop()
self.taskgroup = OldTaskGroup()
self.config = SimpleConfig()
self.config.EXPERIMENTAL_LN_FORWARD_PAYMENTS = True
class MockWallet: