Skip to content

Commit

Permalink
docs: add API docs for electrum client
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Dec 18, 2024
1 parent ce0b4d4 commit c010c3c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -1054,29 +1054,76 @@ interface EsploraClient {
// bdk_electrum crate
// ------------------------------------------------------------------------

/// Wrapper around an electrum_client::ElectrumApi which includes an internal in-memory transaction
/// cache to avoid re-fetching already downloaded transactions.
interface ElectrumClient {
/// Creates a new bdk client from a electrum_client::ElectrumApi
[Throws=ElectrumError]
constructor(string url);

/// Full scan the keychain scripts specified with the blockchain (via an Electrum client) and
/// returns updates for bdk_chain data structures.
///
/// - `full_scan_request`: struct with data required to perform a spk-based blockchain client
/// full scan, see `FullScanRequest`.
/// - `stop_gap`: the full scan for each keychain stops after a gap of script pubkeys with no
/// associated transactions.
/// - `batch_size`: specifies the max number of script pubkeys to request for in a single batch
/// request.
/// - `fetch_prev_txouts`: specifies whether we want previous `TxOuts` for fee calculation. Note
/// that this requires additional calls to the Electrum server, but is necessary for
/// calculating the fee on a transaction if your wallet does not own the inputs. Methods like
/// `Wallet.calculate_fee` and `Wallet.calculate_fee_rate` will return a
/// `CalculateFeeError::MissingTxOut` error if those TxOuts are not present in the transaction
/// graph.
[Throws=ElectrumError]
Update full_scan(FullScanRequest full_scan_request, u64 stop_gap, u64 batch_size, boolean fetch_prev_txouts);

/// Sync a set of scripts with the blockchain (via an Electrum client) for the data specified and returns updates for bdk_chain data structures.
///
/// - `sync_request`: struct with data required to perform a spk-based blockchain client
/// sync, see `SyncRequest`.
/// - `batch_size`: specifies the max number of script pubkeys to request for in a single batch
/// request.
/// - `fetch_prev_txouts`: specifies whether we want previous `TxOuts` for fee calculation. Note
/// that this requires additional calls to the Electrum server, but is necessary for
/// calculating the fee on a transaction if your wallet does not own the inputs. Methods like
/// `Wallet.calculate_fee` and `Wallet.calculate_fee_rate` will return a
/// `CalculateFeeError::MissingTxOut` error if those TxOuts are not present in the transaction
/// graph.
///
/// If the scripts to sync are unknown, such as when restoring or importing a keychain that may
/// include scripts that have been used, use full_scan with the keychain.
[Throws=ElectrumError]
Update sync(SyncRequest sync_request, u64 batch_size, boolean fetch_prev_txouts);

/// Broadcasts a transaction to the network.
[Throws=ElectrumError]
string broadcast([ByRef] Transaction transaction);

/// Returns the capabilities of the server.
[Throws=ElectrumError]
ServerFeaturesRes server_features();
};

/// Response to an ElectrumClient.server_features request.
dictionary ServerFeaturesRes {
/// Server version reported.
string server_version;

/// Hash of the genesis block.
string genesis_hash;

/// Minimum supported version of the protocol.
string protocol_min;

/// Maximum supported version of the protocol.
string protocol_max;

/// Hash function used to create the `ScriptHash`.
string? hash_function;

/// Pruned height of the server.
i64? pruning;
};

Expand Down

0 comments on commit c010c3c

Please sign in to comment.