Uh oh!
There was an error while loading. Please reload this page.
Break builder pattern to expose all setters via bindings - #88
Conversation
96a70ae to
e0cc6f8Compareacfcd7c to
0f1e7edComparetnull
commented
May 12, 2023
Rebased on main. |
0dbd449 to
070314fComparetnull
commented
May 18, 2023
Rebased on main after #70 has landed. We now also expose the RGS setter methods via bindings. Moreover, since we already have Additionally, we document the set defaults and switch our default config to |
070314f to
3b3a775Compare3b3a775 to
a9da44aComparea9da44a to
49baa90Comparetnull
commented
May 23, 2023
Rebased after #85 landed. |
cdefbe6 to
b5db6d0Compareb5db6d0 to
7a56598Comparetnull
commented
May 25, 2023
Rebased on main after #101 landed. |
7a56598 to
bb02755CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bb02755 to
b2afd61CompareI now included another commit that moves all UniFFI-specific types and trait impls to a dedicated module, which is now feature-gated behind the
However, I'll look into actually lowering the MSRV separately, as it may require downgrading UniFFI, and IIRC there was good reason why I had upgraded to 0.23.0 in the first place... |
Unfortunately there is no good way of exposing the builder pattern via Uniffi bindings currenlty. We therefore resort to internal mutability and using setters on the `Builder` object.
b2afd61 to
f6c4117Compare
jkczyz
left a comment
There was a problem hiding this comment.
Looks good minus a couple easy comments.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
f6c4117 to
1b4b47aCompareAfter we already have `EntropySourceConfig` and `GossipSourceConfig`, we here move the esplora server URL to a corresponding `enum ChainDataSourceConfig`, which will us to add further variants (e.g., `Electrum`) in the future without breaking the API. Additionally, we document the set default values.
As we're getting ready for release
While we need quite a bit of dependencies and custom impls for UniFFI support, there is no reason to pull them in for Rust-only builds. Here we move the UniFFI-specific types and trait impls to a dedicated module and hide it behind a new `uniffi` feature.
1b4b47a to
de94a54Comparetnull
commented
May 26, 2023
Updated the commits to address feedback and included: diff --git a/src/lib.rs b/src/lib.rs
index b9b75ca..3a0526f 100644
--- a/src/lib.rs+++ b/src/lib.rs@@ -375,22 +375,18 @@ impl Builder {
// Initialize the on-chain wallet and chain access
- let seed_bytes = if let Some(entropy_source_config) =- &*self.entropy_source_config.read().unwrap()- {- // Use the configured entropy source, if the user set one.- match entropy_source_config {- EntropySourceConfig::SeedBytes(bytes) => bytes.clone(),- EntropySourceConfig::SeedFile(seed_path) => {- io::utils::read_or_generate_seed_file(seed_path)- }- EntropySourceConfig::Bip39Mnemonic { mnemonic, passphrase } => match passphrase {- Some(passphrase) => mnemonic.to_seed(passphrase),- None => mnemonic.to_seed(""),- },+ let seed_bytes = match &*self.entropy_source_config.read().unwrap() {+ Some(EntropySourceConfig::SeedBytes(bytes)) => bytes.clone(),+ Some(EntropySourceConfig::SeedFile(seed_path)) => {+ io::utils::read_or_generate_seed_file(seed_path)+ }+ Some(EntropySourceConfig::Bip39Mnemonic { mnemonic, passphrase }) => match passphrase {+ Some(passphrase) => mnemonic.to_seed(passphrase),+ None => mnemonic.to_seed(""),+ },+ None => {+ // Default to read or generate from the default location generate a seed file.+ let seed_path = format!("{}/keys_seed", config.storage_dir_path);+ io::utils::read_or_generate_seed_file(&seed_path)
}
- } else {- // Default to read or generate from the default location generate a seed file.- let seed_path = format!("{}/keys_seed", config.storage_dir_path);- io::utils::read_or_generate_seed_file(&seed_path)
};
@@ -417,27 +413,22 @@ impl Builder {
.expect("Failed to set up on-chain wallet");
- let (blockchain, tx_sync) = if let Some(chain_data_source_config) =- &*self.chain_data_source_config.read().unwrap()- {- match chain_data_source_config {- ChainDataSourceConfig::Esplora(server_url) => {- let tx_sync =- Arc::new(EsploraSyncClient::new(server_url.clone(), Arc::clone(&logger)));- let blockchain = EsploraBlockchain::from_client(- tx_sync.client().clone(),- BDK_CLIENT_STOP_GAP,- )- .with_concurrency(BDK_CLIENT_CONCURRENCY);- (blockchain, tx_sync)- }+ let (blockchain, tx_sync) = match &*self.chain_data_source_config.read().unwrap() {+ Some(ChainDataSourceConfig::Esplora(server_url)) => {+ let tx_sync =+ Arc::new(EsploraSyncClient::new(server_url.clone(), Arc::clone(&logger)));+ let blockchain =+ EsploraBlockchain::from_client(tx_sync.client().clone(), BDK_CLIENT_STOP_GAP)+ .with_concurrency(BDK_CLIENT_CONCURRENCY);+ (blockchain, tx_sync)+ }+ None => {+ // Default to Esplora client.+ let server_url = DEFAULT_ESPLORA_SERVER_URL.to_string();+ let tx_sync = Arc::new(EsploraSyncClient::new(server_url, Arc::clone(&logger)));+ let blockchain =+ EsploraBlockchain::from_client(tx_sync.client().clone(), BDK_CLIENT_STOP_GAP)+ .with_concurrency(BDK_CLIENT_CONCURRENCY);+ (blockchain, tx_sync)
}
- } else {- // Default to Esplora client with blockstream endpoint.- let server_url = DEFAULT_ESPLORA_SERVER_URL.to_string();- let tx_sync = Arc::new(EsploraSyncClient::new(server_url, Arc::clone(&logger)));- let blockchain =- EsploraBlockchain::from_client(tx_sync.client().clone(), BDK_CLIENT_STOP_GAP)- .with_concurrency(BDK_CLIENT_CONCURRENCY);- (blockchain, tx_sync)
};
|
Add HMAC-based authentication for RPC/CLI
Closes#65
Unfortunately there is no good way of exposing the builder pattern via Uniffi bindings currently. We therefore resort to internal mutability and using setters on the
Builderobject.