Skip to content

Commit ab4fdde

Browse files
committed
feat(client): add get_mempool_scripthash_txs method
1 parent b24fe96 commit ab4fdde

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/async.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,14 @@ impl<S: Sleeper> AsyncClient<S> {
444444
self.get_response_json(&path).await
445445
}
446446

447+
/// Get mempool [`Transaction`] history for the
448+
/// specified [`Script`] hash, sorted with newest first.
449+
pub async fn get_mempool_scripthash_txs(&self, script: &Script) -> Result<Vec<Tx>, Error> {
450+
let script_hash = sha256::Hash::hash(script.as_bytes());
451+
let path = format!("/scripthash/{script_hash:x}/txs/mempool");
452+
453+
self.get_response_json(&path).await
454+
}
447455
/// Get an map where the key is the confirmation target (in number of
448456
/// blocks) and the value is the estimated feerate (in sat/vB).
449457
pub async fn get_fee_estimates(&self) -> Result<HashMap<u16, f64>, Error> {

src/blocking.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,14 @@ impl BlockingClient {
378378
self.get_response_json(&path)
379379
}
380380

381+
/// Get mempool [`Transaction`] history for the
382+
/// specified [`Script`] hash, sorted with newest first.
383+
pub fn get_mempool_scripthash_txs(&self, script: &Script) -> Result<Vec<Tx>, Error> {
384+
let script_hash = sha256::Hash::hash(script.as_bytes());
385+
let path = format!("/scripthash/{script_hash:x}/txs/mempool");
386+
387+
self.get_response_json(&path)
388+
}
381389
/// Gets some recent block summaries starting at the tip or at `height` if
382390
/// provided.
383391
///

0 commit comments

Comments
 (0)