@@ -838,7 +838,7 @@ async fn send_payment(
838838) {
839839 let payment_id = PaymentId ( ( * invoice. payment_hash ( ) ) . to_byte_array ( ) ) ;
840840 let payment_secret = Some ( * invoice. payment_secret ( ) ) ;
841- match ( invoice. amount_milli_satoshis ( ) , required_amount_msat) {
841+ let amt_msat = match ( invoice. amount_milli_satoshis ( ) , required_amount_msat) {
842842 // pay_for_bolt11_invoice only validates that the amount we pay is >= the invoice's
843843 // required amount, not that its equal (to allow for overpayment). As that is somewhat
844844 // surprising, here we check and reject all disagreements in amount.
@@ -850,8 +850,14 @@ async fn send_payment(
850850 print ! ( "> " ) ;
851851 return ;
852852 } ,
853- _ => { } ,
854- }
853+ ( Some ( inv_amt) , _) => inv_amt,
854+ ( _, Some ( req_amt) ) => req_amt,
855+ ( None , None ) => {
856+ println ! ( "Need an amount to pay an amountless invoice" ) ;
857+ print ! ( "> " ) ;
858+ return ;
859+ } ,
860+ } ;
855861 let write_future = {
856862 let mut outbound_payments = outbound_payments. lock ( ) . unwrap ( ) ;
857863 outbound_payments. payments . insert (
@@ -860,7 +866,7 @@ async fn send_payment(
860866 preimage : None ,
861867 secret : payment_secret,
862868 status : HTLCStatus :: Pending ,
863- amt_msat : MillisatAmount ( invoice . amount_milli_satoshis ( ) ) ,
869+ amt_msat : MillisatAmount ( Some ( amt_msat ) ) ,
864870 } ,
865871 ) ;
866872 fs_store. write ( "" , "" , OUTBOUND_PAYMENTS_FNAME , outbound_payments. encode ( ) )
@@ -876,7 +882,6 @@ async fn send_payment(
876882 ) {
877883 Ok ( _) => {
878884 let payee_pubkey = invoice. recover_payee_pub_key ( ) ;
879- let amt_msat = invoice. amount_milli_satoshis ( ) . unwrap ( ) ;
880885 println ! ( "EVENT: initiated sending {} msats to {}" , amt_msat, payee_pubkey) ;
881886 print ! ( "> " ) ;
882887 } ,
0 commit comments