diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-01-12 17:50:42 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-01-12 17:50:55 +0100 |
commit | f1c3c53e5f94965c3a2c1376cb375257ece53989 (patch) | |
tree | dc2da07a8110e418ca95a1960fa91d8f24f8983b | |
parent | a4bc4c1f79d7090e0c1adcac445be1d52b3fde62 (diff) | |
parent | 19bcf178485c7d2c353581e514582bd569c66c00 (diff) |
Merge #20738: [0.20] final rc2 backports
19bcf178485c7d2c353581e514582bd569c66c00 [doc] Add permissions to the getpeerinfo help. (Amiti Uttarwar)
d0c75abb288afdd295c4aa9d7e747f13d5926327 doc: Extract net permissions doc (MarcoFalke)
bcb655d7d19de9997c5acb4b25a7bf59f4882851 rpc: Add missing description of vout in getrawtransaction help text (Ben Carman)
Pull request description:
ACKs for top commit:
benthecarman:
ACK 19bcf17
fanquake:
ACK 19bcf178485c7d2c353581e514582bd569c66c00
Tree-SHA512: 5c0e500d44adba7707dddccee9a956957ff1771439a0aea9841f01571ac21028531b8e0276a4b7dee2588b1828853bd227a64de1590204472470cd43268a5368
-rw-r--r-- | src/init.cpp | 7 | ||||
-rw-r--r-- | src/net_permissions.cpp | 8 | ||||
-rw-r--r-- | src/net_permissions.h | 8 | ||||
-rw-r--r-- | src/rpc/net.cpp | 4 | ||||
-rw-r--r-- | src/rpc/rawtransaction.cpp | 2 |
5 files changed, 22 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp index f381a53b1b..c716af7b23 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -49,6 +49,7 @@ #include <ui_interface.h> #include <util/asmap.h> #include <util/moneystr.h> +#include <util/string.h> #include <util/system.h> #include <util/threadnames.h> #include <util/translation.h> @@ -460,11 +461,7 @@ void SetupServerArgs() hidden_args.emplace_back("-upnp"); #endif gArgs.AddArg("-whitebind=<[permissions@]addr>", "Bind to given address and whitelist peers connecting to it. " - "Use [host]:port notation for IPv6. Allowed permissions are bloomfilter (allow requesting BIP37 filtered blocks and transactions), " - "noban (do not ban for misbehavior), " - "forcerelay (relay transactions that are already in the mempool; implies relay), " - "relay (relay even in -blocksonly mode), " - "and mempool (allow requesting BIP35 mempool contents). " + "Use [host]:port notation for IPv6. Allowed permissions: " + Join(NET_PERMISSIONS_DOC, ", ") + ". " "Specify multiple permissions separated by commas (default: noban,mempool,relay). Can be specified multiple times.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); gArgs.AddArg("-whitelist=<[permissions@]IP address or network>", "Whitelist peers connecting from the given IP address (e.g. 1.2.3.4) or " diff --git a/src/net_permissions.cpp b/src/net_permissions.cpp index 22fa5ee73b..d76a512a6c 100644 --- a/src/net_permissions.cpp +++ b/src/net_permissions.cpp @@ -8,6 +8,14 @@ #include <util/system.h> #include <util/translation.h> +const std::vector<std::string> NET_PERMISSIONS_DOC{ + "bloomfilter (allow requesting BIP37 filtered blocks and transactions)", + "noban (do not ban for misbehavior)", + "forcerelay (relay transactions that are already in the mempool; implies relay)", + "relay (relay even in -blocksonly mode)", + "mempool (allow requesting BIP35 mempool contents)", +}; + // The parse the following format "perm1,perm2@xxxxxx" bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output, size_t& readen, std::string& error) { diff --git a/src/net_permissions.h b/src/net_permissions.h index a1b45c4009..39cec15287 100644 --- a/src/net_permissions.h +++ b/src/net_permissions.h @@ -2,12 +2,16 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <netaddress.h> + #include <string> #include <vector> -#include <netaddress.h> #ifndef BITCOIN_NET_PERMISSIONS_H #define BITCOIN_NET_PERMISSIONS_H + +extern const std::vector<std::string> NET_PERMISSIONS_DOC; + enum NetPermissionFlags { PF_NONE = 0, @@ -27,6 +31,7 @@ enum NetPermissionFlags PF_ISIMPLICIT = (1U << 31), PF_ALL = PF_BLOOMFILTER | PF_FORCERELAY | PF_RELAY | PF_NOBAN | PF_MEMPOOL, }; + class NetPermissions { public: @@ -45,6 +50,7 @@ public: flags = static_cast<NetPermissionFlags>(flags & ~f); } }; + class NetWhitebindPermissions : public NetPermissions { public: diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 8c400c05a0..5c4a410a9f 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -117,6 +117,10 @@ static UniValue getpeerinfo(const JSONRPCRequest& request) {RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"}, }}, {RPCResult::Type::BOOL, "whitelisted", "Whether the peer is whitelisted"}, + {RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer", + { + {RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"}, + }}, {RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"}, {RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "", { diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index d581349bc5..88a84e100b 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -114,7 +114,7 @@ static UniValue getrawtransaction(const JSONRPCRequest& request) {RPCResult::Type::OBJ, "", "", { {RPCResult::Type::STR_HEX, "txid", "The transaction id"}, - {RPCResult::Type::STR, "vout", ""}, + {RPCResult::Type::NUM, "vout", "The output number"}, {RPCResult::Type::OBJ, "scriptSig", "The script", { {RPCResult::Type::STR, "asm", "asm"}, |