@@ -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'
@@ -1158,6 +1166,7 @@ def test_forward(node_factory, bitcoind):
11581166 # Unknown other peer
11591167 route = copy .deepcopy (baseroute )
11601168 route [1 ]['id' ] = '031a8dc444e41bb989653a4501e11175a488a57439b0c4947704fd6e3de5dca607'
1169+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
11611170 l1 .rpc .sendpay (route , rhash , payment_secret = inv ['payment_secret' ])
11621171 with pytest .raises (RpcError ):
11631172 l1 .rpc .waitsendpay (rhash )
@@ -1560,6 +1569,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15601569
15611570 l2 .rpc .close (c23 , 1 )
15621571
1572+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15631573 with pytest .raises (RpcError ):
15641574 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15651575 l1 .rpc .waitsendpay (payment_hash )
@@ -1585,6 +1595,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15851595 'delay' : 6 ,
15861596 'channel' : c24 }]
15871597
1598+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15881599 with pytest .raises (RpcError ):
15891600 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15901601 l1 .rpc .waitsendpay (payment_hash )
@@ -1611,6 +1622,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16111622 'delay' : 6 ,
16121623 'channel' : c25 }]
16131624
1625+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16141626 with pytest .raises (RpcError ):
16151627 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16161628 l1 .rpc .waitsendpay (payment_hash )
@@ -1634,6 +1646,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16341646 # Replace id with a different pubkey, so onion encoded badly at l2 hop.
16351647 route [1 ]['id' ] = mangled_nodeid
16361648
1649+ l6 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16371650 with pytest .raises (RpcError ):
16381651 l6 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
16391652 l6 .rpc .waitsendpay (payment_hash )
@@ -1661,6 +1674,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16611674 'delay' : 5 ,
16621675 'channel' : c24 }]
16631676
1677+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16641678 executor .submit (l1 .rpc .sendpay , route , payment_hash , payment_secret = inv ['payment_secret' ])
16651679
16661680 l4 .daemon .wait_for_log ('permfail' )
@@ -1716,6 +1730,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17161730
17171731 # L2 tries to pay
17181732 r = l2 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1733+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17191734 l2 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17201735
17211736 # Now increment CLTV
@@ -1724,6 +1739,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17241739
17251740 # L1 tries to pay
17261741 r = l1 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1742+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17271743 l1 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17281744
17291745 # Now increment CLTV
@@ -1732,6 +1748,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
17321748
17331749 # L3 tries to pay
17341750 r = l3 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1751+ l3 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17351752 l3 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
17361753
17371754 # Give them time to go through.
@@ -1797,6 +1814,7 @@ def exhaust_channel(opener, peer, scid, already_spent=0):
17971814 'delay' : 10 ,
17981815 'channel' : scid
17991816 }
1817+ opener .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
18001818 opener .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
18011819 opener .rpc .waitsendpay (inv ['payment_hash' ])
18021820
@@ -2515,6 +2533,7 @@ def test_channel_spendable(node_factory, bitcoind):
25152533
25162534 # Exact amount should succeed.
25172535 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
25182537 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25192538
25202539 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2540,6 +2559,7 @@ def test_channel_spendable(node_factory, bitcoind):
25402559
25412560 # Exact amount should succeed.
25422561 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
25432563 l2 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25442564
25452565 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2701,6 +2721,7 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
27012721 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
27022722 for i in range (0 , 3 ):
27032723 inv = l2 .rpc .invoice ((non_dust_htlc_val_sat * 1000 ), str (i + 100 ), str (i + 100 ))
2724+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27042725 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27052726 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27062727 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
@@ -2710,20 +2731,23 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
27102731 route = l1 .rpc .getroute (l2 .info ['id' ], htlc_val_msat , 1 )['route' ]
27112732 for i in range (0 , num_dusty_htlcs ):
27122733 inv = l2 .rpc .invoice (htlc_val_msat , str (i ), str (i ))
2734+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27132735 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27142736 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27152737 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
27162738 assert res ['status' ] == 'pending'
27172739
27182740 # one more should tip it over, and return a payment failure
27192741 inv = l2 .rpc .invoice (htlc_val_msat , str (num_dusty_htlcs ), str (num_dusty_htlcs ))
2742+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27202743 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27212744 l1 .daemon .wait_for_log ('CHANNEL_ERR_DUST_FAILURE' )
27222745 wait_for (lambda : only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])['status' ] == 'failed' )
27232746
27242747 # but we can still add a non dust htlc
27252748 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
27262749 inv = l2 .rpc .invoice ((10000 * 1000 ), str (120 ), str (120 ))
2750+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
27272751 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
27282752 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
27292753 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
0 commit comments