Skip to content

Commit

Permalink
Merge pull request #1274 from Oscar-Pepper/unify_order_and_deprecate
Browse files Browse the repository at this point in the history
unify pool order in records and add deprecations
  • Loading branch information
fluidvanadium authored Jul 7, 2024
2 parents d2f0acc + e8bd443 commit 09f502c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion zingolib/src/lightclient/deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl LightClient {
})
}

/// This fn is _only_ called inside a block conditioned on "is_outgoing_transaction"
#[allow(deprecated)]
fn append_change_notes(
wallet_transaction: &TransactionRecord,
received_utxo_value: u64,
Expand Down
11 changes: 6 additions & 5 deletions zingolib/src/wallet/transaction_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ pub struct TransactionRecord {
/// List of all Utxos by this wallet received in this Tx. Some of these might be change notes
pub transparent_outputs: Vec<TransparentOutput>,

/// Total amount of transparent funds that belong to us that were spent by this wallet in this Tx.
pub total_transparent_value_spent: u64,

/// Total value of all the sapling nullifiers that were spent by this wallet in this Tx
pub total_sapling_value_spent: u64,

/// Total value of all the orchard nullifiers that were spent by this wallet in this Tx
pub total_orchard_value_spent: u64,

/// Total amount of transparent funds that belong to us that were spent by this wallet in this Tx.
pub total_transparent_value_spent: u64,

/// All outgoing sends
pub outgoing_tx_data: Vec<OutgoingTxData>,

Expand Down Expand Up @@ -203,6 +203,7 @@ impl TransactionRecord {
/// TODO: Add Doc Comment Here!
// TODO: This is incorrect in the edge case where where we have a send-to-self with
// no text memo and 0-value fee
#[allow(deprecated)]
#[deprecated(note = "uses unstable deprecated is_change")]
pub fn is_outgoing_transaction(&self) -> bool {
(!self.outgoing_tx_data.is_empty()) || self.total_value_spent() != 0
Expand Down Expand Up @@ -239,6 +240,7 @@ impl TransactionRecord {
}

/// TODO: Add Doc Comment Here!
#[deprecated(note = "replaced by total_value_input_to_transaction")]
pub fn total_value_spent(&self) -> u64 {
self.value_spent_by_pool().iter().sum()
}
Expand Down Expand Up @@ -442,8 +444,8 @@ impl TransactionRecord {
transparent_outputs: utxos,
spent_sapling_nullifiers,
spent_orchard_nullifiers,
total_sapling_value_spent,
total_transparent_value_spent,
total_sapling_value_spent,
total_orchard_value_spent,
outgoing_tx_data: outgoing_metadata,
price: zec_price,
Expand Down Expand Up @@ -795,7 +797,6 @@ mod tests {
0
);
assert_eq!(new.total_value_received(), 0);
assert_eq!(new.total_value_spent(), 0);
assert_eq!(new.value_outgoing(), 0);
let t: [u64; 3] = [0, 0, 0];
assert_eq!(new.value_spent_by_pool(), t);
Expand Down
3 changes: 3 additions & 0 deletions zingolib/src/wallet/transaction_records_by_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ impl TransactionRecordsById {
}

/// TODO: Add Doc Comment Here!
#[allow(deprecated)]
#[deprecated(note = "uses unstable deprecated functions")]
pub fn total_funds_spent_in(&self, txid: &TxId) -> u64 {
self.get(txid)
.map(TransactionRecord::total_value_spent)
Expand All @@ -389,6 +391,7 @@ impl TransactionRecordsById {
//
// TODO: When we start working on multi-sig, this could cause issues about hiding sends-to-self
/// TODO: Add Doc Comment Here!
#[allow(deprecated)]
#[deprecated(note = "uses unstable deprecated functions")]
pub fn check_notes_mark_change(&mut self, txid: &TxId) {
//TODO: Incorrect with a 0-value fee somehow
Expand Down

0 comments on commit 09f502c

Please sign in to comment.