lightningd: use get_network_blockheight() not get_block_height() for pay.

This is useful once we allow pay before full sync.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-03-26 11:53:54 +10:30 committed by Vincenzo Palazzo
parent bd12b0065d
commit 05ef69fde1
2 changed files with 8 additions and 3 deletions

View file

@ -732,7 +732,8 @@ static const u8 *send_onion(const tal_t *ctx, struct lightningd *ld,
const u8 *onion;
unsigned int base_expiry;
base_expiry = get_block_height(ld->topology) + 1;
/* Use bitcoind's block height, even if we're behind in processing */
base_expiry = get_network_blockheight(ld->topology) + 1;
onion = serialize_onionpacket(tmpctx, packet);
return send_htlc_out(ctx, channel, first_hop->amount,
base_expiry + first_hop->delay,
@ -1162,8 +1163,9 @@ send_payment(struct lightningd *ld,
bool ret;
u8 *onion;
/* Expiry for HTLCs is absolute. And add one to give some margin. */
base_expiry = get_block_height(ld->topology) + 1;
/* Expiry for HTLCs is absolute. And add one to give some margin,
and use bitcoind's block height, even if we're behind in processing */
base_expiry = get_network_blockheight(ld->topology) + 1;
path = sphinx_path_new(tmpctx, rhash->u.u8);
/* Extract IDs for each hop: create_onionpacket wants array. */

View file

@ -336,6 +336,9 @@ bool fromwire_openingd_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNE
/* Generated stub for get_block_height */
u32 get_block_height(const struct chain_topology *topo UNNEEDED)
{ fprintf(stderr, "get_block_height called!\n"); abort(); }
/* Generated stub for get_network_blockheight */
u32 get_network_blockheight(const struct chain_topology *topo UNNEEDED)
{ fprintf(stderr, "get_network_blockheight called!\n"); abort(); }
/* Generated stub for hsmd_wire_name */
const char *hsmd_wire_name(int e UNNEEDED)
{ fprintf(stderr, "hsmd_wire_name called!\n"); abort(); }