@@ -7355,9 +7355,22 @@ bool wallet2::is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height)
7355
7355
//----------------------------------------------------------------------------------------------------
7356
7356
bool wallet2::is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height)
7357
7357
{
7358
- if (use_fork_rules(HF_VERSION_FCMP_PLUS_PLUS, 0))
7358
+ bool use_fcmp_pp_unlock_rules = false;
7359
+ try
7360
+ {
7361
+ // use FCMP++ rules if check daemon earliest height for HF_VERSION_FCMP_PLUS_PLUS is here
7362
+ use_fcmp_pp_unlock_rules = use_fork_rules(HF_VERSION_FCMP_PLUS_PLUS, 0);
7363
+ }
7364
+ catch (...) // in case of daemon failure...
7365
+ {
7366
+ // use FCMP++ rules if latest refreshed height is at least hard fork table's height for HF_VERSION_FCMP_PLUS_PLUS
7367
+ use_fcmp_pp_unlock_rules = use_fork_rules_offline(HF_VERSION_FCMP_PLUS_PLUS, 0);
7368
+ }
7369
+ if (use_fcmp_pp_unlock_rules)
7359
7370
return get_blockchain_current_height() >= (cryptonote::get_last_locked_block_index(unlock_time, block_height)+1);
7360
7371
7372
+ // else, use pre-FCMP++ unlock rules...
7373
+
7361
7374
if(unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER)
7362
7375
{
7363
7376
//interpret as block index
@@ -11654,6 +11667,37 @@ bool wallet2::use_fork_rules(uint8_t version, int64_t early_blocks)
11654
11667
return close_enough;
11655
11668
}
11656
11669
//----------------------------------------------------------------------------------------------------
11670
+ bool wallet2::use_fork_rules_offline(uint8_t version, int64_t early_blocks) const
11671
+ {
11672
+ // get hard fork table based on network type
11673
+ const size_t wallet_num_hard_forks = m_nettype == TESTNET ? num_testnet_hard_forks
11674
+ : m_nettype == STAGENET ? num_stagenet_hard_forks : num_mainnet_hard_forks;
11675
+ const hardfork_t *wallet_hard_forks = m_nettype == TESTNET ? testnet_hard_forks
11676
+ : m_nettype == STAGENET ? stagenet_hard_forks : mainnet_hard_forks;
11677
+
11678
+ // find hard fork with lowest version >= `version`
11679
+ const hardfork_t *best_fork_info = nullptr;
11680
+ for (std::size_t i = 0; i < wallet_num_hard_forks; ++i)
11681
+ {
11682
+ const hardfork_t &fork_info = wallet_hard_forks[i];
11683
+ if (fork_info.version < version)
11684
+ continue;
11685
+ if (nullptr == best_fork_info || fork_info.version < best_fork_info->version)
11686
+ best_fork_info = &fork_info;
11687
+ }
11688
+
11689
+ if (nullptr == best_fork_info) // did not find fork in table
11690
+ return false;
11691
+
11692
+ const int64_t height = static_cast<int64_t>(get_blockchain_current_height());
11693
+ const bool close_enough = height >= static_cast<int64_t>(best_fork_info->height) - early_blocks;
11694
+ if (close_enough)
11695
+ LOG_PRINT_L2("Using v" << static_cast<unsigned>(version) << " rules (offline)");
11696
+ else
11697
+ LOG_PRINT_L2("Not using v" << static_cast<unsigned>(version) << " rules (offline)");
11698
+ return close_enough;
11699
+ }
11700
+ //----------------------------------------------------------------------------------------------------
11657
11701
uint64_t wallet2::get_upper_transaction_weight_limit()
11658
11702
{
11659
11703
if (m_upper_transaction_weight_limit > 0)
0 commit comments