@@ -584,6 +584,7 @@ def invoice_unpaid(dst, label):
584
584
with pytest .raises (RpcError ):
585
585
rs = copy .deepcopy (routestep )
586
586
rs ['amount_msat' ] = rs ['amount_msat' ] - 1
587
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
587
588
l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
588
589
l1 .rpc .waitsendpay (rhash )
589
590
assert invoice_unpaid (l2 , 'testpayment2' )
@@ -592,6 +593,7 @@ def invoice_unpaid(dst, label):
592
593
with pytest .raises (RpcError ):
593
594
rs = copy .deepcopy (routestep )
594
595
rs ['amount_msat' ] = rs ['amount_msat' ] * 2 + 1
596
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
595
597
l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
596
598
l1 .rpc .waitsendpay (rhash )
597
599
assert invoice_unpaid (l2 , 'testpayment2' )
@@ -600,6 +602,7 @@ def invoice_unpaid(dst, label):
600
602
with pytest .raises (RpcError ):
601
603
rs = copy .deepcopy (routestep )
602
604
rs ['delay' ] = rs ['delay' ] - 2
605
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
603
606
l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
604
607
l1 .rpc .waitsendpay (rhash )
605
608
assert invoice_unpaid (l2 , 'testpayment2' )
@@ -609,17 +612,20 @@ def invoice_unpaid(dst, label):
609
612
with pytest .raises (RpcError ):
610
613
rs = copy .deepcopy (routestep )
611
614
rs ['id' ] = '00000000000000000000000000000000'
615
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
612
616
l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
613
617
assert invoice_unpaid (l2 , 'testpayment2' )
614
618
l1 .rpc .check_request_schemas = True
615
619
616
620
# Bad payment_secret
621
+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
617
622
l1 .rpc .sendpay ([routestep ], rhash , payment_secret = "00" * 32 )
618
623
with pytest .raises (RpcError ):
619
624
l1 .rpc .waitsendpay (rhash )
620
625
assert invoice_unpaid (l2 , 'testpayment2' )
621
626
622
627
# Missing payment_secret
628
+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
623
629
l1 .rpc .sendpay ([routestep ], rhash )
624
630
with pytest .raises (RpcError ):
625
631
l1 .rpc .waitsendpay (rhash )
@@ -635,6 +641,7 @@ def invoice_unpaid(dst, label):
635
641
636
642
# This works.
637
643
before = int (time .time ())
644
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
638
645
details = l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
639
646
after = int (time .time ())
640
647
preimage = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
@@ -677,6 +684,7 @@ def check_balances():
677
684
rhash = inv ['payment_hash' ]
678
685
assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'unpaid'
679
686
routestep = {'amount_msat' : amt * 2 , 'id' : l2 .info ['id' ], 'delay' : 5 , 'channel' : first_scid (l1 , l2 )}
687
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
680
688
l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
681
689
preimage3 = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
682
690
assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'paid'
@@ -1112,6 +1120,7 @@ def test_forward(node_factory, bitcoind):
1112
1120
# Unknown other peer
1113
1121
route = copy .deepcopy (baseroute )
1114
1122
route [1 ]['id' ] = '031a8dc444e41bb989653a4501e11175a488a57439b0c4947704fd6e3de5dca607'
1123
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1115
1124
l1 .rpc .sendpay (route , rhash , payment_secret = inv ['payment_secret' ])
1116
1125
with pytest .raises (RpcError ):
1117
1126
l1 .rpc .waitsendpay (rhash )
@@ -1518,6 +1527,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
1518
1527
1519
1528
l2 .rpc .close (c23 , 1 )
1520
1529
1530
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1521
1531
with pytest .raises (RpcError ):
1522
1532
l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
1523
1533
l1 .rpc .waitsendpay (payment_hash )
@@ -1543,6 +1553,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
1543
1553
'delay' : 6 ,
1544
1554
'channel' : c24 }]
1545
1555
1556
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1546
1557
with pytest .raises (RpcError ):
1547
1558
l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
1548
1559
l1 .rpc .waitsendpay (payment_hash )
@@ -1569,6 +1580,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
1569
1580
'delay' : 6 ,
1570
1581
'channel' : c25 }]
1571
1582
1583
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1572
1584
with pytest .raises (RpcError ):
1573
1585
l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
1574
1586
l1 .rpc .waitsendpay (payment_hash )
@@ -1592,6 +1604,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
1592
1604
# Replace id with a different pubkey, so onion encoded badly at l2 hop.
1593
1605
route [1 ]['id' ] = mangled_nodeid
1594
1606
1607
+ l6 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1595
1608
with pytest .raises (RpcError ):
1596
1609
l6 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
1597
1610
l6 .rpc .waitsendpay (payment_hash )
@@ -1619,6 +1632,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
1619
1632
'delay' : 5 ,
1620
1633
'channel' : c24 }]
1621
1634
1635
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1622
1636
executor .submit (l1 .rpc .sendpay , route , payment_hash , payment_secret = inv ['payment_secret' ])
1623
1637
1624
1638
l4 .daemon .wait_for_log ('permfail' )
@@ -1675,6 +1689,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
1675
1689
1676
1690
# L2 tries to pay
1677
1691
r = l2 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1692
+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1678
1693
l2 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
1679
1694
1680
1695
# Now increment CLTV
@@ -1683,6 +1698,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
1683
1698
1684
1699
# L1 tries to pay
1685
1700
r = l1 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1701
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1686
1702
l1 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
1687
1703
1688
1704
# Now increment CLTV
@@ -1691,6 +1707,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
1691
1707
1692
1708
# L3 tries to pay
1693
1709
r = l3 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1710
+ l3 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1694
1711
l3 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
1695
1712
1696
1713
# Give them time to go through.
@@ -1757,6 +1774,7 @@ def exhaust_channel(opener, peer, scid, already_spent=0):
1757
1774
'delay' : 10 ,
1758
1775
'channel' : scid
1759
1776
}
1777
+ opener .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
1760
1778
opener .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
1761
1779
opener .rpc .waitsendpay (inv ['payment_hash' ])
1762
1780
@@ -2484,6 +2502,7 @@ def test_channel_spendable(node_factory, bitcoind):
2484
2502
2485
2503
# Exact amount should succeed.
2486
2504
route = l1 .rpc .getroute (l2 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2505
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
2487
2506
l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
2488
2507
2489
2508
# Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2509,6 +2528,7 @@ def test_channel_spendable(node_factory, bitcoind):
2509
2528
2510
2529
# Exact amount should succeed.
2511
2530
route = l2 .rpc .getroute (l1 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2531
+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
2512
2532
l2 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
2513
2533
2514
2534
# Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2671,6 +2691,7 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
2671
2691
route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
2672
2692
for i in range (0 , 3 ):
2673
2693
inv = l2 .rpc .invoice ((non_dust_htlc_val_sat * 1000 ), str (i + 100 ), str (i + 100 ))
2694
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
2674
2695
l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
2675
2696
l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
2676
2697
res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
@@ -2680,20 +2701,23 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
2680
2701
route = l1 .rpc .getroute (l2 .info ['id' ], htlc_val_msat , 1 )['route' ]
2681
2702
for i in range (0 , num_dusty_htlcs ):
2682
2703
inv = l2 .rpc .invoice (htlc_val_msat , str (i ), str (i ))
2704
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
2683
2705
l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
2684
2706
l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
2685
2707
res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
2686
2708
assert res ['status' ] == 'pending'
2687
2709
2688
2710
# one more should tip it over, and return a payment failure
2689
2711
inv = l2 .rpc .invoice (htlc_val_msat , str (num_dusty_htlcs ), str (num_dusty_htlcs ))
2712
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
2690
2713
l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
2691
2714
l1 .daemon .wait_for_log ('CHANNEL_ERR_DUST_FAILURE' )
2692
2715
wait_for (lambda : only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])['status' ] == 'failed' )
2693
2716
2694
2717
# but we can still add a non dust htlc
2695
2718
route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
2696
2719
inv = l2 .rpc .invoice ((10000 * 1000 ), str (120 ), str (120 ))
2720
+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
2697
2721
l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
2698
2722
l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
2699
2723
res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
0 commit comments