Skip to content

Commit

Permalink
Merge pull request #752 from dirtybits/development
Browse files Browse the repository at this point in the history
WIP: Display Incoming Unlock Time in Blocks and Local Time using wallet-api + zedwallet-beta
  • Loading branch information
zpalmtree committed Mar 29, 2019
2 parents 8323406 + e65a598 commit bdb85f6
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/zedwallet++/CommandImplementations.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2018, The TurtleCoin Developers
// Copyright (c) 2018-2019, The TurtleCoin Developers
// Copyright (c) 2018-2019, The Catalyst Developers
//
// Please see the included LICENSE file for more information.

Expand All @@ -7,6 +8,7 @@
///////////////////////////////////////////////

#include <config/WalletConfig.h>
#include <config/CryptoNoteConfig.h>

#include <Errors/ValidateParameters.h>

Expand Down Expand Up @@ -415,8 +417,37 @@ void printIncomingTransfer(const WalletTypes::Transaction tx)
{
stream << "Payment ID: " << tx.paymentID << "\n";
}

/* Display Unlock time, if applicable; otherwise, don't */
int64_t difference = tx.unlockTime - tx.blockHeight;

/* Here we treat Unlock as a block, and treat it that way in the future */
if (tx.unlockTime != 0 && difference > 0 && tx.unlockTime < CryptoNote::parameters::CRYPTONOTE_MAX_BLOCK_NUMBER)
{
int64_t unlockInUnixTime = tx.timestamp + (difference * CryptoNote::parameters::DIFFICULTY_TARGET);

std::cout << SuccessMsg(stream.str()) << std::endl;
std::cout << SuccessMsg(stream.str())
<< InformationMsg("Unlock height: ")
<< InformationMsg(tx.unlockTime)
<< std::endl
<< InformationMsg("Unlocks at approximately: ")
<< InformationMsg(ZedUtilities::unixTimeToDate(unlockInUnixTime))
<< std::endl
<< std::endl;
}
/* Here we treat Unlock as Unix time, and treat it that way in the future */
else if (tx.unlockTime > std::time(nullptr))
{
std::cout << SuccessMsg(stream.str())
<< InformationMsg("Unlocks at: ")
<< InformationMsg(ZedUtilities::unixTimeToDate(tx.unlockTime))
<< std::endl
<< std::endl;
}
else
{
std::cout << SuccessMsg(stream.str()) << std::endl;
}
}

void listTransfers(
Expand Down

0 comments on commit bdb85f6

Please sign in to comment.