Commit 23c1dc7
committed
Simplify outgoing payment state machine
We previously supported having multiple channels with our peer, because
we didn't yet support splicing. Now that we support splicing, we always
have at most one active channel with our peer. This lets us simplify
greatly the outgoing payment state machine: payments are always made
with a single outgoing HTLC instead of potentially multiple HTLCs (MPP).
We don't need any kind of path-finding: we simply need to check the
balance of our active channel, if any.
We may introduce support for connecting to multiple peers in the future.
When that happens, we will still have a single active channel per peer,
but we may allow splitting outgoing payments across our peers. We will
need to re-work the outgoing payment state machine when this happens,
but it is too early to support this now anyway.
This refactoring makes it easier to create payment onion, by creating
the trampoline onion *and* the outer onion in the same function call.
This will make it simpler to migrate to the version of trampoline
that is currently specified in lightning/bolts#836
where some fields will be included in the payment onion instead of the
trampoline onion.1 parent 40dd1dd commit 23c1dc7
File tree
12 files changed
+942
-1799
lines changed- src
- commonMain/kotlin/fr/acinq/lightning
- channel
- io
- payment
- wire
- commonTest/kotlin/fr/acinq/lightning
- channel
- io/peer
- payment
12 files changed
+942
-1799
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
| 790 | + | |
796 | 791 | | |
797 | 792 | | |
798 | 793 | | |
| |||
813 | 808 | | |
814 | 809 | | |
815 | 810 | | |
816 | | - | |
817 | 811 | | |
818 | 812 | | |
819 | 813 | | |
| |||
Lines changed: 212 additions & 327 deletions
Large diffs are not rendered by default.
Lines changed: 94 additions & 98 deletions
Large diffs are not rendered by default.
Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 6 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 12 | + | |
16 | 13 | | |
17 | 14 | | |
18 | 15 | | |
| |||
498 | 495 | | |
499 | 496 | | |
500 | 497 | | |
501 | | - | |
| 498 | + | |
502 | 499 | | |
503 | 500 | | |
504 | 501 | | |
| |||
508 | 505 | | |
509 | 506 | | |
510 | 507 | | |
511 | | - | |
| 508 | + | |
512 | 509 | | |
513 | 510 | | |
514 | 511 | | |
| |||
538 | 535 | | |
539 | 536 | | |
540 | 537 | | |
541 | | - | |
| 538 | + | |
542 | 539 | | |
543 | 540 | | |
544 | 541 | | |
545 | 542 | | |
546 | 543 | | |
547 | | - | |
548 | | - | |
| 544 | + | |
| 545 | + | |
549 | 546 | | |
550 | 547 | | |
551 | 548 | | |
| |||
Lines changed: 4 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
404 | 403 | | |
405 | 404 | | |
406 | 405 | | |
407 | | - | |
| 406 | + | |
408 | 407 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
417 | 411 | | |
418 | 412 | | |
419 | 413 | | |
| |||
Lines changed: 26 additions & 75 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
| 487 | + | |
| 488 | + | |
491 | 489 | | |
492 | 490 | | |
493 | | - | |
| 491 | + | |
494 | 492 | | |
495 | 493 | | |
496 | | - | |
497 | | - | |
| 494 | + | |
498 | 495 | | |
499 | 496 | | |
500 | 497 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
511 | 501 | | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
536 | 506 | | |
537 | | - | |
| 507 | + | |
538 | 508 | | |
539 | 509 | | |
540 | 510 | | |
541 | 511 | | |
542 | 512 | | |
543 | 513 | | |
544 | | - | |
| 514 | + | |
545 | 515 | | |
546 | 516 | | |
547 | 517 | | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
556 | 522 | | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
569 | 528 | | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
582 | 533 | | |
583 | 534 | | |
584 | 535 | | |
| |||
0 commit comments