aboutsummaryrefslogtreecommitdiff
path: root/src/amount.cpp
diff options
context:
space:
mode:
authorjtimon <jtimon@blockstream.io>2014-10-23 02:05:11 +0200
committerjtimon <jtimon@blockstream.io>2014-10-27 13:54:37 +0100
commiteda37330911b005f4be0c2d934346b26247d50f5 (patch)
tree47b9e17e2ec8bf2a351608a2cada601ec9d7e0bb /src/amount.cpp
parentb6c99efe9ccb44a4324bacb879ab1f43960bf69b (diff)
downloadbitcoin-eda37330911b005f4be0c2d934346b26247d50f5.tar.xz
MOVEONLY: Move CFeeRate and Amount constants to amount.o
Diffstat (limited to 'src/amount.cpp')
-rw-r--r--src/amount.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/amount.cpp b/src/amount.cpp
new file mode 100644
index 0000000000..e6f5b7d440
--- /dev/null
+++ b/src/amount.cpp
@@ -0,0 +1,31 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "amount.h"
+
+#include "tinyformat.h"
+
+CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize)
+{
+ if (nSize > 0)
+ nSatoshisPerK = nFeePaid*1000/nSize;
+ else
+ nSatoshisPerK = 0;
+}
+
+CAmount CFeeRate::GetFee(size_t nSize) const
+{
+ CAmount nFee = nSatoshisPerK*nSize / 1000;
+
+ if (nFee == 0 && nSatoshisPerK > 0)
+ nFee = nSatoshisPerK;
+
+ return nFee;
+}
+
+std::string CFeeRate::ToString() const
+{
+ return strprintf("%d.%08d BTC/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN);
+}