@@ -584,6 +584,7 @@ def invoice_unpaid(dst, label):
584584 with pytest .raises (RpcError ):
585585 rs = copy .deepcopy (routestep )
586586 rs ['amount_msat' ] = rs ['amount_msat' ] - 1
587+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
587588 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
588589 l1 .rpc .waitsendpay (rhash )
589590 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -592,6 +593,7 @@ def invoice_unpaid(dst, label):
592593 with pytest .raises (RpcError ):
593594 rs = copy .deepcopy (routestep )
594595 rs ['amount_msat' ] = rs ['amount_msat' ] * 2 + 1
596+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
595597 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
596598 l1 .rpc .waitsendpay (rhash )
597599 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -600,6 +602,7 @@ def invoice_unpaid(dst, label):
600602 with pytest .raises (RpcError ):
601603 rs = copy .deepcopy (routestep )
602604 rs ['delay' ] = rs ['delay' ] - 2
605+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
603606 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
604607 l1 .rpc .waitsendpay (rhash )
605608 assert invoice_unpaid (l2 , 'testpayment2' )
@@ -609,17 +612,20 @@ def invoice_unpaid(dst, label):
609612 with pytest .raises (RpcError ):
610613 rs = copy .deepcopy (routestep )
611614 rs ['id' ] = '00000000000000000000000000000000'
615+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
612616 l1 .rpc .sendpay ([rs ], rhash , payment_secret = inv ['payment_secret' ])
613617 assert invoice_unpaid (l2 , 'testpayment2' )
614618 l1 .rpc .check_request_schemas = True
615619
616620 # Bad payment_secret
621+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
617622 l1 .rpc .sendpay ([routestep ], rhash , payment_secret = "00" * 32 )
618623 with pytest .raises (RpcError ):
619624 l1 .rpc .waitsendpay (rhash )
620625 assert invoice_unpaid (l2 , 'testpayment2' )
621626
622627 # Missing payment_secret
628+ l1 .rpc .preapprovekeysend (l2 .info ['id' ], rhash , routestep ['amount_msat' ])
623629 l1 .rpc .sendpay ([routestep ], rhash )
624630 with pytest .raises (RpcError ):
625631 l1 .rpc .waitsendpay (rhash )
@@ -635,6 +641,7 @@ def invoice_unpaid(dst, label):
635641
636642 # This works.
637643 before = int (time .time ())
644+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
638645 details = l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
639646 after = int (time .time ())
640647 preimage = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
@@ -677,6 +684,7 @@ def check_balances():
677684 rhash = inv ['payment_hash' ]
678685 assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'unpaid'
679686 routestep = {'amount_msat' : amt * 2 , 'id' : l2 .info ['id' ], 'delay' : 5 , 'channel' : first_scid (l1 , l2 )}
687+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
680688 l1 .rpc .sendpay ([routestep ], rhash , payment_secret = inv ['payment_secret' ])
681689 preimage3 = l1 .rpc .waitsendpay (rhash )['payment_preimage' ]
682690 assert only_one (l2 .rpc .listinvoices ('testpayment3' )['invoices' ])['status' ] == 'paid'
@@ -1112,6 +1120,7 @@ def test_forward(node_factory, bitcoind):
11121120 # Unknown other peer
11131121 route = copy .deepcopy (baseroute )
11141122 route [1 ]['id' ] = '031a8dc444e41bb989653a4501e11175a488a57439b0c4947704fd6e3de5dca607'
1123+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
11151124 l1 .rpc .sendpay (route , rhash , payment_secret = inv ['payment_secret' ])
11161125 with pytest .raises (RpcError ):
11171126 l1 .rpc .waitsendpay (rhash )
@@ -1518,6 +1527,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15181527
15191528 l2 .rpc .close (c23 , 1 )
15201529
1530+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15211531 with pytest .raises (RpcError ):
15221532 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15231533 l1 .rpc .waitsendpay (payment_hash )
@@ -1543,6 +1553,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15431553 'delay' : 6 ,
15441554 'channel' : c24 }]
15451555
1556+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15461557 with pytest .raises (RpcError ):
15471558 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15481559 l1 .rpc .waitsendpay (payment_hash )
@@ -1569,6 +1580,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15691580 'delay' : 6 ,
15701581 'channel' : c25 }]
15711582
1583+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15721584 with pytest .raises (RpcError ):
15731585 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15741586 l1 .rpc .waitsendpay (payment_hash )
@@ -1592,6 +1604,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
15921604 # Replace id with a different pubkey, so onion encoded badly at l2 hop.
15931605 route [1 ]['id' ] = mangled_nodeid
15941606
1607+ l6 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
15951608 with pytest .raises (RpcError ):
15961609 l6 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
15971610 l6 .rpc .waitsendpay (payment_hash )
@@ -1619,6 +1632,7 @@ def test_forward_local_failed_stats(node_factory, bitcoind, executor):
16191632 'delay' : 5 ,
16201633 'channel' : c24 }]
16211634
1635+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16221636 executor .submit (l1 .rpc .sendpay , route , payment_hash , payment_secret = inv ['payment_secret' ])
16231637
16241638 l4 .daemon .wait_for_log ('permfail' )
@@ -1675,6 +1689,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
16751689
16761690 # L2 tries to pay
16771691 r = l2 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1692+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16781693 l2 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
16791694
16801695 # Now increment CLTV
@@ -1683,6 +1698,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
16831698
16841699 # L1 tries to pay
16851700 r = l1 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1701+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16861702 l1 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
16871703
16881704 # Now increment CLTV
@@ -1691,6 +1707,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
16911707
16921708 # L3 tries to pay
16931709 r = l3 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1710+ l3 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
16941711 l3 .rpc .sendpay (r , h , payment_secret = inv ['payment_secret' ])
16951712
16961713 # Give them time to go through.
@@ -1757,6 +1774,7 @@ def exhaust_channel(opener, peer, scid, already_spent=0):
17571774 'delay' : 10 ,
17581775 'channel' : scid
17591776 }
1777+ opener .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
17601778 opener .rpc .sendpay ([routestep ], inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
17611779 opener .rpc .waitsendpay (inv ['payment_hash' ])
17621780
@@ -2484,6 +2502,7 @@ def test_channel_spendable(node_factory, bitcoind):
24842502
24852503 # Exact amount should succeed.
24862504 route = l1 .rpc .getroute (l2 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2505+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
24872506 l1 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
24882507
24892508 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2509,6 +2528,7 @@ def test_channel_spendable(node_factory, bitcoind):
25092528
25102529 # Exact amount should succeed.
25112530 route = l2 .rpc .getroute (l1 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2531+ l2 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
25122532 l2 .rpc .sendpay (route , payment_hash , payment_secret = inv ['payment_secret' ])
25132533
25142534 # Amount should drop to 0 once HTLC is sent; we have time, thanks to
@@ -2671,6 +2691,7 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
26712691 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
26722692 for i in range (0 , 3 ):
26732693 inv = l2 .rpc .invoice ((non_dust_htlc_val_sat * 1000 ), str (i + 100 ), str (i + 100 ))
2694+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
26742695 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
26752696 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
26762697 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
@@ -2680,20 +2701,23 @@ def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
26802701 route = l1 .rpc .getroute (l2 .info ['id' ], htlc_val_msat , 1 )['route' ]
26812702 for i in range (0 , num_dusty_htlcs ):
26822703 inv = l2 .rpc .invoice (htlc_val_msat , str (i ), str (i ))
2704+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
26832705 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
26842706 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
26852707 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
26862708 assert res ['status' ] == 'pending'
26872709
26882710 # one more should tip it over, and return a payment failure
26892711 inv = l2 .rpc .invoice (htlc_val_msat , str (num_dusty_htlcs ), str (num_dusty_htlcs ))
2712+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
26902713 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
26912714 l1 .daemon .wait_for_log ('CHANNEL_ERR_DUST_FAILURE' )
26922715 wait_for (lambda : only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])['status' ] == 'failed' )
26932716
26942717 # but we can still add a non dust htlc
26952718 route = l1 .rpc .getroute (l2 .info ['id' ], non_dust_htlc_val_sat * 1000 , 1 )['route' ]
26962719 inv = l2 .rpc .invoice ((10000 * 1000 ), str (120 ), str (120 ))
2720+ l1 .rpc .preapproveinvoice (bolt11 = inv ['bolt11' ]) # let the signer know this payment is coming
26972721 l1 .rpc .sendpay (route , inv ['payment_hash' ], payment_secret = inv ['payment_secret' ])
26982722 l2 .daemon .wait_for_log (r'their htlc .* dev_ignore_htlcs' )
26992723 res = only_one (l1 .rpc .listsendpays (payment_hash = inv ['payment_hash' ])['payments' ])
0 commit comments