diff --git a/src/CurrentBlockchainStatus.cpp b/src/CurrentBlockchainStatus.cpp index ae02a71..8d78812 100755 --- a/src/CurrentBlockchainStatus.cpp +++ b/src/CurrentBlockchainStatus.cpp @@ -358,6 +358,12 @@ CurrentBlockchainStatus::get_dynamic_base_fee_estimate() const FEE_ESTIMATE_GRACE_BLOCKS); } +uint64_t +CurrentBlockchainStatus::get_tx_unlock_time( + crypto::hash const& tx_hash) const +{ + return mcore->get_tx_unlock_time(tx_hash); +} bool CurrentBlockchainStatus::commit_tx( diff --git a/src/CurrentBlockchainStatus.h b/src/CurrentBlockchainStatus.h index 9da798d..6494197 100755 --- a/src/CurrentBlockchainStatus.h +++ b/src/CurrentBlockchainStatus.h @@ -147,6 +147,9 @@ public: virtual uint64_t get_dynamic_base_fee_estimate() const; + virtual uint64_t + get_tx_unlock_time(crypto::hash const& tx_hash) const; + virtual bool commit_tx(const string& tx_blob, string& error_msg, bool do_not_relay = false); diff --git a/src/MicroCore.h b/src/MicroCore.h index 2aa18ac..7c00651 100755 --- a/src/MicroCore.h +++ b/src/MicroCore.h @@ -98,6 +98,12 @@ public: return core_storage.get_db().get_blocks_range(h1, h2); } + virtual uint64_t + get_tx_unlock_time(crypto::hash const& tx_hash) const + { + return core_storage.get_db().get_tx_unlock_time(tx_hash); + } + virtual bool have_tx(crypto::hash const& tx_hash) const { diff --git a/src/TxSearch.cpp b/src/TxSearch.cpp index 4bb2e51..9773095 100755 --- a/src/TxSearch.cpp +++ b/src/TxSearch.cpp @@ -129,7 +129,7 @@ TxSearch::operator()() txs_in_blocks, txs_data)) { - OMERROR << "Cant get tx in blocks from " << h1 << " to " << h2;; + OMERROR << "Cant get tx in blocks from " << h1 << " to " << h2; return; } @@ -175,10 +175,16 @@ TxSearch::operator()() // flag indicating whether the txs in the given block are spendable. // this is true when block number is more than 10 blocks from current // blockchain height. + // if tx.unlock_time is not given (its value is 0), we set it + // here. For coinbase its always given, so no need to check for that - bool is_spendable = current_bc_status->is_tx_unlocked( - tx.unlock_time, blk_height); + uint64_t tx_unlock_time = tx.unlock_time; + + if (tx_unlock_time == 0) + tx_unlock_time = blk_height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE; + bool is_spendable = current_bc_status->is_tx_unlocked( + tx_unlock_time, blk_height); // this is id of txs in lmdb blockchain table. // it will be used mostly to sort txs in the frontend. @@ -262,7 +268,7 @@ TxSearch::operator()() // for regular tx, the unlock time is // default of 10 blocks. // for coinbase tx it is 60 blocks - tx_data.unlock_time = tx.unlock_time; + tx_data.unlock_time = tx_unlock_time; tx_data.height = blk_height; tx_data.coinbase = oi_identification.tx_is_coinbase; @@ -473,7 +479,7 @@ TxSearch::operator()() //spending, //total_recieved is 0 tx_data.total_sent = total_sent; - tx_data.unlock_time = tx.unlock_time; + tx_data.unlock_time = tx_unlock_time; tx_data.height = blk_height; tx_data.coinbase = oi_identification .tx_is_coinbase;