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:
committed by
Rusty Russell
parent
a7f4c28f5e
commit
4d27efc039
@@ -118,6 +118,7 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd,
|
||||
p->invstring = parent->invstring;
|
||||
p->description = parent->description;
|
||||
p->mods = parent->mods;
|
||||
p->chainlag = parent->chainlag;
|
||||
} else {
|
||||
assert(cmd != NULL);
|
||||
p->partid = 0;
|
||||
@@ -132,6 +133,7 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd,
|
||||
p->local_invreq_id = NULL;
|
||||
p->groupid = 0;
|
||||
p->mods = NULL;
|
||||
p->chainlag = 0;
|
||||
}
|
||||
|
||||
/* Initialize all modifier data so we can point to the fields when
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user