lnworker/config: check if zeroconf is enabled when forwarding
On LSP side we were only checking if ACCEPT_ZEROCONF_CHANNELS is enabled while forwarding a non-trampoline htlc. During trampoline forwarding the config was ignored. The ACCEPT_* prefix implied this was only for accepting inbound zeroconf channels, but it also controls whether we open them when forwarding HTLCs. Renames the config var to OPEN_ZEROCONF_CHANNELS to clarify it enables zeroconf channel opens in both directions, and add the missing check when forwarding trampoline HTLCs.
This commit is contained in:
@@ -1010,7 +1010,7 @@ class LNWallet(Logger):
|
||||
features = LNWALLET_FEATURES
|
||||
if self.config.ENABLE_ANCHOR_CHANNELS:
|
||||
features |= LnFeatures.OPTION_ANCHORS_ZERO_FEE_HTLC_OPT
|
||||
if self.config.ACCEPT_ZEROCONF_CHANNELS:
|
||||
if self.config.OPEN_ZEROCONF_CHANNELS:
|
||||
features |= LnFeatures.OPTION_ZEROCONF_OPT
|
||||
if self.config.EXPERIMENTAL_LN_FORWARD_PAYMENTS or self.config.EXPERIMENTAL_LN_FORWARD_TRAMPOLINE_PAYMENTS:
|
||||
features |= LnFeatures.OPTION_ONION_MESSAGE_OPT
|
||||
@@ -1485,6 +1485,7 @@ class LNWallet(Logger):
|
||||
payment_hash: bytes,
|
||||
next_onion: OnionPacket,
|
||||
) -> str:
|
||||
assert self.config.OPEN_ZEROCONF_CHANNELS
|
||||
# if an exception is raised during negotiation, we raise an OnionRoutingFailure.
|
||||
# this will cancel the incoming HTLC
|
||||
|
||||
@@ -3351,7 +3352,7 @@ class LNWallet(Logger):
|
||||
return False
|
||||
|
||||
def can_get_zeroconf_channel(self) -> bool:
|
||||
if not self.config.ACCEPT_ZEROCONF_CHANNELS and self.config.ZEROCONF_TRUSTED_NODE:
|
||||
if not self.config.OPEN_ZEROCONF_CHANNELS and self.config.ZEROCONF_TRUSTED_NODE:
|
||||
# check if zeroconf is accepted and client has trusted zeroconf node configured
|
||||
return False
|
||||
try:
|
||||
@@ -3998,7 +3999,7 @@ class LNWallet(Logger):
|
||||
|
||||
# do we have a connection to the node?
|
||||
next_peer = self.lnpeermgr.get_peer_by_pubkey(outgoing_node_id)
|
||||
if next_peer and next_peer.accepts_zeroconf():
|
||||
if next_peer and next_peer.accepts_zeroconf() and self.features.supports(LnFeatures.OPTION_ZEROCONF_OPT):
|
||||
self.logger.info(f'JIT: found next_peer')
|
||||
for next_chan in next_peer.channels.values():
|
||||
if next_chan.can_pay(amt_to_forward):
|
||||
|
||||
@@ -954,7 +954,7 @@ Warning: setting this to too low will result in lots of payment failures."""),
|
||||
# anchor outputs channels
|
||||
ENABLE_ANCHOR_CHANNELS = ConfigVar('enable_anchor_channels', default=True, type_=bool)
|
||||
# zeroconf channels
|
||||
ACCEPT_ZEROCONF_CHANNELS = ConfigVar('accept_zeroconf_channels', default=False, type_=bool)
|
||||
OPEN_ZEROCONF_CHANNELS = ConfigVar('open_zeroconf_channels', default=False, type_=bool)
|
||||
ZEROCONF_TRUSTED_NODE = ConfigVar('zeroconf_trusted_node', default='', type_=str)
|
||||
ZEROCONF_MIN_OPENING_FEE = ConfigVar('zeroconf_min_opening_fee', default=5000, type_=int)
|
||||
LN_UTXO_RESERVE = ConfigVar(
|
||||
|
||||
+1
-1
@@ -3458,7 +3458,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
zeroconf_nodeid = extract_nodeid(self.config.ZEROCONF_TRUSTED_NODE)[0]
|
||||
except Exception:
|
||||
zeroconf_nodeid = None
|
||||
can_get_zeroconf_channel = (self.lnworker and self.config.ACCEPT_ZEROCONF_CHANNELS
|
||||
can_get_zeroconf_channel = (self.lnworker and self.config.OPEN_ZEROCONF_CHANNELS
|
||||
and self.lnworker.lnpeermgr.get_peer_by_pubkey(zeroconf_nodeid) is not None)
|
||||
status = self.get_invoice_status(req)
|
||||
|
||||
|
||||
+4
-4
@@ -151,12 +151,12 @@ class TestLightningABC(TestLightning):
|
||||
class TestLightningJIT(TestLightning):
|
||||
agents = {
|
||||
'alice': {
|
||||
'accept_zeroconf_channels': 'true',
|
||||
'open_zeroconf_channels': 'true',
|
||||
},
|
||||
'bob': {
|
||||
'lightning_listen': 'localhost:9735',
|
||||
'lightning_forward_payments': 'true',
|
||||
'accept_zeroconf_channels': 'true',
|
||||
'open_zeroconf_channels': 'true',
|
||||
},
|
||||
'carol': {
|
||||
}
|
||||
@@ -170,13 +170,13 @@ class TestLightningJITTrampoline(TestLightningJIT):
|
||||
agents = {
|
||||
'alice': {
|
||||
'use_gossip': 'false',
|
||||
'accept_zeroconf_channels': 'true',
|
||||
'open_zeroconf_channels': 'true',
|
||||
},
|
||||
'bob': {
|
||||
'lightning_listen': 'localhost:9735',
|
||||
'lightning_forward_payments': 'true',
|
||||
'lightning_forward_trampoline_payments': 'true',
|
||||
'accept_zeroconf_channels': 'true',
|
||||
'open_zeroconf_channels': 'true',
|
||||
},
|
||||
'carol': {
|
||||
'use_gossip': 'false',
|
||||
|
||||
Reference in New Issue
Block a user