Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ class Chain
//! or one of its ancestors.
virtual std::optional<int> findLocatorFork(const CBlockLocator& locator) = 0;

//! Check if transaction will be final given chain height current time.
virtual bool checkFinalTx(const CTransaction& tx) = 0;

//! Check if transaction is locked by InstantSendManager
virtual bool isInstantSendLockedTx(const uint256& hash) = 0;

Expand Down
1 change: 0 additions & 1 deletion src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ struct WalletTxStatus
int depth_in_main_chain;
unsigned int time_received;
uint32_t lock_time;
bool is_final;
bool is_trusted;
bool is_abandoned;
bool is_coinbase;
Expand Down
5 changes: 0 additions & 5 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,11 +771,6 @@ class ChainImpl : public Chain
}
return std::nullopt;
}
bool checkFinalTx(const CTransaction& tx) override
{
LOCK(cs_main);
return CheckFinalTxAtTip(*Assert(m_node.chainman->ActiveChain().Tip()), tx);
}
bool isInstantSendLockedTx(const uint256& hash) override
{
if (m_node.llmq_ctx == nullptr || m_node.llmq_ctx->isman == nullptr) return false;
Expand Down
9 changes: 0 additions & 9 deletions src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <key_io.h>
#include <interfaces/node.h>
#include <interfaces/wallet.h>
#include <script/script.h>
#include <util/system.h>
#include <validation.h>
#include <wallet/ismine.h>
Expand All @@ -30,14 +29,6 @@

QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
{
if (!status.is_final)
{
if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD)
return tr("Open for %n more block(s)", "", wtx.tx->nLockTime - numBlocks);
else
return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.tx->nLockTime));
}
else
{
int nDepth = status.depth_in_main_chain;
if (nDepth < 0) return tr("conflicted");
Expand Down
15 changes: 1 addition & 14 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,8 @@ void TransactionRecord::updateStatus(const interfaces::WalletTxStatus& wtx, cons
status.lockedByChainLocks = wtx.is_chainlocked;
status.lockedByInstantSend = wtx.is_islocked;

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) {
status.status = TransactionStatus::OpenUntilBlock;
status.open_for = wtx.lock_time - numBlocks;
}
else
{
status.status = TransactionStatus::OpenUntilDate;
status.open_for = wtx.lock_time;
}
}
// For generated transactions, determine maturity
else if(type == TransactionRecord::Generated)
{
if (type == TransactionRecord::Generated) {
if (wtx.blocks_to_maturity > 0)
{
status.status = TransactionStatus::Immature;
Expand Down
2 changes: 0 additions & 2 deletions src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class TransactionStatus
enum Status {
Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
/// Normal (sent/received) transactions
OpenUntilDate, /**< Transaction not yet final, waiting for date */
OpenUntilBlock, /**< Transaction not yet final, waiting for block */
Unconfirmed, /**< Not yet mined into a block **/
Confirming, /**< Confirmed, but waiting for the recommended number of confirmations **/
Conflicted, /**< Conflicts with other transaction or mempool **/
Expand Down
9 changes: 0 additions & 9 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,6 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons

switch(wtx->status.status)
{
case TransactionStatus::OpenUntilBlock:
status = tr("Open for %n more block(s)","",wtx->status.open_for);
break;
case TransactionStatus::OpenUntilDate:
status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
break;
case TransactionStatus::Unconfirmed:
status = tr("Unconfirmed");
break;
Expand Down Expand Up @@ -564,9 +558,6 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
{
switch(wtx->status.status)
{
case TransactionStatus::OpenUntilBlock:
case TransactionStatus::OpenUntilDate:
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::TX_STATUS_OPENUNTILDATE);
case TransactionStatus::Unconfirmed:
return GUIUtil::getIcon("transaction_0");
case TransactionStatus::Abandoned:
Expand Down
1 change: 0 additions & 1 deletion src/wallet/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ WalletTxStatus MakeWalletTxStatus(const CWallet& wallet, const CWalletTx& wtx)
result.depth_in_main_chain = wtx.GetDepthInMainChain();
result.time_received = wtx.nTimeReceived;
result.lock_time = wtx.tx->nLockTime;
result.is_final = wallet.chain().checkFinalTx(*wtx.tx);
result.is_trusted = wtx.IsTrusted();
result.is_abandoned = wtx.isAbandoned();
result.is_coinbase = wtx.IsCoinBase();
Expand Down
1 change: 0 additions & 1 deletion src/wallet/receive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ bool CWallet::IsTrusted(const CWalletTx& wtx, std::set<uint256>& trusted_parents
{
AssertLockHeld(cs_wallet);
// Quick answer in most cases
if (!chain().checkFinalTx(*wtx.tx)) return false;
int nDepth = wtx.GetDepthInMainChain();
if (nDepth >= 1) return true;
if (nDepth < 0) return false;
Expand Down
3 changes: 0 additions & 3 deletions src/wallet/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, const CCoinControl* c

const uint256& wtxid = wtx.GetHash();

if (!chain().checkFinalTx(*wtx.tx))
continue;

if (wtx.IsImmatureCoinBase())
continue;

Expand Down
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
'feature_coinstatsindex.py',
'wallet_orphanedreward.py',
'p2p_node_network_limited.py --v1transport',
'wallet_timelock.py',
'p2p_node_network_limited.py --v2transport',
'p2p_permissions.py',
'feature_blocksdir.py',
Expand Down
50 changes: 50 additions & 0 deletions test/functional/wallet_timelock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
# Copyright (c) 2022 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal


class WalletLocktimeTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
node = self.nodes[0]

mtp_tip = node.getblockheader(node.getbestblockhash())["mediantime"]

self.log.info("Get new address with label")
label = "timelock⌛🔓"
address = node.getnewaddress(label=label)

self.log.info("Send to new address with locktime")
node.send(
outputs={address: 5},
options={"locktime": mtp_tip - 1},
)
self.generate(node, 1)

self.log.info("Check that clock can not change finality of confirmed txs")
amount_before_ad = node.getreceivedbyaddress(address)
amount_before_lb = node.getreceivedbylabel(label)
list_before_ad = node.listreceivedbyaddress(address_filter=address)
list_before_lb = node.listreceivedbylabel(include_empty=False)
balance_before = node.getbalances()["mine"]["trusted"]
coin_before = node.listunspent(maxconf=1)
node.setmocktime(mtp_tip - 1)
assert_equal(node.getreceivedbyaddress(address), amount_before_ad)
assert_equal(node.getreceivedbylabel(label), amount_before_lb)
assert_equal(node.listreceivedbyaddress(address_filter=address), list_before_ad)
assert_equal(node.listreceivedbylabel(include_empty=False), list_before_lb)
assert_equal(node.getbalances()["mine"]["trusted"], balance_before)
assert_equal(node.listunspent(maxconf=1), coin_before)


if __name__ == "__main__":
WalletLocktimeTest().main()
Loading