@@ -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'
@@ -702,6 +710,7 @@ def test_repay(node_factory):
702710 'delay' : 5 ,
703711 'channel' : first_scid (l1 , l2 )
704712 }
713+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
705714 l1 .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
706715 l1 .daemon .wait_for_log ("Sending 200000000msat over 1 hops to deliver 200000000msat" )
707716 l1 .rpc .waitsendpay (inv ['payment_hash' ])['payment_preimage' ]
@@ -730,6 +739,7 @@ def test_wait_sendpay(node_factory, executor):
730739 'delay' : 5 ,
731740 'channel' : first_scid (l1 , l2 )
732741 }
742+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
733743 l1 .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
734744 assert wait_created .result (TIMEOUT ) == {'subsystem' : 'sendpays' ,
735745 'created' : 1 ,
@@ -1157,6 +1167,7 @@ def test_forward(node_factory, bitcoind):
11571167 # Unknown other peer
11581168 route = copy .deepcopy (baseroute )
11591169 route [1 ]['id' ] = '031a8dc444e41bb989653a4501e11175a488a57439b0c4947704fd6e3de5dca607'
1170+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
11601171 l1 .rpc .sendpay (route , rhash , payment_secret = inv ['payment_secret' ])
11611172 with pytest .raises (RpcError ):
11621173 l1 .rpc .waitsendpay (rhash )
@@ -1559,6 +1570,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15591570
15601571 l2 .rpc .close (c23 , 1 )
15611572
1573+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15621574 with pytest .raises (RpcError ):
15631575 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15641576 l1 .rpc .waitsendpay (payment_hash )
@@ -1584,6 +1596,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15841596 'delay' : 6 ,
15851597 'channel' : c24 }]
15861598
1599+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15871600 with pytest .raises (RpcError ):
15881601 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15891602 l1 .rpc .waitsendpay (payment_hash )
@@ -1610,6 +1623,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16101623 'delay' : 6 ,
16111624 'channel' : c25 }]
16121625
1626+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16131627 with pytest .raises (RpcError ):
16141628 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16151629 l1 .rpc .waitsendpay (payment_hash )
@@ -1633,6 +1647,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16331647 # Replace id with a different pubkey, so onion encoded badly at l2 hop.
16341648 route [1 ]['id' ] = mangled_nodeid
16351649
1650+ l6 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16361651 with pytest .raises (RpcError ):
16371652 l6 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16381653 l6 .rpc .waitsendpay (payment_hash )
@@ -1660,6 +1675,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16601675 'delay' : 5 ,
16611676 'channel' : c24 }]
16621677
1678+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16631679 executor .submit (l1 .rpc .sendpay , route , payment_hash , payment_secret = inv ['payment_secret' ])
16641680
16651681 l4 .daemon .wait_for_log ('permfail' )
@@ -1715,6 +1731,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17151731
17161732 # L2 tries to pay
17171733 r = l2 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1734+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17181735 l2 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17191736
17201737 # Now increment CLTV
@@ -1723,6 +1740,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17231740
17241741 # L1 tries to pay
17251742 r = l1 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1743+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17261744 l1 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17271745
17281746 # Now increment CLTV
@@ -1731,6 +1749,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17311749
17321750 # L3 tries to pay
17331751 r = l3 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1752+ l3 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17341753 l3 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17351754
17361755 # Give them time to go through.
@@ -1796,6 +1815,7 @@ def exhaust_channel(opener, peer, scid, already_spent=0):
17961815 'delay' : 10 ,
17971816 'channel' : scid
17981817 }
1818+ opener .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17991819 opener .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
18001820 opener .rpc .waitsendpay (inv ['payment_hash' ])
18011821
@@ -2513,6 +2533,7 @@ def test_channel_spendable(node_factory, bitcoind):
25132533
25142534 # Exact amount should succeed.
25152535 route = l1 .rpc .getroute (l2 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2536+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25162537 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25172538
25182539 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2538,6 +2559,7 @@ def test_channel_spendable(node_factory, bitcoind):
25382559
25392560 # Exact amount should succeed.
25402561 route = l2 .rpc .getroute (l1 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2562+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25412563 l2 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25422564
25432565 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2697,6 +2719,7 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
26972719 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
26982720 for i in range (0 , 3 ):
26992721 inv = l2 .rpc .invoice ((non_dust_htlc_val_sat * 1000 ), str (i + 100 ), str (i + 100 ))
2722+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27002723 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27012724 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27022725 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
@@ -2706,20 +2729,23 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
27062729 route = l1 .rpc .getroute (l2 .info ['id' ], htlc_val_msat , 1 )['route' ]
27072730 for i in range (0 , num_dusty_htlcs ):
27082731 inv = l2 .rpc .invoice (htlc_val_msat , str (i ), str (i ))
2732+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27092733 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27102734 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27112735 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
27122736 assert res ['status' ] == 'pending'
27132737
27142738 # one more should tip it over, and return a payment failure
27152739 inv = l2 .rpc .invoice (htlc_val_msat , str (num_dusty_htlcs ), str (num_dusty_htlcs ))
2740+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27162741 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27172742 l1 .daemon .wait_for_log ('CHANNEL_ERR_DUST_FAILURE' )
27182743 wait_for (lambda : only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])['status' ] == 'failed' )
27192744
27202745 # but we can still add a non dust htlc
27212746 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
27222747 inv = l2 .rpc .invoice ((10000 * 1000 ), str (120 ), str (120 ))
2748+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27232749 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27242750 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27252751 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
0 commit comments