Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/blockchain/esplora/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! see: <https://github.com/Blockstream/esplora/blob/master/API.md>
use crate::BlockTime;
use bitcoin::{OutPoint, Script, Transaction, TxIn, TxOut, Txid, blockdata::witness::Witness};
use bitcoin::{blockdata::witness::Witness, OutPoint, Script, Transaction, TxIn, TxOut, Txid};

#[derive(serde::Deserialize, Clone, Debug)]
pub struct PrevOut {
Expand Down
52 changes: 28 additions & 24 deletions src/blockchain/esplora/ureq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,39 @@ impl Blockchain for EsploraBlockchain {
.take(self.concurrency as usize)
.cloned();

let handles = scripts.map(move |script| {
let client = self.url_client.clone();
// make each request in its own thread.
std::thread::spawn(move || {
let mut related_txs: Vec<Tx> = client._scripthash_txs(&script, None)?;

let n_confirmed =
related_txs.iter().filter(|tx| tx.status.confirmed).count();
// esplora pages on 25 confirmed transactions. If there's 25 or more we
// keep requesting to see if there's more.
if n_confirmed >= 25 {
loop {
let new_related_txs: Vec<Tx> = client._scripthash_txs(
&script,
Some(related_txs.last().unwrap().txid),
)?;
let n = new_related_txs.len();
related_txs.extend(new_related_txs);
// we've reached the end
if n < 25 {
break;
let handles = scripts
.map(move |script| {
let client = self.url_client.clone();
// make each request in its own thread.
std::thread::spawn(move || {
let mut related_txs: Vec<Tx> =
client._scripthash_txs(&script, None)?;

let n_confirmed =
related_txs.iter().filter(|tx| tx.status.confirmed).count();
// esplora pages on 25 confirmed transactions. If there's 25 or more we
// keep requesting to see if there's more.
if n_confirmed >= 25 {
loop {
let new_related_txs: Vec<Tx> = client._scripthash_txs(
&script,
Some(related_txs.last().unwrap().txid),
)?;
let n = new_related_txs.len();
related_txs.extend(new_related_txs);
// we've reached the end
if n < 25 {
break;
}
}
}
}
Result::<_, Error>::Ok(related_txs)
Result::<_, Error>::Ok(related_txs)
})
})
});
.collect::<Vec<_>>();

let txs_per_script: Vec<Vec<Tx>> = handles
.into_iter()
.map(|handle| handle.join().unwrap())
.collect::<Result<_, _>>()?;
let mut satisfaction = vec![];
Expand Down
8 changes: 5 additions & 3 deletions src/testutils/blockchain_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::testutils::TestIncomingTx;
use bitcoin::consensus::encode::{deserialize, serialize};
use bitcoin::hashes::hex::{FromHex, ToHex};
use bitcoin::hashes::sha256d;
use bitcoin::{Address, Amount, Script, Transaction, Txid, blockdata::witness::Witness};
use bitcoin::{blockdata::witness::Witness, Address, Amount, Script, Transaction, Txid};
pub use bitcoincore_rpc::{Auth, Client as RpcClient, RpcApi};
use core::str::FromStr;
use electrsd::bitcoind::BitcoinD;
Expand Down Expand Up @@ -197,8 +197,10 @@ impl TestClient {
let mut block = Block { header, txdata };

let witness_root = block.witness_root().unwrap();
let witness_commitment =
Block::compute_witness_commitment(&witness_root, &coinbase_tx.input[0].witness.to_vec()[0]);
let witness_commitment = Block::compute_witness_commitment(
&witness_root,
&coinbase_tx.input[0].witness.to_vec()[0],
);

// now update and replace the coinbase tx
let mut coinbase_witness_commitment_script = vec![0x6a, 0x24, 0xaa, 0x21, 0xa9, 0xed];
Expand Down
1 change: 0 additions & 1 deletion src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,6 @@ where
}
}


/// get the signers
pub fn signers(&self) -> (&SignersContainer, &SignersContainer) {
(self.signers.as_ref(), self.change_signers.as_ref())
Expand Down