danicoin/src/WalletLegacy/WalletUtils.h

36 lines
872 B
C
Raw Normal View History

// Copyright (c) 2011-2016 The Cryptonote developers
2014-06-25 17:21:42 +00:00
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include <exception>
#include <iomanip>
#include <iostream>
2015-07-30 15:22:07 +00:00
#include "IWalletLegacy.h"
#include "Wallet/WalletErrors.h"
2014-06-25 17:21:42 +00:00
namespace CryptoNote {
2015-05-27 12:08:46 +00:00
inline void throwIf(bool expr, CryptoNote::error::WalletErrorCodes ec)
2014-06-25 17:21:42 +00:00
{
if (expr)
throw std::system_error(make_error_code(ec));
}
2015-07-30 15:22:07 +00:00
inline std::ostream& operator <<(std::ostream& ostr, const Crypto::Hash& hash) {
std::ios_base::fmtflags flags = ostr.setf(std::ios_base::hex, std::ios_base::basefield);
char fill = ostr.fill('0');
2015-07-30 15:22:07 +00:00
for (auto b : hash.data) {
ostr << std::setw(2) << static_cast<unsigned int>(b);
}
2014-06-25 17:21:42 +00:00
ostr.fill(fill);
ostr.setf(flags);
return ostr;
}
2014-06-25 17:21:42 +00:00
} //namespace CryptoNote