diff --git a/src/rpc/abc.cpp b/src/rpc/abc.cpp index b23afdfd1..ee0c7bfe2 100644 --- a/src/rpc/abc.cpp +++ b/src/rpc/abc.cpp @@ -1,95 +1,95 @@ // Copyright (c) 2017-2020 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include #include #include static UniValue getexcessiveblock(const Config &config, const JSONRPCRequest &request) { RPCHelpMan{ "getexcessiveblock", - "\nReturn the excessive block size.", + "Return the excessive block size.", {}, RPCResult{" excessiveBlockSize (integer) block size in bytes\n"}, RPCExamples{HelpExampleCli("getexcessiveblock", "") + HelpExampleRpc("getexcessiveblock", "")}, } .Check(request); UniValue ret(UniValue::VOBJ); ret.pushKV("excessiveBlockSize", config.GetMaxBlockSize()); return ret; } static UniValue setexcessiveblock(Config &config, const JSONRPCRequest &request) { RPCHelpMan{ "setexcessiveblock", - "\nSet the excessive block size. Excessive blocks will not be used in " + "Set the excessive block size. Excessive blocks will not be used in " "the active chain or relayed. This discourages the propagation of " "blocks that you consider excessively large.", { {"blockSize", RPCArg::Type::NUM, RPCArg::Optional::NO, "Excessive block size in bytes. Must be greater than " + std::to_string(LEGACY_MAX_BLOCK_SIZE) + "."}, }, RPCResult{" blockSize (integer) excessive block size in bytes\n"}, RPCExamples{HelpExampleCli("setexcessiveblock", "25000000") + HelpExampleRpc("setexcessiveblock", "25000000")}, } .Check(request); if (!request.params[0].isNum()) { throw JSONRPCError( RPC_INVALID_PARAMETER, std::string( "Invalid parameter, excessiveblock must be an integer")); } int64_t ebs = request.params[0].get_int64(); // Do not allow maxBlockSize to be set below historic 1MB limit if (ebs <= int64_t(LEGACY_MAX_BLOCK_SIZE)) { throw JSONRPCError( RPC_INVALID_PARAMETER, std::string( "Invalid parameter, excessiveblock must be larger than ") + std::to_string(LEGACY_MAX_BLOCK_SIZE)); } // Set the new max block size. { LOCK(cs_main); if (!config.SetMaxBlockSize(ebs)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Unexpected error"); } } // settingsToUserAgentString(); std::ostringstream ret; ret << "Excessive Block set to " << ebs << " bytes."; return UniValue(ret.str()); } // clang-format off static const CRPCCommand commands[] = { // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- { "network", "getexcessiveblock", getexcessiveblock, {}}, { "network", "setexcessiveblock", setexcessiveblock, {"maxBlockSize"}}, }; // clang-format on void RegisterABCRPCCommands(CRPCTable &t) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { t.appendCommand(commands[vcidx].name, &commands[vcidx]); } } diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp index c2124023c..f3f9a685f 100644 --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -1,213 +1,213 @@ // Copyright (c) 2020 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include #include #include #include static UniValue getavalanchekey(const Config &config, const JSONRPCRequest &request) { RPCHelpMan{ "getavalanchekey", - "\nReturns the key used to sign avalanche messages.\n", + "Returns the key used to sign avalanche messages.\n", {}, RPCResults{}, RPCExamples{HelpExampleRpc("getavalanchekey", "")}, } .Check(request); if (!g_avalanche) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Avalanche is not initialized"); } return HexStr(g_avalanche->getSessionPubKey()); } static CPubKey ParsePubKey(const UniValue ¶m) { const std::string keyHex = param.get_str(); if ((keyHex.length() != 2 * CPubKey::COMPRESSED_PUBLIC_KEY_SIZE && keyHex.length() != 2 * CPubKey::PUBLIC_KEY_SIZE) || !IsHex(keyHex)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid public key: %s\n", keyHex)); } return HexToPubKey(keyHex); } static UniValue addavalanchenode(const Config &config, const JSONRPCRequest &request) { RPCHelpMan{ "addavalanchenode", - "\nAdd a node in the set of peers to poll for avalanche.\n", + "Add a node in the set of peers to poll for avalanche.\n", { {"nodeid", RPCArg::Type::NUM, RPCArg::Optional::NO, "Node to be added to avalanche."}, {"publickey", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The public key of the node."}, {"proof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Proof that the node is not a sybil."}, }, RPCResult{"\"success\" (boolean) Whether the addition succeeded or " "not.\n"}, RPCExamples{ HelpExampleRpc("addavalanchenode", "5, \"\", \"\"")}, } .Check(request); RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR, UniValue::VSTR}); if (!g_avalanche) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Avalanche is not initialized"); } const NodeId nodeid = request.params[0].get_int64(); const CPubKey key = ParsePubKey(request.params[1]); CDataStream ss(ParseHexV(request.params[2], "proof"), SER_NETWORK, PROTOCOL_VERSION); avalanche::Proof proof; ss >> proof; return g_avalanche->addNode(nodeid, proof, key); } static UniValue buildavalancheproof(const Config &config, const JSONRPCRequest &request) { RPCHelpMan{ "buildavalancheproof", - "\nBuild a proof for avalanche's sybil resistance.\n", + "Build a proof for avalanche's sybil resistance.\n", { {"sequence", RPCArg::Type::NUM, RPCArg::Optional::NO, "The proof's sequence"}, {"expiration", RPCArg::Type::NUM, RPCArg::Optional::NO, "A timestamp indicating when the proof expire"}, {"master", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The master public key"}, { "stakes", RPCArg::Type::ARR, RPCArg::Optional::NO, "The stakes to be signed and associated private keys", { { "stake", RPCArg::Type::OBJ, RPCArg::Optional::NO, "A stake to be attached to this proof", { {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The amount in this UTXO"}, {"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "The height at which this UTXO was mined"}, {"iscoinbase", RPCArg::Type::BOOL, /* default */ "false", "Indicate wether the UTXO is a coinbase"}, {"privatekey", RPCArg::Type::STR, RPCArg::Optional::NO, "private key in base58-encoding"}, }, }, }, }, }, RPCResult{"\"proof\" (string) A string that is a serialized, " "hex-encoded proof data.\n"}, RPCExamples{HelpExampleRpc("buildavalancheproof", "0 1234567800 \"\" []")}, } .Check(request); RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM, UniValue::VSTR, UniValue::VARR}); if (!g_avalanche) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Avalanche is not initialized"); } const uint64_t sequence = request.params[0].get_int64(); const int64_t expiration = request.params[1].get_int64(); avalanche::ProofBuilder pb(sequence, expiration, ParsePubKey(request.params[2])); const UniValue &stakes = request.params[3].get_array(); for (size_t i = 0; i < stakes.size(); i++) { const UniValue &stake = stakes[i]; RPCTypeCheckObj(stake, { {"txid", UniValue::VSTR}, {"vout", UniValue::VNUM}, // "amount" is also required but check is done below // due to UniValue::VNUM erroneously not accepting // quoted numerics (which are valid JSON) {"height", UniValue::VNUM}, {"privatekey", UniValue::VSTR}, }); int nOut = find_value(stake, "vout").get_int(); if (nOut < 0) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout must be positive"); } const int height = find_value(stake, "height").get_int(); if (height < 1) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "height must be positive"); } const TxId txid(ParseHashO(stake, "txid")); const COutPoint utxo(txid, nOut); if (!stake.exists("amount")) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Missing amount"); } const Amount amount = AmountFromValue(find_value(stake, "amount")); const UniValue &iscbparam = find_value(stake, "iscoinbase"); const bool iscoinbase = iscbparam.isNull() ? false : iscbparam.get_bool(); CKey key = DecodeSecret(find_value(stake, "privatekey").get_str()); if (!pb.addUTXO(utxo, amount, uint32_t(height) << 1 | iscoinbase, std::move(key))) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid private key"); } } const avalanche::Proof proof = pb.build(); CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << proof; return HexStr(ss.begin(), ss.end()); } // clang-format off static const CRPCCommand commands[] = { // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- { "avalanche", "getavalanchekey", getavalanchekey, {}}, { "avalanche", "addavalanchenode", addavalanchenode, {"nodeid"}}, { "avalanche", "buildavalancheproof", buildavalancheproof, {"sequence", "expiration", "master", "stakes"}}, }; // clang-format on void RegisterAvalancheRPCCommands(CRPCTable &t) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { t.appendCommand(commands[vcidx].name, &commands[vcidx]); } } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6a16ba931..921d90cc1 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1,2671 +1,2671 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2019 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include