mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-02-11 17:55:47 +00:00
Fix issue where t addresses weren't scanned when locked
This commit is contained in:
parent
654f526918
commit
08a2fded88
@ -842,15 +842,11 @@ impl LightWallet {
|
||||
}
|
||||
}
|
||||
|
||||
// Scan the full Tx and update memos for incoming shielded transactions
|
||||
// Scan the full Tx and update memos for incoming shielded transactions.
|
||||
pub fn scan_full_tx(&self, tx: &Transaction, height: i32, datetime: u64) {
|
||||
// Scan all the inputs to see if we spent any transparent funds in this tx
|
||||
|
||||
// TODO: Save this object
|
||||
let secp = secp256k1::Secp256k1::new();
|
||||
|
||||
let mut total_transparent_spend: u64 = 0;
|
||||
|
||||
// Scan all the inputs to see if we spent any transparent funds in this tx
|
||||
for vin in tx.vin.iter() {
|
||||
// Find the txid in the list of utxos that we have.
|
||||
let txid = TxId {0: vin.prevout.hash};
|
||||
@ -890,19 +886,15 @@ impl LightWallet {
|
||||
.total_transparent_value_spent = total_transparent_spend;
|
||||
}
|
||||
|
||||
// TODO: Iterate over all transparent addresses. This is currently looking only at
|
||||
// the first one.
|
||||
// Scan for t outputs
|
||||
let all_pubkeys = self.tkeys.read().unwrap().iter()
|
||||
.map(|sk|
|
||||
secp256k1::PublicKey::from_secret_key(&secp, sk).serialize()
|
||||
)
|
||||
.collect::<Vec<[u8; secp256k1::constants::PUBLIC_KEY_SIZE]>>();
|
||||
for pubkey in all_pubkeys {
|
||||
let all_taddresses = self.taddresses.read().unwrap().iter()
|
||||
.map(|a| a.clone())
|
||||
.collect::<Vec<_>>();
|
||||
for address in all_taddresses {
|
||||
for (n, vout) in tx.vout.iter().enumerate() {
|
||||
match vout.script_pubkey.address() {
|
||||
Some(TransparentAddress::PublicKey(hash)) => {
|
||||
if hash[..] == ripemd160::Ripemd160::digest(&Sha256::digest(&pubkey))[..] {
|
||||
if address == hash.to_base58check(&self.config.base58_pubkey_address(), &[]) {
|
||||
// This is our address. Add this as an output to the txid
|
||||
self.add_toutput_to_wtx(height, datetime, &tx.txid(), &vout, n as u64);
|
||||
}
|
||||
@ -1316,6 +1308,8 @@ impl LightWallet {
|
||||
|
||||
let total_value = tos.iter().map(|to| to.1).sum::<u64>();
|
||||
|
||||
// TODO: Check for duplicates in destination addresses
|
||||
|
||||
println!(
|
||||
"0: Creating transaction sending {} ztoshis to {} addresses",
|
||||
total_value, tos.len()
|
||||
|
@ -74,13 +74,13 @@ impl BugBip39Derivation {
|
||||
|
||||
// Tranfer money
|
||||
// 1. The desination is z address #0
|
||||
println!("Sending funds to ourself.");
|
||||
let zaddr = client.do_address()["z_addresses"][0].as_str().unwrap().to_string();
|
||||
let balance_json = client.do_balance();
|
||||
let amount: u64 = balance_json["zbalance"].as_u64().unwrap()
|
||||
+ balance_json["tbalance"].as_u64().unwrap();
|
||||
|
||||
let txid = if amount > 0 {
|
||||
println!("Sending funds to ourself.");
|
||||
let fee: u64 = DEFAULT_FEE.try_into().unwrap();
|
||||
match client.do_send(vec![(&zaddr, amount-fee, None)]) {
|
||||
Ok(txid) => txid,
|
||||
|
Loading…
x
Reference in New Issue
Block a user