@@ -419,8 +419,11 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
419
419
logBalance (t .t , nodes , assetID , "initial" )
420
420
421
421
// ------------
422
- // Test case 1: Send a direct keysend payment from Charlie to Dave,
423
- // sending the whole balance.
422
+ // Test case 1: Send a direct asset keysend payment from Charlie to Dave,
423
+ // sending the whole asset balance.
424
+ //
425
+ // Charlie --[assets]--> Dave
426
+ //
424
427
// ------------
425
428
keySendAmount := charlieFundingAmount
426
429
sendAssetKeySendPayment (
@@ -466,7 +469,7 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
466
469
sendKeySendPayment (t .t , charlie , dave , 2000 )
467
470
logBalance (t .t , nodes , assetID , "after BTC only keysend" )
468
471
469
- // Let's keysend the rest of the balance back to Charlie.
472
+ // Let's keysend the rest of the asset balance back to Charlie.
470
473
sendAssetKeySendPayment (
471
474
t .t , dave , charlie , charlieFundingAmount - charlieInvoiceAmount ,
472
475
assetID , fn .None [int64 ](),
@@ -477,9 +480,18 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
477
480
daveAssetBalance -= charlieFundingAmount - charlieInvoiceAmount
478
481
479
482
// ------------
480
- // Test case 2: Pay a normal invoice from Dave by Charlie, making it
481
- // a direct channel invoice payment with no RFQ SCID present in the
482
- // invoice.
483
+ // Test case 2: Pay a normal sats invoice from Dave by
484
+ // Charlie using an asset,
485
+ // making it a direct channel invoice payment with no RFQ SCID present in
486
+ // the invoice (but an RFQ is used when trying to send the payment). In this
487
+ // case, Charlie gets to choose if he wants to pay Dave using assets or
488
+ // sats. In contrast, test case 3.5 we have the opposite scenario where
489
+ // an asset invoice is used and Charlie must pay with assets and not have
490
+ // a choice (and that case is supposed to fail because Charlie tries to
491
+ // pay with sats instead).
492
+ //
493
+ // Charlie --[assets]--> Dave
494
+ //
483
495
// ------------
484
496
createAndPayNormalInvoice (
485
497
t .t , charlie , dave , dave , 20_000 , assetID , withSmallShards (),
@@ -489,13 +501,17 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
489
501
490
502
// We should also be able to do a multi-hop BTC only payment, paying an
491
503
// invoice from Erin by Charlie.
504
+ // Charlie --[assets]--> Dave --[sats]--> Erin
492
505
createAndPayNormalInvoiceWithBtc (t .t , charlie , erin , 2000 )
493
506
logBalance (t .t , nodes , assetID , "after BTC only invoice" )
494
507
495
508
// ------------
496
509
// Test case 3: Pay an asset invoice from Dave by Charlie, making it
497
510
// a direct channel invoice payment with an RFQ SCID present in the
498
511
// invoice.
512
+ //
513
+ // Charlie --[assets]--> Dave
514
+ //
499
515
// ------------
500
516
const daveInvoiceAssetAmount = 2_000
501
517
invoiceResp = createAssetInvoice (
@@ -511,10 +527,20 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
511
527
daveAssetBalance += daveInvoiceAssetAmount
512
528
513
529
// ------------
514
- // Test case 3.5: Pay an asset invoice from Dave by Charlie with normal
530
+ // Test case 3.5: Pay an asset invoice with an RFQ SCID present from Dave
531
+ // by Charlie with normal
515
532
// satoshi payment flow. We expect that payment to fail, since it's a
516
533
// direct channel payment and the invoice is for assets, not sats. So
517
534
// without a conversion, it is rejected by the receiver.
535
+ // Normally, sats is the standard and we can always pay a taproot assets
536
+ // invoice with sats, but this special case where it is a direct channel
537
+ // payment, the fact that Dave requested specifically to receive a
538
+ // taproot asset from Charlie, that must be honored because Charlie did
539
+ // an RFQ with Dave when that invoice was created agreeing that when it
540
+ // was paid that Dave would receive taproot asset instead of sats.
541
+ //
542
+ // Charlie --[assets]--> Dave
543
+ //
518
544
// ------------
519
545
invoiceResp = createAssetInvoice (
520
546
t .t , charlie , dave , daveInvoiceAssetAmount , assetID ,
@@ -530,7 +556,11 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
530
556
// as the invoice payment failed.
531
557
532
558
// ------------
533
- // Test case 4: Pay a normal invoice from Erin by Charlie.
559
+ // Test case 4: Pay a normal sats invoice from Erin by Charlie
560
+ // using an asset.
561
+ //
562
+ // Charlie --[assets]--> Dave --[sats]--> Erin
563
+ //
534
564
// ------------
535
565
paidAssetAmount := createAndPayNormalInvoice (
536
566
t .t , charlie , dave , erin , 20_000 , assetID , withSmallShards (),
@@ -542,7 +572,10 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
542
572
543
573
// ------------
544
574
// Test case 5: Create an asset invoice on Fabia and pay it from
545
- // Charlie.
575
+ // Charlie using an asset.
576
+ //
577
+ // Charlie --[assets]--> Dave --[sats]--> Erin --[assets]--> Fabia
578
+ //
546
579
// ------------
547
580
const fabiaInvoiceAssetAmount1 = 1000
548
581
invoiceResp = createAssetInvoice (
@@ -563,7 +596,13 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
563
596
// Test case 6: Create an asset invoice on Fabia and pay it with just
564
597
// BTC from Dave, making sure it ends up being a multipart payment (we
565
598
// set the maximum shard size to 80k sat and 15k asset units will be
566
- // more than a single shard).
599
+ // more than a single shard). The purpose here is to force testing of multi
600
+ // part payments so that we can do so with a simple network instead of
601
+ // building a more complicated one that actually needs multi part paymemts
602
+ // in order to get the payment to successfully route.
603
+ //
604
+ // Dave --[sats]--> Erin --[assets]--> Fabia
605
+ //
567
606
// ------------
568
607
const fabiaInvoiceAssetAmount2 = 15_000
569
608
invoiceResp = createAssetInvoice (
@@ -579,7 +618,11 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
579
618
// Test case 7: Create an asset invoice on Fabia and pay it with assets
580
619
// from Charlie, making sure it ends up being a multipart payment as
581
620
// well, with the high amount of asset units to send and the hard coded
582
- // 80k sat max shard size.
621
+ // 80k sat max shard size. Again, as in test case 6 above, we are doing
622
+ // this here to test multi part payments in a simpler way.
623
+ //
624
+ // Charlie --[assets]--> Dave --[sats]--> Erin --[assets]--> Fabia
625
+ //
583
626
// ------------
584
627
const fabiaInvoiceAssetAmount3 = 10_000
585
628
invoiceResp = createAssetInvoice (
@@ -599,6 +642,15 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
599
642
// ------------
600
643
// Test case 8: An invoice payment over two channels that are both asset
601
644
// channels.
645
+ //
646
+ // Charlie --[assets]--> Dave
647
+ // |
648
+ // |
649
+ // [assets]
650
+ // |
651
+ // v
652
+ // Yara
653
+ //
602
654
// ------------
603
655
logBalance (t .t , nodes , assetID , "before asset-to-asset" )
604
656
@@ -616,8 +668,11 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
616
668
yaraAssetBalance += yaraInvoiceAssetAmount1
617
669
618
670
// ------------
619
- // Test case 8 : Now we'll close each of the channels, starting with the
671
+ // Test case 9 : Now we'll close each of the channels, starting with the
620
672
// Charlie -> Dave custom channel.
673
+ //
674
+ // Charlie --[assets]--> Dave
675
+ //
621
676
// ------------
622
677
t .Logf ("Closing Charlie -> Dave channel" )
623
678
closeAssetChannelAndAssert (
@@ -1044,7 +1099,7 @@ func testCustomChannelsGroupedAsset(ctx context.Context, net *NetworkHarness,
1044
1099
yaraAssetBalance += yaraInvoiceAssetAmount1
1045
1100
1046
1101
// ------------
1047
- // Test case 8 : Now we'll close each of the channels, starting with the
1102
+ // Test case 9 : Now we'll close each of the channels, starting with the
1048
1103
// Charlie -> Dave custom channel.
1049
1104
// ------------
1050
1105
t .Logf ("Closing Charlie -> Dave channel" )
@@ -2899,8 +2954,8 @@ func testCustomChannelsOraclePricing(ctx context.Context, net *NetworkHarness,
2899
2954
const charlieInvoiceAmount = 104_081_638
2900
2955
require .EqualValues (t .t , charlieInvoiceAmount , numUnits )
2901
2956
2902
- // The default routing fees are 1ppm + 1msat per hop, and we have 2
2903
- // hops in total.
2957
+ // The default routing fees are 1ppm + 1msat per hop, and we have 3
2958
+ // hops in total, but only 1 hop where routing fees are collected in sats .
2904
2959
charliePaidMSat := addRoutingFee (addRoutingFee (lnwire .MilliSatoshi (
2905
2960
decodedInvoice .NumMsat ,
2906
2961
)))
0 commit comments