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