From c55bf8354f63fde6092c69d0619bc45996e82bb2 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 5 Aug 2013 23:00:24 +0200 Subject: [PATCH] Fixing bug with archived transactions This will fix #563, only mark transactions as archived that have been confirmed. --- public/include/classes/transaction.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 420ebae2..b8716ae4 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -35,8 +35,13 @@ class Transaction extends Base { * @param bool boolean True or False **/ public function setArchived($account_id, $txid) { - $stmt = $this->mysqli->prepare("UPDATE $this->table SET archived = 1 WHERE account_id = ? AND id <= ?"); - if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $txid) && $stmt->execute()) + $stmt = $this->mysqli->prepare(" + UPDATE $this->table AS t + INNER JOIN " . $this->block->getTableName() . " AS b + ON b.id = t.block_id + SET t.archived = 1 + WHERE t.account_id = ? AND t.id <= ? AND b.confirmations >= ?"); + if ($this->checkStmt($stmt) && $stmt->bind_param('iii', $account_id, $txid, $this->config['confirmations']) && $stmt->execute()) return true; return false; }