Mark pending utxos

This commit is contained in:
Aditya Kulkarni
2019-09-13 19:42:24 -07:00
parent b75da8724e
commit 09ac9eea52
2 changed files with 31 additions and 0 deletions

View File

@@ -913,6 +913,7 @@ impl LightWallet {
match spent_utxo {
Some(su) => {
su.spent = Some(txid.clone());
su.unconfirmed_spent = None;
su.value // Return the value of the note
},
None => 0
@@ -1212,6 +1213,13 @@ impl LightWallet {
.map(|utxo| {
let outpoint: OutPoint = utxo.to_outpoint();
// Mark this utxo as uncofirmed spent
let mut txs = self.txs.write().unwrap();
let mut spent_utxo = txs.get_mut(&utxo.txid).unwrap().utxos.iter_mut()
.find(|u| utxo.txid == u.txid && utxo.output_index == u.output_index)
.unwrap();
spent_utxo.unconfirmed_spent = Some(utxo.txid);
let coin = TxOut {
value: Amount::from_u64(utxo.value).unwrap(),
script_pubkey: Script { 0: utxo.script.clone() },