Add address index to return type of get_last_unused_address
This commit is contained in:
parent
ff260edb3c
commit
c074a92e0c
@ -49,6 +49,11 @@ enum BdkError {
|
|||||||
"Rusqlite",
|
"Rusqlite",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dictionary AddressInformation {
|
||||||
|
u32 index;
|
||||||
|
string address;
|
||||||
|
};
|
||||||
|
|
||||||
enum Network {
|
enum Network {
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
"Testnet",
|
"Testnet",
|
||||||
@ -127,7 +132,7 @@ interface Wallet {
|
|||||||
[Throws=BdkError]
|
[Throws=BdkError]
|
||||||
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config);
|
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config);
|
||||||
string get_new_address();
|
string get_new_address();
|
||||||
string get_last_unused_address();
|
AddressInformation get_last_unused_address();
|
||||||
[Throws=BdkError]
|
[Throws=BdkError]
|
||||||
u64 get_balance();
|
u64 get_balance();
|
||||||
[Throws=BdkError]
|
[Throws=BdkError]
|
||||||
|
26
src/lib.rs
26
src/lib.rs
@ -13,6 +13,7 @@ use bdk::keys::bip39::{Language, Mnemonic, WordCount};
|
|||||||
use bdk::keys::{DerivableKey, ExtendedKey, GeneratableKey, GeneratedKey};
|
use bdk::keys::{DerivableKey, ExtendedKey, GeneratableKey, GeneratedKey};
|
||||||
use bdk::miniscript::BareCtx;
|
use bdk::miniscript::BareCtx;
|
||||||
use bdk::wallet::AddressIndex;
|
use bdk::wallet::AddressIndex;
|
||||||
|
use bdk::wallet::AddressInfo;
|
||||||
use bdk::{
|
use bdk::{
|
||||||
BlockTime, Error, FeeRate, SignOptions, SyncOptions as BdkSyncOptions, Wallet as BdkWallet,
|
BlockTime, Error, FeeRate, SignOptions, SyncOptions as BdkSyncOptions, Wallet as BdkWallet,
|
||||||
};
|
};
|
||||||
@ -26,6 +27,11 @@ uniffi_macros::include_scaffolding!("bdk");
|
|||||||
|
|
||||||
type BdkError = Error;
|
type BdkError = Error;
|
||||||
|
|
||||||
|
pub struct AddressInformation {
|
||||||
|
pub index: u32,
|
||||||
|
pub address: String,
|
||||||
|
}
|
||||||
|
|
||||||
pub enum DatabaseConfig {
|
pub enum DatabaseConfig {
|
||||||
Memory,
|
Memory,
|
||||||
Sled { config: SledDbConfiguration },
|
Sled { config: SledDbConfiguration },
|
||||||
@ -243,12 +249,22 @@ impl Wallet {
|
|||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_last_unused_address(&self) -> String {
|
// fn get_last_unused_address(&self) -> String {
|
||||||
self.get_wallet()
|
// self.get_wallet()
|
||||||
|
// .get_address(AddressIndex::LastUnused)
|
||||||
|
// .unwrap()
|
||||||
|
// .address
|
||||||
|
// .to_string()
|
||||||
|
// }
|
||||||
|
|
||||||
|
fn get_last_unused_address(&self) -> AddressInformation {
|
||||||
|
let address_info = self.get_wallet()
|
||||||
.get_address(AddressIndex::LastUnused)
|
.get_address(AddressIndex::LastUnused)
|
||||||
.unwrap()
|
.unwrap();
|
||||||
.address
|
return AddressInformation {
|
||||||
.to_string()
|
index: address_info.index,
|
||||||
|
address: address_info.address.to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_balance(&self) -> Result<u64, Error> {
|
fn get_balance(&self) -> Result<u64, Error> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user