mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-22 19:03:25 +01:00
Merge pull request #6546
eda167585
wallet_rpc_server: use unlock_time in suggested confirmations calc (moneromooo-monero)
This commit is contained in:
commit
0f5eb0e70c
@ -80,7 +80,7 @@ namespace
|
|||||||
return pwd_container;
|
return pwd_container;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
void set_confirmations(tools::wallet_rpc::transfer_entry &entry, uint64_t blockchain_height, uint64_t block_reward)
|
void set_confirmations(tools::wallet_rpc::transfer_entry &entry, uint64_t blockchain_height, uint64_t block_reward, uint64_t unlock_time)
|
||||||
{
|
{
|
||||||
if (entry.height >= blockchain_height || (entry.height == 0 && (!strcmp(entry.type.c_str(), "pending") || !strcmp(entry.type.c_str(), "pool"))))
|
if (entry.height >= blockchain_height || (entry.height == 0 && (!strcmp(entry.type.c_str(), "pending") || !strcmp(entry.type.c_str(), "pool"))))
|
||||||
entry.confirmations = 0;
|
entry.confirmations = 0;
|
||||||
@ -91,6 +91,18 @@ namespace
|
|||||||
entry.suggested_confirmations_threshold = 0;
|
entry.suggested_confirmations_threshold = 0;
|
||||||
else
|
else
|
||||||
entry.suggested_confirmations_threshold = (entry.amount + block_reward - 1) / block_reward;
|
entry.suggested_confirmations_threshold = (entry.amount + block_reward - 1) / block_reward;
|
||||||
|
|
||||||
|
if (unlock_time < CRYPTONOTE_MAX_BLOCK_NUMBER)
|
||||||
|
{
|
||||||
|
if (unlock_time > blockchain_height)
|
||||||
|
entry.suggested_confirmations_threshold = std::max(entry.suggested_confirmations_threshold, unlock_time - blockchain_height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const uint64_t now = time(NULL);
|
||||||
|
if (unlock_time > now)
|
||||||
|
entry.suggested_confirmations_threshold = std::max(entry.suggested_confirmations_threshold, (unlock_time - now + DIFFICULTY_TARGET_V2 - 1) / DIFFICULTY_TARGET_V2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +347,7 @@ namespace tools
|
|||||||
entry.subaddr_index = pd.m_subaddr_index;
|
entry.subaddr_index = pd.m_subaddr_index;
|
||||||
entry.subaddr_indices.push_back(pd.m_subaddr_index);
|
entry.subaddr_indices.push_back(pd.m_subaddr_index);
|
||||||
entry.address = m_wallet->get_subaddress_as_str(pd.m_subaddr_index);
|
entry.address = m_wallet->get_subaddress_as_str(pd.m_subaddr_index);
|
||||||
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward());
|
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd)
|
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd)
|
||||||
@ -365,7 +377,7 @@ namespace tools
|
|||||||
for (uint32_t i: pd.m_subaddr_indices)
|
for (uint32_t i: pd.m_subaddr_indices)
|
||||||
entry.subaddr_indices.push_back({pd.m_subaddr_account, i});
|
entry.subaddr_indices.push_back({pd.m_subaddr_account, i});
|
||||||
entry.address = m_wallet->get_subaddress_as_str({pd.m_subaddr_account, 0});
|
entry.address = m_wallet->get_subaddress_as_str({pd.m_subaddr_account, 0});
|
||||||
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward());
|
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd)
|
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd)
|
||||||
@ -396,7 +408,7 @@ namespace tools
|
|||||||
for (uint32_t i: pd.m_subaddr_indices)
|
for (uint32_t i: pd.m_subaddr_indices)
|
||||||
entry.subaddr_indices.push_back({pd.m_subaddr_account, i});
|
entry.subaddr_indices.push_back({pd.m_subaddr_account, i});
|
||||||
entry.address = m_wallet->get_subaddress_as_str({pd.m_subaddr_account, 0});
|
entry.address = m_wallet->get_subaddress_as_str({pd.m_subaddr_account, 0});
|
||||||
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward());
|
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_tx.unlock_time);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
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)
|
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)
|
||||||
@ -419,7 +431,7 @@ namespace tools
|
|||||||
entry.subaddr_index = pd.m_subaddr_index;
|
entry.subaddr_index = pd.m_subaddr_index;
|
||||||
entry.subaddr_indices.push_back(pd.m_subaddr_index);
|
entry.subaddr_indices.push_back(pd.m_subaddr_index);
|
||||||
entry.address = m_wallet->get_subaddress_as_str(pd.m_subaddr_index);
|
entry.address = m_wallet->get_subaddress_as_str(pd.m_subaddr_index);
|
||||||
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward());
|
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
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)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user