Last active
January 15, 2022 10:05
-
-
Save Frank-Buss/7e782bbdddcec58a981c98722ca768e0 to your computer and use it in GitHub Desktop.
handshake test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
starting server | |
receive address: rs1qahw577c0p6t95vsuz9ets6zdu3tewl2uu7mgh0 | |
mining coins | |
name: metaroot | |
blocks until auction starts: 6 | |
blocks until auction reveal: 4 | |
blocks until auction close: 9 | |
record on the blockchain: | |
{ | |
"records": [ | |
{ | |
"type": "GLUE4", | |
"ns": "ns.metaroot.", | |
"address": "127.0.0.1" | |
}, | |
{ | |
"type": "DS", | |
"keyTag": 53462, | |
"algorithm": 8, | |
"digestType": 2, | |
"digest": "1b019a8b90cd44222dfc3df2ec9d571c1338a5c772837f3f125ffc4ec1a5dbbc" | |
} | |
] | |
} | |
[error] (rs) Maximum referrals exceeded. | |
at ResolveContext.hop (/home/frank/data/projects/upwork/name/hsd/node_modules/bns/lib/resolver/recursive.js:629:13) | |
at RecursiveResolver.handleAuthority (/home/frank/data/projects/upwork/name/hsd/node_modules/bns/lib/resolver/recursive.js:474:8) | |
; <<>> DiG 9.11.5-P4-5.1+deb10u6-Debian <<>> @127.0.0.1 -p 25350 metaroot +dnssec | |
; (1 server found) | |
;; global options: +cmd | |
;; Got answer: | |
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 20459 | |
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 2 | |
;; OPT PSEUDOSECTION: | |
; EDNS: version: 0, flags: do; udp: 4096 | |
; COOKIE: 5fda5be3f23f2853 (echoed) | |
;; QUESTION SECTION: | |
;metaroot. IN A | |
;; SIG0 PSEUDOSECTION: | |
. 0 ANY SIG 0 253 0 0 20220115160421 20220115040421 64595 . a1yTceffHf8QZKanrPPYH4StZn02mA3u2NuxyyIYEj1SLchwRgC1fRI1 +qywjrtVSnmbWQUa0eMrseDIvhJ4cw== | |
;; Query time: 29 msec | |
;; SERVER: 127.0.0.1#25350(127.0.0.1) | |
;; WHEN: Sat Jan 15 11:04:21 CET 2022 | |
;; MSG SIZE rcvd: 143 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# first install Handshake as described here: https://github.com/handshake-org/hsd | |
# on Debian Linux it looks like this: | |
# apt-get install npm libunbound-dev libcap2-bin | |
# git clone https://github.com/handshake-org/hsd.git | |
# cd hsd | |
# npm install -g node-gyp | |
# npm install --production | |
# stop any running hsd daemon | |
killall hsd | |
sleep 3 | |
# remove old blockchain data | |
rm -rf ~/.hsd/regtest/ | |
# start server and wait a bit until started | |
# root nameserver at port 53, recursive server at port 25350 | |
echo "starting server" | |
sudo setcap cap_net_bind_service=ep `which node` | |
./bin/hsd --network regtest --http-host 0.0.0.0 --api-key=test --listen --max-inbound 50 --rs-host 0.0.0.0 --ns-port 53 --rs-port 25350 > /dev/null & | |
sleep 5 | |
# call a RPC method | |
hsd-rpc() { | |
./node_modules/.bin/hsd-rpc --network regtest --api-key test "$@" | |
} | |
# call a RPC wallet method | |
hsw-rpc() { | |
./node_modules/.bin/hsw-rpc --network regtest --api-key test "$@" | |
} | |
# call a wallet method | |
hsw-cli() { | |
./node_modules/.bin/hsw-cli --network regtest --api-key=test "$@" | |
} | |
# mine blocks, argument is number of blocks | |
mine() { | |
for (( c=1; c<=$1; c++ )) ; do hsd-rpc generatetoaddress 1 "$receive" > /dev/null ; done | |
} | |
# get a receive address | |
receive=$(hsw-cli account default | jq -r .receiveAddress) | |
echo "receive address: $receive" | |
echo "mining coins" | |
mine 100 | |
# create a random name | |
#name=$(hsd-rpc grindname 10) | |
name="metaroot" | |
echo "name: $name" | |
# open a bid, and mine one block to add it to the blockchain | |
hsw-rpc sendopen "$name" > /dev/null | |
mine 1 | |
# get number of blocks until auction starts and mine them | |
blocks=$(hsd-rpc getnameinfo "$name" | jq -r .info.stats.blocksUntilBidding) | |
echo "blocks until auction starts: $blocks" | |
mine "$blocks" | |
# create bid | |
hsw-rpc sendbid "$name" 1 10 > /dev/null | |
mine 1 | |
# wait until reveal | |
blocks=$(hsd-rpc getnameinfo "$name" | jq -r .info.stats.blocksUntilReveal) | |
echo "blocks until auction reveal: $blocks" | |
mine "$blocks" | |
# send a reveal tx and mine a block to confirm it | |
hsw-rpc sendreveal "$name" > /dev/null | |
mine 1 | |
# mine enough blocks to close the auction | |
blocks=$(hsd-rpc getnameinfo "$name" | jq -r .info.stats.blocksUntilClose) | |
echo "blocks until auction close: $blocks" | |
mine "$blocks" | |
# set a DNSSEC record | |
# created by https://github.com/pinheadmz/handout/tree/proofofconcept and running this command: | |
# node scripts/hnssec-gen.js metaroot 127.0.0.1 | |
hsw-rpc sendupdate "$name" '{"records":[{"type":"GLUE4","ns":"ns.metaroot.","address":"127.0.0.1"},{"type":"DS","keyTag":53462,"algorithm":8,"digestType":2,"digest":"1b019a8b90cd44222dfc3df2ec9d571c1338a5c772837f3f125ffc4ec1a5dbbc"}]}' > /dev/null | |
mine 10 | |
# show the record | |
echo "record on the blockchain:" | |
hsd-rpc getnameresource "$name" | |
# show nameserver output | |
dig @127.0.0.1 -p 25350 "$name" +dnssec |
pinheadmz
commented
Jan 14, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment