Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 460 Lines • ▼ Show 20 Lines | static UniValue sendtoaddress(const Config &config, | ||||
CTxDestination dest = DecodeDestination(request.params[0].get_str(), | CTxDestination dest = DecodeDestination(request.params[0].get_str(), | ||||
wallet->GetChainParams()); | wallet->GetChainParams()); | ||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); | ||||
} | } | ||||
// Amount | // Amount | ||||
Amount nAmount = AmountFromValue(request.params[1]); | Amount nAmount = request.params[1]; | ||||
if (nAmount <= Amount::zero()) { | if (nAmount <= Amount::zero()) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | ||||
} | } | ||||
// Wallet comments | // Wallet comments | ||||
mapValue_t mapValue; | mapValue_t mapValue; | ||||
if (!request.params[2].isNull() && !request.params[2].get_str().empty()) { | if (!request.params[2].isNull() && !request.params[2].get_str().empty()) { | ||||
mapValue["comment"] = request.params[2].get_str(); | mapValue["comment"] = request.params[2].get_str(); | ||||
▲ Show 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | for (const std::string &name_ : keys) { | ||||
if (destinations.count(dest)) { | if (destinations.count(dest)) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
std::string("Invalid parameter, duplicated address: ") + name_); | std::string("Invalid parameter, duplicated address: ") + name_); | ||||
} | } | ||||
destinations.insert(dest); | destinations.insert(dest); | ||||
CScript scriptPubKey = GetScriptForDestination(dest); | CScript scriptPubKey = GetScriptForDestination(dest); | ||||
Amount nAmount = AmountFromValue(sendTo[name_]); | Amount nAmount = sendTo[name_]; | ||||
if (nAmount <= Amount::zero()) { | if (nAmount <= Amount::zero()) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | ||||
} | } | ||||
bool fSubtractFeeFromAmount = false; | bool fSubtractFeeFromAmount = false; | ||||
for (size_t idx = 0; idx < subtractFeeFromAmount.size(); idx++) { | for (size_t idx = 0; idx < subtractFeeFromAmount.size(); idx++) { | ||||
const UniValue &addr = subtractFeeFromAmount[idx]; | const UniValue &addr = subtractFeeFromAmount[idx]; | ||||
if (addr.get_str() == name_) { | if (addr.get_str() == name_) { | ||||
▲ Show 20 Lines • Show All 1,778 Lines • ▼ Show 20 Lines | static UniValue settxfee(const Config &config, const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
if (!wallet) { | if (!wallet) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
Amount nAmount = AmountFromValue(request.params[0]); | Amount nAmount = request.params[0]; | ||||
CFeeRate tx_fee_rate(nAmount, 1000); | CFeeRate tx_fee_rate(nAmount, 1000); | ||||
CFeeRate max_tx_fee_rate(pwallet->m_default_max_tx_fee, 1000); | CFeeRate max_tx_fee_rate(pwallet->m_default_max_tx_fee, 1000); | ||||
if (tx_fee_rate == CFeeRate()) { | if (tx_fee_rate == CFeeRate()) { | ||||
// automatic selection | // automatic selection | ||||
} else if (tx_fee_rate < pwallet->chain().relayMinFee()) { | } else if (tx_fee_rate < pwallet->chain().relayMinFee()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
strprintf("txfee cannot be less than min relay tx fee (%s)", | strprintf("txfee cannot be less than min relay tx fee (%s)", | ||||
▲ Show 20 Lines • Show All 736 Lines • ▼ Show 20 Lines | static UniValue listunspent(const Config &config, | ||||
Amount nMaximumAmount = MAX_MONEY; | Amount nMaximumAmount = MAX_MONEY; | ||||
Amount nMinimumSumAmount = MAX_MONEY; | Amount nMinimumSumAmount = MAX_MONEY; | ||||
uint64_t nMaximumCount = 0; | uint64_t nMaximumCount = 0; | ||||
if (!request.params[4].isNull()) { | if (!request.params[4].isNull()) { | ||||
const UniValue &options = request.params[4].get_obj(); | const UniValue &options = request.params[4].get_obj(); | ||||
if (options.exists("minimumAmount")) { | if (options.exists("minimumAmount")) { | ||||
nMinimumAmount = AmountFromValue(options["minimumAmount"]); | nMinimumAmount = options["minimumAmount"]; | ||||
} | } | ||||
if (options.exists("maximumAmount")) { | if (options.exists("maximumAmount")) { | ||||
nMaximumAmount = AmountFromValue(options["maximumAmount"]); | nMaximumAmount = options["maximumAmount"]; | ||||
} | } | ||||
if (options.exists("minimumSumAmount")) { | if (options.exists("minimumSumAmount")) { | ||||
nMinimumSumAmount = AmountFromValue(options["minimumSumAmount"]); | nMinimumSumAmount = options["minimumSumAmount"]; | ||||
} | } | ||||
if (options.exists("maximumCount")) { | if (options.exists("maximumCount")) { | ||||
nMaximumCount = options["maximumCount"].get_int64(); | nMaximumCount = options["maximumCount"].get_int64(); | ||||
} | } | ||||
} | } | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | if (!options.isNull()) { | ||||
coinControl.fAllowWatchOnly = | coinControl.fAllowWatchOnly = | ||||
ParseIncludeWatchonly(options["includeWatching"], *pwallet); | ParseIncludeWatchonly(options["includeWatching"], *pwallet); | ||||
if (options.exists("lockUnspents")) { | if (options.exists("lockUnspents")) { | ||||
lockUnspents = options["lockUnspents"].get_bool(); | lockUnspents = options["lockUnspents"].get_bool(); | ||||
} | } | ||||
if (options.exists("feeRate")) { | if (options.exists("feeRate")) { | ||||
coinControl.m_feerate = | coinControl.m_feerate = CFeeRate(options["feeRate"]); | ||||
CFeeRate(AmountFromValue(options["feeRate"])); | |||||
coinControl.fOverrideFeeRate = true; | coinControl.fOverrideFeeRate = true; | ||||
} | } | ||||
if (options.exists("subtractFeeFromOutputs")) { | if (options.exists("subtractFeeFromOutputs")) { | ||||
subtractFeeFromOutputs = | subtractFeeFromOutputs = | ||||
options["subtractFeeFromOutputs"].get_array(); | options["subtractFeeFromOutputs"].get_array(); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,264 Lines • Show Last 20 Lines |