pay: Add the chainlag to the payment

The `chainlag` is defined as the positive difference between the
height of the last block processed by the node and the best height
known by the bitcoin backend. The chainlag is positive when we are
still catching up with the blockchain, and `0` otherwise.

The `chainlag` is used as an additional offset to the CLTV values when
sending payments, allowing payments to be sent even before the chain
sync completes.
This commit is contained in:
Christian Decker
2024-04-16 11:54:51 +02:00
committed by Rusty Russell
parent a7f4c28f5e
commit 4d27efc039
2 changed files with 7 additions and 0 deletions

View File

@@ -326,6 +326,11 @@ struct payment {
* explanation if a payment is aborted. */
char *aborterror;
/* How many blocks are we lagging behind the rest of the
network? This needs to be taken into consideration when
sending payments before being fully caught up.*/
u32 chainlag;
/* Callback to be called when the entire payment process
* completes successfully. */
void (*on_payment_success)(struct payment *p);