Update historical utxos with <spent in txid>

This commit is contained in:
Aditya Kulkarni
2019-09-13 18:43:51 -07:00
parent bee501bae0
commit 66a82bdb88

View File

@@ -904,12 +904,19 @@ impl LightWallet {
// println!("Looking for {}, {}", txid, vin.prevout.n); // println!("Looking for {}, {}", txid, vin.prevout.n);
let value = match self.txs.read().unwrap().get(&txid) { let value = match self.txs.write().unwrap().get_mut(&txid) {
Some(wtx) => { Some(wtx) => {
// One of the tx outputs is a match // One of the tx outputs is a match
wtx.utxos.iter() let spent_utxo = wtx.utxos.iter_mut()
.find(|u| u.txid == txid && u.output_index == (vin.prevout.n as u64)) .find(|u| u.txid == txid && u.output_index == (vin.prevout.n as u64));
.map_or(0, |u| u.value)
match spent_utxo {
Some(su) => {
su.spent = Some(txid.clone());
su.value // Return the value of the note
},
None => 0
}
}, },
_ => 0 _ => 0
}; };