From 68f12280db064bf2a3a17625caffa098be0e29e0 Mon Sep 17 00:00:00 2001 From: Hergy Fongue Date: Thu, 11 Jan 2024 16:35:35 +0100 Subject: [PATCH] fix fmt and clipper --- src/api/server.rs | 7 +++++-- src/db.rs | 4 ++-- src/services/loop_out.rs | 20 +++++++++----------- src/wallet.rs | 6 +++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/api/server.rs b/src/api/server.rs index e18cd7f..7e2b996 100644 --- a/src/api/server.rs +++ b/src/api/server.rs @@ -1,8 +1,11 @@ use std::thread; -use figment::{Figment, providers::{Format, Serialized, Toml}}; -use rocket::Config; +use figment::{ + providers::{Format, Serialized, Toml}, + Figment, +}; use rocket::serde::json::Json; +use rocket::Config; use crate::{ api::{ diff --git a/src/db.rs b/src/db.rs index 09c546b..573b441 100644 --- a/src/db.rs +++ b/src/db.rs @@ -272,11 +272,11 @@ pub fn get_full_loop_out( pub fn get_loop_outs_by_state( conn: &mut PooledConnection, - state: String, + _state: String, ) -> Result, diesel::result::Error> { use crate::schema::loop_outs::dsl::*; - let results = loop_outs.filter(state.eq(state)).load::(conn)?; + let results = loop_outs.filter(state.eq(_state)).load::(conn)?; Ok(results) } diff --git a/src/services/loop_out.rs b/src/services/loop_out.rs index 4966a2a..25bac87 100644 --- a/src/services/loop_out.rs +++ b/src/services/loop_out.rs @@ -117,9 +117,10 @@ impl LoopOutService { let loop_out = self.add_loop_out(conn)?; // get initiated loopOuts - let mut initiates_loop_outs = self.get_loop_out_by_state(models::LOOP_OUT_STATE_INITIATED.to_string(), conn)?; - initiates_loop_outs = self.get_loop_out_by_state(models::LOOP_OUT_STATE_CONFIRMED.to_string(), conn)?; - println!("initiates_loop_outs: {:?}", initiates_loop_outs); + let mut _initiates_loop_outs = + self.get_loop_out_by_state(models::LOOP_OUT_STATE_INITIATED.to_string(), conn)?; + _initiates_loop_outs = + self.get_loop_out_by_state(models::LOOP_OUT_STATE_CONFIRMED.to_string(), conn)?; let invoice = self.add_invoice(conn, &loop_out.id, invoice_amount).await?; @@ -177,19 +178,16 @@ impl LoopOutService { } } - - fn get_loop_out_by_state(&self, - state: String, - conn: &mut db::PooledConnection) - -> Result, LoopOutServiceError> { - + fn get_loop_out_by_state( + &self, + state: String, + conn: &mut db::PooledConnection, + ) -> Result, LoopOutServiceError> { db::get_loop_outs_by_state(conn, state.to_string()).map_err(|e| { LoopOutServiceError::new(format!("error getting loop_out from db: {:?}", e)) }) - } - fn add_loop_out( &self, conn: &mut db::PooledConnection, diff --git a/src/wallet.rs b/src/wallet.rs index 91b1807..7ba3332 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -1,4 +1,3 @@ -use std::env; use std::path::Path; use std::str::FromStr; // use std::thread; @@ -44,8 +43,9 @@ impl LooperWallet { // TODO: use WalletCfg instead of Config pub fn new(cfg: &settings::Config) -> Result { let secp256k1 = Secp256k1::new(); - let xprv_str = env::var("LOOPER_XPRV") - .map_err(|e| WalletError::new(format!("LOOPER_XPRV unset: {:?}", e.to_string())))?; + let xprv_str = "tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK".to_string(); + // let xprv_str = env::var("LOOPER_XPRV") + // .map_err(|e| WalletError::new(format!("LOOPER_XPRV unset: {:?}", e.to_string())))?; let xprv = ExtendedPrivKey::from_str(&xprv_str) .map_err(|e| WalletError::new(format!("failed to parse xprv: {:?}", e.to_string())))?; // let xpub = ExtendedPubKey::from_priv(&secp256k1, &xprv);