@@ -437,13 +437,15 @@ namespace
437
437
UniValue
438
438
name_show (const JSONRPCRequest& request)
439
439
{
440
- bool allow_expired = DEFAULT_ALLOWEXPIRED;
440
+ bool allow_expired_default = DEFAULT_ALLOWEXPIRED;
441
441
442
442
NameOptionsHelp optHelp;
443
443
optHelp
444
444
.withNameEncoding ()
445
445
.withValueEncoding ()
446
- .withByHash ();
446
+ .withByHash ()
447
+ .withArg (" allowExpired" , RPCArg::Type::BOOL, allow_expired_default ? " true" : " false" ,
448
+ " Whether to throw error for expired names" );
447
449
448
450
RPCHelpMan (" name_show" ,
449
451
" \n Looks up the current data for the given name. Fails if the name doesn't exist.\n " ,
@@ -456,6 +458,7 @@ name_show (const JSONRPCRequest& request)
456
458
.finish (),
457
459
RPCExamples {
458
460
HelpExampleCli (" name_show" , " \" myname\" " )
461
+ + HelpExampleCli (" name_show" , R"( "myname" '{"allowExpired": false}')" )
459
462
+ HelpExampleRpc (" name_show" , " \" myname\" " )
460
463
}
461
464
).Check (request);
@@ -470,6 +473,17 @@ name_show (const JSONRPCRequest& request)
470
473
if (request.params .size () >= 2 )
471
474
options = request.params [1 ].get_obj ();
472
475
476
+ /* Parse and interpret the name_show-specific options. */
477
+ RPCTypeCheckObj (options,
478
+ {
479
+ {" allowExpired" , UniValueType (UniValue::VBOOL)},
480
+ },
481
+ true , false );
482
+
483
+ bool allow_expired = allow_expired_default;
484
+ if (options.exists (" allowExpired" ))
485
+ allow_expired = options[" allowExpired" ].get_bool ();
486
+
473
487
const valtype name = GetNameForLookup (request.params [0 ], options);
474
488
475
489
CNameData data;
@@ -488,11 +502,12 @@ name_show (const JSONRPCRequest& request)
488
502
UniValue name_object = getNameInfo (options, name, data, wallet);
489
503
assert (!name_object[" expired" ].isNull ());
490
504
const bool is_expired = name_object[" expired" ].get_bool ();
491
- if (is_expired && !allow_expired) {
505
+ if (is_expired && !allow_expired)
506
+ {
492
507
std::ostringstream msg;
493
508
msg << " name not found: " << EncodeNameForMessage (name);
494
509
throw JSONRPCError (RPC_WALLET_ERROR, msg.str ());
495
- }
510
+ }
496
511
return name_object;
497
512
}
498
513
0 commit comments