Skip to content

Commit

Permalink
Merge pull request #684 from fluidvanadium/cleanup_height_from_transp…
Browse files Browse the repository at this point in the history
…arent_note

remove unused TransparentNote field
  • Loading branch information
AloeareV authored Nov 24, 2023
2 parents d0b0001 + 0732155 commit a66dc43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions zingolib/src/wallet/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ pub struct TransparentNote {
pub output_index: u64,
pub script: Vec<u8>,
pub value: u64,
pub height: i32,

pub spent_at_height: Option<i32>,
pub spent: Option<TxId>, // If this utxo was confirmed spent Todo: incoherent with unconfirmed_spent
Expand Down Expand Up @@ -585,7 +584,7 @@ impl TransparentNote {

let output_index = reader.read_u64::<LittleEndian>()?;
let value = reader.read_u64::<LittleEndian>()?;
let height = reader.read_i32::<LittleEndian>()?;
let _height = reader.read_i32::<LittleEndian>()?;

let script = Vector::read(&mut reader, |r| {
let mut byte = [0; 1];
Expand Down Expand Up @@ -623,7 +622,6 @@ impl TransparentNote {
output_index,
script,
value,
height,
spent_at_height,
spent,
unconfirmed_spent: None,
Expand All @@ -640,7 +638,7 @@ impl TransparentNote {

writer.write_u64::<LittleEndian>(self.output_index)?;
writer.write_u64::<LittleEndian>(self.value)?;
writer.write_i32::<LittleEndian>(self.height)?;
writer.write_i32::<LittleEndian>(0)?;

Vector::write(&mut writer, &self.script, |w, b| w.write_all(&[*b]))?;

Expand Down
6 changes: 2 additions & 4 deletions zingolib/src/wallet/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,13 +697,12 @@ impl TransactionMetadataSet {
);

// Add this UTXO if it doesn't already exist
if let Some(utxo) = transaction_metadata
if transaction_metadata
.transparent_notes
.iter_mut()
.find(|utxo| utxo.txid == txid && utxo.output_index == output_num as u64)
.any(|utxo| utxo.txid == txid && utxo.output_index == output_num as u64)
{
// If it already exists, it is likely an mempool tx, so update the height
utxo.height = height as i32
} else {
transaction_metadata
.transparent_notes
Expand All @@ -713,7 +712,6 @@ impl TransactionMetadataSet {
output_index: output_num as u64,
script: vout.script_pubkey.0.clone(),
value: u64::try_from(vout.value).expect("Valid value for u64."),
height: height as i32,
spent_at_height: None,
spent: None,
unconfirmed_spent: None,
Expand Down

0 comments on commit a66dc43

Please sign in to comment.