@@ -167,6 +167,7 @@ UniValue validateaddress(const JSONRPCRequest& request)
167167 " \" pubkey\" : \" publickeyhex\" , (string) The hex value of the raw public key\n "
168168 " \" iscompressed\" : true|false, (boolean) If the address is compressed\n "
169169 " \" account\" : \" account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n "
170+ " \" timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n "
170171 " \" hdkeypath\" : \" keypath\" (string, optional) The HD keypath if the key is HD and available\n "
171172 " \" hdmasterkeyid\" : \" <hash160>\" (string, optional) The Hash160 of the HD master pubkey\n "
172173 " }\n "
@@ -204,10 +205,16 @@ UniValue validateaddress(const JSONRPCRequest& request)
204205 if (pwalletMain && pwalletMain->mapAddressBook .count (dest))
205206 ret.push_back (Pair (" account" , pwalletMain->mapAddressBook [dest].name ));
206207 CKeyID keyID;
207- if (pwalletMain && address.GetKeyID (keyID) && pwalletMain->mapKeyMetadata .count (keyID) && !pwalletMain->mapKeyMetadata [keyID].hdKeypath .empty ())
208- {
209- ret.push_back (Pair (" hdkeypath" , pwalletMain->mapKeyMetadata [keyID].hdKeypath ));
210- ret.push_back (Pair (" hdmasterkeyid" , pwalletMain->mapKeyMetadata [keyID].hdMasterKeyID .GetHex ()));
208+ if (pwalletMain) {
209+ const auto & meta = pwalletMain->mapKeyMetadata ;
210+ auto it = address.GetKeyID (keyID) ? meta.find (keyID) : meta.end ();
211+ if (it != meta.end ()) {
212+ ret.push_back (Pair (" timestamp" , it->second .nCreateTime ));
213+ if (!it->second .hdKeypath .empty ()) {
214+ ret.push_back (Pair (" hdkeypath" , it->second .hdKeypath ));
215+ ret.push_back (Pair (" hdmasterkeyid" , it->second .hdMasterKeyID .GetHex ()));
216+ }
217+ }
211218 }
212219#endif
213220 }
0 commit comments