router: refactor payment lifecycle (payments, routing)

https://github.com/lightningnetwork/lnd/pull/7391

Host: GeorgeTsagk  -  PR author: yyforyongyu

Notes

  • 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: https://docs.lightning.engineering/the-lightning-network/pathfinding/multipath-payments-mpp
  • AMP: https://docs.lightning.engineering/lightning-network-tools/lnd/amp

Questions

  • 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?