Revert "Remove callback interface"
This reverts commit f04c1f7fa8c821a50e36210a99e892d96bcdbf92.
This commit is contained in:
parent
f5be0fae3d
commit
95074b4834
@ -120,6 +120,10 @@ interface BlockchainConfig {
|
||||
Esplora(EsploraConfig config);
|
||||
};
|
||||
|
||||
callback interface BdkProgress {
|
||||
void update(f32 progress, string? message);
|
||||
};
|
||||
|
||||
interface OnlineWallet {
|
||||
[Throws=BdkError]
|
||||
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config, BlockchainConfig blockchain_config);
|
||||
@ -136,7 +140,7 @@ interface OnlineWallet {
|
||||
// OnlineWalletInterface
|
||||
Network get_network();
|
||||
[Throws=BdkError]
|
||||
void sync(u32? max_address_param);
|
||||
void sync(BdkProgress progress_update, u32? max_address_param);
|
||||
[Throws=BdkError]
|
||||
string broadcast([ByRef] PartiallySignedBitcoinTransaction psbt);
|
||||
};
|
||||
|
16
src/lib.rs
16
src/lib.rs
@ -154,10 +154,13 @@ pub trait BdkProgress: Send + Sync {
|
||||
fn update(&self, progress: f32, message: Option<String>);
|
||||
}
|
||||
|
||||
struct BdkProgressHolder {}
|
||||
struct BdkProgressHolder {
|
||||
progress_update: Box<dyn BdkProgress>,
|
||||
}
|
||||
|
||||
impl Progress for BdkProgressHolder {
|
||||
fn update(&self, _progress: f32, _message: Option<String>) -> Result<(), Error> {
|
||||
fn update(&self, progress: f32, message: Option<String>) -> Result<(), Error> {
|
||||
self.progress_update.update(progress, message);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -235,11 +238,16 @@ impl OnlineWallet {
|
||||
self.wallet.lock().unwrap().network()
|
||||
}
|
||||
|
||||
fn sync(&self, max_address_param: Option<u32>) -> Result<(), BdkError> {
|
||||
fn sync(
|
||||
&self,
|
||||
progress_update: Box<dyn BdkProgress>,
|
||||
max_address_param: Option<u32>,
|
||||
) -> Result<(), BdkError> {
|
||||
progress_update.update(21.0, Some("message".to_string()));
|
||||
self.wallet
|
||||
.lock()
|
||||
.unwrap()
|
||||
.sync(BdkProgressHolder {}, max_address_param)
|
||||
.sync(BdkProgressHolder { progress_update }, max_address_param)
|
||||
}
|
||||
|
||||
fn broadcast<'a>(&self, psbt: &'a PartiallySignedBitcoinTransaction) -> Result<String, Error> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user