diff --git a/src/query.rs b/src/query.rs index 843ff86..5231bba 100644 --- a/src/query.rs +++ b/src/query.rs @@ -259,14 +259,15 @@ impl Query { fn confirmed_status( &self, script_hash: &[u8], - current_block_index: usize + current_block_index: usize, + use_txid_limit: bool, ) -> Result<(Vec, Vec)> { let mut funding = vec![]; let mut spending = vec![]; let read_store = self.app.read_store(); let txos = self.find_funding_outputs(read_store, script_hash, current_block_index)?; - if self.txid_limit > 0 && txos.len() > self.txid_limit { + if use_txid_limit && self.txid_limit > 0 && txos.len() > self.txid_limit { bail!( "{}+ transactions found, query may take a long time", txos.len() @@ -287,6 +288,7 @@ impl Query { &self, script_hash: &[u8], confirmed_funding: &[Txo], + use_txid_limit: bool, ) -> Result<(Vec, Vec)> { let mut funding = vec![]; let mut spending = vec![]; @@ -294,7 +296,7 @@ impl Query { let tracker = self.tracker.read().unwrap(); let txos = self.find_funding_outputs(tracker.index(), script_hash, 9999999999)?; - if self.txid_limit > 0 && txos.len() > self.txid_limit { + if use_txid_limit && self.txid_limit > 0 && txos.len() > self.txid_limit { bail!( "{}+ transactions found, query may take a long time", txos.len() @@ -311,20 +313,20 @@ impl Query { Ok((funding, spending)) } - pub fn status(&self, script_hash: &[u8], current_block_index: usize) -> Result { + pub fn status(&self, script_hash: &[u8], current_block_index: usize, use_txid_limit: bool) -> Result { let confirmed = self - .confirmed_status(script_hash, current_block_index) + .confirmed_status(script_hash, current_block_index, use_txid_limit) .chain_err(|| "failed to get confirmed status")?; let mempool = self - .mempool_status(script_hash, &confirmed.0) + .mempool_status(script_hash, &confirmed.0, use_txid_limit) .chain_err(|| "failed to get mempool status")?; Ok(Status { confirmed, mempool }) } pub fn oldest_tx(&self, script_hash: &[u8], current_block_index: usize) -> Result { - let all_status = self.status(script_hash, current_block_index).unwrap(); + let all_status = self.status(script_hash, current_block_index, true).unwrap(); all_status.oldest().chain_err(|| "no txs for address") } diff --git a/src/rpc.rs b/src/rpc.rs index d94dbe3..1ec2cd4 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -76,7 +76,7 @@ impl Connection { fn blockchain_scripthash_get_history(&self, params: &[Value]) -> Result { let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?; - let status = self.query.status(&script_hash[..], 9999999999)?; + let status = self.query.status(&script_hash[..], 9999999999, false)?; Ok(json!(Value::Array( status .history() @@ -104,7 +104,7 @@ impl Connection { fn blockchain_scripthash_get_utxos(&self, params: &[Value]) -> Result { let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?; - let status = self.query.status(&script_hash[..], 9999999999)?; + let status = self.query.status(&script_hash[..], 9999999999, false)?; let mut dict = HashMap::new(); for item in status.funding().into_iter() {