@@ -1820,6 +1820,33 @@ static u32 route_cltv(u32 cltv,
18201820 return cltv ;
18211821}
18221822
1823+ /* Change the destination and compute the final msatoshi amount to send to the
1824+ * routehint entry point. */
1825+ static void routehint_pre_getroute (struct routehints_data * d , struct payment * p )
1826+ {
1827+ d -> current_routehint = next_routehint (d , p );
1828+ if (d -> current_routehint != NULL ) {
1829+ if (!route_msatoshi (& p -> getroute -> amount , p -> amount ,
1830+ d -> current_routehint ,
1831+ tal_count (d -> current_routehint ))) {
1832+ }
1833+ d -> final_cltv = p -> getroute -> cltv ;
1834+ p -> getroute -> destination = & d -> current_routehint [0 ].pubkey ;
1835+ p -> getroute -> cltv =
1836+ route_cltv (p -> getroute -> cltv , d -> current_routehint ,
1837+ tal_count (d -> current_routehint ));
1838+ plugin_log (
1839+ p -> plugin , LOG_DBG , "Using routehint %s (%s) cltv_delta=%d" ,
1840+ type_to_string (tmpctx , struct node_id ,
1841+ & d -> current_routehint -> pubkey ),
1842+ type_to_string (tmpctx , struct short_channel_id ,
1843+ & d -> current_routehint -> short_channel_id ),
1844+ d -> current_routehint -> cltv_expiry_delta );
1845+ } else {
1846+ plugin_log (p -> plugin , LOG_DBG , "Not using a routehint" );
1847+ }
1848+ }
1849+
18231850static struct command_result * routehint_getroute_result (struct command * cmd ,
18241851 const char * buffer ,
18251852 const jsmntok_t * toks ,
@@ -1836,7 +1863,7 @@ static struct command_result *routehint_getroute_result(struct command *cmd,
18361863 if (d -> destination_reachable )
18371864 tal_arr_expand (& d -> routehints , NULL );
18381865
1839- d -> current_routehint = next_routehint (d , p );
1866+ routehint_pre_getroute (d , p );
18401867
18411868 plugin_log (p -> plugin , LOG_DBG ,
18421869 "The destination is%s directly reachable %s attempts "
@@ -1897,25 +1924,7 @@ static void routehint_step_cb(struct routehints_data *d, struct payment *p)
18971924 return routehint_check_reachable (p );
18981925 }
18991926
1900- d -> current_routehint = next_routehint (d , p );
1901- if (d -> current_routehint != NULL ) {
1902- /* Change the destination and compute the final msatoshi
1903- * amount to send to the routehint entry point. */
1904- if (!route_msatoshi (& p -> getroute -> amount , p -> amount ,
1905- d -> current_routehint ,
1906- tal_count (d -> current_routehint ))) {
1907- }
1908- d -> final_cltv = p -> getroute -> cltv ;
1909- p -> getroute -> destination = & d -> current_routehint [0 ].pubkey ;
1910- p -> getroute -> cltv =
1911- route_cltv (p -> getroute -> cltv , d -> current_routehint ,
1912- tal_count (d -> current_routehint ));
1913- plugin_log (p -> plugin , LOG_DBG , "Using routehint %s (%s) cltv_delta=%d" ,
1914- type_to_string (tmpctx , struct node_id , & d -> current_routehint -> pubkey ),
1915- type_to_string (tmpctx , struct short_channel_id , & d -> current_routehint -> short_channel_id ),
1916- d -> current_routehint -> cltv_expiry_delta
1917- );
1918- }
1927+ routehint_pre_getroute (d , p );
19191928 } else if (p -> step == PAYMENT_STEP_GOT_ROUTE && d -> current_routehint != NULL ) {
19201929 /* Now it's time to stitch the two partial routes together. */
19211930 struct amount_msat dest_amount ;
0 commit comments