@@ -377,7 +377,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
377
377
// Test case 1: Send a direct keysend payment from Charlie to Dave.
378
378
// ------------
379
379
const keySendAmount = 100
380
- sendKeySendPayment (t .t , charlie , dave , keySendAmount , assetID )
380
+ sendAssetKeySendPayment (t .t , charlie , dave , keySendAmount , assetID )
381
381
logBalance (t .t , nodes , assetID , "after keysend" )
382
382
383
383
charlieAssetBalance -= keySendAmount
@@ -386,12 +386,16 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
386
386
// We should be able to send the 100 assets back immediately, because
387
387
// there is enough on-chain balance on Dave's side to be able to create
388
388
// an HTLC.
389
- sendKeySendPayment (t .t , dave , charlie , keySendAmount , assetID )
389
+ sendAssetKeySendPayment (t .t , dave , charlie , keySendAmount , assetID )
390
390
logBalance (t .t , nodes , assetID , "after keysend back" )
391
391
392
392
charlieAssetBalance += keySendAmount
393
393
daveAssetBalance -= keySendAmount
394
394
395
+ // We should also be able to do a non-asset (BTC only) keysend payment.
396
+ sendKeySendPayment (t .t , charlie , dave , 2000 , nil )
397
+ logBalance (t .t , nodes , assetID , "after BTC only keysend" )
398
+
395
399
// ------------
396
400
// Test case 2: Pay a normal invoice from Dave by Charlie, making it
397
401
// a direct channel invoice payment with no RFQ SCID present in the
@@ -405,6 +409,11 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
405
409
charlieAssetBalance -= paidAssetAmount
406
410
daveAssetBalance += paidAssetAmount
407
411
412
+ // We should also be able to do a multi-hop BTC only payment, paying an
413
+ // invoice from Erin by Charlie.
414
+ createAndPayNormalInvoiceWithBtc (t .t , charlie , erin , 2000 )
415
+ logBalance (t .t , nodes , assetID , "after BTC only invoice" )
416
+
408
417
// ------------
409
418
// Test case 3: Pay an asset invoice from Dave by Charlie, making it
410
419
// a direct channel invoice payment with an RFQ SCID present in the
@@ -861,7 +870,7 @@ func getAssetChannelBalance(t *testing.T, node *HarnessNode, assetID []byte,
861
870
return localSum , remoteSum
862
871
}
863
872
864
- func sendKeySendPayment (t * testing.T , src , dst * HarnessNode , amt uint64 ,
873
+ func sendAssetKeySendPayment (t * testing.T , src , dst * HarnessNode , amt uint64 ,
865
874
assetID []byte ) {
866
875
867
876
ctxb := context .Background ()
@@ -886,9 +895,22 @@ func sendKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
886
895
)
887
896
require .NoError (t , err )
888
897
898
+ const htlcCarrierAmt = 500
899
+ sendKeySendPayment (
900
+ t , src , dst , htlcCarrierAmt , encodeResp .CustomRecords ,
901
+ )
902
+ }
903
+
904
+ func sendKeySendPayment (t * testing.T , src , dst * HarnessNode , amt btcutil.Amount ,
905
+ firstHopCustomRecords map [uint64 ][]byte ) {
906
+
907
+ ctxb := context .Background ()
908
+ ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
909
+ defer cancel ()
910
+
889
911
// Read out the custom preimage for the keysend payment.
890
912
var preimage lntypes.Preimage
891
- _ , err = rand .Read (preimage [:])
913
+ _ , err : = rand .Read (preimage [:])
892
914
require .NoError (t , err )
893
915
894
916
hash := preimage .Hash ()
@@ -898,12 +920,11 @@ func sendKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
898
920
customRecords := make (map [uint64 ][]byte )
899
921
customRecords [record .KeySendType ] = preimage [:]
900
922
901
- const htlcCarrierAmt = 500
902
923
req := & routerrpc.SendPaymentRequest {
903
924
Dest : dst .PubKey [:],
904
- Amt : htlcCarrierAmt ,
925
+ Amt : int64 ( amt ) ,
905
926
DestCustomRecords : customRecords ,
906
- FirstHopCustomRecords : encodeResp . CustomRecords ,
927
+ FirstHopCustomRecords : firstHopCustomRecords ,
907
928
PaymentHash : hash [:],
908
929
TimeoutSeconds : 3 ,
909
930
}
@@ -918,6 +939,24 @@ func sendKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
918
939
require .Equal (t , lnrpc .Payment_SUCCEEDED , result .Status )
919
940
}
920
941
942
+ func createAndPayNormalInvoiceWithBtc (t * testing.T , src , dst * HarnessNode ,
943
+ amountSat btcutil.Amount ) {
944
+
945
+ ctxb := context .Background ()
946
+ ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
947
+ defer cancel ()
948
+
949
+ expirySeconds := 10
950
+ invoiceResp , err := dst .AddInvoice (ctxt , & lnrpc.Invoice {
951
+ Value : int64 (amountSat ),
952
+ Memo : "normal invoice" ,
953
+ Expiry : int64 (expirySeconds ),
954
+ })
955
+ require .NoError (t , err )
956
+
957
+ payInvoiceWithSatoshi (t , src , invoiceResp )
958
+ }
959
+
921
960
func createAndPayNormalInvoice (t * testing.T , src , rfqPeer , dst * HarnessNode ,
922
961
amountSat btcutil.Amount , assetID []byte ) uint64 {
923
962
0 commit comments