@@ -575,6 +575,7 @@ def invoice_unpaid(dst, label):
575575 with pytest .raises (RpcError ):
576576 rs = copy .deepcopy (routestep )
577577 rs ['amount_msat' ] = rs ['amount_msat' ] - 1
578+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
578579 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
579580 l1 .rpc .waitsendpay (rhash )
580581 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -583,6 +584,7 @@ def invoice_unpaid(dst, label):
583584 with pytest .raises (RpcError ):
584585 rs = copy .deepcopy (routestep )
585586 rs ['amount_msat' ] = rs ['amount_msat' ] * 2 + 1
587+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
586588 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
587589 l1 .rpc .waitsendpay (rhash )
588590 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -591,6 +593,7 @@ def invoice_unpaid(dst, label):
591593 with pytest .raises (RpcError ):
592594 rs = copy .deepcopy (routestep )
593595 rs ['delay' ] = rs ['delay' ] - 2
596+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
594597 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
595598 l1 .rpc .waitsendpay (rhash )
596599 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -600,17 +603,20 @@ def invoice_unpaid(dst, label):
600603 with pytest .raises (RpcError ):
601604 rs = copy .deepcopy (routestep )
602605 rs ['id' ] = '00000000000000000000000000000000'
606+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
603607 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
604608 assert invoice_unpaid (l2 , 'testpayment2' )
605609 l1 .rpc .check_request_schemas = True
606610
607611 # Bad payment_secret
612+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
608613 l1 .rpc .sendpay ([routestep ], rhash , payment_secret = "00" * 32 )
609614 with pytest .raises (RpcError ):
610615 l1 .rpc .waitsendpay (rhash )
611616 assert invoice_unpaid (l2 , 'testpayment2' )
612617
613618 # Missing payment_secret
619+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
614620 l1 .rpc .sendpay ([routestep ], rhash )
615621 with pytest .raises (RpcError ):
616622 l1 .rpc .waitsendpay (rhash )
@@ -626,6 +632,7 @@ def invoice_unpaid(dst, label):
626632
627633 # This works.
628634 before = int (time .time ())
635+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
629636 details = l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
630637 after = int (time .time ())
631638 preimage = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
@@ -668,6 +675,7 @@ def check_balances():
668675 rhash = inv ['payment_hash' ]
669676 assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'unpaid'
670677 routestep = {'amount_msat' : amt * 2 , 'id' : l2 .info ['id' ], 'delay' : 5 , 'channel' : first_scid (l1 , l2 )}
678+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
671679 l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
672680 preimage3 = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
673681 assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'paid'
@@ -703,6 +711,7 @@ def test_repay(node_factory):
703711 'delay' : 5 ,
704712 'channel' : first_scid (l1 , l2 )
705713 }
714+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
706715 l1 .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
707716 l1 .daemon .wait_for_log ("Sending 200000000msat over 1 hops to deliver 200000000msat" )
708717 l1 .rpc .waitsendpay (inv ['payment_hash' ])['payment_preimage' ]
@@ -731,6 +740,7 @@ def test_wait_sendpay(node_factory, executor):
731740 'delay' : 5 ,
732741 'channel' : first_scid (l1 , l2 )
733742 }
743+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
734744 l1 .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
735745 assert wait_created .result (TIMEOUT ) == {'subsystem' : 'sendpays' ,
736746 'created' : 1 ,
@@ -1158,6 +1168,7 @@ def test_forward(node_factory, bitcoind):
11581168 # Unknown other peer
11591169 route = copy .deepcopy (baseroute )
11601170 route [1 ]['id' ] = '031a8dc444e41bb989653a4501e11175a488a57439b0c4947704fd6e3de5dca607'
1171+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
11611172 l1 .rpc .sendpay (route , rhash , payment_secret = inv ['payment_secret' ])
11621173 with pytest .raises (RpcError ):
11631174 l1 .rpc .waitsendpay (rhash )
@@ -1560,6 +1571,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15601571
15611572 l2 .rpc .close (c23 , 1 )
15621573
1574+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15631575 with pytest .raises (RpcError ):
15641576 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15651577 l1 .rpc .waitsendpay (payment_hash )
@@ -1585,6 +1597,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15851597 'delay' : 6 ,
15861598 'channel' : c24 }]
15871599
1600+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15881601 with pytest .raises (RpcError ):
15891602 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15901603 l1 .rpc .waitsendpay (payment_hash )
@@ -1611,6 +1624,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16111624 'delay' : 6 ,
16121625 'channel' : c25 }]
16131626
1627+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16141628 with pytest .raises (RpcError ):
16151629 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16161630 l1 .rpc .waitsendpay (payment_hash )
@@ -1634,6 +1648,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16341648 # Replace id with a different pubkey, so onion encoded badly at l2 hop.
16351649 route [1 ]['id' ] = mangled_nodeid
16361650
1651+ l6 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16371652 with pytest .raises (RpcError ):
16381653 l6 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16391654 l6 .rpc .waitsendpay (payment_hash )
@@ -1661,6 +1676,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16611676 'delay' : 5 ,
16621677 'channel' : c24 }]
16631678
1679+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16641680 executor .submit (l1 .rpc .sendpay , route , payment_hash , payment_secret = inv ['payment_secret' ])
16651681
16661682 l4 .daemon .wait_for_log ('permfail' )
@@ -1716,6 +1732,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17161732
17171733 # L2 tries to pay
17181734 r = l2 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1735+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17191736 l2 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17201737
17211738 # Now increment CLTV
@@ -1724,6 +1741,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17241741
17251742 # L1 tries to pay
17261743 r = l1 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1744+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17271745 l1 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17281746
17291747 # Now increment CLTV
@@ -1732,6 +1750,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17321750
17331751 # L3 tries to pay
17341752 r = l3 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1753+ l3 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17351754 l3 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17361755
17371756 # Give them time to go through.
@@ -1797,6 +1816,7 @@ def exhaust_channel(opener, peer, scid, already_spent=0):
17971816 'delay' : 10 ,
17981817 'channel' : scid
17991818 }
1819+ opener .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
18001820 opener .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
18011821 opener .rpc .waitsendpay (inv ['payment_hash' ])
18021822
@@ -2515,6 +2535,7 @@ def test_channel_spendable(node_factory, bitcoind):
25152535
25162536 # Exact amount should succeed.
25172537 route = l1 .rpc .getroute (l2 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2538+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25182539 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25192540
25202541 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2540,6 +2561,7 @@ def test_channel_spendable(node_factory, bitcoind):
25402561
25412562 # Exact amount should succeed.
25422563 route = l2 .rpc .getroute (l1 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2564+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25432565 l2 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25442566
25452567 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2701,6 +2723,7 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
27012723 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
27022724 for i in range (0 , 3 ):
27032725 inv = l2 .rpc .invoice ((non_dust_htlc_val_sat * 1000 ), str (i + 100 ), str (i + 100 ))
2726+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27042727 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27052728 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27062729 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
@@ -2710,20 +2733,23 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
27102733 route = l1 .rpc .getroute (l2 .info ['id' ], htlc_val_msat , 1 )['route' ]
27112734 for i in range (0 , num_dusty_htlcs ):
27122735 inv = l2 .rpc .invoice (htlc_val_msat , str (i ), str (i ))
2736+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27132737 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27142738 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27152739 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
27162740 assert res ['status' ] == 'pending'
27172741
27182742 # one more should tip it over, and return a payment failure
27192743 inv = l2 .rpc .invoice (htlc_val_msat , str (num_dusty_htlcs ), str (num_dusty_htlcs ))
2744+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27202745 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27212746 l1 .daemon .wait_for_log ('CHANNEL_ERR_DUST_FAILURE' )
27222747 wait_for (lambda : only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])['status' ] == 'failed' )
27232748
27242749 # but we can still add a non dust htlc
27252750 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
27262751 inv = l2 .rpc .invoice ((10000 * 1000 ), str (120 ), str (120 ))
2752+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27272753 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27282754 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27292755 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
0 commit comments