Skip to content

Commit

Permalink
lightningd: use get_network_blockheight() not get_block_height() for …
Browse files Browse the repository at this point in the history
…pay.

This is useful once we allow pay before full sync.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell authored and vincenzopalazzo committed Apr 1, 2024
1 parent bd12b00 commit 05ef69f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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. */
Expand Down
3 changes: 3 additions & 0 deletions wallet/test/run-wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down

0 comments on commit 05ef69f

Please sign in to comment.