Skip to content

Commit

Permalink
plugins/pay: use final_cltc from bolt11 invoice.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and dflate committed Jan 18, 2019
1 parent c52c060 commit e40c03a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e40c03a

Please sign in to comment.