Skip to content

Commit 087559c

Browse files
committed
Add scripthash_txs
1 parent 748df84 commit 087559c

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/lib.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl_error!(bitcoin::hashes::hex::Error, Hex, Error);
199199
mod test {
200200
use super::*;
201201
use bitcoin::hash_types::TxMerkleNode;
202-
use bitcoin::{BlockHeader, Transaction};
202+
use bitcoin::{BlockHeader, Script, Transaction};
203203
use std::str::FromStr;
204204

205205
#[test]
@@ -281,7 +281,8 @@ mod test {
281281
224, 70, 254, 228, 94, 132, 168, 164, 138, 208, 91, 216, 219, 179, 149, 192, 17, 163,
282282
44, 249, 248, 128, 83, 174, 0, 0, 0, 0,
283283
];
284-
let expected_tx: Transaction = bitcoin::consensus::encode::deserialize(&expected_tx_serialized).unwrap();
284+
let expected_tx: Transaction =
285+
bitcoin::consensus::encode::deserialize(&expected_tx_serialized).unwrap();
285286
let tx = blocking_client.get_tx(&txid).unwrap();
286287
let tx_async = async_client.get_tx(&txid).await.unwrap();
287288
assert_eq!(tx, Some(expected_tx.clone()));
@@ -415,5 +416,23 @@ mod test {
415416
.unwrap();
416417
assert_eq!(txid_at_block_index, expected_txid_at_block_index);
417418
assert_eq!(txid_at_block_index, txid_at_block_index_async);
419+
420+
// Test `scripthash_txs`
421+
let script = &expected_tx.output[0].script_pubkey;
422+
423+
let scripthash_txs_txids: Vec<Txid> = blocking_client
424+
.scripthash_txs(script, None)
425+
.unwrap()
426+
.iter()
427+
.map(|tx| tx.txid)
428+
.collect();
429+
let scripthash_txs_txids_async: Vec<Txid> = async_client
430+
.scripthash_txs(script, None)
431+
.await
432+
.unwrap()
433+
.iter()
434+
.map(|tx| tx.txid)
435+
.collect();
436+
assert_eq!(scripthash_txs_txids, scripthash_txs_txids_async);
418437
}
419438
}

0 commit comments

Comments
 (0)