Balance format improvement

This commit is contained in:
Antonio Juarez 2015-04-08 16:08:54 +01:00
parent 1743402759
commit e15c01585f
6 changed files with 23 additions and 14 deletions

4
README
View file

@ -2,7 +2,7 @@
On *nix:
Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, and Boost 1.53 or later (except 1.54, more details here: http://goo.gl/RrCFmA).
Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, and Boost 1.55.
You may download them from:
http://gcc.gnu.org/
http://www.cmake.org/
@ -18,7 +18,7 @@ Test suite: run `make test-release' to run tests in addition to building. Runnin
Building with Clang: it may be possible to use Clang instead of GCC, but this may not work everywhere. To build, run `export CC=clang CXX=clang++' before running `make'.
On Windows:
Dependencies: MSVC 2012 or later, CMake 2.8.6 or later, and Boost 1.53 or later. You may download them from:
Dependencies: MSVC 2012 or later, CMake 2.8.6 or later, and Boost 1.55. You may download them from:
http://www.microsoft.com/
http://www.cmake.org/
http://www.boost.org/

View file

@ -575,7 +575,9 @@ bool simple_wallet::deinit()
if (!m_wallet.get())
return true;
return close_wallet();
bool r = close_wallet();
m_wallet->shutdown();
return r;
}
//----------------------------------------------------------------------------------------------------
void simple_wallet::handle_command_line(const boost::program_options::variables_map& vm)
@ -781,17 +783,24 @@ void simple_wallet::externalTransactionCreated(CryptoNote::TransactionId transac
TransactionInfo txInfo;
m_wallet->getTransaction(transactionId, txInfo);
if (txInfo.totalAmount >= 0) {
message_writer(epee::log_space::console_color_green, false) <<
"Height " << txInfo.blockHeight <<
", transaction " << epee::string_tools::pod_to_hex(txInfo.hash) <<
", received " << m_currency.formatAmount(txInfo.totalAmount);
", received " << m_currency.formatAmount(static_cast<uint64_t>(txInfo.totalAmount));
} else {
message_writer(epee::log_space::console_color_magenta, false) <<
"Height " << txInfo.blockHeight <<
", transaction " << epee::string_tools::pod_to_hex(txInfo.hash) <<
", spent " << m_currency.formatAmount(static_cast<uint64_t>(-txInfo.totalAmount));
}
m_refresh_progress_reporter.update(txInfo.blockHeight, true);
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::show_balance(const std::vector<std::string>& args/* = std::vector<std::string>()*/)
{
success_msg_writer() << "balance: " << m_currency.formatAmount(m_wallet->pendingBalance()) <<
", unlocked balance: " << m_currency.formatAmount(m_wallet->actualBalance());
success_msg_writer() << "available balance: " << m_currency.formatAmount(m_wallet->actualBalance()) <<
", locked amount: " << m_currency.formatAmount(m_wallet->pendingBalance());
return true;
}
//----------------------------------------------------------------------------------------------------
@ -1001,7 +1010,6 @@ bool simple_wallet::run()
void simple_wallet::stop()
{
m_cmd_binder.stop_handling();
m_wallet->shutdown();
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
@ -1145,8 +1153,8 @@ int main(int argc, char* argv[])
try
{
walletFileName = ::tryToOpenWalletOrLoadKeysOrThrow(wallet, wallet_file, wallet_password);
LOG_PRINT_L1("balance: " << currency.formatAmount(wallet->pendingBalance()) <<
", unlocked balance: " << currency.formatAmount(wallet->actualBalance()));
LOG_PRINT_L1("available balance: " << currency.formatAmount(wallet->actualBalance()) <<
", locked amount: " << currency.formatAmount(wallet->pendingBalance()));
LOG_PRINT_GREEN("Loaded ok", LOG_LEVEL_0);
}
catch (const std::exception& e)

View file

@ -223,7 +223,7 @@ void Wallet::initAndLoad(std::istream& source, const std::string& password) {
void Wallet::initSync() {
AccountSubscription sub;
sub.keys = reinterpret_cast<const AccountKeys&>(m_account.get_keys());
sub.transactionSpendableAge = 10;
sub.transactionSpendableAge = 1;
sub.syncStart.height = 0;
sub.syncStart.timestamp = m_account.get_createtime() - (60 * 60 * 24);

View file

@ -127,6 +127,7 @@ bool TestBlockchainGenerator::getBlockRewardForAddress(const cryptonote::Account
cryptonote::Transaction tx;
creator.generate(address, tx);
tx.unlockTime = 10; //default unlock time for coinbase transactions
addToBlockchain(tx);

View file

@ -413,8 +413,8 @@ TEST_F(DetachTest, testDetachWithWallet) {
ASSERT_EQ(txInfo.blockHeight, m_node.getLastLocalBlockHeight());
ASSERT_EQ(txInfo.totalAmount, tr.amount);
ASSERT_EQ(Bob.pendingBalance(), tr.amount);
ASSERT_EQ(Bob.actualBalance(), 0);
ASSERT_EQ(Bob.pendingBalance(), 0);
ASSERT_EQ(Bob.actualBalance(), tr.amount);
m_node.startAlternativeChain(m_node.getLastLocalBlockHeight() - 1);
generator.generateEmptyBlocks(2);

View file

@ -1016,8 +1016,8 @@ TEST_F(WalletApi, checkPendingBalance) {
bobNode->updateObservers();
ASSERT_NO_FATAL_FAILURE(WaitWalletSync(bobWalletObserver.get()));
ASSERT_EQ(0, bob->actualBalance());
ASSERT_EQ(sendAmount, bob->pendingBalance());
ASSERT_EQ(sendAmount, bob->actualBalance());
ASSERT_EQ(0, bob->pendingBalance());
alice->shutdown();
bob->shutdown();