Skip to content

Commit 3915272

Browse files
committed
rpc: Let name_show error for expired names (disabled by default)
1 parent adc9f79 commit 3915272

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/rpc/names.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ namespace
437437
UniValue
438438
name_show (const JSONRPCRequest& request)
439439
{
440+
bool allow_expired = DEFAULT_ALLOWEXPIRED;
441+
440442
NameOptionsHelp optHelp;
441443
optHelp
442444
.withNameEncoding ()
@@ -483,7 +485,15 @@ name_show (const JSONRPCRequest& request)
483485

484486
MaybeWalletForRequest wallet(request);
485487
LOCK2 (wallet.getLock (), cs_main);
486-
return getNameInfo (options, name, data, wallet);
488+
UniValue name_object = getNameInfo(options, name, data, wallet);
489+
assert(!name_object["expired"].isNull());
490+
const bool is_expired = name_object["expired"].get_bool();
491+
if (is_expired && !allow_expired) {
492+
std::ostringstream msg;
493+
msg << "name not found: " << EncodeNameForMessage(name);
494+
throw JSONRPCError(RPC_WALLET_ERROR, msg.str());
495+
}
496+
return name_object;
487497
}
488498

489499
/* ************************************************************************** */

src/rpc/names.h

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <string>
1414
#include <vector>
1515

16+
/** Default value for the -allowexpired argument. */
17+
static constexpr bool DEFAULT_ALLOWEXPIRED = true;
18+
1619
class CNameData;
1720
class COutPoint;
1821
class CScript;

0 commit comments

Comments
 (0)