lightningd/payalgo.c
static bool json_pay_try(struct pay *pay)
{
	u8 *req;
	struct command *cmd = pay->cmd;
	struct timeabs now = time_now();
	struct json_result *data;
	struct siphash_seed seed;

	/* If too late anyway, fail now. */
	if (time_after(now, pay->expiry)) {
		data = new_json_result(cmd);
		json_object_start(data, NULL);
		json_add_num(data, "now", now.ts.tv_sec);
		json_add_num(data, "expiry", pay->expiry.ts.tv_sec);
		json_add_num(data, "getroute_tries", pay->getroute_tries);
		json_add_num(data, "sendpay_tries", pay->sendpay_tries);
		json_object_end(data);
		command_fail_detailed(cmd, PAY_INVOICE_EXPIRED, data,
				      "Invoice expired");
		return false;
	}

	/* Clear previous try memory. */
	pay->try_parent = tal_free(pay->try_parent);
	pay->try_parent = tal(pay, char);

	/* Generate random seed */
	randombytes_buf(&seed, sizeof(seed));

	++pay->getroute_tries;

	/* FIXME: use b11->routes */
	req = towire_gossip_getroute_request(pay->try_parent,
					     &cmd->ld->id,
					     &pay->receiver_id,
					     pay->msatoshi,
					     pay->riskfactor,
					     pay->min_final_cltv_expiry,
					     &pay->fuzz,
					     &seed);
	subd_req(pay->try_parent, cmd->ld->gossip, req, -1, 0, json_pay_getroute_reply, pay);

	return true;
}
/* Start a payment attempt. Return true if deferred,
 * false if resolved now. */
Start a payment attempt. Return true if deferred,
false if resolved now.
Start a payment attempt . Return true if deferred false if resolved now .
static bool json_pay_try(struct pay *pay)
{
	u8 *req;
	struct command *cmd = pay->cmd;
	struct timeabs now = time_now();
	struct json_result *data;
	struct siphash_seed seed;
	if (time_after(now, pay->expiry)) {
		data = new_json_result(cmd);
		json_object_start(data, NULL);
		json_add_num(data, "now", now.ts.tv_sec);
		json_add_num(data, "expiry", pay->expiry.ts.tv_sec);
		json_add_num(data, "getroute_tries", pay->getroute_tries);
		json_add_num(data, "sendpay_tries", pay->sendpay_tries);
		json_object_end(data);
		command_fail_detailed(cmd, PAY_INVOICE_EXPIRED, data,
				      "Invoice expired");
		return false;
	}
	pay->try_parent = tal_free(pay->try_parent);
	pay->try_parent = tal(pay, char);
	randombytes_buf(&seed, sizeof(seed));
	++pay->getroute_tries;
	req = towire_gossip_getroute_request(pay->try_parent,
					     &cmd->ld->id,
					     &pay->receiver_id,
					     pay->msatoshi,
					     pay->riskfactor,
					     pay->min_final_cltv_expiry,
					     &pay->fuzz,
					     &seed);
	subd_req(pay->try_parent, cmd->ld->gossip, req, -1, 0, json_pay_getroute_reply, pay);
	return true;
}
static bool json_pay_try ( struct pay * pay ) { u8 * req ; struct command * cmd = pay -> cmd ; struct timeabs now = time_now ( ) ; struct json_result * data ; struct siphash_seed seed ; if ( time_after ( now , pay -> expiry ) ) { data = new_json_result ( cmd ) ; json_object_start ( data , NULL ) ; json_add_num ( data , " " , now . ts . tv_sec ) ; json_add_num ( data , " " , pay -> expiry . ts . tv_sec ) ; json_add_num ( data , " " , pay -> getroute_tries ) ; json_add_num ( data , " " , pay -> sendpay_tries ) ; json_object_end ( data ) ; command_fail_detailed ( cmd , PAY_INVOICE_EXPIRED , data , " " ) ; return false ; } pay -> try_parent = tal_free ( pay -> try_parent ) ; pay -> try_parent = tal ( pay , char ) ; randombytes_buf ( & seed , sizeof ( seed ) ) ; ++ pay -> getroute_tries ; req = towire_gossip_getroute_request ( pay -> try_parent , & cmd -> ld -> id , & pay -> receiver_id , pay -> msatoshi , pay -> riskfactor , pay -> min_final_cltv_expiry , & pay -> fuzz , & seed ) ; subd_req ( pay -> try_parent , cmd -> ld -> gossip , req , -1 , 0 , json_pay_getroute_reply , pay ) ; return true ; }
Start a payment attempt.
Start a payment attempt .
/* If too late anyway, fail now. */ /* Clear previous try memory. */ /* Generate random seed */ /* FIXME: use b11->routes */