@@ -161,7 +161,7 @@ namespace
161161 return pwd_container;
162162 }
163163 // ------------------------------------------------------------------------------------------------------------------------------
164- void set_confirmations (tools::wallet_rpc::transfer_entry &entry, uint64_t blockchain_height, uint64_t block_reward, uint64_t unlock_time)
164+ void set_confirmations (tools::wallet_rpc::transfer_entry &entry, tools::wallet2 &wallet, uint64_t blockchain_height, uint64_t block_reward, uint64_t unlock_time)
165165 {
166166 if (entry.height >= blockchain_height || (entry.height == 0 && (!strcmp (entry.type .c_str (), " pending" ) || !strcmp (entry.type .c_str (), " pool" ))))
167167 entry.confirmations = 0 ;
@@ -178,9 +178,14 @@ namespace
178178 if (unlock_time > blockchain_height)
179179 entry.suggested_confirmations_threshold = std::max (entry.suggested_confirmations_threshold , unlock_time - blockchain_height);
180180 }
181+ else if (wallet.use_fork_rules (HF_VERSION_FCMP_PLUS_PLUS , 0 ))
182+ {
183+ const uint64_t last_locked = cryptonote::get_last_locked_block_index (unlock_time, entry.height );
184+ if (last_locked + 1 > blockchain_height)
185+ entry.suggested_confirmations_threshold = std::max (entry.suggested_confirmations_threshold , last_locked + 1 - blockchain_height);
186+ }
181187 else
182188 {
183- // FIXME: update for FCMP++
184189 const uint64_t now = time (NULL );
185190 if (unlock_time > now)
186191 entry.suggested_confirmations_threshold = std::max (entry.suggested_confirmations_threshold , (unlock_time - now + DIFFICULTY_TARGET_V2 - 1 ) / DIFFICULTY_TARGET_V2 );
@@ -506,7 +511,7 @@ namespace tools
506511 entry.subaddr_index = pd.m_subaddr_index ;
507512 entry.subaddr_indices .push_back (pd.m_subaddr_index );
508513 entry.address = m_wallet->get_subaddress_as_str (pd.m_subaddr_index );
509- set_confirmations (entry, m_wallet->get_blockchain_current_height (), m_wallet->get_last_block_reward (), pd.m_unlock_time );
514+ set_confirmations (entry, *m_wallet, m_wallet->get_blockchain_current_height (), m_wallet->get_last_block_reward (), pd.m_unlock_time );
510515 }
511516 // ------------------------------------------------------------------------------------------------------------------------------
512517 void wallet_rpc_server::fill_transfer_entry (tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd) const
@@ -536,7 +541,7 @@ namespace tools
536541 for (uint32_t i: pd.m_subaddr_indices )
537542 entry.subaddr_indices .push_back ({pd.m_subaddr_account , i});
538543 entry.address = m_wallet->get_subaddress_as_str ({pd.m_subaddr_account , 0 });
539- set_confirmations (entry, m_wallet->get_blockchain_current_height (), m_wallet->get_last_block_reward (), pd.m_unlock_time );
544+ set_confirmations (entry, *m_wallet, m_wallet->get_blockchain_current_height (), m_wallet->get_last_block_reward (), pd.m_unlock_time );
540545 }
541546 // ------------------------------------------------------------------------------------------------------------------------------
542547 void wallet_rpc_server::fill_transfer_entry (tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd) const
@@ -566,7 +571,7 @@ namespace tools
566571 for (uint32_t i: pd.m_subaddr_indices )
567572 entry.subaddr_indices .push_back ({pd.m_subaddr_account , i});
568573 entry.address = m_wallet->get_subaddress_as_str ({pd.m_subaddr_account , 0 });
569- set_confirmations (entry, m_wallet->get_blockchain_current_height (), m_wallet->get_last_block_reward (), pd.m_tx .unlock_time );
574+ set_confirmations (entry, *m_wallet, m_wallet->get_blockchain_current_height (), m_wallet->get_last_block_reward (), pd.m_tx .unlock_time );
570575 }
571576 // ------------------------------------------------------------------------------------------------------------------------------
572577 void wallet_rpc_server::fill_transfer_entry (tools::wallet_rpc::transfer_entry &entry, const crypto::hash &payment_id, const tools::wallet2::pool_payment_details &ppd) const
@@ -589,7 +594,7 @@ namespace tools
589594 entry.subaddr_index = pd.m_subaddr_index ;
590595 entry.subaddr_indices .push_back (pd.m_subaddr_index );
591596 entry.address = m_wallet->get_subaddress_as_str (pd.m_subaddr_index );
592- set_confirmations (entry, m_wallet->get_blockchain_current_height (), m_wallet->get_last_block_reward (), pd.m_unlock_time );
597+ set_confirmations (entry, *m_wallet, m_wallet->get_blockchain_current_height (), m_wallet->get_last_block_reward (), pd.m_unlock_time );
593598 }
594599 // ------------------------------------------------------------------------------------------------------------------------------
595600 bool wallet_rpc_server::on_getbalance (const wallet_rpc::COMMAND_RPC_GET_BALANCE ::request& req, wallet_rpc::COMMAND_RPC_GET_BALANCE ::response& res, epee::json_rpc::error& er, const connection_context *ctx)
0 commit comments