Auto merge of #2616 - nathan-at-least:importprivkey-shows-address.4, r=str4d

Importprivkey shows address

Scratching an itch: make `importprivkey` output the corresponding address.

Without this PR, `importprivkey` shows no output. Because we're moving towards an "address-based" RPC interface, rather than "account-based", there's a gap when using `importprivkey` because there's no way to assign it to a specific account, but also no easy way to determine the address. This change fixes that wart.
This commit is contained in:
Homu
2017-09-21 14:29:03 -07:00
3 changed files with 117 additions and 3 deletions

View File

@@ -128,8 +128,9 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
pwalletMain->SetAddressBook(vchAddress, strLabel, "receive");
// Don't throw error in case a key is already there
if (pwalletMain->HaveKey(vchAddress))
return NullUniValue;
if (pwalletMain->HaveKey(vchAddress)) {
return CBitcoinAddress(vchAddress).ToString();
}
pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1;
@@ -144,7 +145,7 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
}
}
return NullUniValue;
return CBitcoinAddress(vchAddress).ToString();
}
UniValue importaddress(const UniValue& params, bool fHelp)