diff --git a/README.md b/README.md index 86ecc65..29a4926 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ $ ./dero_ns_cli.pl --name KingZulo --register --wallet-rpc 127.0.0.1:40403 --dae Install dependencies and run the script with the following command ``` -$ sudo apt install libwww-curl-perl libjson-perl -y +$ sudo apt install libwww-curl-perl libjson-perl libutf8-all-perl -y $ git clone https://git.mysrv.cloud/MySrv.Cloud/Dero_Name_Service_Cli_Tool.git $ cd Dero_Name_Service_Cli_Tool $ ./dero_ns_cli.pl --help @@ -98,3 +98,25 @@ Dero Stargate * [Nameservice](https://docs.dero.io/rtd_pages/dev_dvm.html#nameservice) * [DVM Example](https://github.com/deroproject/documentation/tree/master/DVMDOCS/examples/nameservice) +### Chinese and Fun with UNICODE + +``` +$ ./dero_ns_cli.pl --name "🔥 MySrvCloud 🔥" +Dero Name Service Cli Tool - register name to wallet +Name: (🔥 MySrvCloud 🔥) is AVAILABLE to register + +$ ./dero_ns_cli.pl --name "🔥 MySrvCloud 🔥" --register +Dero Name Service Cli Tool - register name to wallet +Name: (🔥 MySrvCloud 🔥) is AVAILABLE - and will be registered in a little while +Checking wallet RPC (127.0.0.1:10103) +Wallet connected (127.0.0.1:10103) +Name: (🔥 MySrvCloud 🔥) registered on the DERO Stargate with TX ID (622b0e96827e6369bc6ff780b3f9dc612ed144654da664c1db2fcc0982d5c7b4) +Name: (🔥 MySrvCloud 🔥) is now registered to this address (dero1qy3dspltmkakl4gzpfvhc35kxxqpp2ypd9ehz72puyxhgs0sqglj6qgqt28kd) +Congratulations your name was successfully registered! + +$ ./dero_ns_cli.pl --name "🔥 MySrvCloud 🔥" +Dero Name Service Cli Tool - register name to wallet +Name: (🔥 MySrvCloud 🔥) is taken by this address (dero1qy3dspltmkakl4gzpfvhc35kxxqpp2ypd9ehz72puyxhgs0sqglj6qgqt28kd) + +``` + * [Full Emoji List](https://unicode.org/emoji/charts/full-emoji-list.html) diff --git a/dero_ns_cli.pl b/dero_ns_cli.pl index fd9e2ed..1d997c7 100755 --- a/dero_ns_cli.pl +++ b/dero_ns_cli.pl @@ -27,7 +27,7 @@ use WWW::Curl::Easy; # options use Getopt::Long; -my $name; +my ($name,$debug); my %options; GetOptions( 'daemon-rpc=s' => \$options{'daemon-rpc'}, @@ -36,6 +36,7 @@ GetOptions( 'name=s' => \$name, 'check-list=s' => \$options{'list'}, 'help+' => \$options{'help'}, + 'debug+' => \$debug, ); my $daemon = 'https://dero-node.mysrv.cloud'; @@ -55,6 +56,7 @@ sub usage { print "\t--daemon-rpc Specify URL for daemon if you don't want to use https://dero-node.mysrv.cloud/\n"; print "\t This is just to check if the name is registered already\n"; print "\t--wallet-rpc Specify wallet RPC if other than 127.0.0.1:10103 (local wallet)\n"; + print "\t--debug Show debug information\n"; exit; } @@ -82,6 +84,11 @@ if ($options{'list'}) { foreach my $check_name (@check_list) { + if (length $check_name < 6 or length $check_name >= 64) { + print "Name: ($check_name) not compatible, need to longer than 6 charaters and shorter than 64\n"; + next; + } + my $check = check_name($check_name); if (defined $check and $check->{'status'} eq 'OK') { @@ -89,22 +96,20 @@ foreach my $check_name (@check_list) { } else { if ($options{'register'}) { printf "Name: (%s) is AVAILABLE - and will be registered in a little while\n", $check_name; + register_name($check_name); } else { printf "Name: (%s) is AVAILABLE to register\n", $check_name; } } } -if ($options{'register'}) { +sub register_name { + + my $name = shift; my $max_wait = 120; usage() if $options{'list'}; - if (check_name($name)) { - printf "Name: (%s) is already registered, nothing to do\n", $name; - exit 0; - } - printf "Checking wallet RPC (%s)\n", $wallet_rpc; my $count = 0; while (not defined check_wallet_rpc() and $count < $max_wait) { @@ -200,6 +205,8 @@ sub register { my $status = decode_json( post_url($url, $data) ); + print Dumper($status) if $debug; + return $status; } @@ -221,11 +228,6 @@ sub check_name { my $name = shift; - if (length $name < 6 or length $name >= 64) { - print "Name ($name) not compatible, need to longer than 6 charaters and shorter than 64\n"; - return; - } - # Check if name is registered # curl http://127.0.0.1:40402/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"nametoaddress","params":{"name":"TESTUSERNAME" }}' -H 'Content-Type: application/json' @@ -241,9 +243,13 @@ sub check_name { my $url = sprintf '%s/json_rpc', $daemon; - my $status = decode_json( post_url($url, $data) ); + my $response = decode_json( post_url($url, $data) ); - return $status->{'result'}; + print Dumper($response) if $debug; + + return $response->{'result'} if defined $response and exists $response->{'result'}; + + return; } @@ -253,6 +259,8 @@ sub post_url { my $url = shift; my $data = shift; + print Dumper($data) if $debug; + my $response_data;