- persister.persist(OUTBOUND_PAYMENTS_FNAME, &*outbound_payments).unwrap();
- match pay_invoice(invoice, Retry::Timeout(Duration::from_secs(10)), channel_manager) {
- Ok(_payment_id) => {
+ fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+
+ let mut recipient_onion = RecipientOnionFields::secret_only(*invoice.payment_secret());
+ recipient_onion.payment_metadata = invoice.payment_metadata().map(|v| v.clone());
+ let mut payment_params = match PaymentParameters::from_node_id(
+ invoice.recover_payee_pub_key(),
+ invoice.min_final_cltv_expiry_delta() as u32,
+ )
+ .with_expiry_time(
+ invoice.duration_since_epoch().as_secs().saturating_add(invoice.expiry_time().as_secs()),
+ )
+ .with_route_hints(invoice.route_hints())
+ {
+ Err(e) => {
+ println!("ERROR: Could not process invoice to prepare payment parameters, {:?}, invoice: {:?}", e, invoice);
+ return;
+ }
+ Ok(p) => p,
+ };
+ if let Some(features) = invoice.features() {
+ payment_params = match payment_params.with_bolt11_features(features.clone()) {
+ Err(e) => {
+ println!("ERROR: Could not build BOLT11 payment parameters! {:?}", e);
+ return;
+ }
+ Ok(p) => p,
+ };
+ }
+ let invoice_amount = match invoice.amount_milli_satoshis() {
+ None => {
+ println!("ERROR: An invoice with an amount is expected; {:?}", invoice);
+ return;
+ }
+ Some(a) => a,
+ };
+ let route_params =
+ RouteParameters::from_payment_params_and_value(payment_params, invoice_amount);
+
+ match channel_manager.send_payment(
+ payment_hash,
+ recipient_onion,
+ payment_id,
+ route_params,
+ Retry::Timeout(Duration::from_secs(10)),
+ ) {
+ Ok(_) => {