@@ -577,6 +577,7 @@ def invoice_unpaid(dst, label):
577577 with pytest .raises (RpcError ):
578578 rs = copy .deepcopy (routestep )
579579 rs ['amount_msat' ] = rs ['amount_msat' ] - 1
580+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
580581 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
581582 l1 .rpc .waitsendpay (rhash )
582583 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -585,6 +586,7 @@ def invoice_unpaid(dst, label):
585586 with pytest .raises (RpcError ):
586587 rs = copy .deepcopy (routestep )
587588 rs ['amount_msat' ] = rs ['amount_msat' ] * 2 + 1
589+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
588590 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
589591 l1 .rpc .waitsendpay (rhash )
590592 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -593,6 +595,7 @@ def invoice_unpaid(dst, label):
593595 with pytest .raises (RpcError ):
594596 rs = copy .deepcopy (routestep )
595597 rs ['delay' ] = rs ['delay' ] - 2
598+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
596599 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
597600 l1 .rpc .waitsendpay (rhash )
598601 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -602,17 +605,20 @@ def invoice_unpaid(dst, label):
602605 with pytest .raises (RpcError ):
603606 rs = copy .deepcopy (routestep )
604607 rs ['id' ] = '00000000000000000000000000000000'
608+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
605609 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
606610 assert invoice_unpaid (l2 , 'testpayment2' )
607611 l1 .rpc .check_request_schemas = True
608612
609613 # Bad payment_secret
614+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
610615 l1 .rpc .sendpay ([routestep ], rhash , payment_secret = "00" * 32 )
611616 with pytest .raises (RpcError ):
612617 l1 .rpc .waitsendpay (rhash )
613618 assert invoice_unpaid (l2 , 'testpayment2' )
614619
615620 # Missing payment_secret
621+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
616622 l1 .rpc .sendpay ([routestep ], rhash )
617623 with pytest .raises (RpcError ):
618624 l1 .rpc .waitsendpay (rhash )
@@ -628,6 +634,7 @@ def invoice_unpaid(dst, label):
628634
629635 # This works.
630636 before = int (time .time ())
637+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
631638 details = l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
632639 after = int (time .time ())
633640 preimage = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
@@ -670,6 +677,7 @@ def check_balances():
670677 rhash = inv ['payment_hash' ]
671678 assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'unpaid'
672679 routestep = {'amount_msat' : amt * 2 , 'id' : l2 .info ['id' ], 'delay' : 5 , 'channel' : first_scid (l1 , l2 )}
680+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
673681 l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
674682 preimage3 = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
675683 assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'paid'
@@ -705,6 +713,7 @@ def test_repay(node_factory):
705713 'delay' : 5 ,
706714 'channel' : first_scid (l1 , l2 )
707715 }
716+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
708717 l1 .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
709718 l1 .daemon .wait_for_log ("Sending 200000000msat over 1 hops to deliver 200000000msat" )
710719 l1 .rpc .waitsendpay (inv ['payment_hash' ])['payment_preimage' ]
@@ -733,6 +742,7 @@ def test_wait_sendpay(node_factory, executor):
733742 'delay' : 5 ,
734743 'channel' : first_scid (l1 , l2 )
735744 }
745+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
736746 l1 .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
737747 assert wait_created .result (TIMEOUT ) == {'subsystem' : 'sendpays' ,
738748 'created' : 1 ,
@@ -1160,6 +1170,7 @@ def test_forward(node_factory, bitcoind):
11601170 # Unknown other peer
11611171 route = copy .deepcopy (baseroute )
11621172 route [1 ]['id' ] = '031a8dc444e41bb989653a4501e11175a488a57439b0c4947704fd6e3de5dca607'
1173+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
11631174 l1 .rpc .sendpay (route , rhash , payment_secret = inv ['payment_secret' ])
11641175 with pytest .raises (RpcError ):
11651176 l1 .rpc .waitsendpay (rhash )
@@ -1563,6 +1574,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15631574
15641575 l2 .rpc .close (c23 , 1 )
15651576
1577+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15661578 with pytest .raises (RpcError ):
15671579 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15681580 l1 .rpc .waitsendpay (payment_hash )
@@ -1588,6 +1600,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15881600 'delay' : 6 ,
15891601 'channel' : c24 }]
15901602
1603+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15911604 with pytest .raises (RpcError ):
15921605 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15931606 l1 .rpc .waitsendpay (payment_hash )
@@ -1614,6 +1627,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16141627 'delay' : 6 ,
16151628 'channel' : c25 }]
16161629
1630+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16171631 with pytest .raises (RpcError ):
16181632 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16191633 l1 .rpc .waitsendpay (payment_hash )
@@ -1637,6 +1651,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16371651 # Replace id with a different pubkey, so onion encoded badly at l2 hop.
16381652 route [1 ]['id' ] = mangled_nodeid
16391653
1654+ l6 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16401655 with pytest .raises (RpcError ):
16411656 l6 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16421657 l6 .rpc .waitsendpay (payment_hash )
@@ -1664,6 +1679,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16641679 'delay' : 5 ,
16651680 'channel' : c24 }]
16661681
1682+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16671683 executor .submit (l1 .rpc .sendpay , route , payment_hash , payment_secret = inv ['payment_secret' ])
16681684
16691685 l4 .daemon .wait_for_log ('permfail' )
@@ -1719,6 +1735,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17191735
17201736 # L2 tries to pay
17211737 r = l2 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1738+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17221739 l2 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17231740
17241741 # Now increment CLTV
@@ -1727,6 +1744,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17271744
17281745 # L1 tries to pay
17291746 r = l1 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1747+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17301748 l1 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17311749
17321750 # Now increment CLTV
@@ -1735,6 +1753,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17351753
17361754 # L3 tries to pay
17371755 r = l3 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1756+ l3 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17381757 l3 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17391758
17401759 # Give them time to go through.
@@ -1800,6 +1819,7 @@ def exhaust_channel(opener, peer, scid, already_spent=0):
18001819 'delay' : 10 ,
18011820 'channel' : scid
18021821 }
1822+ opener .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
18031823 opener .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
18041824 opener .rpc .waitsendpay (inv ['payment_hash' ])
18051825
@@ -2527,6 +2547,7 @@ def test_channel_spendable(node_factory, bitcoind):
25272547
25282548 # Exact amount should succeed.
25292549 route = l1 .rpc .getroute (l2 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2550+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25302551 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25312552
25322553 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2552,6 +2573,7 @@ def test_channel_spendable(node_factory, bitcoind):
25522573
25532574 # Exact amount should succeed.
25542575 route = l2 .rpc .getroute (l1 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2576+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25552577 l2 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25562578
25572579 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2710,6 +2732,7 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
27102732 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
27112733 for i in range (0 , 3 ):
27122734 inv = l2 .rpc .invoice ((non_dust_htlc_val_sat * 1000 ), str (i + 100 ), str (i + 100 ))
2735+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27132736 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27142737 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27152738 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
@@ -2719,20 +2742,23 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
27192742 route = l1 .rpc .getroute (l2 .info ['id' ], htlc_val_msat , 1 )['route' ]
27202743 for i in range (0 , num_dusty_htlcs ):
27212744 inv = l2 .rpc .invoice (htlc_val_msat , str (i ), str (i ))
2745+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27222746 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27232747 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27242748 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
27252749 assert res ['status' ] == 'pending'
27262750
27272751 # one more should tip it over, and return a payment failure
27282752 inv = l2 .rpc .invoice (htlc_val_msat , str (num_dusty_htlcs ), str (num_dusty_htlcs ))
2753+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27292754 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27302755 l1 .daemon .wait_for_log ('CHANNEL_ERR_DUST_FAILURE' )
27312756 wait_for (lambda : only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])['status' ] == 'failed' )
27322757
27332758 # but we can still add a non dust htlc
27342759 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
27352760 inv = l2 .rpc .invoice ((10000 * 1000 ), str (120 ), str (120 ))
2761+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27362762 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27372763 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27382764 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
0 commit comments