You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

amount.cpp 817B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2015 The Bitcoin Core developers
  3. // Distributed under the MIT software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #include "amount.h"
  6. #include "tinyformat.h"
  7. const std::string CURRENCY_UNIT = "BTC";
  8. CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize)
  9. {
  10. if (nSize > 0)
  11. nSatoshisPerK = nFeePaid*1000/nSize;
  12. else
  13. nSatoshisPerK = 0;
  14. }
  15. CAmount CFeeRate::GetFee(size_t nSize) const
  16. {
  17. CAmount nFee = nSatoshisPerK*nSize / 1000;
  18. if (nFee == 0 && nSatoshisPerK > 0)
  19. nFee = nSatoshisPerK;
  20. return nFee;
  21. }
  22. std::string CFeeRate::ToString() const
  23. {
  24. return strprintf("%d.%08d %s/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN, CURRENCY_UNIT);
  25. }