@@ -574,6 +574,7 @@ def invoice_unpaid(dst, label):
574574 with pytest .raises (RpcError ):
575575 rs = copy .deepcopy (routestep )
576576 rs ['amount_msat' ] = rs ['amount_msat' ] - 1
577+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
577578 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
578579 l1 .rpc .waitsendpay (rhash )
579580 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -582,6 +583,7 @@ def invoice_unpaid(dst, label):
582583 with pytest .raises (RpcError ):
583584 rs = copy .deepcopy (routestep )
584585 rs ['amount_msat' ] = rs ['amount_msat' ] * 2 + 1
586+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
585587 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
586588 l1 .rpc .waitsendpay (rhash )
587589 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -590,6 +592,7 @@ def invoice_unpaid(dst, label):
590592 with pytest .raises (RpcError ):
591593 rs = copy .deepcopy (routestep )
592594 rs ['delay' ] = rs ['delay' ] - 2
595+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
593596 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
594597 l1 .rpc .waitsendpay (rhash )
595598 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -599,17 +602,20 @@ def invoice_unpaid(dst, label):
599602 with pytest .raises (RpcError ):
600603 rs = copy .deepcopy (routestep )
601604 rs ['id' ] = '00000000000000000000000000000000'
605+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
602606 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
603607 assert invoice_unpaid (l2 , 'testpayment2' )
604608 l1 .rpc .check_request_schemas = True
605609
606610 # Bad payment_secret
611+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
607612 l1 .rpc .sendpay ([routestep ], rhash , payment_secret = "00" * 32 )
608613 with pytest .raises (RpcError ):
609614 l1 .rpc .waitsendpay (rhash )
610615 assert invoice_unpaid (l2 , 'testpayment2' )
611616
612617 # Missing payment_secret
618+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
613619 l1 .rpc .sendpay ([routestep ], rhash )
614620 with pytest .raises (RpcError ):
615621 l1 .rpc .waitsendpay (rhash )
@@ -625,6 +631,7 @@ def invoice_unpaid(dst, label):
625631
626632 # This works.
627633 before = int (time .time ())
634+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
628635 details = l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
629636 after = int (time .time ())
630637 preimage = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
@@ -667,6 +674,7 @@ def check_balances():
667674 rhash = inv ['payment_hash' ]
668675 assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'unpaid'
669676 routestep = {'amount_msat' : amt * 2 , 'id' : l2 .info ['id' ], 'delay' : 5 , 'channel' : first_scid (l1 , l2 )}
677+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
670678 l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
671679 preimage3 = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
672680 assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'paid'
@@ -1157,6 +1165,7 @@ def test_forward(node_factory, bitcoind):
11571165 # Unknown other peer
11581166 route = copy .deepcopy (baseroute )
11591167 route [1 ]['id' ] = '031a8dc444e41bb989653a4501e11175a488a57439b0c4947704fd6e3de5dca607'
1168+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
11601169 l1 .rpc .sendpay (route , rhash , payment_secret = inv ['payment_secret' ])
11611170 with pytest .raises (RpcError ):
11621171 l1 .rpc .waitsendpay (rhash )
@@ -1559,6 +1568,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15591568
15601569 l2 .rpc .close (c23 , 1 )
15611570
1571+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15621572 with pytest .raises (RpcError ):
15631573 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15641574 l1 .rpc .waitsendpay (payment_hash )
@@ -1584,6 +1594,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15841594 'delay' : 6 ,
15851595 'channel' : c24 }]
15861596
1597+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15871598 with pytest .raises (RpcError ):
15881599 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15891600 l1 .rpc .waitsendpay (payment_hash )
@@ -1610,6 +1621,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16101621 'delay' : 6 ,
16111622 'channel' : c25 }]
16121623
1624+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16131625 with pytest .raises (RpcError ):
16141626 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16151627 l1 .rpc .waitsendpay (payment_hash )
@@ -1633,6 +1645,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16331645 # Replace id with a different pubkey, so onion encoded badly at l2 hop.
16341646 route [1 ]['id' ] = mangled_nodeid
16351647
1648+ l6 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16361649 with pytest .raises (RpcError ):
16371650 l6 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16381651 l6 .rpc .waitsendpay (payment_hash )
@@ -1660,6 +1673,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16601673 'delay' : 5 ,
16611674 'channel' : c24 }]
16621675
1676+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16631677 executor .submit (l1 .rpc .sendpay , route , payment_hash , payment_secret = inv ['payment_secret' ])
16641678
16651679 l4 .daemon .wait_for_log ('permfail' )
@@ -1715,6 +1729,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17151729
17161730 # L2 tries to pay
17171731 r = l2 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1732+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17181733 l2 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17191734
17201735 # Now increment CLTV
@@ -1723,6 +1738,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17231738
17241739 # L1 tries to pay
17251740 r = l1 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1741+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17261742 l1 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17271743
17281744 # Now increment CLTV
@@ -1731,6 +1747,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17311747
17321748 # L3 tries to pay
17331749 r = l3 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1750+ l3 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17341751 l3 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17351752
17361753 # Give them time to go through.
@@ -1796,6 +1813,7 @@ def exhaust_channel(opener, peer, scid, already_spent=0):
17961813 'delay' : 10 ,
17971814 'channel' : scid
17981815 }
1816+ opener .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17991817 opener .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
18001818 opener .rpc .waitsendpay (inv ['payment_hash' ])
18011819
@@ -2513,6 +2531,7 @@ def test_channel_spendable(node_factory, bitcoind):
25132531
25142532 # Exact amount should succeed.
25152533 route = l1 .rpc .getroute (l2 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2534+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25162535 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25172536
25182537 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2538,6 +2557,7 @@ def test_channel_spendable(node_factory, bitcoind):
25382557
25392558 # Exact amount should succeed.
25402559 route = l2 .rpc .getroute (l1 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2560+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25412561 l2 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25422562
25432563 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2697,6 +2717,7 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
26972717 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
26982718 for i in range (0 , 3 ):
26992719 inv = l2 .rpc .invoice ((non_dust_htlc_val_sat * 1000 ), str (i + 100 ), str (i + 100 ))
2720+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27002721 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27012722 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27022723 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
@@ -2706,20 +2727,23 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
27062727 route = l1 .rpc .getroute (l2 .info ['id' ], htlc_val_msat , 1 )['route' ]
27072728 for i in range (0 , num_dusty_htlcs ):
27082729 inv = l2 .rpc .invoice (htlc_val_msat , str (i ), str (i ))
2730+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27092731 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27102732 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27112733 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
27122734 assert res ['status' ] == 'pending'
27132735
27142736 # one more should tip it over, and return a payment failure
27152737 inv = l2 .rpc .invoice (htlc_val_msat , str (num_dusty_htlcs ), str (num_dusty_htlcs ))
2738+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27162739 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27172740 l1 .daemon .wait_for_log ('CHANNEL_ERR_DUST_FAILURE' )
27182741 wait_for (lambda : only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])['status' ] == 'failed' )
27192742
27202743 # but we can still add a non dust htlc
27212744 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
27222745 inv = l2 .rpc .invoice ((10000 * 1000 ), str (120 ), str (120 ))
2746+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27232747 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27242748 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27252749 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
0 commit comments