Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing Wallet APIs related to revealing and querying the wallet for addresses and indices #599

Merged
12 changes: 12 additions & 0 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,18 @@ interface Wallet {

AddressInfo reveal_next_address(KeychainKind keychain);

AddressInfo peek_address(KeychainKind keychain, u32 index);

u32 next_derivation_index(KeychainKind keychain);

AddressInfo next_unused_address(KeychainKind keychain);

boolean mark_used(KeychainKind keychain, u32 index);

sequence<AddressInfo> reveal_addresses_to(KeychainKind keychain, u32 index);

sequence<AddressInfo> list_unused_addresses(KeychainKind keychain);

Network network();

Balance balance();
Expand Down
34 changes: 32 additions & 2 deletions bdk-ffi/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,38 @@ impl Wallet {
self.inner_mutex.lock().expect("wallet")
}

pub fn reveal_next_address(&self, keychain_kind: KeychainKind) -> AddressInfo {
self.get_wallet().reveal_next_address(keychain_kind).into()
pub fn reveal_next_address(&self, keychain: KeychainKind) -> AddressInfo {
self.get_wallet().reveal_next_address(keychain).into()
}

pub fn peek_address(&self, keychain: KeychainKind, index: u32) -> AddressInfo {
self.get_wallet().peek_address(keychain, index).into()
}

pub fn next_derivation_index(&self, keychain: KeychainKind) -> u32 {
self.get_wallet().next_derivation_index(keychain)
}

pub fn next_unused_address(&self, keychain: KeychainKind) -> AddressInfo {
self.get_wallet().next_unused_address(keychain).into()
}

pub fn mark_used(&self, keychain: KeychainKind, index: u32) -> bool {
self.get_wallet().mark_used(keychain, index)
}

pub fn reveal_addresses_to(&self, keychain: KeychainKind, index: u32) -> Vec<AddressInfo> {
self.get_wallet()
.reveal_addresses_to(keychain, index)
.map(|address_info| address_info.into())
.collect()
}

pub fn list_unused_addresses(&self, keychain: KeychainKind) -> Vec<AddressInfo> {
self.get_wallet()
.list_unused_addresses(keychain)
.map(|address_info| address_info.into())
.collect()
}

pub fn apply_update(&self, update: Arc<Update>) -> Result<(), CannotConnectError> {
Expand Down
Loading