Browse Source

plugins/pay: use final_cltc from bolt11 invoice.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
plugin-timeout-inc
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
802b772cad
  1. 6
      plugins/pay.c
  2. 3
      tests/test_misc.py

6
plugins/pay.c

@ -22,6 +22,7 @@ struct pay_command {
/* How much we're paying, and what riskfactor for routing. */
u64 msatoshi;
double riskfactor;
unsigned int final_cltv;
/* Limits on what routes we'll accept. */
double maxfeepercent;
@ -199,8 +200,10 @@ static struct command_result *start_pay_attempt(struct command *cmd,
return send_outreq(cmd, "getroute", getroute_done, forward_error, pc,
"'id': '%s',"
"'msatoshi': %"PRIu64","
"'cltv': %u,"
"'riskfactor': %f%s",
pc->dest, pc->msatoshi, pc->riskfactor, exclude);
pc->dest, pc->msatoshi, pc->final_cltv, pc->riskfactor,
exclude);
}
/* gossipd doesn't know much about the current state of channels; here we
@ -316,6 +319,7 @@ static struct command_result *handle_pay(struct command *cmd,
pc->maxdelay = *maxdelay;
pc->exemptfee = *exemptfee;
pc->riskfactor = *riskfactor;
pc->final_cltv = b11->min_final_cltv_expiry;
pc->dest = type_to_string(cmd, struct pubkey, &b11->receiver_id);
pc->payment_hash = type_to_string(pc, struct sha256,
&b11->payment_hash);

3
tests/test_misc.py

@ -234,8 +234,7 @@ def test_htlc_out_timeout(node_factory, bitcoind, executor):
l1.daemon.wait_for_log('dev_disconnect: @WIRE_REVOKE_AND_ACK')
# Takes 6 blocks to timeout (cltv-final + 1), but we also give grace period of 1 block.
# FIXME: pay plugin uses default value of 9...
bitcoind.generate_block(9 + 1)
bitcoind.generate_block(5 + 1)
time.sleep(3)
assert not l1.daemon.is_in_log('hit deadline')
bitcoind.generate_block(1)

Loading…
Cancel
Save