chore: bump rust bdk to alpha 10

This commit is contained in:
thunderbiscuit 2024-05-05 20:00:44 -04:00
parent 7d951578d0
commit 19723240b7
No known key found for this signature in database
GPG Key ID: 88253696EB836462
6 changed files with 53 additions and 95 deletions

35
bdk-ffi/Cargo.lock generated
View File

@ -138,11 +138,13 @@ dependencies = [
[[package]]
name = "bdk"
version = "1.0.0-alpha.9"
version = "1.0.0-alpha.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ffe2761cc729d09bcaf88fe6e283ff5b5af0398c0eee855469295b59d6c6a9d"
checksum = "66fc0ebc2a63463f709cfdfbb7e7877b9975bcaea9d2d4f02f97ad012de37e3b"
dependencies = [
"anyhow",
"bdk_chain",
"bdk_persist",
"bip39",
"bitcoin",
"getrandom",
@ -162,16 +164,15 @@ dependencies = [
"bdk_esplora",
"bdk_file_store",
"bitcoin-internals",
"esplora-client",
"thiserror",
"uniffi",
]
[[package]]
name = "bdk_chain"
version = "0.12.0"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd4e915470c6bb196a4c2515c6db3190dcdec482255d8f1022068646641cc8f"
checksum = "e879c03ebf3a64643295152a19a8b0e0a3af22e25539d2bc56ce07d07b059c33"
dependencies = [
"bitcoin",
"miniscript",
@ -180,9 +181,9 @@ dependencies = [
[[package]]
name = "bdk_esplora"
version = "0.11.0"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7b5358eb90cbf99f7725ec5b1786e25a869cacba555f74f70cc4bf453921c34"
checksum = "b0aad9d99b103cd9c67ce1f4702720f2813db7aeba72abc9628ae9b00462a492"
dependencies = [
"bdk_chain",
"esplora-client",
@ -190,15 +191,27 @@ dependencies = [
[[package]]
name = "bdk_file_store"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c19806b6b4e898e351e0bc2d8bd4cb96f7d8e2730c8b277e9e889c72dfb32de"
checksum = "492a011ee853773bce14f2d899fa34fe3ac3b5f39eeb1504d0d2b28de448bd73"
dependencies = [
"anyhow",
"bdk_chain",
"bdk_persist",
"bincode",
"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]]
name = "bech32"
version = "0.10.0-beta"
@ -640,9 +653,9 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.21.11"
version = "0.21.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4"
checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
dependencies = [
"log",
"ring",

View File

@ -18,11 +18,9 @@ path = "uniffi-bindgen.rs"
default = ["uniffi/cli"]
[dependencies]
bdk = { version = "1.0.0-alpha.9", features = ["all-keys", "keys-bip39"] }
bdk_esplora = { version = "0.11.0", default-features = false, features = ["std", "blocking"] }
esplora-client = { version = "0.7.0", default-features = false, features = ["blocking-https-rustls"] }
# bdk_esplora = { version = "0.10.0", default-features = false, features = ["std", "blocking", "async-https-rustls"] }
bdk_file_store = { version = "0.9.0" }
bdk = { version = "1.0.0-alpha.10", features = ["all-keys", "keys-bip39"] }
bdk_esplora = { version = "0.12.0", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] }
bdk_file_store = { version = "0.10.0" }
uniffi = { version = "=0.26.1" }
bitcoin-internals = { version = "0.2.0", features = ["alloc"] }

View File

@ -180,10 +180,9 @@ interface WalletCreationError {
Io(string error_message);
InvalidMagicBytes(sequence<u8> got, sequence<u8> expected);
Descriptor();
Write();
Load();
Persist(string error_message);
NotInitialized();
LoadedGenesisDoesNotMatch();
LoadedGenesisDoesNotMatch(string expected, string got);
LoadedNetworkDoesNotMatch(Network expected, Network? got);
};
@ -202,13 +201,6 @@ dictionary AddressInfo {
KeychainKind keychain;
};
[Enum]
interface AddressIndex {
New();
LastUnused();
Peek(u32 index);
};
dictionary Balance {
u64 immature;
@ -260,10 +252,8 @@ interface Wallet {
[Throws=WalletCreationError]
constructor(Descriptor descriptor, Descriptor? change_descriptor, string persistence_backend_path, Network network);
AddressInfo get_address(AddressIndex address_index);
[Throws=PersistenceError]
AddressInfo try_get_internal_address(AddressIndex address_index);
AddressInfo reveal_next_address(KeychainKind keychain);
Network network();

View File

@ -36,7 +36,6 @@ use crate::keys::DerivationPath;
use crate::keys::DescriptorPublicKey;
use crate::keys::DescriptorSecretKey;
use crate::keys::Mnemonic;
use crate::types::AddressIndex;
use crate::types::AddressInfo;
use crate::types::Balance;
use crate::types::CanonicalTx;

View File

@ -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 immature: u64,
pub trusted_pending: u64,

View File

@ -12,8 +12,8 @@ use bdk::bitcoin::Psbt as BdkPsbt;
use bdk::bitcoin::{OutPoint as BdkOutPoint, Sequence, Txid};
use bdk::wallet::tx_builder::ChangeSpendPolicy;
use bdk::wallet::{ChangeSet, Update as BdkUpdate};
use bdk::SignOptions;
use bdk::Wallet as BdkWallet;
use bdk::{KeychainKind, SignOptions};
use bdk_file_store::Store;
use std::collections::HashSet;
@ -23,7 +23,7 @@ use std::sync::{Arc, Mutex, MutexGuard};
const MAGIC_BYTES: &[u8] = "bdkffi".as_bytes();
pub struct Wallet {
inner_mutex: Mutex<BdkWallet<Store<ChangeSet>>>,
inner_mutex: Mutex<BdkWallet>,
}
impl Wallet {
@ -37,7 +37,7 @@ impl Wallet {
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 wallet: bdk::wallet::Wallet<Store<ChangeSet>> =
let wallet: BdkWallet =
BdkWallet::new_or_load(&descriptor, change_descriptor.as_ref(), db, network)?;
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")
}
pub fn get_address(&self, address_index: AddressIndex) -> AddressInfo {
pub fn reveal_next_address(
&self,
keychain_kind: KeychainKind,
) -> Result<AddressInfo, PersistenceError> {
self.get_wallet()
.try_get_address(address_index.into())
.unwrap()
.into()
.reveal_next_address(keychain_kind)
.map(|address_info| address_info.into())
.map_err(|e| PersistenceError::Write {
error_message: e.to_string(),
})
}
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?
// 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(
&self,
address_index: AddressIndex,
) -> Result<AddressInfo, PersistenceError> {
let address_info = self
.get_wallet()
.try_get_internal_address(address_index.into())?
.into();
Ok(address_info)
}
// pub fn try_get_internal_address(
// &self,
// address_index: AddressIndex,
// ) -> Result<AddressInfo, PersistenceError> {
// let address_info = self
// .get_wallet()
// .try_get_internal_address(address_index.into())?
// .into();
// Ok(address_info)
// }
pub fn network(&self) -> Network {
self.get_wallet().network()