@@ -844,7 +844,7 @@ async fn send_payment(
844844) {
845845 let payment_id = PaymentId ( ( * invoice. payment_hash ( ) ) . to_byte_array ( ) ) ;
846846 let payment_secret = Some ( * invoice. payment_secret ( ) ) ;
847- match ( invoice. amount_milli_satoshis ( ) , required_amount_msat) {
847+ let amt_msat = match ( invoice. amount_milli_satoshis ( ) , required_amount_msat) {
848848 // pay_for_bolt11_invoice only validates that the amount we pay is >= the invoice's
849849 // required amount, not that its equal (to allow for overpayment). As that is somewhat
850850 // surprising, here we check and reject all disagreements in amount.
@@ -856,8 +856,14 @@ async fn send_payment(
856856 print ! ( "> " ) ;
857857 return ;
858858 } ,
859- _ => { } ,
860- }
859+ ( Some ( inv_amt) , _) => inv_amt,
860+ ( _, Some ( req_amt) ) => req_amt,
861+ ( None , None ) => {
862+ println ! ( "Need an amount to pay an amountless invoice" ) ;
863+ print ! ( "> " ) ;
864+ return ;
865+ } ,
866+ } ;
861867 let write_future = {
862868 let mut outbound_payments = outbound_payments. lock ( ) . unwrap ( ) ;
863869 outbound_payments. payments . insert (
@@ -866,7 +872,7 @@ async fn send_payment(
866872 preimage : None ,
867873 secret : payment_secret,
868874 status : HTLCStatus :: Pending ,
869- amt_msat : MillisatAmount ( invoice . amount_milli_satoshis ( ) ) ,
875+ amt_msat : MillisatAmount ( Some ( amt_msat ) ) ,
870876 } ,
871877 ) ;
872878 fs_store. write ( "" , "" , OUTBOUND_PAYMENTS_FNAME , outbound_payments. encode ( ) )
@@ -882,7 +888,6 @@ async fn send_payment(
882888 ) {
883889 Ok ( _) => {
884890 let payee_pubkey = invoice. recover_payee_pub_key ( ) ;
885- let amt_msat = invoice. amount_milli_satoshis ( ) . unwrap ( ) ;
886891 println ! ( "EVENT: initiated sending {} msats to {}" , amt_msat, payee_pubkey) ;
887892 print ! ( "> " ) ;
888893 } ,
0 commit comments