Skip to content

Commit

Permalink
fix: bring electrum/esplora APIs in line with Rust libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Jan 6, 2025
1 parent 6518846 commit 4960119
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -1035,10 +1035,10 @@ interface EsploraClient {
constructor(string url);

[Throws=EsploraError]
Update full_scan(FullScanRequest full_scan_request, u64 stop_gap, u64 parallel_requests);
Update full_scan(FullScanRequest request, u64 stop_gap, u64 parallel_requests);

[Throws=EsploraError]
Update sync(SyncRequest sync_request, u64 parallel_requests);
Update sync(SyncRequest request, u64 parallel_requests);

[Throws=EsploraError]
void broadcast([ByRef] Transaction transaction);
Expand All @@ -1064,7 +1064,7 @@ interface ElectrumClient {
/// 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
/// - `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.
Expand All @@ -1077,11 +1077,11 @@ interface ElectrumClient {
/// `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);
Update full_scan(FullScanRequest 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
/// - `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.
Expand All @@ -1095,11 +1095,11 @@ interface ElectrumClient {
/// 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);
Update sync(SyncRequest request, u64 batch_size, boolean fetch_prev_txouts);

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

/// Returns the capabilities of the server.
[Throws=ElectrumError]
Expand Down
4 changes: 2 additions & 2 deletions bdk-ffi/src/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ impl ElectrumClient {
Ok(Arc::new(Update(update)))
}

pub fn broadcast(&self, transaction: &Transaction) -> Result<String, ElectrumError> {
let bdk_transaction: BdkTransaction = transaction.into();
pub fn transaction_broadcast(&self, tx: &Transaction) -> Result<String, ElectrumError> {
let bdk_transaction: BdkTransaction = tx.into();
self.0
.transaction_broadcast(&bdk_transaction)
.map_err(ElectrumError::from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class LiveElectrumClientTests: XCTestCase {
let electrumClient: ElectrumClient = try ElectrumClient(url: SIGNET_ELECTRUM_URL)
let fullScanRequest: FullScanRequest = try wallet.startFullScan().build()
let update = try electrumClient.fullScan(
fullScanRequest: fullScanRequest,
request: fullScanRequest,
stopGap: 10,
batchSize: 10,
fetchPrevTxouts: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class LiveMemoryWalletTests: XCTestCase {
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
let fullScanRequest: FullScanRequest = try wallet.startFullScan().build()
let update = try esploraClient.fullScan(
fullScanRequest: fullScanRequest,
request: fullScanRequest,
stopGap: 10,
parallelRequests: 1
)
Expand Down Expand Up @@ -61,7 +61,7 @@ final class LiveMemoryWalletTests: XCTestCase {
let fullScanRequest = try wallet.startFullScan().inspectSpksForAllKeychains(inspector: scriptInspector).build()

let update = try esploraClient.fullScan(
fullScanRequest: fullScanRequest,
request: fullScanRequest,
stopGap: 21,
parallelRequests: 1
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class LiveTransactionTests: XCTestCase {
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
let fullScanRequest: FullScanRequest = try wallet.startFullScan().build()
let update = try esploraClient.fullScan(
fullScanRequest: fullScanRequest,
request: fullScanRequest,
stopGap: 10,
parallelRequests: 1
)
Expand Down
4 changes: 2 additions & 2 deletions bdk-swift/Tests/BitcoinDevKitTests/LiveTxBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class LiveTxBuilderTests: XCTestCase {
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
let fullScanRequest: FullScanRequest = try wallet.startFullScan().build()
let update = try esploraClient.fullScan(
fullScanRequest: fullScanRequest,
request: fullScanRequest,
stopGap: 10,
parallelRequests: 1
)
Expand Down Expand Up @@ -87,7 +87,7 @@ final class LiveTxBuilderTests: XCTestCase {
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
let fullScanRequest: FullScanRequest = try wallet.startFullScan().build()
let update = try esploraClient.fullScan(
fullScanRequest: fullScanRequest,
request: fullScanRequest,
stopGap: 10,
parallelRequests: 1
)
Expand Down
4 changes: 2 additions & 2 deletions bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class LiveWalletTests: XCTestCase {
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
let fullScanRequest: FullScanRequest = try wallet.startFullScan().build()
let update = try esploraClient.fullScan(
fullScanRequest: fullScanRequest,
request: fullScanRequest,
stopGap: 10,
parallelRequests: 1
)
Expand Down Expand Up @@ -79,7 +79,7 @@ final class LiveWalletTests: XCTestCase {
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
let fullScanRequest: FullScanRequest = try wallet.startFullScan().build()
let update = try esploraClient.fullScan(
fullScanRequest: fullScanRequest,
request: fullScanRequest,
stopGap: 10,
parallelRequests: 1
)
Expand Down

0 comments on commit 4960119

Please sign in to comment.