chore: bump rust bdk to alpha 10
This commit is contained in:
parent
7d951578d0
commit
19723240b7
35
bdk-ffi/Cargo.lock
generated
35
bdk-ffi/Cargo.lock
generated
@ -138,11 +138,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bdk"
|
name = "bdk"
|
||||||
version = "1.0.0-alpha.9"
|
version = "1.0.0-alpha.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ffe2761cc729d09bcaf88fe6e283ff5b5af0398c0eee855469295b59d6c6a9d"
|
checksum = "66fc0ebc2a63463f709cfdfbb7e7877b9975bcaea9d2d4f02f97ad012de37e3b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"bdk_chain",
|
"bdk_chain",
|
||||||
|
"bdk_persist",
|
||||||
"bip39",
|
"bip39",
|
||||||
"bitcoin",
|
"bitcoin",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
@ -162,16 +164,15 @@ dependencies = [
|
|||||||
"bdk_esplora",
|
"bdk_esplora",
|
||||||
"bdk_file_store",
|
"bdk_file_store",
|
||||||
"bitcoin-internals",
|
"bitcoin-internals",
|
||||||
"esplora-client",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"uniffi",
|
"uniffi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bdk_chain"
|
name = "bdk_chain"
|
||||||
version = "0.12.0"
|
version = "0.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4cd4e915470c6bb196a4c2515c6db3190dcdec482255d8f1022068646641cc8f"
|
checksum = "e879c03ebf3a64643295152a19a8b0e0a3af22e25539d2bc56ce07d07b059c33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitcoin",
|
"bitcoin",
|
||||||
"miniscript",
|
"miniscript",
|
||||||
@ -180,9 +181,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bdk_esplora"
|
name = "bdk_esplora"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7b5358eb90cbf99f7725ec5b1786e25a869cacba555f74f70cc4bf453921c34"
|
checksum = "b0aad9d99b103cd9c67ce1f4702720f2813db7aeba72abc9628ae9b00462a492"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bdk_chain",
|
"bdk_chain",
|
||||||
"esplora-client",
|
"esplora-client",
|
||||||
@ -190,15 +191,27 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bdk_file_store"
|
name = "bdk_file_store"
|
||||||
version = "0.9.0"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c19806b6b4e898e351e0bc2d8bd4cb96f7d8e2730c8b277e9e889c72dfb32de"
|
checksum = "492a011ee853773bce14f2d899fa34fe3ac3b5f39eeb1504d0d2b28de448bd73"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"bdk_chain",
|
"bdk_chain",
|
||||||
|
"bdk_persist",
|
||||||
"bincode",
|
"bincode",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bdk_persist"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f6f7d6b38071ee828329434f86799e0bb6aaa5a4256e225480c2c53b7b2df295"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"bdk_chain",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bech32"
|
name = "bech32"
|
||||||
version = "0.10.0-beta"
|
version = "0.10.0-beta"
|
||||||
@ -640,9 +653,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.21.11"
|
version = "0.21.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4"
|
checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"ring",
|
"ring",
|
||||||
|
@ -18,11 +18,9 @@ path = "uniffi-bindgen.rs"
|
|||||||
default = ["uniffi/cli"]
|
default = ["uniffi/cli"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bdk = { version = "1.0.0-alpha.9", features = ["all-keys", "keys-bip39"] }
|
bdk = { version = "1.0.0-alpha.10", features = ["all-keys", "keys-bip39"] }
|
||||||
bdk_esplora = { version = "0.11.0", default-features = false, features = ["std", "blocking"] }
|
bdk_esplora = { version = "0.12.0", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] }
|
||||||
esplora-client = { version = "0.7.0", default-features = false, features = ["blocking-https-rustls"] }
|
bdk_file_store = { version = "0.10.0" }
|
||||||
# bdk_esplora = { version = "0.10.0", default-features = false, features = ["std", "blocking", "async-https-rustls"] }
|
|
||||||
bdk_file_store = { version = "0.9.0" }
|
|
||||||
|
|
||||||
uniffi = { version = "=0.26.1" }
|
uniffi = { version = "=0.26.1" }
|
||||||
bitcoin-internals = { version = "0.2.0", features = ["alloc"] }
|
bitcoin-internals = { version = "0.2.0", features = ["alloc"] }
|
||||||
|
@ -180,10 +180,9 @@ interface WalletCreationError {
|
|||||||
Io(string error_message);
|
Io(string error_message);
|
||||||
InvalidMagicBytes(sequence<u8> got, sequence<u8> expected);
|
InvalidMagicBytes(sequence<u8> got, sequence<u8> expected);
|
||||||
Descriptor();
|
Descriptor();
|
||||||
Write();
|
Persist(string error_message);
|
||||||
Load();
|
|
||||||
NotInitialized();
|
NotInitialized();
|
||||||
LoadedGenesisDoesNotMatch();
|
LoadedGenesisDoesNotMatch(string expected, string got);
|
||||||
LoadedNetworkDoesNotMatch(Network expected, Network? got);
|
LoadedNetworkDoesNotMatch(Network expected, Network? got);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -202,13 +201,6 @@ dictionary AddressInfo {
|
|||||||
KeychainKind keychain;
|
KeychainKind keychain;
|
||||||
};
|
};
|
||||||
|
|
||||||
[Enum]
|
|
||||||
interface AddressIndex {
|
|
||||||
New();
|
|
||||||
LastUnused();
|
|
||||||
Peek(u32 index);
|
|
||||||
};
|
|
||||||
|
|
||||||
dictionary Balance {
|
dictionary Balance {
|
||||||
u64 immature;
|
u64 immature;
|
||||||
|
|
||||||
@ -260,10 +252,8 @@ interface Wallet {
|
|||||||
[Throws=WalletCreationError]
|
[Throws=WalletCreationError]
|
||||||
constructor(Descriptor descriptor, Descriptor? change_descriptor, string persistence_backend_path, Network network);
|
constructor(Descriptor descriptor, Descriptor? change_descriptor, string persistence_backend_path, Network network);
|
||||||
|
|
||||||
AddressInfo get_address(AddressIndex address_index);
|
|
||||||
|
|
||||||
[Throws=PersistenceError]
|
[Throws=PersistenceError]
|
||||||
AddressInfo try_get_internal_address(AddressIndex address_index);
|
AddressInfo reveal_next_address(KeychainKind keychain);
|
||||||
|
|
||||||
Network network();
|
Network network();
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ use crate::keys::DerivationPath;
|
|||||||
use crate::keys::DescriptorPublicKey;
|
use crate::keys::DescriptorPublicKey;
|
||||||
use crate::keys::DescriptorSecretKey;
|
use crate::keys::DescriptorSecretKey;
|
||||||
use crate::keys::Mnemonic;
|
use crate::keys::Mnemonic;
|
||||||
use crate::types::AddressIndex;
|
|
||||||
use crate::types::AddressInfo;
|
use crate::types::AddressInfo;
|
||||||
use crate::types::Balance;
|
use crate::types::Balance;
|
||||||
use crate::types::CanonicalTx;
|
use crate::types::CanonicalTx;
|
||||||
|
@ -63,53 +63,6 @@ impl From<BdkAddressInfo> for AddressInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum AddressIndex {
|
|
||||||
New,
|
|
||||||
LastUnused,
|
|
||||||
Peek { index: u32 },
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<AddressIndex> for BdkAddressIndex {
|
|
||||||
fn from(address_index: AddressIndex) -> Self {
|
|
||||||
match address_index {
|
|
||||||
AddressIndex::New => BdkAddressIndex::New,
|
|
||||||
AddressIndex::LastUnused => BdkAddressIndex::LastUnused,
|
|
||||||
AddressIndex::Peek { index } => BdkAddressIndex::Peek(index),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<BdkAddressIndex> for AddressIndex {
|
|
||||||
fn from(address_index: BdkAddressIndex) -> Self {
|
|
||||||
match address_index {
|
|
||||||
BdkAddressIndex::New => AddressIndex::New,
|
|
||||||
BdkAddressIndex::LastUnused => AddressIndex::LastUnused,
|
|
||||||
_ => panic!("Mmmm not working"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO 9: Peek is not correctly implemented
|
|
||||||
impl From<&AddressIndex> for BdkAddressIndex {
|
|
||||||
fn from(address_index: &AddressIndex) -> Self {
|
|
||||||
match address_index {
|
|
||||||
AddressIndex::New => BdkAddressIndex::New,
|
|
||||||
AddressIndex::LastUnused => BdkAddressIndex::LastUnused,
|
|
||||||
AddressIndex::Peek { index } => BdkAddressIndex::Peek(*index),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&BdkAddressIndex> for AddressIndex {
|
|
||||||
fn from(address_index: &BdkAddressIndex) -> Self {
|
|
||||||
match address_index {
|
|
||||||
BdkAddressIndex::New => AddressIndex::New,
|
|
||||||
BdkAddressIndex::LastUnused => AddressIndex::LastUnused,
|
|
||||||
_ => panic!("Mmmm not working"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Balance {
|
pub struct Balance {
|
||||||
pub immature: u64,
|
pub immature: u64,
|
||||||
pub trusted_pending: u64,
|
pub trusted_pending: u64,
|
||||||
|
@ -12,8 +12,8 @@ use bdk::bitcoin::Psbt as BdkPsbt;
|
|||||||
use bdk::bitcoin::{OutPoint as BdkOutPoint, Sequence, Txid};
|
use bdk::bitcoin::{OutPoint as BdkOutPoint, Sequence, Txid};
|
||||||
use bdk::wallet::tx_builder::ChangeSpendPolicy;
|
use bdk::wallet::tx_builder::ChangeSpendPolicy;
|
||||||
use bdk::wallet::{ChangeSet, Update as BdkUpdate};
|
use bdk::wallet::{ChangeSet, Update as BdkUpdate};
|
||||||
use bdk::SignOptions;
|
|
||||||
use bdk::Wallet as BdkWallet;
|
use bdk::Wallet as BdkWallet;
|
||||||
|
use bdk::{KeychainKind, SignOptions};
|
||||||
use bdk_file_store::Store;
|
use bdk_file_store::Store;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
@ -23,7 +23,7 @@ use std::sync::{Arc, Mutex, MutexGuard};
|
|||||||
const MAGIC_BYTES: &[u8] = "bdkffi".as_bytes();
|
const MAGIC_BYTES: &[u8] = "bdkffi".as_bytes();
|
||||||
|
|
||||||
pub struct Wallet {
|
pub struct Wallet {
|
||||||
inner_mutex: Mutex<BdkWallet<Store<ChangeSet>>>,
|
inner_mutex: Mutex<BdkWallet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Wallet {
|
impl Wallet {
|
||||||
@ -37,7 +37,7 @@ impl Wallet {
|
|||||||
let change_descriptor = change_descriptor.map(|d| d.as_string_private());
|
let change_descriptor = change_descriptor.map(|d| d.as_string_private());
|
||||||
let db = Store::<ChangeSet>::open_or_create_new(MAGIC_BYTES, persistence_backend_path)?;
|
let db = Store::<ChangeSet>::open_or_create_new(MAGIC_BYTES, persistence_backend_path)?;
|
||||||
|
|
||||||
let wallet: bdk::wallet::Wallet<Store<ChangeSet>> =
|
let wallet: BdkWallet =
|
||||||
BdkWallet::new_or_load(&descriptor, change_descriptor.as_ref(), db, network)?;
|
BdkWallet::new_or_load(&descriptor, change_descriptor.as_ref(), db, network)?;
|
||||||
|
|
||||||
Ok(Wallet {
|
Ok(Wallet {
|
||||||
@ -45,15 +45,20 @@ impl Wallet {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_wallet(&self) -> MutexGuard<BdkWallet<Store<ChangeSet>>> {
|
pub(crate) fn get_wallet(&self) -> MutexGuard<BdkWallet> {
|
||||||
self.inner_mutex.lock().expect("wallet")
|
self.inner_mutex.lock().expect("wallet")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_address(&self, address_index: AddressIndex) -> AddressInfo {
|
pub fn reveal_next_address(
|
||||||
|
&self,
|
||||||
|
keychain_kind: KeychainKind,
|
||||||
|
) -> Result<AddressInfo, PersistenceError> {
|
||||||
self.get_wallet()
|
self.get_wallet()
|
||||||
.try_get_address(address_index.into())
|
.reveal_next_address(keychain_kind)
|
||||||
.unwrap()
|
.map(|address_info| address_info.into())
|
||||||
.into()
|
.map_err(|e| PersistenceError::Write {
|
||||||
|
error_message: e.to_string(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_update(&self, update: Arc<Update>) -> Result<(), CannotConnectError> {
|
pub fn apply_update(&self, update: Arc<Update>) -> Result<(), CannotConnectError> {
|
||||||
@ -64,16 +69,16 @@ impl Wallet {
|
|||||||
|
|
||||||
// TODO: This is the fallible version of get_internal_address; should I rename it to get_internal_address?
|
// TODO: This is the fallible version of get_internal_address; should I rename it to get_internal_address?
|
||||||
// It's a slight change of the API, the other option is to rename the get_address to try_get_address
|
// It's a slight change of the API, the other option is to rename the get_address to try_get_address
|
||||||
pub fn try_get_internal_address(
|
// pub fn try_get_internal_address(
|
||||||
&self,
|
// &self,
|
||||||
address_index: AddressIndex,
|
// address_index: AddressIndex,
|
||||||
) -> Result<AddressInfo, PersistenceError> {
|
// ) -> Result<AddressInfo, PersistenceError> {
|
||||||
let address_info = self
|
// let address_info = self
|
||||||
.get_wallet()
|
// .get_wallet()
|
||||||
.try_get_internal_address(address_index.into())?
|
// .try_get_internal_address(address_index.into())?
|
||||||
.into();
|
// .into();
|
||||||
Ok(address_info)
|
// Ok(address_info)
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn network(&self) -> Network {
|
pub fn network(&self) -> Network {
|
||||||
self.get_wallet().network()
|
self.get_wallet().network()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user