diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1212,7 +1212,7 @@ std::set destinations; std::vector vecSend; - CAmount totalAmount = 0; + Amount totalAmount = 0; std::vector keys = sendTo.getKeys(); for (const std::string &name_ : keys) { CTxDestination dest = DecodeDestination(name_); @@ -1230,8 +1230,8 @@ destinations.insert(dest); CScript scriptPubKey = GetScriptForDestination(dest); - CAmount nAmount = AmountFromValue(sendTo[name_]).GetSatoshis(); - if (nAmount <= 0) { + Amount nAmount = AmountFromValue(sendTo[name_]); + if (nAmount <= Amount(0)) { throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); } totalAmount += nAmount; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -133,7 +133,7 @@ struct CRecipient { CScript scriptPubKey; - CAmount nAmount; + Amount nAmount; bool fSubtractFeeFromAmount; }; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2569,7 +2569,7 @@ // Turn the txout set into a CRecipient vector. for (size_t idx = 0; idx < tx.vout.size(); idx++) { const CTxOut &txOut = tx.vout[idx]; - CRecipient recipient = {txOut.scriptPubKey, txOut.nValue.GetSatoshis(), + CRecipient recipient = {txOut.scriptPubKey, txOut.nValue, setSubtractFeeFromOutputs.count(idx) == 1}; vecSend.push_back(recipient); } @@ -2628,11 +2628,11 @@ CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, const CCoinControl *coinControl, bool sign) { - CAmount nValue = 0; + Amount nValue = 0; int nChangePosRequest = nChangePosInOut; unsigned int nSubtractFeeFromAmount = 0; for (const auto &recipient : vecSend) { - if (nValue < 0 || recipient.nAmount < 0) { + if (nValue < Amount(0) || recipient.nAmount < Amount(0)) { strFailReason = _("Transaction amounts must not be negative"); return false; } @@ -2702,7 +2702,7 @@ wtxNew.fFromMe = true; bool fFirst = true; - CAmount nValueToSelect = nValue; + Amount nValueToSelect = nValue; if (nSubtractFeeFromAmount == 0) { nValueToSelect += nFeeRet; }