router: refactor payment lifecycle (payments, routing)

Host: GeorgeTsagk  -  PR author: yyforyongyu


  • Reviewing PR #7175 is not mandatory, but will provide more context.
  • Requires a high-level understanding of how a payment makes use of HTLCs.
  • MPP:
  • AMP:


  • Did you review the PR? If yes, what’s your overall verdict? (ACK, NACK, concept ACK, unknown)
  • When is a payment marked as completed: - from the sender’s PoV? - from the receiver’s PoV?
  • Is the interface of MPPayment user-friendly & sufficient? What is its responsibility?
  • What’s the significance of NeedWaitAttempts? Why do we need to very carefully control the HTLCs that relate to a payment?
  • When all payment shards (that cover the full amount) are released what is LND waiting for?
  • If the receiver reveals the preimage prematurely (before they receive all the HTLCs) what should LND do? Does AMP eliminate this issue?
  • What’s the importance of refactoring the payment lifecycle? Can a node lose funds if they erroneously track a payment’s lifecycle?