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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ tsify-next = {version = "0.5.5", default-features = false}
# methods (plain `def` instead of `async def`). Fixed upstream in 0.30.0.
# Switch back to upstream once we upgrade to uniffi >= 0.30.
uniffi = { git = "https://github.com/breez/uniffi-rs", branch = "fix-python-async-protocol-v0.29.5" }
uuid = { version = "1.17.0", features = ["v7", "v4"] }
uuid = { version = "1.17.0", features = ["v7", "v5", "v4"] }
wasm-bindgen = "0.2.100"
wasm-bindgen-futures = "0.4.50"
wasm-bindgen-test = "0.3.50"
Expand Down
11 changes: 8 additions & 3 deletions crates/breez-sdk/bindings/examples/cli/langs/csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@
if (stableBalanceTokenIdentifier != null)
{
stableBalanceConfig = new StableBalanceConfig(
tokenIdentifier: stableBalanceTokenIdentifier,
tokens: new StableBalanceToken[] {
new StableBalanceToken(
label: "USDB",
tokenIdentifier: stableBalanceTokenIdentifier
)
},
defaultActiveLabel: "USDB",
thresholdSats: stableBalanceThreshold,
maxSlippageBps: null,
reservedSats: null
maxSlippageBps: null
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ Future<void> runCli({
if (stableBalanceTokenIdentifier != null) {
config = config.copyWith(
stableBalanceConfig: StableBalanceConfig(
tokenIdentifier: stableBalanceTokenIdentifier,
tokens: [StableBalanceToken(label: "USDB", tokenIdentifier: stableBalanceTokenIdentifier)],
defaultActiveLabel: "USDB",
thresholdSats: stableBalanceThreshold,
maxSlippageBps: null,
reservedSats: null,
),
);
}
Expand Down
6 changes: 5 additions & 1 deletion crates/breez-sdk/bindings/examples/cli/langs/golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ func main() {

// Stable balance config
if *stableBalanceTokenIdentifier != "" {
defaultActiveLabel := "USDB"
sbc := breez_sdk_spark.StableBalanceConfig{
TokenIdentifier: *stableBalanceTokenIdentifier,
Tokens: []breez_sdk_spark.StableBalanceToken{
{Label: "USDB", TokenIdentifier: *stableBalanceTokenIdentifier},
},
DefaultActiveLabel: &defaultActiveLabel,
}
if *stableBalanceThreshold > 0 {
sbc.ThresholdSats = stableBalanceThreshold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,13 @@ fun main(args: Array<String>) {
// Build stable balance config
val stableBalanceConfig = if (stableBalanceTokenIdentifier != null) {
StableBalanceConfig(
tokenIdentifier = stableBalanceTokenIdentifier,
tokens = listOf(StableBalanceToken(
label = "USDB",
tokenIdentifier = stableBalanceTokenIdentifier,
)),
defaultActiveLabel = "USDB",
thresholdSats = stableBalanceThreshold,
maxSlippageBps = null,
reservedSats = null,
)
} else null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SdkEvent,
Seed,
StableBalanceConfig,
StableBalanceToken,
default_config,
default_postgres_storage_config,
init_logging,
Expand Down Expand Up @@ -96,10 +97,10 @@ async def main(data_dir, network, account_number, postgres_connection_string,

if stable_balance_token_identifier:
config.stable_balance_config = StableBalanceConfig(
token_identifier=stable_balance_token_identifier,
tokens=[StableBalanceToken(label="USDB", token_identifier=stable_balance_token_identifier)],
default_active_label="USDB",
threshold_sats=stable_balance_threshold,
max_slippage_bps=None,
reserved_sats=None,
)

if passkey_provider:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,13 @@ let breezApiKey: String? = {
config.apiKey = breezApiKey
if let tokenIdentifier = opts.stableBalanceTokenIdentifier {
config.stableBalanceConfig = StableBalanceConfig(
tokenIdentifier: tokenIdentifier,
tokens: [StableBalanceToken(
label: "USDB",
tokenIdentifier: tokenIdentifier
)],
defaultActiveLabel: "USDB",
thresholdSats: opts.stableBalanceThreshold,
maxSlippageBps: nil,
reservedSats: nil
maxSlippageBps: nil
)
}

Expand Down
41 changes: 18 additions & 23 deletions crates/breez-sdk/breez-itest/src/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod docker;
pub mod lnurl;

use anyhow::Result;
use breez_sdk_spark::{MaxFee, Network, StableBalanceConfig, default_config};
use breez_sdk_spark::{MaxFee, Network, StableBalanceConfig, StableBalanceToken, default_config};
use rand::RngCore;
use rstest::fixture;
use tempdir::TempDir;
Expand All @@ -13,6 +13,12 @@ use crate::{
SdkInstance, build_sdk_with_custom_config, build_sdk_with_dir, build_sdk_with_external_signer,
};

/// Token identifiers for regtest
pub const BEAN_REGTEST_TOKEN_ID: &str =
"btknrt1muwlm2aeur2jhe4pkuh7v08jjaleqgeu69c5sk7p7qfhkywg7nkqerzl06";
pub const SHELL_REGTEST_TOKEN_ID: &str =
"btknrt1ra8lrwpqgqfz7gcy3gfcucaw3fh62tp3d6qkjxafx0cnxm5gmd3q0xy27c";

/// Fixture: Alice's SDK with temporary storage
#[fixture]
pub async fn alice_sdk() -> Result<SdkInstance> {
Expand Down Expand Up @@ -101,30 +107,19 @@ pub async fn alice_sdk_stable_balance() -> Result<SdkInstance> {

let mut cfg = default_config(Network::Regtest);
cfg.stable_balance_config = Some(StableBalanceConfig {
token_identifier: "btknrt1ra8lrwpqgqfz7gcy3gfcucaw3fh62tp3d6qkjxafx0cnxm5gmd3q0xy27c"
.to_string(),
threshold_sats: Some(1000),
max_slippage_bps: Some(500),
reserved_sats: None,
});
build_sdk_with_custom_config(path, seed, cfg, Some(alice_dir), true).await
}

/// Fixture: Alice's SDK with stable balance config and explicit reserved sats
#[fixture]
pub async fn alice_sdk_stable_balance_with_reserve() -> Result<SdkInstance> {
let alice_dir = TempDir::new("breez-sdk-alice-stable-balance-reserve")?;
let path = alice_dir.path().to_string_lossy().to_string();
let mut seed = [0u8; 32];
rand::thread_rng().fill_bytes(&mut seed);

let mut cfg = default_config(Network::Regtest);
cfg.stable_balance_config = Some(StableBalanceConfig {
token_identifier: "btknrt1ra8lrwpqgqfz7gcy3gfcucaw3fh62tp3d6qkjxafx0cnxm5gmd3q0xy27c"
.to_string(),
tokens: vec![
StableBalanceToken {
label: "SHELL".to_string(),
token_identifier: SHELL_REGTEST_TOKEN_ID.to_string(),
},
StableBalanceToken {
label: "BEAN".to_string(),
token_identifier: BEAN_REGTEST_TOKEN_ID.to_string(),
},
],
default_active_label: Some("SHELL".to_string()),
threshold_sats: Some(1000),
max_slippage_bps: Some(500),
reserved_sats: Some(2000),
});
build_sdk_with_custom_config(path, seed, cfg, Some(alice_dir), true).await
}
Loading
Loading