Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions examples/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ fn get_config(network: Network) -> Result<WalletConfig> {
network,
seed,
tunables: Tunables::default(),
extra_config: ExtraConfig::Spark(SparkWalletConfig::default_config(
network.try_into().expect("valid network"),
)),
extra_config: ExtraConfig::Spark(SparkWalletConfig::default()),
})
},
Network::Bitcoin => {
Expand All @@ -118,9 +116,7 @@ fn get_config(network: Network) -> Result<WalletConfig> {
network,
seed,
tunables: Tunables::default(),
extra_config: ExtraConfig::Spark(SparkWalletConfig::default_config(
network.try_into().expect("valid network"),
)),
extra_config: ExtraConfig::Spark(SparkWalletConfig::default()),
})
},
_ => Err(anyhow::anyhow!("Unsupported network: {network:?}")),
Expand Down
4 changes: 2 additions & 2 deletions orange-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name = "orange_sdk"
[features]
default = ["spark"]
uniffi = ["dep:uniffi", "spark", "cashu"]
spark = ["spark-wallet", "uuid"]
spark = ["breez-sdk-spark", "uuid", "serde_json"]
cashu = ["cdk", "serde_json"]
_test-utils = ["corepc-node", "cashu", "uuid/v7", "rand"]
_cashu-tests = ["_test-utils", "cdk-ldk-node", "cdk/mint", "cdk-sqlite", "cdk-axum", "axum"]
Expand All @@ -23,7 +23,7 @@ bitcoin-payment-instructions = { workspace = true }
chrono = { version = "0.4", default-features = false }
rand = { version = "0.8.5", optional = true }
reqwest = { version = "0.12.23", default-features = false, features = ["rustls-tls"] }
spark-wallet = { git = "https://github.com/breez/spark-sdk.git", rev = "6e12f98be3f100fca0411e3209a610decfa32279", default-features = false, features = ["rustls-tls"], optional = true }
breez-sdk-spark = { git = "https://github.com/breez/spark-sdk.git", rev = "41212dfcfe36e22a55ac224c791b326f259f90d6", default-features = false, features = ["rustls-tls"], optional = true }
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "sync"] }
uuid = { version = "1.0", default-features = false, optional = true }
cdk = { git = "https://github.com/benthecarman/cdk.git", rev = "7d25e9ae5ed7f47f9ae7e87d8a9ee16797fee8cd", default-features = false, features = ["wallet"], optional = true }
Expand Down
37 changes: 6 additions & 31 deletions orange-sdk/src/ffi/spark.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,18 @@
use spark_wallet::Network as SparkNetwork;
use spark_wallet::SparkWalletConfig as SparkSparkWalletConfig;

use crate::ffi::Network;
use crate::SparkWalletConfig as OrangeSparkWalletConfig;
use crate::{impl_from_core_type, impl_into_core_type};

impl From<SparkNetwork> for Network {
fn from(network: SparkNetwork) -> Self {
match network {
SparkNetwork::Mainnet => Network::Mainnet,
SparkNetwork::Regtest => Network::Regtest,
SparkNetwork::Testnet => Network::Testnet,
SparkNetwork::Signet => Network::Signet,
}
}
}

impl From<Network> for SparkNetwork {
fn from(network: Network) -> Self {
match network {
Network::Mainnet => SparkNetwork::Mainnet,
Network::Regtest => SparkNetwork::Regtest,
Network::Testnet => SparkNetwork::Testnet,
Network::Signet => SparkNetwork::Signet,
}
}
}

#[derive(Clone, Debug, uniffi::Object)]
pub struct SparkWalletConfig(pub SparkSparkWalletConfig);
pub struct SparkWalletConfig(pub OrangeSparkWalletConfig);

// TODO: For now just support the default configuration.
// In the future we will want to expose all of the Spark configuration objects
#[uniffi::export]
impl SparkWalletConfig {
#[uniffi::constructor]
pub fn default_config(network: Network) -> Self {
SparkWalletConfig(SparkSparkWalletConfig::default_config(network.into()))
pub fn default_config() -> Self {
SparkWalletConfig(OrangeSparkWalletConfig::default())
}
}

impl_from_core_type!(SparkSparkWalletConfig, SparkWalletConfig);
impl_into_core_type!(SparkWalletConfig, SparkSparkWalletConfig);
impl_from_core_type!(OrangeSparkWalletConfig, SparkWalletConfig);
impl_into_core_type!(SparkWalletConfig, OrangeSparkWalletConfig);
6 changes: 3 additions & 3 deletions orange-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ use trusted_wallet::TrustedError;

#[cfg(feature = "cashu")]
pub use crate::trusted_wallet::cashu::CashuConfig;
#[cfg(feature = "spark")]
pub use crate::trusted_wallet::spark::SparkWalletConfig;
pub use bitcoin_payment_instructions;
#[cfg(feature = "cashu")]
pub use cdk::nuts::nut00::CurrencyUnit;
pub use event::{Event, EventQueue};
pub use ldk_node::bip39::Mnemonic;
pub use ldk_node::bitcoin;
pub use ldk_node::payment::ConfirmationStatus;
#[cfg(feature = "spark")]
pub use spark_wallet::{OperatorPoolConfig, ServiceProviderConfig, SparkWalletConfig};
pub use store::{PaymentId, PaymentType, Transaction, TxStatus};
pub use trusted_wallet::ExtraConfig;

Expand Down Expand Up @@ -522,7 +522,7 @@ impl Wallet {
ExtraConfig::Spark(sp) => Arc::new(Box::new(
Spark::init(
&config,
sp.clone(),
*sp,
Arc::clone(&store),
Arc::clone(&event_queue),
tx_metadata.clone(),
Expand Down
Loading
Loading