Skip to content

Commit c96d010

Browse files
refactor: migrate EsploraClient type to procedural macros
1 parent 8313460 commit c96d010

File tree

3 files changed

+3
-60
lines changed

3 files changed

+3
-60
lines changed

bdk-ffi/src/bdk.udl

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -622,65 +622,6 @@ interface Descriptor {
622622
sequence<Descriptor> to_single_descriptors();
623623
};
624624

625-
// ------------------------------------------------------------------------
626-
// bdk_esplora crate
627-
// ------------------------------------------------------------------------
628-
629-
/// Wrapper around an esplora_client::BlockingClient which includes an internal in-memory transaction
630-
/// cache to avoid re-fetching already downloaded transactions.
631-
interface EsploraClient {
632-
/// Creates a new bdk client from a esplora_client::BlockingClient
633-
/// Optional: Set the proxy of the builder
634-
constructor(string url, optional string? proxy = null);
635-
636-
/// Scan keychain scripts for transactions against Esplora, returning an update that can be
637-
/// applied to the receiving structures.
638-
///
639-
/// `request` provides the data required to perform a script-pubkey-based full scan
640-
/// (see [`FullScanRequest`]). The full scan for each keychain (`K`) stops after a gap of
641-
/// `stop_gap` script pubkeys with no associated transactions. `parallel_requests` specifies
642-
/// the maximum number of HTTP requests to make in parallel.
643-
[Throws=EsploraError]
644-
Update full_scan(FullScanRequest request, u64 stop_gap, u64 parallel_requests);
645-
646-
/// Sync a set of scripts, txids, and/or outpoints against Esplora.
647-
///
648-
/// `request` provides the data required to perform a script-pubkey-based sync (see
649-
/// [`SyncRequest`]). `parallel_requests` specifies the maximum number of HTTP requests to make
650-
/// in parallel.
651-
[Throws=EsploraError]
652-
Update sync(SyncRequest request, u64 parallel_requests);
653-
654-
/// Broadcast a [`Transaction`] to Esplora.
655-
[Throws=EsploraError]
656-
void broadcast([ByRef] Transaction transaction);
657-
658-
/// Get a [`Transaction`] option given its [`Txid`].
659-
[Throws=EsploraError]
660-
Transaction? get_tx(string txid);
661-
662-
/// Get the height of the current blockchain tip.
663-
[Throws=EsploraError]
664-
u32 get_height();
665-
666-
/// Get a map where the key is the confirmation target (in number of
667-
/// blocks) and the value is the estimated feerate (in sat/vB).
668-
[Throws=EsploraError]
669-
record<u16, f64> get_fee_estimates();
670-
671-
/// Get the [`BlockHash`] of a specific block height
672-
[Throws=EsploraError]
673-
string get_block_hash(u32 block_height);
674-
675-
/// Get the status of a [`Transaction`] given its [`Txid`].
676-
[Throws=EsploraError]
677-
TxStatus get_tx_status(string txid);
678-
679-
/// Get transaction info given it's [`Txid`].
680-
[Throws=EsploraError]
681-
Tx? get_tx_info(string txid);
682-
};
683-
684625
// ------------------------------------------------------------------------
685626
// bdk_electrum crate
686627
// ------------------------------------------------------------------------

bdk-ffi/src/esplora.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ use std::sync::Arc;
2222

2323
/// Wrapper around an esplora_client::BlockingClient which includes an internal in-memory transaction
2424
/// cache to avoid re-fetching already downloaded transactions.
25+
#[derive(uniffi::Object)]
2526
pub struct EsploraClient(BlockingClient);
2627

28+
#[uniffi::export]
2729
impl EsploraClient {
2830
/// Creates a new bdk client from an esplora_client::BlockingClient.
2931
/// Optional: Set the proxy of the builder.
32+
#[uniffi::constructor(default(proxy = None))]
3033
pub fn new(url: String, proxy: Option<String>) -> Self {
3134
let mut builder = Builder::new(url.as_str());
3235
if let Some(proxy) = proxy {

bdk-ffi/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use crate::error::PsbtFinalizeError;
4444
use crate::error::PsbtParseError;
4545
use crate::error::RequestBuilderError;
4646
use crate::error::TransactionError;
47-
use crate::esplora::EsploraClient;
4847
use crate::keys::DerivationPath;
4948
use crate::keys::DescriptorPublicKey;
5049
use crate::keys::DescriptorSecretKey;

0 commit comments

Comments
 (0)