Revert "Remove callback interface"
This reverts commit 4ad9b89e2591dccf36b48512a4caa3ce343e3ec5.
This commit is contained in:
parent
ef73e38154
commit
9681f30e19
@ -120,6 +120,10 @@ interface BlockchainConfig {
|
|||||||
Esplora(EsploraConfig config);
|
Esplora(EsploraConfig config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
callback interface BdkProgress {
|
||||||
|
void update(f32 progress, string? message);
|
||||||
|
};
|
||||||
|
|
||||||
interface OnlineWallet {
|
interface OnlineWallet {
|
||||||
[Throws=BdkError]
|
[Throws=BdkError]
|
||||||
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config, BlockchainConfig blockchain_config);
|
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config, BlockchainConfig blockchain_config);
|
||||||
@ -136,7 +140,7 @@ interface OnlineWallet {
|
|||||||
// OnlineWalletInterface
|
// OnlineWalletInterface
|
||||||
Network get_network();
|
Network get_network();
|
||||||
[Throws=BdkError]
|
[Throws=BdkError]
|
||||||
void sync(u32? max_address_param);
|
void sync(BdkProgress progress_update, u32? max_address_param);
|
||||||
[Throws=BdkError]
|
[Throws=BdkError]
|
||||||
string broadcast([ByRef] PartiallySignedBitcoinTransaction psbt);
|
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>);
|
fn update(&self, progress: f32, message: Option<String>);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BdkProgressHolder {}
|
struct BdkProgressHolder {
|
||||||
|
progress_update: Box<dyn BdkProgress>,
|
||||||
|
}
|
||||||
|
|
||||||
impl Progress for BdkProgressHolder {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,11 +238,16 @@ impl OnlineWallet {
|
|||||||
self.wallet.lock().unwrap().network()
|
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
|
self.wallet
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.sync(BdkProgressHolder {}, max_address_param)
|
.sync(BdkProgressHolder { progress_update }, max_address_param)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn broadcast<'a>(&self, psbt: &'a PartiallySignedBitcoinTransaction) -> Result<String, Error> {
|
fn broadcast<'a>(&self, psbt: &'a PartiallySignedBitcoinTransaction) -> Result<String, Error> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user