mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-02-12 01:34:38 +01:00
Move get_all_external_input_parsers to Config
This commit is contained in:
@@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize};
|
||||
use strum_macros::{Display, EnumString};
|
||||
|
||||
use crate::error::{PaymentError, SdkError, SdkResult};
|
||||
use crate::prelude::DEFAULT_EXTERNAL_INPUT_PARSERS;
|
||||
use crate::receive_swap::{
|
||||
DEFAULT_ZERO_CONF_MAX_SAT, DEFAULT_ZERO_CONF_MIN_FEE_RATE_MAINNET,
|
||||
DEFAULT_ZERO_CONF_MIN_FEE_RATE_TESTNET,
|
||||
@@ -127,6 +128,24 @@ impl Config {
|
||||
LiquidNetwork::Testnet => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_all_external_input_parsers(&self) -> Vec<ExternalInputParser> {
|
||||
let mut external_input_parsers = Vec::new();
|
||||
if self.use_default_external_input_parsers {
|
||||
let default_parsers = DEFAULT_EXTERNAL_INPUT_PARSERS
|
||||
.iter()
|
||||
.map(|(id, regex, url)| ExternalInputParser {
|
||||
provider_id: id.to_string(),
|
||||
input_regex: regex.to_string(),
|
||||
parser_url: url.to_string(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
external_input_parsers.extend(default_parsers);
|
||||
}
|
||||
external_input_parsers.extend(self.external_input_parsers.clone().unwrap_or_default());
|
||||
|
||||
external_input_parsers
|
||||
}
|
||||
}
|
||||
|
||||
/// Network chosen for this Liquid SDK instance. Note that it represents both the Liquid and the
|
||||
|
||||
@@ -225,7 +225,7 @@ impl LiquidSdk {
|
||||
let buy_bitcoin_service =
|
||||
Arc::new(BuyBitcoinService::new(config.clone(), breez_server.clone()));
|
||||
|
||||
let external_input_parsers = Self::get_all_external_input_parsers(&config);
|
||||
let external_input_parsers = config.get_all_external_input_parsers();
|
||||
|
||||
let sdk = Arc::new(LiquidSdk {
|
||||
config: config.clone(),
|
||||
@@ -250,24 +250,6 @@ impl LiquidSdk {
|
||||
Ok(sdk)
|
||||
}
|
||||
|
||||
fn get_all_external_input_parsers(config: &Config) -> Vec<ExternalInputParser> {
|
||||
let mut external_input_parsers = Vec::new();
|
||||
if config.use_default_external_input_parsers {
|
||||
let default_parsers = DEFAULT_EXTERNAL_INPUT_PARSERS
|
||||
.iter()
|
||||
.map(|(id, regex, url)| ExternalInputParser {
|
||||
provider_id: id.to_string(),
|
||||
input_regex: regex.to_string(),
|
||||
parser_url: url.to_string(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
external_input_parsers.extend(default_parsers);
|
||||
}
|
||||
external_input_parsers.extend(config.external_input_parsers.clone().unwrap_or_default());
|
||||
|
||||
external_input_parsers
|
||||
}
|
||||
|
||||
/// Starts an SDK instance.
|
||||
///
|
||||
/// Internal method. Should only be called once per instance.
|
||||
|
||||
Reference in New Issue
Block a user