|
67 | 67 | NUM_MAX_EDGES_IN_PAYMENT_PATH, SENT, RECEIVED, HTLCOwner, |
68 | 68 | UpdateAddHtlc, Direction, LnFeatures, ShortChannelID, |
69 | 69 | HtlcLog, derive_payment_secret_from_payment_preimage, |
70 | | - NoPathFound, InvalidGossipMsg) |
| 70 | + NoPathFound, InvalidGossipMsg, FeeBudgetExceeded) |
71 | 71 | from .lnutil import ln_compare_features, IncompatibleLightningFeatures, PaymentFeeBudget |
72 | 72 | from .transaction import PartialTxOutput, PartialTransaction, PartialTxInput |
73 | 73 | from .lnonion import decode_onion_error, OnionFailureCode, OnionRoutingFailure, OnionPacket |
@@ -1880,6 +1880,7 @@ async def create_routes_for_payment( |
1880 | 1880 | and mpp is supported by the receiver, we will split the payment.""" |
1881 | 1881 | trampoline_features = LnFeatures.VAR_ONION_OPT |
1882 | 1882 | local_height = self.network.get_local_height() |
| 1883 | + fee_related_error = None # type: Optional[FeeBudgetExceeded] |
1883 | 1884 | if channels: |
1884 | 1885 | my_active_channels = channels |
1885 | 1886 | else: |
@@ -1970,8 +1971,9 @@ async def create_routes_for_payment( |
1970 | 1971 | ) |
1971 | 1972 | routes.append((shi, per_trampoline_cltv_delta, trampoline_onion)) |
1972 | 1973 | if per_trampoline_fees != 0: |
1973 | | - self.logger.info('not enough margin to pay trampoline fee') |
1974 | | - raise NoPathFound() |
| 1974 | + e = 'not enough margin to pay trampoline fee' |
| 1975 | + self.logger.info(e) |
| 1976 | + raise FeeBudgetExceeded(e) |
1975 | 1977 | else: |
1976 | 1978 | # We atomically loop through a split configuration. If there was |
1977 | 1979 | # a failure to find a path for a single part, we try the next configuration |
@@ -2004,9 +2006,14 @@ async def create_routes_for_payment( |
2004 | 2006 | routes.append((shi, paysession.min_final_cltv_delta, fwd_trampoline_onion)) |
2005 | 2007 | except NoPathFound: |
2006 | 2008 | continue |
| 2009 | + except FeeBudgetExceeded as e: |
| 2010 | + fee_related_error = e |
| 2011 | + continue |
2007 | 2012 | for route in routes: |
2008 | 2013 | yield route |
2009 | 2014 | return |
| 2015 | + if fee_related_error is not None: |
| 2016 | + raise fee_related_error |
2010 | 2017 | raise NoPathFound() |
2011 | 2018 |
|
2012 | 2019 | @profiler |
@@ -2079,7 +2086,7 @@ def create_route_for_single_htlc( |
2079 | 2086 | route, budget=budget, amount_msat_for_dest=amount_msat, cltv_delta_for_dest=min_final_cltv_delta, |
2080 | 2087 | ): |
2081 | 2088 | self.logger.info(f"rejecting route (exceeds budget): {route=}. {budget=}") |
2082 | | - raise NoPathFound() |
| 2089 | + raise FeeBudgetExceeded() |
2083 | 2090 | assert len(route) > 0 |
2084 | 2091 | if route[-1].end_node != invoice_pubkey: |
2085 | 2092 | raise LNPathInconsistent("last node_id != invoice pubkey") |
|
0 commit comments