Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Satoshis become quanta #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/addressindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ struct CAddressUnspentKey {
};

struct CAddressUnspentValue {
CAmount satoshis;
CAmount quanta;
CScript script;
int blockHeight;

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(satoshis);
READWRITE(quanta);
READWRITE(*(CScriptBase*)(&script));
READWRITE(blockHeight);
}

CAddressUnspentValue(CAmount sats, CScript scriptPubKey, int height) {
satoshis = sats;
quanta = sats;
script = scriptPubKey;
blockHeight = height;
}
Expand All @@ -79,13 +79,13 @@ struct CAddressUnspentValue {
}

void SetNull() {
satoshis = -1;
quanta = -1;
script.clear();
blockHeight = 0;
}

bool IsNull() const {
return (satoshis == -1);
return (quanta == -1);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <stdint.h>

/** Amount in satoshis (Can be negative) */
/** Amount in quanta (Can be negative) */
typedef int64_t CAmount;

static const CAmount COIN = 100000000;
Expand Down
12 changes: 6 additions & 6 deletions src/policy/feerate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nBytes_)
int64_t nSize = int64_t(nBytes_);

if (nSize > 0)
nSatoshisPerK = nFeePaid * 1000 / nSize;
nQuantaPerK = nFeePaid * 1000 / nSize;
else
nSatoshisPerK = 0;
nQuantaPerK = 0;
}

CAmount CFeeRate::GetFee(size_t nBytes_) const
{
assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max()));
int64_t nSize = int64_t(nBytes_);

CAmount nFee = nSatoshisPerK * nSize / 1000;
CAmount nFee = nQuantaPerK * nSize / 1000;

if (nFee == 0 && nSize != 0) {
if (nSatoshisPerK > 0)
if (nQuantaPerK > 0)
nFee = CAmount(1);
if (nSatoshisPerK < 0)
if (nQuantaPerK < 0)
nFee = CAmount(-1);
}

Expand All @@ -40,5 +40,5 @@ CAmount CFeeRate::GetFee(size_t nBytes_) const

std::string CFeeRate::ToString() const
{
return strprintf("%d.%08d %s/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN, CURRENCY_UNIT);
return strprintf("%d.%08d %s/kB", nQuantaPerK / COIN, nQuantaPerK % COIN, CURRENCY_UNIT);
}
32 changes: 16 additions & 16 deletions src/policy/feerate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,40 @@
extern const std::string CURRENCY_UNIT;

/**
* Fee rate in satoshis per kilobyte: CAmount / kB
* Fee rate in quanta per kilobyte: CAmount / kB
*/
class CFeeRate
{
private:
CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes
CAmount nQuantaPerK; // unit is quanta-per-1,000-bytes
public:
/** Fee rate of 0 satoshis per kB */
CFeeRate() : nSatoshisPerK(0) { }
explicit CFeeRate(const CAmount& _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { }
/** Constructor for a fee rate in satoshis per kB. The size in bytes must not exceed (2^63 - 1)*/
/** Fee rate of 0 quanta per kB */
CFeeRate() : nQuantaPerK(0) { }
explicit CFeeRate(const CAmount& _nQuantaPerK): nQuantaPerK(_nQuantaPerK) { }
/** Constructor for a fee rate in quanta per kB. The size in bytes must not exceed (2^63 - 1)*/
CFeeRate(const CAmount& nFeePaid, size_t nBytes);
/**
* Return the fee in satoshis for the given size in bytes.
* Return the fee in quanta for the given size in bytes.
*/
CAmount GetFee(size_t nBytes) const;
/**
* Return the fee in satoshis for a size of 1000 bytes
* Return the fee in quanta for a size of 1000 bytes
*/
CAmount GetFeePerK() const { return GetFee(1000); }
friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; }
friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK != b.nSatoshisPerK; }
CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nQuantaPerK < b.nQuantaPerK; }
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nQuantaPerK > b.nQuantaPerK; }
friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nQuantaPerK == b.nQuantaPerK; }
friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nQuantaPerK <= b.nQuantaPerK; }
friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nQuantaPerK >= b.nQuantaPerK; }
friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nQuantaPerK != b.nQuantaPerK; }
CFeeRate& operator+=(const CFeeRate& a) { nQuantaPerK += a.nQuantaPerK; return *this; }
std::string ToString() const;

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(nSatoshisPerK);
READWRITE(nQuantaPerK);
}
};

Expand Down
12 changes: 6 additions & 6 deletions src/policy/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
{
// "Dust" is defined in terms of dustRelayFee,
// which has units satoshis-per-kilobyte.
// which has units quanta-per-kilobyte.
// If you'd pay more in fees than the value of the output
// to spend something, then we consider it dust.
// A typical spendable non-segwit txout is 34 bytes big, and will
// need a CTxIn of at least 148 bytes to spend:
// so dust is a spendable txout less than
// 182*dustRelayFee/1000 (in satoshis).
// 546 satoshis at the default rate of 3000 sat/kB.
// 182*dustRelayFee/1000 (in quanta).
// 546 quanta at the default rate of 3000 sat/kB.
// A typical spendable segwit txout is 31 bytes big, and will
// need a CTxIn of at least 67 bytes to spend:
// so dust is a spendable txout less than
// 98*dustRelayFee/1000 (in satoshis).
// 294 satoshis at the default rate of 3000 sat/kB.
// 98*dustRelayFee/1000 (in quanta).
// 294 quanta at the default rate of 3000 sat/kB.
if (txout.scriptPubKey.IsUnspendable())
return 0;

Expand All @@ -58,7 +58,7 @@ bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
/**
* Check transaction inputs to mitigate two
* potential denial-of-service attacks:
*
*
* 1. scriptSigs with extra data stuffed into them,
* not consumed by scriptPubKey (or P2SH script)
* 2. P2SH scripts with a crazy number of expensive
Expand Down
4 changes: 2 additions & 2 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
if (fWitness)
{
// there is some fudging in these numbers related to the actual virtual transaction size calculation that will keep this estimate from being exact.
// usually, the result will be an overestimate within a couple of satoshis so that the confirmation dialog ends up displaying a slightly smaller fee.
// usually, the result will be an overestimate within a couple of quanta so that the confirmation dialog ends up displaying a slightly smaller fee.
// also, the witness stack size value is a variable sized integer. usually, the number of stack items will be well under the single byte var int limit.
nBytes += 2; // account for the serialized marker and flag bytes
nBytes += nQuantity; // account for the witness byte that holds the number of stack items for each input.
Expand Down Expand Up @@ -582,7 +582,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
// tool tips
QString toolTipDust = tr("This label turns red if any recipient receives an amount smaller than the current dust threshold.");

// how many satoshis the estimated fee can vary per byte we guess wrong
// how many quanta the estimated fee can vary per byte we guess wrong
double dFeeVary = (double)nPayFee / nBytes;

QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/meritamountfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AmountSpinBox: public QAbstractSpinBox
explicit AmountSpinBox(QWidget *parent):
QAbstractSpinBox(parent),
currentUnit(MeritUnits::MRT),
singleStep(100000) // satoshis
singleStep(100000) // quanta
{
setAlignment(Qt::AlignRight);

Expand Down
2 changes: 1 addition & 1 deletion src/qt/meritamountfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MeritAmountField: public QWidget
CAmount value(bool *value=0) const;
void setValue(const CAmount& value);

/** Set single step in satoshis **/
/** Set single step in quanta **/
void setSingleStep(const CAmount& step);

/** Make read-only **/
Expand Down
4 changes: 2 additions & 2 deletions src/qt/meritunits.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class MeritUnits: public QAbstractListModel
static QString name(int unit);
//! Longer description
static QString description(int unit);
//! Number of Satoshis (1e-8) per unit
//! Number of quanta (1e-8) per unit
static qint64 factor(int unit);
//! Number of decimals left
static int decimals(int unit);
Expand Down Expand Up @@ -118,7 +118,7 @@ class MeritUnits: public QAbstractListModel
return text;
}

//! Return maximum number of base units (Satoshis)
//! Return maximum number of base units (quanta)
static CAmount maxMoney();

private:
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
} else {
continue;
}
delta.push_back(Pair("satoshis", -1 * spentInfo.satoshis));
delta.push_back(Pair("quanta", -1 * spentInfo.quanta));
delta.push_back(Pair("index", (int)j));
delta.push_back(Pair("prevtxid", input.prevout.hash.GetHex()));
delta.push_back(Pair("prevout", (int)input.prevout.n));
Expand Down Expand Up @@ -250,7 +250,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
continue;
}

delta.push_back(Pair("satoshis", out.nValue));
delta.push_back(Pair("quanta", out.nValue));
delta.push_back(Pair("index", (int)k));

outputs.push_back(delta);
Expand Down Expand Up @@ -1743,7 +1743,7 @@ UniValue getchaintxstats(const JSONRPCRequest& request)
pindex = chainActive.Tip();
}
}

assert(pindex != nullptr);

if (blockcount < 1 || blockcount >= pindex->nHeight) {
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ UniValue prioritisetransaction(const JSONRPCRequest& request)
"1. \"txid\" (string, required) The transaction id.\n"
"2. dummy (numeric, optional) API-Compatibility for previous API. Must be zero or null.\n"
" DEPRECATED. For forward compatibility use named arguments and omit this parameter.\n"
"3. fee_delta (numeric, required) The fee value (in satoshis) to add (or subtract, if negative).\n"
"3. fee_delta (numeric, required) The fee value (in quanta) to add (or subtract, if negative).\n"
" The fee is not actually paid, only the algorithm for selecting transactions into a block\n"
" considers the transaction as it would have paid a higher (or lower) fee.\n"
"\nResult:\n"
Expand Down Expand Up @@ -340,7 +340,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
" n (numeric) transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is\n"
" ,...\n"
" ],\n"
" \"fee\": n, (numeric) difference in value between transaction inputs and outputs (in satoshis); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one\n"
" \"fee\": n, (numeric) difference in value between transaction inputs and outputs (in quanta); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one\n"
" \"sigops\" : n, (numeric) total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero\n"
" \"weight\" : n, (numeric) total transaction weight, as counted for purposes of block limits\n"
" \"required\" : true|false (boolean) if provided and true, this transaction must be in the final block\n"
Expand All @@ -350,7 +350,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
" \"coinbaseaux\" : { (json object) data that should be included in the coinbase's scriptSig content\n"
" \"flags\" : \"xx\" (string) key name is to be ignored, and value included in scriptSig\n"
" },\n"
" \"coinbasevalue\" : n, (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)\n"
" \"coinbasevalue\" : n, (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in quanta)\n"
" \"coinbasetxn\" : { ... }, (json object) information for coinbase transaction\n"
" \"target\" : \"xxxx\", (string) The hash target\n"
" \"mintime\" : xxx, (numeric) The minimum timestamp appropriate for next block time in seconds since epoch (Jan 1 1970 GMT)\n"
Expand Down
16 changes: 8 additions & 8 deletions src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ UniValue getaddressmempool(const JSONRPCRequest& request)
" \"address\" (string) The base58check encoded address\n"
" \"txid\" (string) The related txid\n"
" \"index\" (number) The related input or output index\n"
" \"satoshis\" (number) The difference of satoshis\n"
" \"quanta\" (number) The difference of quanta\n"
" \"timestamp\" (number) The time the transaction entered the mempool (seconds)\n"
" \"prevtxid\" (string) The previous txid (if spending)\n"
" \"prevout\" (string) The previous transaction output index (if spending)\n"
Expand Down Expand Up @@ -766,7 +766,7 @@ UniValue getaddressmempool(const JSONRPCRequest& request)
delta.push_back(Pair("address", address));
delta.push_back(Pair("txid", it->first.txhash.GetHex()));
delta.push_back(Pair("index", (int)it->first.index));
delta.push_back(Pair("satoshis", it->second.amount));
delta.push_back(Pair("quanta", it->second.amount));
delta.push_back(Pair("timestamp", it->second.time));
if (it->second.amount < 0) {
delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex()));
Expand Down Expand Up @@ -801,7 +801,7 @@ UniValue getaddressutxos(const JSONRPCRequest& request)
" \"height\" (number) The block height\n"
" \"outputIndex\" (number) The output index\n"
" \"script\" (strin) The script hex encoded\n"
" \"satoshis\" (number) The number of satoshis of the output\n"
" \"quanta\" (number) The number of quanta of the output\n"
" }\n"
"]\n"
"\nExamples:\n"
Expand Down Expand Up @@ -846,7 +846,7 @@ UniValue getaddressutxos(const JSONRPCRequest& request)
output.push_back(Pair("txid", it->first.txhash.GetHex()));
output.push_back(Pair("outputIndex", (int)it->first.index));
output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end())));
output.push_back(Pair("satoshis", it->second.satoshis));
output.push_back(Pair("quanta", it->second.quanta));
output.push_back(Pair("height", it->second.blockHeight));
utxos.push_back(output);
}
Expand Down Expand Up @@ -884,7 +884,7 @@ UniValue getaddressdeltas(const JSONRPCRequest& request)
"\nResult:\n"
"[\n"
" {\n"
" \"satoshis\" (number) The difference of satoshis\n"
" \"quanta\" (number) The difference of quanta\n"
" \"txid\" (string) The related txid\n"
" \"index\" (number) The related input or output index\n"
" \"height\" (number) The block height\n"
Expand Down Expand Up @@ -949,7 +949,7 @@ UniValue getaddressdeltas(const JSONRPCRequest& request)
}

UniValue delta(UniValue::VOBJ);
delta.push_back(Pair("satoshis", it->second));
delta.push_back(Pair("quanta", it->second));
delta.push_back(Pair("txid", it->first.txhash.GetHex()));
delta.push_back(Pair("index", (int)it->first.index));
delta.push_back(Pair("blockindex", (int)it->first.txindex));
Expand Down Expand Up @@ -1005,8 +1005,8 @@ UniValue getaddressbalance(const JSONRPCRequest& request)
"}\n"
"\nResult:\n"
"{\n"
" \"balance\" (string) The current balance in satoshis\n"
" \"received\" (string) The total number of satoshis received (including change)\n"
" \"balance\" (string) The current balance in quanta\n"
" \"received\" (string) The total number of quanta received (including change)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
Expand Down
10 changes: 5 additions & 5 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue&
CSpentIndexValue spentInfo;
CSpentIndexKey spentKey(txin.prevout.hash, txin.prevout.n);
if (GetSpentIndex(spentKey, spentInfo)) {
in.push_back(Pair("value", ValueFromAmount(spentInfo.satoshis)));
in.push_back(Pair("valueSat", spentInfo.satoshis));
in.push_back(Pair("value", ValueFromAmount(spentInfo.quanta)));
in.push_back(Pair("valueSat", spentInfo.quanta));
if (spentInfo.addressType == 1) {
in.push_back(Pair("address", CMeritAddress(CKeyID(spentInfo.addressHash)).ToString()));
} else if (spentInfo.addressType == 2) {
Expand Down Expand Up @@ -729,7 +729,7 @@ UniValue combinerawtransaction(const JSONRPCRequest& request)
}

// switch back to avoid locking mempool for too long
view.SetBackend(viewDummy);
view.SetBackend(viewDummy);
}

// Use CTransaction for the constant parts of the
Expand Down Expand Up @@ -882,15 +882,15 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
CMeritSecret vchSecret;
bool fGood = vchSecret.SetString(k.get_str());

if (!fGood) {
if (!fGood) {
throw JSONRPCError(
RPC_INVALID_ADDRESS_OR_KEY,
"Invalid private key");
}

CKey key = vchSecret.GetKey();

if (!key.IsValid()) {
if (!key.IsValid()) {
throw JSONRPCError(
RPC_INVALID_ADDRESS_OR_KEY,
"Private key outside allowed range");
Expand Down
Loading