From 05ef69fde1ae50af2d78dc53540f4c9ad60d2d65 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 26 Mar 2024 11:53:54 +1030 Subject: [PATCH] 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 --- lightningd/pay.c | 8 +++++--- wallet/test/run-wallet.c | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lightningd/pay.c b/lightningd/pay.c index 5c8dbeaa2356..f04c28f2a368 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -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. */ diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 5f28ba8978de..c3a3c65a1de4 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -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(); }