This PR makes a new RPC command called getaddressinfo which relies on the wallet. It contains all of validateaddress's address info stuff. Those parts in validateaddress have been marked as deprecated. The tests have been updated to use getaddressinfo except the disablewallet test which is the only test that actually uses validateaddress to validate an address.
[RPC] Split part of validateaddress into getaddressinfo #10583
pull achow101 wants to merge 4 commits into bitcoin:master from achow101:getaddressinfo changing 23 files +427 −302-
achow101 commented at 10:17 PM on June 13, 2017: member
- fanquake added the label RPC/REST/ZMQ on Jun 14, 2017
-
laanwj commented at 2:16 PM on June 14, 2017: member
Concept ACK. Makes a lot of sense to move the wallet-specific information to a separate RPC.
-
gmaxwell commented at 7:33 PM on June 15, 2017: contributor
Concept ACK.
-
sipa commented at 10:20 PM on June 16, 2017: member
Currently this duplicates a singificant amount of code. Would it be possible to abstract out the 'info' part of
getaddressinfo, and then call that fromvalidateaddressas well (temporarily, until removed)? - sipa added the label Needs release notes on Jun 17, 2017
- achow101 force-pushed on Jun 19, 2017
-
achow101 commented at 11:33 PM on June 19, 2017: member
@sipa Apparently, no, this is not possible. My attempt at doing so has resulted in a linker failure. Apparently there is some makefile problems with that. https://github.com/achow101/bitcoin/tree/getaddressinfo-broken is the branch with the duplication removed, but there is a linker error with
IsMinecalls. The full build error is here: https://gist.github.com/achow101/0f0e2d9e75d9d77132ab83a7605f2377 -
achow101 commented at 12:04 AM on June 20, 2017: member
On second thought, I think I fixed the problem.
- achow101 force-pushed on Jun 20, 2017
- achow101 force-pushed on Jun 20, 2017
-
sipa commented at 8:16 PM on June 20, 2017: member
I believe you can do:
bitcoind_LDADD = \ $(LIBBITCOIN_SERVER) \ + $(LIBBITCOIN_WALLET) \ $(LIBBITCOIN_COMMON) \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ - $(LIBBITCOIN_WALLET) \ $(LIBBITCOIN_ZMQ) \in
Makefile.am.Then the _ismine code can move from wallet to common (which I think belongs there, as signing code is already in common too).
- achow101 force-pushed on Jun 21, 2017
-
laanwj commented at 2:21 PM on June 24, 2017: member
Then the _ismine code can move from wallet to common (which I think belongs there, as signing code is already in common too).
From what I remember it was already moved in the other direction at some point for the same reason. The circular dependency between
_walletand_serverremains a problem. We'll need to solve #7965 to get rid of it. Unfortunately, this is part of that... -
jnewbery commented at 2:35 PM on August 15, 2017: member
needs rebase
- achow101 force-pushed on Aug 15, 2017
-
achow101 commented at 9:27 PM on August 15, 2017: member
rebased
- achow101 force-pushed on Aug 15, 2017
- achow101 force-pushed on Aug 17, 2017
-
jnewbery commented at 4:07 PM on September 1, 2017: member
Concept ACK. This PR is currently difficult to review because there are broken intermediate commits, commits which reverse previous commits, random style changes in unconnected commits, etc. Are you able to tidy this up to make it easier to review? If not, I'm happy to take this PR and tidy it up.
My high-level feedback is that we should hide the deprecated fields in
validateaddressbehind a command-line argument (similar to #11031). Theisminemove to libbitcoin_common seems fine to me. - achow101 force-pushed on Sep 5, 2017
- achow101 force-pushed on Sep 5, 2017
- achow101 force-pushed on Sep 5, 2017
-
achow101 commented at 5:39 PM on September 5, 2017: member
Rebased and tidied up
-
jnewbery commented at 8:29 PM on September 5, 2017: member
Travis is failing on invalid scripted diff check.
- achow101 force-pushed on Sep 5, 2017
-
in src/rpc/misc.cpp:172 in 7c3e7ac6cd outdated
195 | - ret.push_back(Pair("hdkeypath", it->second.hdKeypath)); 196 | - ret.push_back(Pair("hdmasterkeyid", it->second.hdMasterKeyID.GetHex())); 197 | - } 198 | + try { 199 | + ret.pushKVs(getaddressinfo(request)); 200 | + } catch (UniValue e) {
jnewbery commented at 8:48 PM on September 5, 2017:I don't understand this. Why do we swallow the
RPC_METHOD_NOT_FOUNDerror?Can you add a comment explaining this?
achow101 commented at 11:21 PM on September 5, 2017:That is swallowed in the event that
-disablewalletis used;getaddressinfowill returnRPC_METHOD_NOT_FOUNDbutvalidateaddressshould still work and validate addresses.I will add a comment.
jnewbery commented at 11:45 PM on September 5, 2017:In that case, I think it's preferable to test for wallet existence before calling
getaddressinfo. The following should do it:if (!::vpwallets.empty()) { ret.pushKVs(getaddressinfo(request)); }
achow101 commented at 12:16 AM on September 6, 2017:Done
in src/wallet/rpcwallet.cpp:3219 in 7c3e7ac6cd outdated
3214 | +{ 3215 | + CWallet * const pwallet = GetWalletForJSONRPCRequest(request); 3216 | + if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) 3217 | + return NullUniValue; 3218 | + 3219 | + if (request.fHelp || request.params.size() != 1)
jnewbery commented at 9:46 PM on September 5, 2017:nit: braces for if block
in src/wallet/rpcwallet.cpp:3242 in 7c3e7ac6cd outdated
3223 | + "to be in the wallet.\n" 3224 | + "\nArguments:\n" 3225 | + "1. \"address\" (string, required) The bitcoin address to get the information of.\n" 3226 | + "\nResult:\n" 3227 | + "{\n" 3228 | + " \"address\" : \"address\", (string) The bitcoin address validated\n"
jnewbery commented at 9:48 PM on September 5, 2017:Help text seems to be missing result fields, including at least
script,hex,addresses,sigsrequired.
achow101 commented at 2:04 AM on September 19, 2017:Forgot to say that this was addressed.
jnewbery commented at 11:05 PM on September 5, 2017: memberA few nits inline. I think you could drop the third commit by making your scripted diff more focussed:
find ./test/functional -path '*py' -not -path ./test/functional/disablewallet.py -exec sed -i'' -e 's/validateaddress/getaddressinfo/g' {} \;note that sed syntax differs between BSD and GNU. You'll need to use
sed -i ''(space betweeniand empty string) on BSD.(this also has the benefit of not breaking git bisect)
I still think it's a good idea to hide the deprecated functionality behind a command-line argument to make removing it in the next version easier.
in src/wallet/rpcwallet.cpp:3178 in 7c3e7ac6cd outdated
3169 | @@ -3169,6 +3170,114 @@ UniValue generate(const JSONRPCRequest& request) 3170 | return generateBlocks(coinbase_script, num_generate, max_tries, true); 3171 | } 3172 | 3173 | +class DescribeAddressVisitor : public boost::static_visitor<UniValue> 3174 | +{ 3175 | +public: 3176 | + CWallet * const pwallet; 3177 | + 3178 | + DescribeAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {}
promag commented at 11:20 PM on September 5, 2017:Nit,
*and&next to type. In this case also const:const CWallet* wallet.
achow101 commented at 2:06 AM on September 19, 2017:Done
in src/wallet/rpcwallet.cpp:3569 in 7c3e7ac6cd outdated
3175 | +public: 3176 | + CWallet * const pwallet; 3177 | + 3178 | + DescribeAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {} 3179 | + 3180 | + UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
promag commented at 11:21 PM on September 5, 2017:Nit, expand to multiline?
achow101 commented at 2:06 AM on September 19, 2017:I don't think that is necessary
achow101 force-pushed on Sep 5, 2017achow101 force-pushed on Sep 6, 2017promag commented at 12:52 AM on September 6, 2017: memberNew code (and probably moved code) should take into account developer notes.
achow101 force-pushed on Sep 19, 2017achow101 force-pushed on Sep 19, 2017achow101 commented at 2:58 PM on September 19, 2017: memberRebased
in src/rpc/misc.cpp:76 in 098cebb709 outdated
82 | +#ifdef ENABLE_WALLET 83 | + if (!::vpwallets.empty()) { 84 | + ret.pushKVs(getaddressinfo(request)); 85 | + } 86 | +#endif 87 | + if (ret["address"].isNull()) {
jnewbery commented at 3:06 PM on September 19, 2017:nit: indentation for this if block
in src/wallet/rpcwallet.cpp:3230 in 098cebb709 outdated
3225 | +}; 3226 | + 3227 | +UniValue getaddressinfo(const JSONRPCRequest& request) 3228 | +{ 3229 | + CWallet * const pwallet = GetWalletForJSONRPCRequest(request); 3230 | + if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
jnewbery commented at 3:07 PM on September 19, 2017:nit: braces
in src/wallet/rpcwallet.cpp:3277 in 098cebb709 outdated
3272 | + ret.push_back(Pair("address", currentAddress)); 3273 | + 3274 | + CScript scriptPubKey = GetScriptForDestination(dest); 3275 | + ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));; 3276 | + 3277 | + ret.push_back(Pair("isscript", scriptPubKey.IsPayToScriptHash()));
jnewbery commented at 3:10 PM on September 19, 2017:micronit: not in same ordering as help text (either for
getaddressinfoorvalidateaddress. Suggest you move this line belowret.push_back(Pair("iswatchonly", ...in src/wallet/rpcwallet.cpp:3239 in 098cebb709 outdated
3234 | + throw std::runtime_error( 3235 | + "getaddressinfo \"address\"\n" 3236 | + "\nReturn information about the given bitcoin address. Some information requires the address\n" 3237 | + "to be in the wallet.\n" 3238 | + "\nArguments:\n" 3239 | + "1. \"address\" (string, required) The bitcoin address to get the information of.\n"
jnewbery commented at 3:18 PM on September 19, 2017:nit: help text alignment
in src/wallet/rpcwallet.cpp:3242 in 098cebb709 outdated
3237 | + "to be in the wallet.\n" 3238 | + "\nArguments:\n" 3239 | + "1. \"address\" (string, required) The bitcoin address to get the information of.\n" 3240 | + "\nResult:\n" 3241 | + "{\n" 3242 | + " \"address\" : \"address\", (string) The bitcoin address validated\n"
jnewbery commented at 3:18 PM on September 19, 2017:nit: help text alignment
in src/wallet/rpcwallet.cpp:3257 in 098cebb709 outdated
3252 | + " ,...\n" 3253 | + " ]\n" 3254 | + " \"sigsrequired\" : xxxxx (numeric, optional) Number of signatures required to spend multisig output\n" 3255 | + " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" 3256 | + " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" 3257 | + " \"timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n"
jnewbery commented at 3:18 PM on September 19, 2017:nit: help text alignment
in src/rpc/misc.cpp:143 in 098cebb709 outdated
82 | throw std::runtime_error( 83 | "validateaddress \"address\"\n" 84 | "\nReturn information about the given bitcoin address.\n" 85 | + "Parts of this command have been deprecated and moved to getaddressinfo\n" 86 | "\nArguments:\n" 87 | "1. \"address\" (string, required) The bitcoin address to validate\n"
jnewbery commented at 3:18 PM on September 19, 2017:nit: help text alignment
in src/rpc/misc.cpp:46 in 098cebb709 outdated
86 | "\nArguments:\n" 87 | "1. \"address\" (string, required) The bitcoin address to validate\n" 88 | "\nResult:\n" 89 | "{\n" 90 | " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" 91 | " \"address\" : \"address\", (string) The bitcoin address validated\n"
jnewbery commented at 3:18 PM on September 19, 2017:nit: help text alignment
in src/rpc/misc.cpp:63 in 098cebb709 outdated
114 | + " \"iscompressed\" : true|false, (boolean) DEPRECATED. If the address is compressed\n" 115 | " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" 116 | - " \"timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n" 117 | - " \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n" 118 | - " \"hdmasterkeyid\" : \"<hash160>\" (string, optional) The Hash160 of the HD master pubkey\n" 119 | + " \"timestamp\" : timestamp, (number, optional) DEPRECATED. The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n"
jnewbery commented at 3:18 PM on September 19, 2017:nit: help text alignment
jnewbery commented at 3:28 PM on September 19, 2017: memberA bunch of nits inline. I'm currently running this over the extended test suite to verify no regressions.
My high-level feedback hasn't been addressed:
we should hide the deprecated fields in validateaddress behind a command-line argument (similar to #11031).
We need to do something to phase out deprecated RPC methods over a couple of releases. The proposal in #11031 is my suggested way of doing that, but I'm open to other suggestions.
jnewbery commented at 5:34 PM on September 19, 2017: memberextended test suite passes. Travis is failing the scripted diff check.
achow101 force-pushed on Sep 19, 2017jnewbery commented at 6:40 PM on September 19, 2017: memberThanks for addressing the nits.
My preference is that this doesn't get merged without some kind of phased deprecation. I'm happy to provide a commit to cherry pick if that would help.
achow101 commented at 6:45 PM on September 19, 2017: memberMy preference is that this doesn't get merged without some kind of phased deprecation. I'm happy to provide a commit to cherry pick if that would help.
I'm planning on making a generic deprecation interface type thing that I will then rebase this and some other stuff on top of.
achow101 force-pushed on Sep 26, 2017in src/rpc/misc.cpp:40 in c288c958e9 outdated
80 | { 81 | if (request.fHelp || request.params.size() != 1) 82 | throw std::runtime_error( 83 | "validateaddress \"address\"\n" 84 | "\nReturn information about the given bitcoin address.\n" 85 | + "Parts of this command have been deprecated and moved to getaddressinfo. To have those deprecated\n"
jnewbery commented at 7:30 PM on September 26, 2017:Suggestion only: Perhaps start this with
DEPRECATION WARNING:to draw attention. It might be easy to miss this warning.
achow101 commented at 8:43 PM on September 26, 2017:Done
jnewbery commented at 7:36 PM on September 26, 2017: memberLooks good. Tested ACK c288c958e96d9c2c856abcde901518f0de9fd3ce.
One suggestion inline, which you could take or leave.
A test for the difference between the return object when
-deprecatedrpc=validateaddressis set and not would be a nice to have, but not essential.achow101 force-pushed on Sep 26, 2017in src/rpc/misc.cpp:90 in 8d5d4cf4c3 outdated
112 | + ret.pushKVs(getaddressinfo(request)); 113 | } 114 | #endif 115 | + if (ret["address"].isNull()) { 116 | + std::string currentAddress = EncodeDestination(dest); 117 | + ret.push_back(Pair("address", currentAddress));
achow101 commented at 10:11 PM on September 26, 2017:Done.
in src/wallet/rpcwallet.h:13 in 8d5d4cf4c3 outdated
9 | @@ -10,6 +10,7 @@ 10 | class CRPCTable; 11 | class CWallet; 12 | class JSONRPCRequest; 13 | +class UniValue;
promag commented at 9:27 PM on September 26, 2017:Why?
achow101 commented at 10:10 PM on September 26, 2017:UniValueis needed below forUniValue getaddressinfo...in src/wallet/rpcwallet.cpp:3279 in 8d5d4cf4c3 outdated
3274 | + 3275 | + CScript scriptPubKey = GetScriptForDestination(dest); 3276 | + ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));; 3277 | + 3278 | + isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO; 3279 | + ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
promag commented at 9:32 PM on September 26, 2017:bool(mine & ISMINE_SPENDABLE)? Same below.in test/functional/deprecated_rpc.py:24 in df53fd1c4d outdated
19 | + self.log.info("Using -deprecatedrpc=estimatefee bypasses the error") 20 | + self.nodes[1].estimatefee(1) 21 | + 22 | + # test validateaddress deprecation 23 | + dep_validate_address = self.nodes[0].validateaddress("mnvGjUy3NMj67yJ6gkK5o9e5RS33Z2Vqcu") 24 | + assert("ismine" not in dep_validate_address)
jnewbery commented at 9:34 PM on September 26, 2017:assert is a statement, not a function:
assert "ismine" not in dep_validate_addresssame for assert below.
achow101 commented at 10:11 PM on September 26, 2017:Done
in test/functional/deprecated_rpc.py:22 in df53fd1c4d outdated
17 | + assert_raises_jsonrpc(-32, 'estimatefee is deprecated', self.nodes[0].estimatefee, 1) 18 | + 19 | + self.log.info("Using -deprecatedrpc=estimatefee bypasses the error") 20 | + self.nodes[1].estimatefee(1) 21 | + 22 | + # test validateaddress deprecation
jnewbery commented at 9:34 PM on September 26, 2017:suggestion: change this to a
self.log.info()
achow101 commented at 10:11 PM on September 26, 2017:Done
achow101 force-pushed on Sep 26, 2017in test/functional/deprecated_rpc.py:23 in df53fd1c4d outdated
18 | + 19 | + self.log.info("Using -deprecatedrpc=estimatefee bypasses the error") 20 | + self.nodes[1].estimatefee(1) 21 | + 22 | + # test validateaddress deprecation 23 | + dep_validate_address = self.nodes[0].validateaddress("mnvGjUy3NMj67yJ6gkK5o9e5RS33Z2Vqcu")
jnewbery commented at 9:36 PM on September 26, 2017:Perhaps declare this address as a variable above (with comment) to avoid having magic strings in the RPC method call.
achow101 commented at 10:11 PM on September 26, 2017:Done
in test/functional/deprecated_rpc.py:24 in 8d5d4cf4c3 outdated
18 | @@ -19,5 +19,11 @@ def run_test(self): 19 | self.log.info("Using -deprecatedrpc=estimatefee bypasses the error") 20 | self.nodes[1].estimatefee(1) 21 | 22 | + # test validateaddress deprecation 23 | + dep_validate_address = self.nodes[0].validateaddress("mnvGjUy3NMj67yJ6gkK5o9e5RS33Z2Vqcu") 24 | + assert("ismine" not in dep_validate_address)
promag commented at 9:36 PM on September 26, 2017:Is it enough to check
isminekey? Maybe mergenodes[0].validateaddresswithnodes[0].getaddressinfoand that should containnodes[1].validateaddress?
achow101 commented at 10:09 PM on September 26, 2017:It's enough to determine that they are returning different things as one should have
ismineand the other not.jnewbery commented at 9:36 PM on September 26, 2017: memberThe changed commit broke the scripted-diff checker. You'll need to add your
-deprecatedrpc=validateaddresstest as a separate commit.promag commented at 9:36 PM on September 26, 2017: memberOnly reviewed [RPC] Split part of validateaddress into getaddressinfo commit.
achow101 force-pushed on Sep 26, 2017achow101 commented at 10:12 PM on September 26, 2017: memberThe changed commit broke the scripted-diff checker.
I noticed. I believe that should be fixed now as I changed the script to exclude
deprecatedrpc.py.achow101 force-pushed on Sep 26, 2017achow101 force-pushed on Sep 26, 2017achow101 force-pushed on Sep 26, 2017achow101 force-pushed on Sep 27, 2017achow101 commented at 3:26 PM on September 27, 2017: memberRebased onto master
in src/rpc/misc.cpp:42 in fa4eea7385 outdated
81 | if (request.fHelp || request.params.size() != 1) 82 | throw std::runtime_error( 83 | "validateaddress \"address\"\n" 84 | "\nReturn information about the given bitcoin address.\n" 85 | + "DEPRECATION WARNING: Parts of this command have been deprecated and moved to getaddressinfo. To have those deprecated\n" 86 | + "information shown, start bitcoind with -deprecatedrpc=validateaddress"
jnewbery commented at 8:33 PM on September 27, 2017:I think this warning should also say something like "Clients must transition to using getaddressinfo to access this information before upgrading to v0.17"
achow101 commented at 12:04 AM on September 28, 2017:Done
jnewbery commented at 8:38 PM on September 27, 2017: memberLooks generally good. One question. If I pass an invalid address to
getaddressinfo, I get the following output:→ bitcoin-cli getaddressinfo fAkEAdDrEsS { "address": "", "scriptPubKey": "", "ismine": 0, "iswatchonly": 0, "isscript": 0 }I think it would be more intuitive to either:
- have an
isvalidfield that returns False (like forvalidateaddress); or - throw a
RPC_INVALID_ADDRESS_OR_KEYerror
What do you think?
jtimon commented at 11:48 PM on September 27, 2017: contributorConcept ACK
throw a RPC_INVALID_ADDRESS_OR_KEY error
I like this option.
achow101 force-pushed on Sep 28, 2017achow101 commented at 12:04 AM on September 28, 2017: memberthrow a RPC_INVALID_ADDRESS_OR_KEY error
Did that. I didn't realize that I hadn't added that error there.
jnewbery commented at 8:38 PM on September 28, 2017: memberACK ea088845fb8dd903f681c4c08b6bfe412cecc536
in src/wallet/rpcwallet.cpp:3680 in ea088845fb outdated
3270 | + UniValue ret(UniValue::VOBJ); 3271 | + CTxDestination dest = DecodeDestination(request.params[0].get_str()); 3272 | + 3273 | + // Make sure the destination is valid 3274 | + if (!IsValidDestination(dest)) { 3275 | + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
promag commented at 8:51 PM on September 28, 2017:Missing test.
achow101 commented at 2:35 AM on September 29, 2017:Added a brief test for
getaddressinfoinwallet.pyin src/wallet/rpcwallet.cpp:3284 in ea088845fb outdated
3279 | + ret.pushKV("address", currentAddress); 3280 | + 3281 | + CScript scriptPubKey = GetScriptForDestination(dest); 3282 | + ret.pushKV("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())); 3283 | + 3284 | + isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO;
promag commented at 8:52 PM on September 28, 2017:pwalletis valid because ofEnsureWalletIsAvailableabove.
achow101 commented at 2:35 AM on September 29, 2017:Removed the
pwalletcheck.in src/wallet/rpcwallet.cpp:3231 in ea088845fb outdated
3226 | + 3227 | +UniValue getaddressinfo(const JSONRPCRequest& request) 3228 | +{ 3229 | + CWallet * const pwallet = GetWalletForJSONRPCRequest(request); 3230 | + if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { 3231 | + return NullUniValue;
promag commented at 8:52 PM on September 28, 2017:Nit, fix indentation.
achow101 commented at 2:35 AM on September 29, 2017:Done
in src/wallet/rpcwallet.cpp:3472 in ea088845fb outdated
3215 | + UniValue a(UniValue::VARR); 3216 | + for (const CTxDestination& addr : addresses) { 3217 | + a.push_back(EncodeDestination(addr)); 3218 | + } 3219 | + obj.push_back(Pair("addresses", a)); 3220 | + if (whichType == TX_MULTISIG)
promag commented at 8:53 PM on September 28, 2017:Nit, add
{or single line.
achow101 commented at 2:35 AM on September 29, 2017:Done
in src/rpc/misc.cpp:42 in ea088845fb outdated
82 | throw std::runtime_error( 83 | "validateaddress \"address\"\n" 84 | "\nReturn information about the given bitcoin address.\n" 85 | + "DEPRECATION WARNING: Parts of this command have been deprecated and moved to getaddressinfo. Clients must\n" 86 | + "transition to using getaddressinfo to access this information before upgrading to v0.17. To have those deprecated\n" 87 | + "information shown, start bitcoind with -deprecatedrpc=validateaddress"
TheBlueMatt commented at 12:48 AM on September 29, 2017:Grammar here: "To have those deprecated information shown" -> "To have those deprecated fields shown"
achow101 commented at 2:35 AM on September 29, 2017:Done
in src/wallet/rpcwallet.cpp:3248 in ea088845fb outdated
3243 | + " \"address\" : \"address\", (string) The bitcoin address validated\n" 3244 | + " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n" 3245 | + " \"ismine\" : true|false, (boolean) If the address is yours or not\n" 3246 | + " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n" 3247 | + " \"isscript\" : true|false, (boolean) If the key is a script\n" 3248 | + " \"script\" : \"type\" (string, optional) The output script type. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash\n"
TheBlueMatt commented at 12:59 AM on September 29, 2017:While you're at it, can you clarify the docs on this? Its the redeemScript type, afaict, not the address type...Maybe even move the redeemScript-specific stuff to a separate object? like redeemScript: { script:, hex: addresses: []}...
achow101 commented at 2:36 AM on September 29, 2017:I changed that field to
redeemscript. I didn't make it a separate object.in src/rpc/misc.cpp:186 in ea088845fb outdated
132 | -#ifdef ENABLE_WALLET 133 | - CWallet * const pwallet = GetWalletForJSONRPCRequest(request); 134 | - 135 | - LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr); 136 | -#else 137 | LOCK(cs_main);
TheBlueMatt commented at 1:08 AM on September 29, 2017:I do not believe you need cs_main here anymore.
in src/wallet/rpcwallet.cpp:3268 in ea088845fb outdated
3263 | + + HelpExampleCli("getaddressinfo", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") 3264 | + + HelpExampleRpc("getaddressinfo", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") 3265 | + ); 3266 | + } 3267 | + 3268 | + LOCK2(cs_main, pwallet->cs_wallet);
TheBlueMatt commented at 1:08 AM on September 29, 2017:I believe you only need cs_wallet here.
achow101 commented at 2:36 AM on September 29, 2017:Done.
in src/rpc/misc.cpp:52 in ea088845fb outdated
98 | - " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n" 99 | " \"isscript\" : true|false, (boolean) If the key is a script\n" 100 | - " \"script\" : \"type\" (string, optional) The output script type. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash\n" 101 | - " \"hex\" : \"hex\", (string, optional) The redeemscript for the p2sh address\n" 102 | - " \"addresses\" (string, optional) Array of addresses associated with the known redeemscript\n" 103 | + " \"ismine\" : true|false, (boolean) DEPRECATED. If the address is yours or not\n"
TheBlueMatt commented at 1:19 AM on September 29, 2017:Why change the ordering here? UniValue returns things ordered in insertion-order (and hence bitcoin-cli and some JSON libraries will print it in that order) so might as well just leave it...having deprecation warnings interspersed is fine, they'll all go away soon enough :)
achow101 commented at 2:10 AM on September 29, 2017:The idea was to group the deprecated things together. The ordering is still correct though.
in src/rpc/misc.cpp:74 in ea088845fb outdated
114 | - " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" 115 | - " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" 116 | + " \"sigsrequired\" : xxxxx (numeric, optional) DEPRECATED. Number of signatures required to spend multisig output\n" 117 | + " \"pubkey\" : \"publickeyhex\", (string) DEPRECATED. The hex value of the raw public key\n" 118 | + " \"iscompressed\" : true|false, (boolean) DEPRECATED. If the address is compressed\n" 119 | " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n"
TheBlueMatt commented at 1:23 AM on September 29, 2017:You removed this from the output, but not the docs. For now I think we should leave the account display here, primarily just because we will want to keep it identical but just rename it label when we do accounts->label conversion.
achow101 commented at 2:35 AM on September 29, 2017:Added the accounts field back to the output.
TheBlueMatt commented at 1:24 AM on September 29, 2017: memberThanks for tackling one of the ifdef WALLETs!
achow101 force-pushed on Sep 29, 2017achow101 commented at 2:38 AM on September 29, 2017: memberAddressed @TheBlueMatt's and @promag's comments. I also changed two of the
pushKVs back topush_back(Pair(...))because they were not properly showing booleans (they were displayed as 0 and 1).achow101 force-pushed on Sep 29, 2017MarcoFalke commented at 2:36 PM on September 29, 2017: memberNeeds rebase
in test/functional/wallet.py:429 in 205fdcdfc1 outdated
425 | @@ -426,6 +426,15 @@ def run_test(self): 426 | 427 | # Verify nothing new in wallet 428 | assert_equal(total_txs, len(self.nodes[0].listtransactions("*",99999))) 429 | +
MarcoFalke commented at 2:37 PM on September 29, 2017:No trailing whitespace, please.
achow101 commented at 3:15 PM on September 29, 2017:Removed.
achow101 force-pushed on Sep 29, 2017achow101 commented at 3:15 PM on September 29, 2017: memberRebased onto master.
achow101 force-pushed on Sep 29, 2017achow101 force-pushed on Sep 29, 2017achow101 commented at 3:33 AM on October 19, 2017: membern'th rebase
achow101 force-pushed on Oct 19, 2017achow101 force-pushed on Oct 19, 2017in src/rpc/misc.cpp:57 in d1539bd607 outdated
147 | + " \"ismine\" : true|false, (boolean) DEPRECATED. If the address is yours or not\n" 148 | + " \"iswatchonly\" : true|false, (boolean) DEPRECATED. If the address is watchonly\n" 149 | + " \"iswitness\" : true|false, (boolean) DEPRECATED. If the address is a witness address\n" 150 | + " \"witness_version\" : version (numeric, optional) DEPRECATED. The version number of the witness program\n" 151 | + " \"witness_program\" : \"hex\" (string, optional) DEPRECATED. The hex value of the witness program\n" 152 | + " \"isscript\" : true|false, (boolean) DEPRECATED. If the key is a script\n"
meshcollider commented at 7:03 AM on November 17, 2017:Is this deprecated or not?
isscriptis on line 51 too which hasn't been deleted, and in the if-statement belowPair("isscript", scriptPubKey.IsPayToScriptHash())is pushed on line 98. I think the deprecation is correct, so both those lines should be removed?
achow101 commented at 5:04 PM on November 30, 2017:I think that
isscriptshouldn't be deprecated, so I fixed thatin src/wallet/rpcwallet.cpp:3661 in d1539bd607 outdated
3405 | + " \"address\"\n" 3406 | + " ,...\n" 3407 | + " ]\n" 3408 | + " \"sigsrequired\" : xxxxx (numeric, optional) Number of signatures required to spend multisig output\n" 3409 | + " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" 3410 | + " \"iscompressed\" : true|false, (boolean) If the address is compressed\n"
meshcollider commented at 7:09 AM on November 17, 2017:Should be
optional. Same aspubkeyon line above. Then make same changes to the deprecated fields invalidateaddressso they're consistent.
achow101 commented at 5:04 PM on November 30, 2017:Done.
in src/rpc/misc.cpp:57 in d1539bd607 outdated
148 | + " \"iswatchonly\" : true|false, (boolean) DEPRECATED. If the address is watchonly\n" 149 | + " \"iswitness\" : true|false, (boolean) DEPRECATED. If the address is a witness address\n" 150 | + " \"witness_version\" : version (numeric, optional) DEPRECATED. The version number of the witness program\n" 151 | + " \"witness_program\" : \"hex\" (string, optional) DEPRECATED. The hex value of the witness program\n" 152 | + " \"isscript\" : true|false, (boolean) DEPRECATED. If the key is a script\n" 153 | + " \"redeemscript\" : \"type\" (string, optional) DEPRECATED. The type of the redeemscript. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash\n"
meshcollider commented at 7:18 AM on November 17, 2017:If the deprecation switch is enabled, should
redeemscriptbe namedscriptfor compatibility in the output ofvalidateaddress? Otherwise its a breaking change anyway
achow101 commented at 5:04 PM on November 30, 2017:Done
meshcollider commented at 7:25 AM on November 17, 2017: contributorutACK https://github.com/bitcoin/bitcoin/pull/10583/commits/aa32c679e75e18996a26f2d4659f91cfa5654964, generally looks good, modulo some feedback inline.
In the case of P2SH-P2WPKH and P2SH-P2WSH, IMO the output should include the
witness_versionandwitness_programof the internal witness too. Although sipa mentioned he may have done this or something similar in 11403 I thinkThe deprecation warning mentions v0.17 specifically, perhaps this should have a 0.16.0 milestone, or that may need to be modified
Needs another rebase too sorry :)
achow101 force-pushed on Nov 30, 2017achow101 force-pushed on Nov 30, 2017achow101 commented at 5:06 PM on November 30, 2017: memberRebased and addresses @MeshCollider's comments.
The P2SH nested witness info is being done in #11403.
in src/rpc/misc.cpp:43 in 4ecc207a48 outdated
125 | if (request.fHelp || request.params.size() != 1) 126 | throw std::runtime_error( 127 | "validateaddress \"address\"\n" 128 | "\nReturn information about the given bitcoin address.\n" 129 | + "DEPRECATION WARNING: Parts of this command have been deprecated and moved to getaddressinfo. Clients must\n" 130 | + "transition to using getaddressinfo to access this information before upgrading to v0.17. To have those deprecated\n"
instagibbs commented at 8:26 PM on November 30, 2017:please tell the reader what type of things are moving
jnewbery commented at 6:16 PM on December 4, 2017: memberSorry for the late feedback after several rebases, but looking at this again I don't really like DescribeAddressVisitor moving into bitcoin-wallet, since there's functionality in there that's useful even when running with wallet disabled.
Can you take a look at https://github.com/jnewbery/bitcoin/commits/pr10583.1 . It's almost the same as this, but I've moved the generic parts of DescribeAddressVisitor into rpc/util, so they can be accessed by bitcoin-server.
achow101 force-pushed on Dec 5, 2017jnewbery commented at 3:37 PM on December 5, 2017: memberI think this is better, but obviously needs more review from others.
Incidentally, I think that you've made this more difficult to review by squashing my commits down into a single commit (having a commit that splits a function into two and moves half of it to a new file is more difficult to review than one commit to split and a second commit that is move-only). You've also:
- re-added the
DEPRECATEDnotice toiswitness,witness_versionandwitness_programwhen they're not actually now deprecated - re-introduced the
script/redeemscripterror in the help text.
achow101 force-pushed on Dec 7, 2017achow101 commented at 7:39 PM on December 7, 2017: memberI cherry-picked the split and move commits from @jnewbery and I think I fixed the regressions
They actually weren't squashed earlier. Rather I had only cherry picked one commit due to merge conflict stuff. That is resolved by taking the commits before mine.
achow101 force-pushed on Jan 10, 2018achow101 commented at 8:04 PM on January 10, 2018: memberRebased this but there's a linker error I can't quite figure out.
meshcollider commented at 9:36 AM on January 11, 2018: contributor@achow101: I guess it might be because you're adding rpc/util.cpp to libbitcoin_server_a_SOURCES rather than libbitcoin_util_a_SOURCES in the Makefile.am Also the scripted diff seems to have an issue
achow101 force-pushed on Jan 11, 2018achow101 commented at 7:00 PM on January 11, 2018: memberRebased and fixed the linker error.
achow101 force-pushed on Jan 11, 2018achow101 force-pushed on Feb 1, 2018achow101 commented at 9:36 PM on February 1, 2018: memberRebased
achow101 force-pushed on Feb 1, 2018achow101 force-pushed on Feb 2, 2018achow101 force-pushed on Feb 2, 2018in src/rpc/util.cpp:76 in 1de28c236c outdated
71 | + return UniValue(UniValue::VOBJ); 72 | +} 73 | + 74 | +UniValue DescribeAddressVisitor::operator()(const CKeyID &keyID) const { 75 | + UniValue obj(UniValue::VOBJ); 76 | + CPubKey vchPubKey;
jamesob commented at 9:10 PM on February 5, 2018:in src/rpc/util.cpp:84 in 1de28c236c outdated
79 | + return obj; 80 | +} 81 | + 82 | +UniValue DescribeAddressVisitor::operator()(const CScriptID &scriptID) const { 83 | + UniValue obj(UniValue::VOBJ); 84 | + CScript subscript;
jamesob commented at 9:10 PM on February 5, 2018:in src/rpc/util.cpp:93 in 1de28c236c outdated
88 | +} 89 | + 90 | +UniValue DescribeAddressVisitor::operator()(const WitnessV0KeyHash& id) const 91 | +{ 92 | + UniValue obj(UniValue::VOBJ); 93 | + CPubKey pubkey;
jamesob commented at 9:10 PM on February 5, 2018:in src/rpc/util.cpp:104 in 1de28c236c outdated
99 | +} 100 | + 101 | +UniValue DescribeAddressVisitor::operator()(const WitnessV0ScriptHash& id) const 102 | +{ 103 | + UniValue obj(UniValue::VOBJ); 104 | + CScript subscript;
jamesob commented at 9:11 PM on February 5, 2018:in src/rpc/util.cpp:115 in 1de28c236c outdated
110 | +} 111 | + 112 | +UniValue DescribeAddressVisitor::operator()(const WitnessUnknown& id) const 113 | +{ 114 | + UniValue obj(UniValue::VOBJ); 115 | + CScript subscript;
jamesob commented at 9:11 PM on February 5, 2018:in src/rpc/util.h:26 in 1de28c236c outdated
22 | @@ -16,4 +23,17 @@ CPubKey HexToPubKey(const std::string& hex_in); 23 | CPubKey AddrToPubKey(CKeyStore* const keystore, const std::string& addr_in); 24 | CScript CreateMultisigRedeemscript(const int required, const std::vector<CPubKey>& pubkeys); 25 | 26 | +class DescribeAddressVisitor : public boost::static_visitor<UniValue>
jamesob commented at 9:33 PM on February 5, 2018:In https://github.com/bitcoin/bitcoin/pull/10583/commits/4dadd7c7ac0934447b8ca33942535cc8a22e78f5
Curious: if we're looking to eventually get away from using Boost, should we reserve continued/new usage of it for cases when the feature at hand would be hard to replicate on our own? Seems like each use of
boost::apply_visitor(DescribeAddressVisitor(), foo);could be replaced with
DescribeAddressVisitor()(foo).I guess usages of
static_visitorare relatively easy to unwind if we ever want to, and it may be worthwhile to remain consistent with our usage of it in the wallet code.Feel free to ignore; not proposing we hold this changeset up on the basis of Boost usage, just curious.
sipa commented at 2:30 AM on February 9, 2018:I think you can keep the
DescribeAddressVisitorclass entirely local torpc/util.cpp, and only expose aUniValue DescribeAddress(const CTxDestination& dest)function.
achow101 commented at 5:01 PM on February 9, 2018:Changed this and
DescribeWalletAddressVisitorto helper functions which called the visitors.jamesob commented at 10:03 PM on February 5, 2018: memberTested concept ACK https://github.com/bitcoin/bitcoin/pull/10583/commits/1de28c236c593fc3af770e901ae5d2977370be3f
A few small comments attached. I think the only blocking ones are about unused variables.
achow101 force-pushed on Feb 6, 2018achow101 commented at 6:09 PM on February 6, 2018: memberRemoved the unused variables.
jamesob commented at 6:29 PM on February 6, 2018: memberACK https://github.com/bitcoin/bitcoin/pull/10583/commits/8a82bf5dc6355486e1b5a86346812c33bc454a1d
Nice work (and a heroic amount of rebasing).
meshcollider commented at 9:56 PM on February 7, 2018: contributorHopefully this can go in soon now 0.16 is branched off, looks like a painful one to keep rebasing. Will re-review as soon as I can
laanwj added this to the "Blockers" column in a project
achow101 force-pushed on Feb 8, 2018achow101 commented at 8:43 PM on February 8, 2018: memberRebased yet again.
in src/rpc/misc.cpp:73 in 9f61967fef outdated
71 | + } 72 | + 73 | + UniValue operator()(const WitnessV0ScriptHash& id) const 74 | + { 75 | + UniValue obj(UniValue::VOBJ); 76 | + CScript subscript;
instagibbs commented at 8:50 PM on February 8, 2018:unused?
in src/rpc/misc.cpp:45 in 9f61967fef outdated
42 | + 43 | + UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } 44 | + 45 | + UniValue operator()(const CKeyID &keyID) const { 46 | + UniValue obj(UniValue::VOBJ); 47 | + CPubKey vchPubKey;
instagibbs commented at 8:51 PM on February 8, 2018:unused?
in src/rpc/misc.cpp:53 in 9f61967fef outdated
50 | + return obj; 51 | + } 52 | + 53 | + UniValue operator()(const CScriptID &scriptID) const { 54 | + UniValue obj(UniValue::VOBJ); 55 | + CScript subscript;
instagibbs commented at 8:51 PM on February 8, 2018:unused?
in src/rpc/misc.cpp:62 in 9f61967fef outdated
60 | 61 | - explicit DescribeAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {} 62 | + UniValue operator()(const WitnessV0KeyHash& id) const 63 | + { 64 | + UniValue obj(UniValue::VOBJ); 65 | + CPubKey pubkey;
instagibbs commented at 8:51 PM on February 8, 2018:unused?
in src/rpc/misc.cpp:84 in 9f61967fef outdated
82 | + } 83 | + 84 | + UniValue operator()(const WitnessUnknown& id) const 85 | + { 86 | + UniValue obj(UniValue::VOBJ); 87 | + CScript subscript;
instagibbs commented at 8:52 PM on February 8, 2018:unused?
instagibbs approvedinstagibbs commented at 9:07 PM on February 8, 2018: memberutACK
unused variables don't break anything and quickly disappear, just noting them
sipa commented at 11:18 PM on February 8, 2018: memberLooking very good, and the commits are easy to follow. A few comments:
- The unused variables @instagibbs pointed out are removed after your move commit, but not before.
- I think
addressesandpubkeysalso moved togetaddressinfo, but aren't listed as DEPRECATED in the help. - Can we remove
addressesfromgetaddressinfoat the same time? It could remain invalidateaddresswhen-deprecatedrpc=validateaddressis given, but this is the perfect opportunity to remove it in favor ofpubkeysfor new users. - Do we need to keep the full description of all deprecated fields in
validateaddress? I think you could just say at the top "DEPRECATION WARNING: The following fields have moved to getaddressinfo and are only included here when running with -deprecatedrpc=validateaddress: ismine, iswatchonly, script, sigsrequired, pubkey, pubkeys, embedded, iscompressed, timestamp, hdkeypath, hdmasterkeyid.".
achow101 force-pushed on Feb 9, 2018achow101 force-pushed on Feb 9, 2018achow101 commented at 1:40 AM on February 9, 2018: member- Removed the extra unused variables
- Shortened
validateaddresshelp - Set
addressesto only be shown if-deprecatedrpc=validateaddressis set.
achow101 force-pushed on Feb 9, 2018in src/rpc/misc.cpp:45 in 66ba1b84c7 outdated
156 | "validateaddress \"address\"\n" 157 | "\nReturn information about the given bitcoin address.\n" 158 | + "DEPRECATION WARNING: Parts of this command have been deprecated and moved to getaddressinfo. Clients must\n" 159 | + "transition to using getaddressinfo to access this information before upgrading to v0.18. The following deprecated\n" 160 | + "fields have moved to getaddressinfo and will only be shown here with -deprecatedrpc=validateaddress: ismine, iswatchonly,\n" 161 | + "script, hex, pubkeys, sigsrequired, pubkey, embedded, iscompressed, account, timestamp, hdkeypath, kdmasterkeyid.\n"
sipa commented at 2:14 AM on February 9, 2018:There probably still needs to be a mention of
addresses, as there is now no information about it anywhere anymore.
achow101 commented at 5:00 PM on February 9, 2018:Added mention of it back.
in src/wallet/rpcwallet.cpp:3565 in 66ba1b84c7 outdated
3560 | + 3561 | + // The "addresses" field is confusing because it refers to public keys using their P2PKH address. 3562 | + // For that reason, only add the 'addresses' field when needed for backward compatibility. New applications 3563 | + // can use the 'embedded'->'address' field for P2SH or P2WSH wrapped addresses, and 'pubkeys' for 3564 | + // inspecting multisig participants. 3565 | + if (IsDeprecatedRPCEnabled("validateaddress")) obj.pushKV("addresses", std::move(a));
sipa commented at 2:27 AM on February 9, 2018:This will include the
addressesfield when-deprecatedrpc=validateaddressis set, even for witness addresses (currently it will only include it for legacy addresses).
achow101 commented at 5:01 PM on February 9, 2018:I changed it back to the original one and used
IsDeprecatedRPCin a different place to handle this issue.achow101 force-pushed on Feb 9, 2018achow101 force-pushed on Feb 9, 2018in src/rpc/util.cpp:126 in ba2cc57065 outdated
121 | +}; 122 | + 123 | +UniValue DescribeAddress(CTxDestination dest) 124 | +{ 125 | + return boost::apply_visitor(DescribeAddressVisitor(), dest); 126 | +}
promag commented at 10:28 PM on February 15, 2018:Nit, add newline.
achow101 commented at 11:28 PM on February 15, 2018:Done
in src/rpc/util.cpp:86 in ba2cc57065 outdated
81 | + obj.push_back(Pair("isscript", false)); 82 | + obj.push_back(Pair("iswitness", false)); 83 | + return obj; 84 | + } 85 | + 86 | + UniValue operator()(const CScriptID &scriptID) const {
promag commented at 10:28 PM on February 15, 2018:Nit,
const CScriptID& scriptID.{on new line.
achow101 commented at 11:28 PM on February 15, 2018:Done
in src/rpc/util.cpp:75 in ba2cc57065 outdated
70 | +class DescribeAddressVisitor : public boost::static_visitor<UniValue> 71 | +{ 72 | +public: 73 | + explicit DescribeAddressVisitor() {} 74 | + 75 | + UniValue operator()(const CNoDestination &dest) const {
promag commented at 10:29 PM on February 15, 2018:Nit,
const CNoDestination& dest.{on new line.
achow101 commented at 11:28 PM on February 15, 2018:Done
in src/rpc/misc.cpp:56 in ba2cc57065 outdated
194 | - " \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n" 195 | - " \"hdmasterkeyid\" : \"<hash160>\" (string, optional) The Hash160 of the HD master pubkey\n" 196 | + " \"isscript\" : true|false, (boolean) If the key is a script\n" 197 | + " \"iswitness\" : true|false, (boolean) If the address is a witness address\n" 198 | + " \"witness_version\" : version (numeric, optional) The version number of the witness program\n" 199 | + " \"witness_program\" : \"hex\" (string, optional) The hex value of the witness program\n"
promag commented at 10:30 PM on February 15, 2018:Fix alignment.
achow101 commented at 11:32 PM on February 15, 2018:Done
in src/Makefile.am:337 in ba2cc57065 outdated
333 | @@ -335,6 +334,7 @@ libbitcoin_common_a_SOURCES = \ 334 | scheduler.cpp \ 335 | script/sign.cpp \ 336 | script/standard.cpp \ 337 | + script/ismine.cpp \
promag commented at 10:30 PM on February 15, 2018:Nit, sort.
achow101 commented at 11:28 PM on February 15, 2018:Done
in src/Makefile.am:392 in ba2cc57065 outdated
388 | @@ -389,10 +389,10 @@ endif 389 | 390 | bitcoind_LDADD = \ 391 | $(LIBBITCOIN_SERVER) \ 392 | + $(LIBBITCOIN_WALLET) \
promag commented at 10:30 PM on February 15, 2018:Why this change? Does the order matter? 🙄
achow101 commented at 11:17 PM on February 15, 2018:Yes, the order matters
in src/rpc/util.h:26 in ba2cc57065 outdated
22 | @@ -16,4 +23,6 @@ CPubKey HexToPubKey(const std::string& hex_in); 23 | CPubKey AddrToPubKey(CKeyStore* const keystore, const std::string& addr_in); 24 | CScript CreateMultisigRedeemscript(const int required, const std::vector<CPubKey>& pubkeys); 25 | 26 | +UniValue DescribeAddress(CTxDestination dest);
promag commented at 10:33 PM on February 15, 2018:const CTxDestination& dest.
achow101 commented at 11:28 PM on February 15, 2018:Done
in src/wallet/rpcwallet.cpp:30 in ba2cc57065 outdated
26 | @@ -27,6 +27,7 @@ 27 | #include <wallet/feebumper.h> 28 | #include <wallet/wallet.h> 29 | #include <wallet/walletdb.h> 30 | +#include <wallet/rpcwallet.h>
promag commented at 10:33 PM on February 15, 2018:Nit, sort.
achow101 commented at 11:31 PM on February 15, 2018:Done
in src/wallet/rpcwallet.cpp:3521 in ba2cc57065 outdated
3515 | @@ -3515,6 +3516,207 @@ UniValue rescanblockchain(const JSONRPCRequest& request) 3516 | return response; 3517 | } 3518 | 3519 | +class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue> 3520 | +{ 3521 | +public: 3522 | + CWallet * const pwallet;
promag commented at 10:34 PM on February 15, 2018:Nit, m_wallet, why public?
achow101 commented at 11:17 PM on February 15, 2018:why not?
promag commented at 9:34 AM on February 16, 2018:See
CAffectedKeysVisitor,DestinationEncoderandCScriptVisitorwith private members. On the other handWitnessifiermembers are public (could be "fixed") .IMO all members, by default, should be private. When reading the code it's clear that a private member is not externally accessed/changed.
promag commented at 10:36 PM on February 15, 2018: memberNeeds rebase, some comments (mostly nits).
[rpc] split wallet and non-wallet parts of DescribeAddressVisitor 39633ecd5cin src/rpc/util.cpp:79 in ba2cc57065 outdated
74 | + 75 | + UniValue operator()(const CNoDestination &dest) const { 76 | + return UniValue(UniValue::VOBJ); 77 | + } 78 | + 79 | + UniValue operator()(const CKeyID &keyID) const {
promag commented at 10:37 PM on February 15, 2018:Nit,
const CKeyID& keyID.{on new line.
achow101 commented at 11:28 PM on February 15, 2018:Done
achow101 force-pushed on Feb 15, 2018achow101 force-pushed on Feb 15, 2018in src/wallet/rpcwallet.cpp:3571 in baef775c41 outdated
3566 | + 3567 | + explicit DescribeWalletAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {} 3568 | + 3569 | + UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } 3570 | + 3571 | + UniValue operator()(const CKeyID &keyID) const {
promag commented at 9:36 AM on February 16, 2018:&before space and{new line.in src/wallet/rpcwallet.cpp:3581 in baef775c41 outdated
3576 | + obj.pushKV("iscompressed", vchPubKey.IsCompressed()); 3577 | + } 3578 | + return obj; 3579 | + } 3580 | + 3581 | + UniValue operator()(const CScriptID &scriptID) const {
promag commented at 9:36 AM on February 16, 2018:&before space and{new line.in src/rpc/util.cpp:75 in baef775c41 outdated
70 | +class DescribeAddressVisitor : public boost::static_visitor<UniValue> 71 | +{ 72 | +public: 73 | + explicit DescribeAddressVisitor() {} 74 | + 75 | + UniValue operator()(const CNoDestination &dest) const
promag commented at 9:41 AM on February 16, 2018:&before space.
instagibbs commented at 2:47 PM on February 16, 2018:travis linter is complaining about trailing whitespace.... I don't know protocol if it matters but just reporting where the complaint is coming from
in src/wallet/rpcwallet.cpp:3569 in baef775c41 outdated
3564 | + if (include_addresses) obj.pushKV("addresses", std::move(a)); 3565 | + } 3566 | + 3567 | + explicit DescribeWalletAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {} 3568 | + 3569 | + UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
promag commented at 9:42 AM on February 16, 2018:&before space.in src/wallet/rpcwallet.cpp:3694 in baef775c41 outdated
3687 | + isminetype mine = IsMine(*pwallet, dest); 3688 | + ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE)); 3689 | + ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)); 3690 | + UniValue detail = DescribeWalletAddress(pwallet, dest); 3691 | + ret.pushKVs(detail); 3692 | + if (pwallet->mapAddressBook.count(dest)) {
promag commented at 9:46 AM on February 16, 2018:Use find to avoid 2nd lookup below (unless you don't want to touch moved code).
in src/wallet/rpcwallet.cpp:3648 in baef775c41 outdated
3643 | + " \"ismine\" : true|false, (boolean) If the address is yours or not\n" 3644 | + " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n" 3645 | + " \"isscript\" : true|false, (boolean) If the key is a script\n" 3646 | + " \"iswitness\" : true|false, (boolean) If the address is a witness address\n" 3647 | + " \"witness_version\" : version (numeric, optional) The version number of the witness program\n" 3648 | + " \"witness_program\" : \"hex\" (string, optional) The hex value of the witness program\n"
promag commented at 9:53 AM on February 16, 2018:Fix alignment.
in src/wallet/rpcwallet.cpp:3649 in baef775c41 outdated
3644 | + " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n" 3645 | + " \"isscript\" : true|false, (boolean) If the key is a script\n" 3646 | + " \"iswitness\" : true|false, (boolean) If the address is a witness address\n" 3647 | + " \"witness_version\" : version (numeric, optional) The version number of the witness program\n" 3648 | + " \"witness_program\" : \"hex\" (string, optional) The hex value of the witness program\n" 3649 | + " \"script\" : \"type\" (string, optional) The output script type. Only if \"isscript\" is true and the redeemscript is known. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash, witness_unknown\n"
promag commented at 9:53 AM on February 16, 2018:Fix alignment.
in src/wallet/rpcwallet.cpp:3660 in baef775c41 outdated
3653 | + " \"pubkey\"\n" 3654 | + " ,...\n" 3655 | + " ]\n" 3656 | + " \"sigsrequired\" : xxxxx (numeric, optional) Number of signatures required to spend multisig output (only if \"script\" is \"multisig\")\n" 3657 | + " \"pubkey\" : \"publickeyhex\", (string, optional) The hex value of the raw public key, for single-key addresses (possibly embedded in P2SH or P2WSH)\n" 3658 | + " \"embedded\" : {...}, (object, optional) Information about the address embedded in P2SH or P2WSH, if relevant and known. It includes all getaddressinfo output fields for the embedded address, excluding metadata (\"timestamp\", \"hdkeypath\", \"hdmasterkeyid\") and relation to the wallet (\"ismine\", \"iswatchonly\", \"account\").\n"
promag commented at 9:58 AM on February 16, 2018:Remove period? (my personal preference if to add period on all, currently it's a mix)
in src/wallet/rpcwallet.cpp:3567 in baef775c41 outdated
3562 | + // can use the 'embedded'->'address' field for P2SH or P2WSH wrapped addresses, and 'pubkeys' for 3563 | + // inspecting multisig participants. 3564 | + if (include_addresses) obj.pushKV("addresses", std::move(a)); 3565 | + } 3566 | + 3567 | + explicit DescribeWalletAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {}
promag commented at 9:59 AM on February 16, 2018:*before space.in src/wallet/rpcwallet.cpp:3620 in baef775c41 outdated
3613 | + UniValue operator()(const WitnessUnknown& id) const { return UniValue(UniValue::VOBJ); } 3614 | +}; 3615 | + 3616 | +UniValue DescribeWalletAddress(CWallet* pwallet, const CTxDestination& dest) 3617 | +{ 3618 | + UniValue ret(UniValue::VOBJ);
promag commented at 10:01 AM on February 16, 2018:Nit, could
AssertLockHeld(pwallet->cs_wallet).in src/wallet/rpcwallet.cpp:3586 in baef775c41 outdated
3579 | + } 3580 | + 3581 | + UniValue operator()(const CScriptID &scriptID) const { 3582 | + UniValue obj(UniValue::VOBJ); 3583 | + CScript subscript; 3584 | + if (pwallet && pwallet->GetCScript(scriptID, subscript)) {
promag commented at 10:02 AM on February 16, 2018:In this context
pwalletis valid so:if (pwallet->GetCScript(scriptID, subscript)) {in src/wallet/rpcwallet.cpp:3575 in baef775c41 outdated
3569 | + UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } 3570 | + 3571 | + UniValue operator()(const CKeyID &keyID) const { 3572 | + UniValue obj(UniValue::VOBJ); 3573 | + CPubKey vchPubKey; 3574 | + if (pwallet && pwallet->GetPubKey(keyID, vchPubKey)) {
promag commented at 10:03 AM on February 16, 2018:In this context
pwalletis valid so:if (pwallet->GetCScript(scriptID, subscript)) {in src/wallet/rpcwallet.cpp:3608 in baef775c41 outdated
3601 | + { 3602 | + UniValue obj(UniValue::VOBJ); 3603 | + CScript subscript; 3604 | + CRIPEMD160 hasher; 3605 | + uint160 hash; 3606 | + hasher.Write(id.begin(), 32).Finalize(hash.begin());
promag commented at 10:06 AM on February 16, 2018:Unless you don't want to touch moved code, remove
hasherand just do:CRIPEMD160().Write(id.begin(), 32).Finalize(hash.begin());in src/wallet/rpcwallet.cpp:3609 in baef775c41 outdated
3602 | + UniValue obj(UniValue::VOBJ); 3603 | + CScript subscript; 3604 | + CRIPEMD160 hasher; 3605 | + uint160 hash; 3606 | + hasher.Write(id.begin(), 32).Finalize(hash.begin()); 3607 | + if (pwallet && pwallet->GetCScript(CScriptID(hash), subscript)) {
promag commented at 10:07 AM on February 16, 2018:In this context
pwalletis valid so:if (pwallet->GetCScript(CScriptID(hash), subscript)) {in src/rpc/misc.cpp:72 in baef775c41 outdated
253 | - if (!meta->hdKeypath.empty()) { 254 | - ret.pushKV("hdkeypath", meta->hdKeypath); 255 | - ret.pushKV("hdmasterkeyid", meta->hdMasterKeyID.GetHex()); 256 | - } 257 | - } 258 | + if (!::vpwallets.empty() && IsDeprecatedRPCEnabled("validateaddress")) {
promag commented at 10:09 AM on February 16, 2018:Why
!::vpwallets.empty()? There is alwasy one wallet right?
achow101 commented at 5:07 PM on February 16, 2018:No, you can run with
-disablewalletwhich will disable wallets and thusvpwalletswill be empty.in src/rpc/util.cpp:80 in baef775c41 outdated
75 | + UniValue operator()(const CNoDestination &dest) const 76 | + { 77 | + return UniValue(UniValue::VOBJ); 78 | + } 79 | + 80 | + UniValue operator()(const CKeyID &keyID) const
promag commented at 10:10 AM on February 16, 2018:&before space.in src/rpc/util.cpp:88 in baef775c41 outdated
83 | + obj.pushKV("isscript", false); 84 | + obj.pushKV("iswitness", false); 85 | + return obj; 86 | + } 87 | + 88 | + UniValue operator()(const CScriptID &scriptID) const
promag commented at 10:10 AM on February 16, 2018:&before space.in src/wallet/rpcwallet.cpp:3596 in baef775c41 outdated
3589 | + 3590 | + UniValue operator()(const WitnessV0KeyHash& id) const 3591 | + { 3592 | + UniValue obj(UniValue::VOBJ); 3593 | + CPubKey pubkey; 3594 | + if (pwallet && pwallet->GetPubKey(CKeyID(id), pubkey)) {
promag commented at 10:11 AM on February 16, 2018:In this context
pwalletis valid so:if (pwallet->GetPubKey(CKeyID(id), pubkey)) {promag commented at 10:24 AM on February 16, 2018: memberLightly tested ACK. Please consider the following comments.
jnewbery commented at 2:36 PM on February 16, 2018: member@promag - personally, I'd generally discourage nits after a PR has been open for many months and been rebased/re-reviewed many times already. Adding additional churn and workload to the contributor and reviewers at this point seems borderline sadistic :slightly_smiling_face:
(just my opinion though)
[rpc] Move DescribeAddressVisitor to rpc/util 1598f32304b98bfc5ed0Create getaddressinfo RPC and deprecate parts of validateaddress
Moves the parts of validateaddress which require the wallet into getaddressinfo which is part of the wallet RPCs. Mark those parts of validateaddress which require the wallet as deprecated. Validateaddress will call getaddressinfo for the data that both share for right now. Moves IsMine functions to libbitcoin_common and then links libbitcoin_wallet before libbitcoin_common in order to prevent linker errors since IsMine is no longer used in libbitcoin_server.
b22cce0148scripted-diff: validateaddress to getaddressinfo in tests
Change all instances of validateaddress to getaddressinfo since it seems that no test actually uses validateaddress for actually validating addresses. -BEGIN VERIFY SCRIPT- find ./test/functional -path '*py' -not -path ./test/functional/wallet_disable.py -not -path ./test/functional/rpc_deprecated.py -not -path ./test/functional/wallet_address_types.py -exec sed -i'' -e 's/validateaddress/getaddressinfo/g' {} \; -END VERIFY SCRIPT-achow101 force-pushed on Feb 16, 2018jnewbery commented at 6:48 PM on February 16, 2018: memberTested ACK b22cce014852b082d80f1cc35f902b375cba0318. Travis failure looks unrelated.
Let's get this merged!
sipa commented at 7:12 PM on February 16, 2018: memberutACK b22cce014852b082d80f1cc35f902b375cba0318
I have a few minor improvements, but I'll submit them as a separate PR after merge, nothing worth holding this up for.
jonasschnelli commented at 11:27 AM on February 17, 2018: contributorTested ACK b22cce014
jonasschnelli merged this on Feb 17, 2018jonasschnelli closed this on Feb 17, 2018jonasschnelli referenced this in commit 8a98dfeebf on Feb 17, 2018laanwj removed this from the "Blockers" column in a project
tynes referenced this in commit 5b47d87430 on Mar 16, 2019fanquake removed the label Needs release note on Mar 20, 2019tynes referenced this in commit 26a2000b01 on Mar 26, 2019tynes referenced this in commit d350c097af on Apr 2, 2019boymanjor referenced this in commit 62b4de584c on Apr 9, 2019tuxcanfly referenced this in commit 4c6c73e555 on Apr 19, 2019xdustinface referenced this in commit 122078b9ec on Dec 17, 2020DrahtBot locked this on Dec 16, 2021
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 06:15 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me