From f42fd94281d3a816c01d3fc81c519cb849776b3f Mon Sep 17 00:00:00 2001 From: ardocrat Date: Sun, 21 Apr 2024 12:04:23 +0300 Subject: [PATCH] wallet: posting status for two transactions with same slate id --- src/wallet/wallet.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.rs b/src/wallet/wallet.rs index ad72e01..cc25c57 100644 --- a/src/wallet/wallet.rs +++ b/src/wallet/wallet.rs @@ -956,7 +956,7 @@ fn sync_wallet_data(wallet: &Wallet) { }).collect::>(); // Create wallet txs. - let mut txs = vec![]; + let mut txs: Vec = vec![]; for tx in &filter_txs { println!("{}", serde_json::to_string(tx).unwrap()); let amount = if tx.amount_debited > tx.amount_credited { @@ -969,13 +969,28 @@ fn sync_wallet_data(wallet: &Wallet) { let posting = if (tx.tx_type == TxLogEntryType::TxSent || tx.tx_type == TxLogEntryType::TxReceived) && !tx.confirmed && tx.tx_slate_id.is_some() { + // Create slate to check existing file. let mut slate = Slate::blank(1, false); slate.id = tx.tx_slate_id.unwrap(); slate.state = match tx.tx_type { TxLogEntryType::TxReceived => SlateState::Invoice3, _ => SlateState::Standard3 }; - wallet.read_slatepack(&slate).is_some() + + // Setup posting status if we have other tx with same slate id. + let mut same_tx_posting = false; + for t in &mut txs { + if t.data.tx_slate_id == tx.tx_slate_id && + tx.tx_type != t.data.tx_type { + same_tx_posting = t.posting || + wallet.read_slatepack(&slate).is_some(); + if same_tx_posting && !t.posting { + t.posting = true; + } + break; + } + } + same_tx_posting || wallet.read_slatepack(&slate).is_some() } else { false };