From 9ca7857df74c52eb2c46be36c88a12879be6cf8c Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Sat, 1 Aug 2015 20:15:23 +0100 Subject: Rationalize currency unit to "BTC" Previously various user-facing strings have used inconsistent currency units "BTC", "btc" and "bitcoins". This adds a single constant and uses it for each reference to the currency unit. Also adds a description of the unit for --maxtxfee, and adds the missing "amount" field description to the (deprecated) move RPC command. --- src/amount.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/amount.cpp') diff --git a/src/amount.cpp b/src/amount.cpp index 0a394c96f..b46918198 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -7,6 +7,8 @@ #include "tinyformat.h" +const std::string CURRENCY_UNIT = "BTC"; + CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize) { if (nSize > 0) @@ -27,5 +29,5 @@ CAmount CFeeRate::GetFee(size_t nSize) const std::string CFeeRate::ToString() const { - return strprintf("%d.%08d BTC/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN); + return strprintf("%d.%08d %s/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN, CURRENCY_UNIT); } -- cgit v1.2.3 From fa24439ff3d8ab5b9efaf66ef4dae6713b88cb35 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 13 Dec 2015 17:58:29 +0100 Subject: Bump copyright headers to 2015 --- src/amount.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/amount.cpp') diff --git a/src/amount.cpp b/src/amount.cpp index b46918198..a3abd8cd8 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -- cgit v1.2.3 From faf756ae4ed63a31f073c09f3d0f25c13971cb98 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 9 Mar 2016 12:54:55 +0100 Subject: [amount] Make GetFee() monotonic This reverts the hard-to-read and buggy code introduced in d88af560111863c3e9c1ae855dcc287f04dffb02 and adds documentation --- src/amount.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/amount.cpp') diff --git a/src/amount.cpp b/src/amount.cpp index a3abd8cd8..d03ed5cfa 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -19,10 +19,10 @@ CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize) CAmount CFeeRate::GetFee(size_t nSize) const { - CAmount nFee = nSatoshisPerK*nSize / 1000; + CAmount nFee = nSatoshisPerK * nSize / 1000; - if (nFee == 0 && nSatoshisPerK > 0) - nFee = nSatoshisPerK; + if (nFee == 0 && nSize != 0 && nSatoshisPerK != 0) + nFee = CAmount(1); return nFee; } -- cgit v1.2.3 From fad13b1612b5de16d94c78c1a464d431a4f770bf Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sat, 19 Mar 2016 15:19:29 +0100 Subject: [amount] Preempt issues with negative fee rates --- src/amount.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/amount.cpp') diff --git a/src/amount.cpp b/src/amount.cpp index d03ed5cfa..68806ff06 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -21,7 +21,7 @@ CAmount CFeeRate::GetFee(size_t nSize) const { CAmount nFee = nSatoshisPerK * nSize / 1000; - if (nFee == 0 && nSize != 0 && nSatoshisPerK != 0) + if (nFee == 0 && nSize != 0 && nSatoshisPerK > 0) nFee = CAmount(1); return nFee; -- cgit v1.2.3 From fa2da2cb607ba359231fccc9635abe7c8616de56 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 3 Apr 2016 13:44:01 +0200 Subject: [amount] Add support for negative fee rates Currently negative fee rates are not supported on archs of 64-bit or more --- src/amount.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/amount.cpp') diff --git a/src/amount.cpp b/src/amount.cpp index 68806ff06..7b8618de3 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -9,20 +9,30 @@ const std::string CURRENCY_UNIT = "BTC"; -CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize) +CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nBytes_) { + assert(nBytes_ <= uint64_t(std::numeric_limits::max())); + int64_t nSize = int64_t(nBytes_); + if (nSize > 0) - nSatoshisPerK = nFeePaid*1000/nSize; + nSatoshisPerK = nFeePaid * 1000 / nSize; else nSatoshisPerK = 0; } -CAmount CFeeRate::GetFee(size_t nSize) const +CAmount CFeeRate::GetFee(size_t nBytes_) const { + assert(nBytes_ <= uint64_t(std::numeric_limits::max())); + int64_t nSize = int64_t(nBytes_); + CAmount nFee = nSatoshisPerK * nSize / 1000; - if (nFee == 0 && nSize != 0 && nSatoshisPerK > 0) - nFee = CAmount(1); + if (nFee == 0 && nSize != 0) { + if (nSatoshisPerK > 0) + nFee = CAmount(1); + if (nSatoshisPerK < 0) + nFee = CAmount(-1); + } return nFee; } -- cgit v1.2.3 From 27765b6403cece54320374b37afb01a0cfe571c3 Mon Sep 17 00:00:00 2001 From: isle2983 Date: Sat, 31 Dec 2016 11:01:21 -0700 Subject: Increment MIT Licence copyright header year on files modified in 2016 Edited via: $ contrib/devtools/copyright_header.py update . --- src/amount.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/amount.cpp') diff --git a/src/amount.cpp b/src/amount.cpp index 7b8618de3..a5f6bc3cd 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2015 The Bitcoin Core developers +// Copyright (c) 2009-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -- cgit v1.2.3 From 9c3a11b2488f3e01e6763bc1217598a4d1c69bde Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Sun, 11 Feb 2018 21:00:50 +0000 Subject: Clean up RPC tests (#1465) * Enable full block tests * Fix invalidblocktest * Move watch only address funding to immediately before it's used, so node 0 doesn't spend the output before it checks it later. * Fix `fundrawtransaction` tests and sanitize fee calculation at the same time * Correct resolution of chain parameters when validating tx inputs, especially from previous coinbase transactions * Set block versions on full block tests so that the generated blocks are AuxPoW compatible --- src/amount.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/amount.cpp') diff --git a/src/amount.cpp b/src/amount.cpp index a5f6bc3cd..d6a7d8c30 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -25,6 +25,11 @@ CAmount CFeeRate::GetFee(size_t nBytes_) const assert(nBytes_ <= uint64_t(std::numeric_limits::max())); int64_t nSize = int64_t(nBytes_); + // Dogecoin: Round up to the nearest 1000 bytes so we get round tx fees + if (nSize % 1000 > 0) { + nSize = nSize + 1000 - (nSize % 1000); + } + CAmount nFee = nSatoshisPerK * nSize / 1000; if (nFee == 0 && nSize != 0) { -- cgit v1.2.3 From 148a2aca05fe98031bcf857fa186d792c507090c Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Mon, 27 Jul 2015 16:35:30 +0100 Subject: Introduce basic Dogecoin branding --- src/amount.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/amount.cpp') diff --git a/src/amount.cpp b/src/amount.cpp index d6a7d8c30..176c0be85 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -7,7 +7,7 @@ #include "tinyformat.h" -const std::string CURRENCY_UNIT = "BTC"; +const std::string CURRENCY_UNIT = "DOGE"; CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nBytes_) { -- cgit v1.2.3