pay: Remove the waitheight paymod
It is getting replaced with a paymod that adjusts the chain height used to offset all calculations from.
This commit is contained in:
committed by
Rusty Russell
parent
c95b70d52a
commit
a7f4c28f5e
@@ -179,7 +179,6 @@ struct payment_modifier *pay_mods[] = {
|
||||
&shadowroute_pay_mod,
|
||||
&routehints_pay_mod,
|
||||
&exemptfee_pay_mod,
|
||||
&waitblockheight_pay_mod,
|
||||
&retry_pay_mod,
|
||||
NULL,
|
||||
};
|
||||
|
||||
@@ -3419,100 +3419,6 @@ static struct direct_pay_data *direct_pay_init(struct payment *p)
|
||||
REGISTER_PAYMENT_MODIFIER(directpay, struct direct_pay_data *, direct_pay_init,
|
||||
direct_pay_cb);
|
||||
|
||||
static struct command_result *waitblockheight_rpc_cb(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *toks,
|
||||
struct payment *p)
|
||||
{
|
||||
const jsmntok_t *blockheighttok, *codetok;
|
||||
|
||||
u32 blockheight;
|
||||
int code;
|
||||
struct payment *subpayment;
|
||||
|
||||
blockheighttok = json_get_member(buffer, toks, "blockheight");
|
||||
|
||||
if (!blockheighttok ||
|
||||
!json_to_number(buffer, blockheighttok, &blockheight)) {
|
||||
codetok = json_get_member(buffer, toks, "code");
|
||||
json_to_int(buffer, codetok, &code);
|
||||
if (code == WAIT_TIMEOUT) {
|
||||
payment_fail(
|
||||
p,
|
||||
"Timed out while attempting to sync to blockheight "
|
||||
"returned by destination. Please finish syncing "
|
||||
"with the blockchain and try again.");
|
||||
|
||||
} else {
|
||||
plugin_err(
|
||||
p->plugin,
|
||||
"Unexpected result from waitblockheight: %.*s",
|
||||
json_tok_full_len(toks),
|
||||
json_tok_full(buffer, toks));
|
||||
}
|
||||
} else {
|
||||
subpayment = payment_new(p, NULL, p, p->modifiers);
|
||||
payment_start_at_blockheight(subpayment, blockheight);
|
||||
payment_set_step(p, PAYMENT_STEP_RETRY);
|
||||
subpayment->why = tal_fmt(
|
||||
subpayment, "Retrying after waiting for blockchain sync.");
|
||||
paymod_log(
|
||||
p, LOG_DBG,
|
||||
"Retrying after waitblockheight, new partid %" PRIu32,
|
||||
subpayment->partid);
|
||||
payment_continue(p);
|
||||
}
|
||||
return command_still_pending(cmd);
|
||||
}
|
||||
|
||||
static void waitblockheight_cb(void *d, struct payment *p)
|
||||
{
|
||||
struct out_req *req;
|
||||
struct timeabs now = time_now();
|
||||
struct timerel remaining;
|
||||
u32 blockheight;
|
||||
if (p->step != PAYMENT_STEP_FAILED)
|
||||
return payment_continue(p);
|
||||
|
||||
/* If we don't have an error message to parse we can't wait for blockheight. */
|
||||
if (p->result == NULL)
|
||||
return payment_continue(p);
|
||||
|
||||
/* Check if we'd be waiting more than 0 seconds. If we have
|
||||
* less than a second then waitblockheight would return
|
||||
* immediately resulting in a loop. */
|
||||
if (time_after(now, p->deadline))
|
||||
return payment_continue(p);
|
||||
|
||||
remaining = time_between(p->deadline, now);
|
||||
if (time_to_sec(remaining) < 1)
|
||||
return payment_continue(p);
|
||||
|
||||
/* *Was* it a blockheight disagreement that caused the failure? */
|
||||
if (!failure_is_blockheight_disagreement(p, &blockheight))
|
||||
return payment_continue(p);
|
||||
|
||||
paymod_log(p, LOG_INFORM,
|
||||
"Remote node appears to be on a longer chain, which causes "
|
||||
"CLTV timeouts to be incorrect. Waiting up to %" PRIu64
|
||||
" seconds to catch up to block %d before retrying.",
|
||||
time_to_sec(remaining), blockheight);
|
||||
|
||||
/* Set temporarily set the state of the payment to not failed, so
|
||||
* interim status queries don't show this as terminally failed. We're
|
||||
* in control for this payment so nobody else could be fooled by
|
||||
* this. The callback will set it to retry anyway. */
|
||||
payment_set_step(p, PAYMENT_STEP_RETRY);
|
||||
|
||||
req = jsonrpc_request_start(p->plugin, NULL, "waitblockheight",
|
||||
waitblockheight_rpc_cb,
|
||||
waitblockheight_rpc_cb, p);
|
||||
json_add_u32(req->js, "blockheight", blockheight);
|
||||
json_add_u32(req->js, "timeout", time_to_sec(remaining));
|
||||
send_outreq(p->plugin, req);
|
||||
}
|
||||
|
||||
REGISTER_PAYMENT_MODIFIER(waitblockheight, void *, NULL, waitblockheight_cb);
|
||||
|
||||
static u32 payment_max_htlcs(const struct payment *p)
|
||||
{
|
||||
|
||||
@@ -441,7 +441,6 @@ REGISTER_PAYMENT_MODIFIER_HEADER(routehints, struct routehints_data);
|
||||
REGISTER_PAYMENT_MODIFIER_HEADER(exemptfee, struct exemptfee_data);
|
||||
REGISTER_PAYMENT_MODIFIER_HEADER(shadowroute, struct shadow_route_data);
|
||||
REGISTER_PAYMENT_MODIFIER_HEADER(directpay, struct direct_pay_data);
|
||||
extern struct payment_modifier waitblockheight_pay_mod;
|
||||
REGISTER_PAYMENT_MODIFIER_HEADER(presplit, struct presplit_mod_data);
|
||||
REGISTER_PAYMENT_MODIFIER_HEADER(adaptive_splitter, struct adaptive_split_mod_data);
|
||||
|
||||
|
||||
@@ -998,7 +998,6 @@ struct payment_modifier *paymod_mods[] = {
|
||||
*/
|
||||
&routehints_pay_mod,
|
||||
&payee_incoming_limit_pay_mod,
|
||||
&waitblockheight_pay_mod,
|
||||
&retry_pay_mod,
|
||||
&adaptive_splitter_pay_mod,
|
||||
NULL,
|
||||
|
||||
Reference in New Issue
Block a user