@ -15,13 +15,6 @@
static struct gossmap * gossmap ;
static struct gossmap * gossmap ;
/* BOLT #11:
* * ` c ` ( 24 ) : ` data_length ` variable .
* ` min_final_cltv_expiry ` to use for the last HTLC in the route .
* Default is 18 if not specified .
*/
# define DEFAULT_FINAL_CLTV_DELTA 18
struct payment * payment_new ( tal_t * ctx , struct command * cmd ,
struct payment * payment_new ( tal_t * ctx , struct command * cmd ,
struct payment * parent ,
struct payment * parent ,
struct payment_modifier * * mods )
struct payment_modifier * * mods )
@ -74,7 +67,9 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd,
p - > constraints = * parent - > start_constraints ;
p - > constraints = * parent - > start_constraints ;
p - > deadline = parent - > deadline ;
p - > deadline = parent - > deadline ;
p - > invoice = parent - > invoice ;
p - > min_final_cltv_expiry = parent - > min_final_cltv_expiry ;
p - > routes = parent - > routes ;
p - > features = parent - > features ;
p - > id = parent - > id ;
p - > id = parent - > id ;
p - > local_id = parent - > local_id ;
p - > local_id = parent - > local_id ;
} else {
} else {
@ -264,10 +259,7 @@ void payment_start_at_blockheight(struct payment *p, u32 blockheight)
* before we actually call ` getroute ` */
* before we actually call ` getroute ` */
p - > getroute - > destination = p - > destination ;
p - > getroute - > destination = p - > destination ;
p - > getroute - > max_hops = ROUTING_MAX_HOPS ;
p - > getroute - > max_hops = ROUTING_MAX_HOPS ;
if ( root - > invoice ! = NULL & & root - > invoice - > min_final_cltv_expiry ! = 0 )
p - > getroute - > cltv = root - > min_final_cltv_expiry ;
p - > getroute - > cltv = root - > invoice - > min_final_cltv_expiry ;
else
p - > getroute - > cltv = DEFAULT_FINAL_CLTV_DELTA ;
p - > getroute - > amount = p - > amount ;
p - > getroute - > amount = p - > amount ;
p - > start_constraints = tal_dup ( p , struct payment_constraints , & p - > constraints ) ;
p - > start_constraints = tal_dup ( p , struct payment_constraints , & p - > constraints ) ;
@ -2419,13 +2411,13 @@ static struct command_result *routehint_getroute_result(struct command *cmd,
if ( d - > destination_reachable ) {
if ( d - > destination_reachable ) {
tal_arr_expand ( & d - > routehints , NULL ) ;
tal_arr_expand ( & d - > routehints , NULL ) ;
/* The above could trigger a realloc.
/* The above could trigger a realloc.
* However , p - > invoice - > routes and d - > routehints are
* However , p - > routes and d - > routehints are
* actually the same array , so we need to update the
* actually the same array , so we need to update the
* p - > invoice - > routes pointer , since the realloc
* p - > routes pointer , since the realloc
* might have changed pointer addresses , in order to
* might have changed pointer addresses , in order to
* ensure that the pointers are not stale .
* ensure that the pointers are not stale .
*/
*/
p - > invoice - > routes = d - > routehints ;
p - > routes = d - > routehints ;
/* FIXME: ***DO*** we need to add this extra routehint?
/* FIXME: ***DO*** we need to add this extra routehint?
* Once we run out of routehints the default system will
* Once we run out of routehints the default system will
@ -2474,7 +2466,7 @@ static void routehint_step_cb(struct routehints_data *d, struct payment *p)
const struct payment * root = payment_root ( p ) ;
const struct payment * root = payment_root ( p ) ;
if ( p - > step = = PAYMENT_STEP_INITIALIZED ) {
if ( p - > step = = PAYMENT_STEP_INITIALIZED ) {
if ( root - > invoice = = NULL | | root - > invoice - > routes = = NULL )
if ( root - > routes = = NULL )
return payment_continue ( p ) ;
return payment_continue ( p ) ;
/* We filter out non-functional routehints once at the
/* We filter out non-functional routehints once at the
@ -2482,18 +2474,18 @@ static void routehint_step_cb(struct routehints_data *d, struct payment *p)
* exluded ones on the fly . */
* exluded ones on the fly . */
if ( p - > parent = = NULL ) {
if ( p - > parent = = NULL ) {
d - > routehints = filter_routehints ( d , p - > local_id ,
d - > routehints = filter_routehints ( d , p - > local_id ,
p - > invoice - > routes ) ;
p - > routes ) ;
/* filter_routehints modifies the array, but
/* filter_routehints modifies the array, but
* this could trigger a resize and the resize
* this could trigger a resize and the resize
* could trigger a realloc .
* could trigger a realloc .
* Keep the invoice pointer up - to - date .
* Keep the invoice pointer up - to - date .
* FIXME : We should really consider that if we are
* FIXME : We should really consider that if we are
* mutating p - > invoices - > routes , maybe we should
* mutating p - > routes , maybe we should
* drop d - > routehints and just use p - > invoice - > routes
* drop d - > routehints and just use p - > routes
* directly .
* directly .
* It is probably not a good idea to * copy * the
* It is probably not a good idea to * copy * the
* routehints : other paymods are interested in
* routehints : other paymods are interested in
* p - > invoice - > routes , and if the routehints system
* p - > routes , and if the routehints system
* itself adds or removes routehints from its
* itself adds or removes routehints from its
* copy , the * actual * number of routehints that we
* copy , the * actual * number of routehints that we
* end up using is the one that the routehints paymod
* end up using is the one that the routehints paymod
@ -2501,9 +2493,9 @@ static void routehint_step_cb(struct routehints_data *d, struct payment *p)
* set of routehints that is the important one .
* set of routehints that is the important one .
* So rather than copying the array of routehints
* So rather than copying the array of routehints
* in paymod , paymod should use ( and mutate ) the
* in paymod , paymod should use ( and mutate ) the
* p - > invoice - > routes array , and
* p - > routes array , and
*/
*/
p - > invoice - > routes = d - > routehints ;
p - > routes = d - > routehints ;
paymod_log ( p , LOG_DBG ,
paymod_log ( p , LOG_DBG ,
" After filtering routehints we're left with "
" After filtering routehints we're left with "
@ -3167,10 +3159,7 @@ static void payment_lower_max_htlcs(struct payment *p, u32 limit,
static bool payment_supports_mpp ( struct payment * p )
static bool payment_supports_mpp ( struct payment * p )
{
{
if ( p - > invoice = = NULL | | p - > invoice - > features = = NULL )
return feature_offered ( p - > features , OPT_BASIC_MPP ) ;
return false ;
return feature_offered ( p - > invoice - > features , OPT_BASIC_MPP ) ;
}
}
/* Return fuzzed amount ~= target, but never exceeding max */
/* Return fuzzed amount ~= target, but never exceeding max */
@ -3524,8 +3513,8 @@ payee_incoming_limit_count(struct command *cmd,
num_channels = channelstok - > size ;
num_channels = channelstok - > size ;
/* If num_channels is 0, check if there is an invoice. */
/* If num_channels is 0, check if there is an invoice. */
if ( num_channels = = 0 & & p - > invoice )
if ( num_channels = = 0 )
num_channels = tal_count ( p - > invoice - > routes ) ;
num_channels = tal_count ( p - > routes ) ;
/* If we got a decent number of channels, limit! */
/* If we got a decent number of channels, limit! */
if ( num_channels ! = 0 ) {
if ( num_channels ! = 0 ) {