@@ -838,7 +838,7 @@ async fn send_payment(
838
838
) {
839
839
let payment_id = PaymentId ( ( * invoice. payment_hash ( ) ) . to_byte_array ( ) ) ;
840
840
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) {
842
842
// pay_for_bolt11_invoice only validates that the amount we pay is >= the invoice's
843
843
// required amount, not that its equal (to allow for overpayment). As that is somewhat
844
844
// surprising, here we check and reject all disagreements in amount.
@@ -850,8 +850,14 @@ async fn send_payment(
850
850
print ! ( "> " ) ;
851
851
return ;
852
852
} ,
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
+ } ;
855
861
let write_future = {
856
862
let mut outbound_payments = outbound_payments. lock ( ) . unwrap ( ) ;
857
863
outbound_payments. payments . insert (
@@ -860,7 +866,7 @@ async fn send_payment(
860
866
preimage : None ,
861
867
secret : payment_secret,
862
868
status : HTLCStatus :: Pending ,
863
- amt_msat : MillisatAmount ( invoice . amount_milli_satoshis ( ) ) ,
869
+ amt_msat : MillisatAmount ( Some ( amt_msat ) ) ,
864
870
} ,
865
871
) ;
866
872
fs_store. write ( "" , "" , OUTBOUND_PAYMENTS_FNAME , outbound_payments. encode ( ) )
@@ -876,7 +882,6 @@ async fn send_payment(
876
882
) {
877
883
Ok ( _) => {
878
884
let payee_pubkey = invoice. recover_payee_pub_key ( ) ;
879
- let amt_msat = invoice. amount_milli_satoshis ( ) . unwrap ( ) ;
880
885
println ! ( "EVENT: initiated sending {} msats to {}" , amt_msat, payee_pubkey) ;
881
886
print ! ( "> " ) ;
882
887
} ,
0 commit comments