Skip to content

Commit cd15d56

Browse files
authored
change from spark-wallet to breez-sdk-spark (#22)
1 parent fc1d440 commit cd15d56

7 files changed

Lines changed: 708 additions & 830 deletions

File tree

examples/cli/src/main.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ fn get_config(network: Network) -> Result<WalletConfig> {
8989
network,
9090
seed,
9191
tunables: Tunables::default(),
92-
extra_config: ExtraConfig::Spark(SparkWalletConfig::default_config(
93-
network.try_into().expect("valid network"),
94-
)),
92+
extra_config: ExtraConfig::Spark(SparkWalletConfig::default()),
9593
})
9694
},
9795
Network::Bitcoin => {
@@ -118,9 +116,7 @@ fn get_config(network: Network) -> Result<WalletConfig> {
118116
network,
119117
seed,
120118
tunables: Tunables::default(),
121-
extra_config: ExtraConfig::Spark(SparkWalletConfig::default_config(
122-
network.try_into().expect("valid network"),
123-
)),
119+
extra_config: ExtraConfig::Spark(SparkWalletConfig::default()),
124120
})
125121
},
126122
_ => Err(anyhow::anyhow!("Unsupported network: {network:?}")),

orange-sdk/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name = "orange_sdk"
1010
[features]
1111
default = ["spark"]
1212
uniffi = ["dep:uniffi", "spark", "cashu"]
13-
spark = ["spark-wallet", "uuid"]
13+
spark = ["breez-sdk-spark", "uuid", "serde_json"]
1414
cashu = ["cdk", "serde_json"]
1515
_test-utils = ["corepc-node", "cashu", "uuid/v7", "rand"]
1616
_cashu-tests = ["_test-utils", "cdk-ldk-node", "cdk/mint", "cdk-sqlite", "cdk-axum", "axum"]
@@ -23,7 +23,7 @@ bitcoin-payment-instructions = { workspace = true }
2323
chrono = { version = "0.4", default-features = false }
2424
rand = { version = "0.8.5", optional = true }
2525
reqwest = { version = "0.12.23", default-features = false, features = ["rustls-tls"] }
26-
spark-wallet = { git = "https://github.com/breez/spark-sdk.git", rev = "6e12f98be3f100fca0411e3209a610decfa32279", default-features = false, features = ["rustls-tls"], optional = true }
26+
breez-sdk-spark = { git = "https://github.com/breez/spark-sdk.git", rev = "41212dfcfe36e22a55ac224c791b326f259f90d6", default-features = false, features = ["rustls-tls"], optional = true }
2727
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "sync"] }
2828
uuid = { version = "1.0", default-features = false, optional = true }
2929
cdk = { git = "https://github.com/benthecarman/cdk.git", rev = "7d25e9ae5ed7f47f9ae7e87d8a9ee16797fee8cd", default-features = false, features = ["wallet"], optional = true }

orange-sdk/src/ffi/spark.rs

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,18 @@
1-
use spark_wallet::Network as SparkNetwork;
2-
use spark_wallet::SparkWalletConfig as SparkSparkWalletConfig;
3-
4-
use crate::ffi::Network;
1+
use crate::SparkWalletConfig as OrangeSparkWalletConfig;
52
use crate::{impl_from_core_type, impl_into_core_type};
63

7-
impl From<SparkNetwork> for Network {
8-
fn from(network: SparkNetwork) -> Self {
9-
match network {
10-
SparkNetwork::Mainnet => Network::Mainnet,
11-
SparkNetwork::Regtest => Network::Regtest,
12-
SparkNetwork::Testnet => Network::Testnet,
13-
SparkNetwork::Signet => Network::Signet,
14-
}
15-
}
16-
}
17-
18-
impl From<Network> for SparkNetwork {
19-
fn from(network: Network) -> Self {
20-
match network {
21-
Network::Mainnet => SparkNetwork::Mainnet,
22-
Network::Regtest => SparkNetwork::Regtest,
23-
Network::Testnet => SparkNetwork::Testnet,
24-
Network::Signet => SparkNetwork::Signet,
25-
}
26-
}
27-
}
28-
294
#[derive(Clone, Debug, uniffi::Object)]
30-
pub struct SparkWalletConfig(pub SparkSparkWalletConfig);
5+
pub struct SparkWalletConfig(pub OrangeSparkWalletConfig);
316

327
// TODO: For now just support the default configuration.
338
// In the future we will want to expose all of the Spark configuration objects
349
#[uniffi::export]
3510
impl SparkWalletConfig {
3611
#[uniffi::constructor]
37-
pub fn default_config(network: Network) -> Self {
38-
SparkWalletConfig(SparkSparkWalletConfig::default_config(network.into()))
12+
pub fn default_config() -> Self {
13+
SparkWalletConfig(OrangeSparkWalletConfig::default())
3914
}
4015
}
4116

42-
impl_from_core_type!(SparkSparkWalletConfig, SparkWalletConfig);
43-
impl_into_core_type!(SparkWalletConfig, SparkSparkWalletConfig);
17+
impl_from_core_type!(OrangeSparkWalletConfig, SparkWalletConfig);
18+
impl_into_core_type!(SparkWalletConfig, OrangeSparkWalletConfig);

orange-sdk/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ use trusted_wallet::TrustedError;
6565

6666
#[cfg(feature = "cashu")]
6767
pub use crate::trusted_wallet::cashu::CashuConfig;
68+
#[cfg(feature = "spark")]
69+
pub use crate::trusted_wallet::spark::SparkWalletConfig;
6870
pub use bitcoin_payment_instructions;
6971
#[cfg(feature = "cashu")]
7072
pub use cdk::nuts::nut00::CurrencyUnit;
7173
pub use event::{Event, EventQueue};
7274
pub use ldk_node::bip39::Mnemonic;
7375
pub use ldk_node::bitcoin;
7476
pub use ldk_node::payment::ConfirmationStatus;
75-
#[cfg(feature = "spark")]
76-
pub use spark_wallet::{OperatorPoolConfig, ServiceProviderConfig, SparkWalletConfig};
7777
pub use store::{PaymentId, PaymentType, Transaction, TxStatus};
7878
pub use trusted_wallet::ExtraConfig;
7979

@@ -522,7 +522,7 @@ impl Wallet {
522522
ExtraConfig::Spark(sp) => Arc::new(Box::new(
523523
Spark::init(
524524
&config,
525-
sp.clone(),
525+
*sp,
526526
Arc::clone(&store),
527527
Arc::clone(&event_queue),
528528
tx_metadata.clone(),

0 commit comments

Comments
 (0)