lnworker: differentiate PaymentInfo by direction

Allows storing two different payment info of the same payment hash by
including the direction into the db key.
We create and store PaymentInfo for sending attempts and for requests (receiving),
if we try to pay ourself (e.g. through a channel rebalance) the checks
in `save_payment_info` would prevent this and throw an exception.
By storing the PaymentInfos of outgoing and incoming payments separately in
the db this collision is avoided and it makes it easier to reason about
which PaymentInfo belongs where.
This commit is contained in:
f321x
2025-11-28 16:22:22 +01:00
parent 828fc569c9
commit 923d48f9db
12 changed files with 125 additions and 88 deletions
+1
View File
@@ -1089,6 +1089,7 @@ class HTLCOwner(IntEnum):
return HTLCOwner(super().__neg__())
# part of lightning_payments db keys
class Direction(IntEnum):
SENT = -1 # in the context of HTLCs: "offered" HTLCs
RECEIVED = 1 # in the context of HTLCs: "received" HTLCs