Trampoline: always increase fees, to ensure we do not get stuck in a loop.
Also handle TEMPORARY_CHANNEL_FAILURE, which is sometimes returned by Eclair.
This commit is contained in:
@@ -1274,25 +1274,32 @@ class LNWallet(LNWorker):
|
|||||||
raise PaymentFailure(failure_msg.code_name())
|
raise PaymentFailure(failure_msg.code_name())
|
||||||
# trampoline
|
# trampoline
|
||||||
if not self.channel_db:
|
if not self.channel_db:
|
||||||
|
def maybe_raise_trampoline_fee(htlc_log):
|
||||||
|
global trampoline_fee_level
|
||||||
|
if htlc_log.trampoline_fee_level == trampoline_fee_level:
|
||||||
|
trampoline_fee_level += 1
|
||||||
|
self.logger.info(f'raising trampoline fee level {trampoline_fee_level}')
|
||||||
|
else:
|
||||||
|
self.logger.info(f'NOT raising trampoline fee level, already at {trampoline_fee_level}')
|
||||||
# FIXME The trampoline nodes in the path are chosen randomly.
|
# FIXME The trampoline nodes in the path are chosen randomly.
|
||||||
# Some of the errors might depend on how we have chosen them.
|
# Some of the errors might depend on how we have chosen them.
|
||||||
# Having more attempts is currently useful in part because of the randomness,
|
# Having more attempts is currently useful in part because of the randomness,
|
||||||
# instead we should give feedback to create_routes_for_payment.
|
# instead we should give feedback to create_routes_for_payment.
|
||||||
if code in (OnionFailureCode.TRAMPOLINE_FEE_INSUFFICIENT,
|
if code in (
|
||||||
OnionFailureCode.TRAMPOLINE_EXPIRY_TOO_SOON):
|
OnionFailureCode.TRAMPOLINE_FEE_INSUFFICIENT,
|
||||||
|
OnionFailureCode.TRAMPOLINE_EXPIRY_TOO_SOON):
|
||||||
# TODO: parse the node policy here (not returned by eclair yet)
|
# TODO: parse the node policy here (not returned by eclair yet)
|
||||||
# TODO: erring node is always the first trampoline even if second
|
# TODO: erring node is always the first trampoline even if second
|
||||||
# trampoline demands more fees, we can't influence this
|
# trampoline demands more fees, we can't influence this
|
||||||
if htlc_log.trampoline_fee_level == trampoline_fee_level:
|
maybe_raise_trampoline_fee(htlc_log)
|
||||||
trampoline_fee_level += 1
|
|
||||||
self.logger.info(f'raising trampoline fee level {trampoline_fee_level}')
|
|
||||||
else:
|
|
||||||
self.logger.info(f'NOT raising trampoline fee level, already at {trampoline_fee_level}')
|
|
||||||
continue
|
continue
|
||||||
elif use_two_trampolines:
|
elif use_two_trampolines:
|
||||||
use_two_trampolines = False
|
use_two_trampolines = False
|
||||||
elif code in (OnionFailureCode.UNKNOWN_NEXT_PEER,
|
elif code in (
|
||||||
OnionFailureCode.TEMPORARY_NODE_FAILURE):
|
OnionFailureCode.UNKNOWN_NEXT_PEER,
|
||||||
|
OnionFailureCode.TEMPORARY_NODE_FAILURE,
|
||||||
|
OnionFailureCode.TEMPORARY_CHANNEL_FAILURE):
|
||||||
|
maybe_raise_trampoline_fee(htlc_log)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
raise PaymentFailure(failure_msg.code_name())
|
raise PaymentFailure(failure_msg.code_name())
|
||||||
|
|||||||
Reference in New Issue
Block a user