Return all available information via validateaddress
`"validateaddress"` omits some information, even in cases where is it available. The primary motivation is to be able to retrieve redeemScripts, after using `"addmultisigaddress"`, when not all keys are available in the keystore, but the redeemScript actually is. The output of `"validateaddress"` with this commit: Keys not available: ```js validateaddress "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3" { "isvalid": true, "address": "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3", "scriptPubKey": "76a914fa20d564550b105787f7ce3a9ad7fd9a45cd407088ac", "ismine": false, "iswatchonly": false, "isscript": false } ``` ```js validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK" { "isvalid": true, "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK", "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187", "ismine": false, "iswatchonly": false, "isscript": true } ``` After adding the redeemScript: ```js addmultisigaddress 2 '["02537357B156A33306A7A014A3748631C59DF405B56F11BA4AA4A3CE81501AF095","02F1FB200390E7864EF4450C07B15988179A57C3CF3A878F668E1070CB615749FE"]' 2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK" { "isvalid": true, "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK", "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187", "ismine": false, "iswatchonly": false, "isscript": true, "script": "multisig", "hex": "522102537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af0952102f1fb200390e7864ef4450c07b15988179a57c3cf3a878f668e1070cb615749fe52ae", "addresses": [ "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3", "mmSKNtbYYHRrhTLKiok5TuYrGEs4Y2A4k6" ], "sigsrequired": 2, "account": "" } ``` All keys available: ```js validateaddress "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3" { "isvalid": true, "address": "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3", "scriptPubKey": "76a914fa20d564550b105787f7ce3a9ad7fd9a45cd407088ac", "ismine": true, "iswatchonly": false, "isscript": false, "pubkey": "02537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af095", "iscompressed": true, "account": "" } ``` ```js validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK" { "isvalid": true, "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK", "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187", "ismine": true, "iswatchonly": false, "isscript": true, "script": "multisig", "hex": "522102537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af0952102f1fb200390e7864ef4450c07b15988179a57c3cf3a878f668e1070cb615749fe52ae", "addresses": [ "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3", "mmSKNtbYYHRrhTLKiok5TuYrGEs4Y2A4k6" ], "sigsrequired": 2, "account": "" } ```
This commit is contained in:
parent
defa4fc25c
commit
506bae3ac9
1 changed files with 6 additions and 15 deletions
|
@ -109,20 +109,14 @@ UniValue getinfo(const UniValue& params, bool fHelp)
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
class DescribeAddressVisitor : public boost::static_visitor<UniValue>
|
class DescribeAddressVisitor : public boost::static_visitor<UniValue>
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
isminetype mine;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DescribeAddressVisitor(isminetype mineIn) : mine(mineIn) {}
|
|
||||||
|
|
||||||
UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
|
UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
|
||||||
|
|
||||||
UniValue operator()(const CKeyID &keyID) const {
|
UniValue operator()(const CKeyID &keyID) const {
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
CPubKey vchPubKey;
|
CPubKey vchPubKey;
|
||||||
obj.push_back(Pair("isscript", false));
|
obj.push_back(Pair("isscript", false));
|
||||||
if (mine == ISMINE_SPENDABLE) {
|
if (pwalletMain->GetPubKey(keyID, vchPubKey)) {
|
||||||
pwalletMain->GetPubKey(keyID, vchPubKey);
|
|
||||||
obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
|
obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
|
||||||
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
|
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
|
||||||
}
|
}
|
||||||
|
@ -131,10 +125,9 @@ public:
|
||||||
|
|
||||||
UniValue operator()(const CScriptID &scriptID) const {
|
UniValue operator()(const CScriptID &scriptID) const {
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
|
CScript subscript;
|
||||||
obj.push_back(Pair("isscript", true));
|
obj.push_back(Pair("isscript", true));
|
||||||
if (mine != ISMINE_NO) {
|
if (pwalletMain->GetCScript(scriptID, subscript)) {
|
||||||
CScript subscript;
|
|
||||||
pwalletMain->GetCScript(scriptID, subscript);
|
|
||||||
std::vector<CTxDestination> addresses;
|
std::vector<CTxDestination> addresses;
|
||||||
txnouttype whichType;
|
txnouttype whichType;
|
||||||
int nRequired;
|
int nRequired;
|
||||||
|
@ -200,11 +193,9 @@ UniValue validateaddress(const UniValue& params, bool fHelp)
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
|
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
|
||||||
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
|
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
|
||||||
if (mine != ISMINE_NO) {
|
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
|
||||||
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
|
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
|
||||||
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest);
|
ret.pushKVs(detail);
|
||||||
ret.pushKVs(detail);
|
|
||||||
}
|
|
||||||
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
|
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
|
||||||
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name));
|
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue