TAddr scan checks empty accounts with txs
This commit is contained in:
parent
880fd98729
commit
c1b4c88fe1
27
src/taddr.rs
27
src/taddr.rs
|
@ -1,9 +1,13 @@
|
||||||
use crate::coinconfig::CoinConfig;
|
use crate::coinconfig::CoinConfig;
|
||||||
use crate::db::AccountData;
|
use crate::db::AccountData;
|
||||||
use crate::{AddressList, CompactTxStreamerClient, GetAddressUtxosArg, GetAddressUtxosReply};
|
use crate::{
|
||||||
|
AddressList, CompactTxStreamerClient, GetAddressUtxosArg, GetAddressUtxosReply,
|
||||||
|
TransparentAddressBlockFilter,
|
||||||
|
};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use base58check::FromBase58Check;
|
use base58check::FromBase58Check;
|
||||||
use bip39::{Language, Mnemonic, Seed};
|
use bip39::{Language, Mnemonic, Seed};
|
||||||
|
use futures::StreamExt;
|
||||||
use ripemd::{Digest, Ripemd160};
|
use ripemd::{Digest, Ripemd160};
|
||||||
use secp256k1::{All, PublicKey, Secp256k1, SecretKey};
|
use secp256k1::{All, PublicKey, Secp256k1, SecretKey};
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
|
@ -28,6 +32,22 @@ pub async fn get_taddr_balance(
|
||||||
Ok(rep.value_zat as u64)
|
Ok(rep.value_zat as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_taddr_tx_count(
|
||||||
|
client: &mut CompactTxStreamerClient<Channel>,
|
||||||
|
address: &str,
|
||||||
|
) -> anyhow::Result<u32> {
|
||||||
|
let req = TransparentAddressBlockFilter {
|
||||||
|
address: address.to_string(),
|
||||||
|
range: None,
|
||||||
|
};
|
||||||
|
let rep = client
|
||||||
|
.get_taddress_txids(Request::new(req))
|
||||||
|
.await?
|
||||||
|
.into_inner();
|
||||||
|
let count = rep.count().await;
|
||||||
|
Ok(count as u32)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_utxos(
|
pub async fn get_utxos(
|
||||||
client: &mut CompactTxStreamerClient<Channel>,
|
client: &mut CompactTxStreamerClient<Channel>,
|
||||||
t_address: &str,
|
t_address: &str,
|
||||||
|
@ -71,9 +91,14 @@ pub async fn scan_transparent_accounts(
|
||||||
balance,
|
balance,
|
||||||
});
|
});
|
||||||
gap = 0;
|
gap = 0;
|
||||||
|
} else {
|
||||||
|
let tx_count = get_taddr_tx_count(client, &address).await?;
|
||||||
|
if tx_count != 0 {
|
||||||
|
gap = 0;
|
||||||
} else {
|
} else {
|
||||||
gap += 1;
|
gap += 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
aindex += 1;
|
aindex += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue