Changeset View
Changeset View
Standalone View
Standalone View
src/qt/transactionrecord.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <qt/transactionrecord.h> | #include <qt/transactionrecord.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <dstencode.h> | #include <dstencode.h> | ||||
#include <interfaces/wallet.h> | #include <interfaces/wallet.h> | ||||
#include <timedata.h> | #include <timedata.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <wallet/finaltx.h> | #include <wallet/finaltx.h> | ||||
#include <QDateTime> | |||||
#include <cstdint> | #include <cstdint> | ||||
/** | /** | ||||
* Return positive answer if transaction should be shown in list. | * Return positive answer if transaction should be shown in list. | ||||
*/ | */ | ||||
bool TransactionRecord::showTransaction() { | bool TransactionRecord::showTransaction() { | ||||
// There are currently no cases where we hide transactions, but we may want | // There are currently no cases where we hide transactions, but we may want | ||||
// to use this in the future for things like RBF. | // to use this in the future for things like RBF. | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | if (nNet > Amount::zero() || wtx.is_coinbase) { | ||||
parts.last().involvesWatchAddress = involvesWatchAddress; | parts.last().involvesWatchAddress = involvesWatchAddress; | ||||
} | } | ||||
} | } | ||||
return parts; | return parts; | ||||
} | } | ||||
void TransactionRecord::updateStatus(const interfaces::WalletTxStatus &wtx, | void TransactionRecord::updateStatus(const interfaces::WalletTxStatus &wtx, | ||||
int numBlocks) { | int numBlocks, int64_t block_time) { | ||||
// Determine transaction status | // Determine transaction status | ||||
// Sort order, unrecorded transactions sort to the top | // Sort order, unrecorded transactions sort to the top | ||||
status.sortKey = strprintf("%010d-%01d-%010u-%03d", wtx.block_height, | status.sortKey = strprintf("%010d-%01d-%010u-%03d", wtx.block_height, | ||||
wtx.is_coinbase ? 1 : 0, wtx.time_received, idx); | wtx.is_coinbase ? 1 : 0, wtx.time_received, idx); | ||||
status.countsForBalance = wtx.is_trusted && !(wtx.blocks_to_maturity > 0); | status.countsForBalance = wtx.is_trusted && !(wtx.blocks_to_maturity > 0); | ||||
status.depth = wtx.depth_in_main_chain; | status.depth = wtx.depth_in_main_chain; | ||||
status.cur_num_blocks = numBlocks; | status.cur_num_blocks = numBlocks; | ||||
if (!wtx.is_final) { | const bool up_to_date = | ||||
(int64_t(QDateTime::currentMSecsSinceEpoch()) / 1000 - block_time < | |||||
MAX_BLOCK_TIME_GAP); | |||||
if (up_to_date && !wtx.is_final) { | |||||
if (wtx.lock_time < LOCKTIME_THRESHOLD) { | if (wtx.lock_time < LOCKTIME_THRESHOLD) { | ||||
status.status = TransactionStatus::OpenUntilBlock; | status.status = TransactionStatus::OpenUntilBlock; | ||||
status.open_for = wtx.lock_time - numBlocks; | status.open_for = wtx.lock_time - numBlocks; | ||||
} else { | } else { | ||||
status.status = TransactionStatus::OpenUntilDate; | status.status = TransactionStatus::OpenUntilDate; | ||||
status.open_for = wtx.lock_time; | status.open_for = wtx.lock_time; | ||||
} | } | ||||
} else if (type == TransactionRecord::Generated) { | } else if (type == TransactionRecord::Generated) { | ||||
Show All 39 Lines |