Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + | ||||
HelpExampleRpc( | HelpExampleRpc( | ||||
"setaccount", | "setaccount", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")); | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
CTxDestination dest = DecodeDestination(request.params[0].get_str()); | CTxDestination dest = | ||||
DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | |||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid Bitcoin address"); | "Invalid Bitcoin address"); | ||||
} | } | ||||
std::string strAccount; | std::string strAccount; | ||||
if (request.params.size() > 1) { | if (request.params.size() > 1) { | ||||
strAccount = AccountFromValue(request.params[1]); | strAccount = AccountFromValue(request.params[1]); | ||||
Show All 40 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
HelpExampleCli("getaccount", | HelpExampleCli("getaccount", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") + | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") + | ||||
HelpExampleRpc("getaccount", | HelpExampleRpc("getaccount", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"")); | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
CTxDestination dest = DecodeDestination(request.params[0].get_str()); | CTxDestination dest = | ||||
DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | |||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid Bitcoin address"); | "Invalid Bitcoin address"); | ||||
} | } | ||||
std::string strAccount; | std::string strAccount; | ||||
std::map<CTxDestination, CAddressBookData>::iterator mi = | std::map<CTxDestination, CAddressBookData>::iterator mi = | ||||
pwallet->mapAddressBook.find(dest); | pwallet->mapAddressBook.find(dest); | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 2 || | ||||
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"\" \"\" true") + | "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"\" \"\" true") + | ||||
HelpExampleRpc("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay" | HelpExampleRpc("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay" | ||||
"dd\", 0.1, \"donation\", \"seans " | "dd\", 0.1, \"donation\", \"seans " | ||||
"outpost\"")); | "outpost\"")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
CTxDestination dest = DecodeDestination(request.params[0].get_str()); | CTxDestination dest = | ||||
DecodeDestination(request.params[0].get_str(), config.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 = AmountFromValue(request.params[1]); | ||||
if (nAmount <= Amount(0)) { | if (nAmount <= Amount(0)) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | static UniValue signmessage(const Config &config, | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
EnsureWalletIsUnlocked(pwallet); | EnsureWalletIsUnlocked(pwallet); | ||||
std::string strAddress = request.params[0].get_str(); | std::string strAddress = request.params[0].get_str(); | ||||
std::string strMessage = request.params[1].get_str(); | std::string strMessage = request.params[1].get_str(); | ||||
CTxDestination dest = DecodeDestination(strAddress); | CTxDestination dest = | ||||
DecodeDestination(strAddress, config.GetChainParams()); | |||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); | throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); | ||||
} | } | ||||
const CKeyID *keyID = boost::get<CKeyID>(&dest); | const CKeyID *keyID = boost::get<CKeyID>(&dest); | ||||
if (!keyID) { | if (!keyID) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); | throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"\nAs a json rpc call\n" + | "\nAs a json rpc call\n" + | ||||
HelpExampleRpc("getreceivedbyaddress", | HelpExampleRpc("getreceivedbyaddress", | ||||
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")); | "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
// Bitcoin address | // Bitcoin address | ||||
CTxDestination dest = DecodeDestination(request.params[0].get_str()); | CTxDestination dest = | ||||
DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | |||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid Bitcoin address"); | "Invalid Bitcoin address"); | ||||
} | } | ||||
CScript scriptPubKey = GetScriptForDestination(dest); | CScript scriptPubKey = GetScriptForDestination(dest); | ||||
if (!IsMine(*pwallet, scriptPubKey)) { | if (!IsMine(*pwallet, scriptPubKey)) { | ||||
return ValueFromAmount(Amount(0)); | return ValueFromAmount(Amount(0)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 3 || | ||||
HelpExampleRpc("sendfrom", | HelpExampleRpc("sendfrom", | ||||
"\"tabby\", \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", " | "\"tabby\", \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", " | ||||
"0.01, 6, \"donation\", \"seans outpost\"")); | "0.01, 6, \"donation\", \"seans outpost\"")); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
std::string strAccount = AccountFromValue(request.params[0]); | std::string strAccount = AccountFromValue(request.params[0]); | ||||
CTxDestination dest = DecodeDestination(request.params[1].get_str()); | CTxDestination dest = | ||||
DecodeDestination(request.params[1].get_str(), config.GetChainParams()); | |||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid Bitcoin address"); | "Invalid Bitcoin address"); | ||||
} | } | ||||
Amount nAmount = AmountFromValue(request.params[2]); | Amount nAmount = AmountFromValue(request.params[2]); | ||||
if (nAmount <= Amount(0)) { | if (nAmount <= Amount(0)) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | static UniValue sendmany(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
std::set<CTxDestination> destinations; | std::set<CTxDestination> destinations; | ||||
std::vector<CRecipient> vecSend; | std::vector<CRecipient> vecSend; | ||||
Amount totalAmount(0); | Amount totalAmount(0); | ||||
std::vector<std::string> keys = sendTo.getKeys(); | std::vector<std::string> keys = sendTo.getKeys(); | ||||
for (const std::string &name_ : keys) { | for (const std::string &name_ : keys) { | ||||
CTxDestination dest = DecodeDestination(name_); | CTxDestination dest = DecodeDestination(name_, config.GetChainParams()); | ||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
std::string("Invalid Bitcoin address: ") + | std::string("Invalid Bitcoin address: ") + | ||||
name_); | name_); | ||||
} | } | ||||
if (destinations.count(dest)) { | if (destinations.count(dest)) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
▲ Show 20 Lines • Show All 1,871 Lines • ▼ Show 20 Lines | static UniValue listunspent(const Config &config, | ||||
} | } | ||||
std::set<CTxDestination> destinations; | std::set<CTxDestination> destinations; | ||||
if (request.params.size() > 2 && !request.params[2].isNull()) { | if (request.params.size() > 2 && !request.params[2].isNull()) { | ||||
RPCTypeCheckArgument(request.params[2], UniValue::VARR); | RPCTypeCheckArgument(request.params[2], UniValue::VARR); | ||||
UniValue inputs = request.params[2].get_array(); | UniValue inputs = request.params[2].get_array(); | ||||
for (size_t idx = 0; idx < inputs.size(); idx++) { | for (size_t idx = 0; idx < inputs.size(); idx++) { | ||||
const UniValue &input = inputs[idx]; | const UniValue &input = inputs[idx]; | ||||
CTxDestination dest = DecodeDestination(input.get_str()); | CTxDestination dest = | ||||
DecodeDestination(input.get_str(), config.GetChainParams()); | |||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
std::string("Invalid Bitcoin address: ") + | std::string("Invalid Bitcoin address: ") + | ||||
input.get_str()); | input.get_str()); | ||||
} | } | ||||
if (!destinations.insert(dest).second) { | if (!destinations.insert(dest).second) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | if (request.params.size() > 1) { | ||||
// will be checked below | // will be checked below | ||||
{"feeRate", UniValueType()}, | {"feeRate", UniValueType()}, | ||||
{"subtractFeeFromOutputs", UniValueType(UniValue::VARR)}, | {"subtractFeeFromOutputs", UniValueType(UniValue::VARR)}, | ||||
}, | }, | ||||
true, true); | true, true); | ||||
if (options.exists("changeAddress")) { | if (options.exists("changeAddress")) { | ||||
CTxDestination dest = | CTxDestination dest = | ||||
DecodeDestination(options["changeAddress"].get_str()); | DecodeDestination(options["changeAddress"].get_str(), | ||||
config.GetChainParams()); | |||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_ADDRESS_OR_KEY, | RPC_INVALID_ADDRESS_OR_KEY, | ||||
"changeAddress must be a valid bitcoin address"); | "changeAddress must be a valid bitcoin address"); | ||||
} | } | ||||
changeAddress = dest; | changeAddress = dest; | ||||
▲ Show 20 Lines • Show All 191 Lines • Show Last 20 Lines |