Skip to content

Instantly share code, notes, and snippets.

@pinheadmz
Last active August 23, 2020 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinheadmz/ca0e1a5739607307c7a515158ad89c98 to your computer and use it in GitHub Desktop.
Save pinheadmz/ca0e1a5739607307c7a515158ad89c98 to your computer and use it in GitHub Desktop.
'use strict';
const {NodeClient, WalletClient} = require('hs-client');
const {Network} = require('hsd');
const network = Network.get('regtest');
const nodeOptions = {
network: network.type,
port: network.rpcPort
};
const walletOptions = {
network: network.type,
port: network.walletPort
};
const nodeClient = new NodeClient(nodeOptions);
const walletClient = new WalletClient(walletOptions);
(async () => {
await nodeClient.open();
await walletClient.open();
console.log('funding wallet...');
const addr = await walletClient.execute('getnewaddress', []);
await nodeClient.execute('generatetoaddress', [100, addr]);
console.log('opening auctions...');
await walletClient.execute('sendopen', ['test-ds']);
await walletClient.execute('sendopen', ['test-ns-glue']);
await walletClient.execute('sendopen', ['test-glue4-glue']);
await walletClient.execute('sendopen', ['test-glue6-glue']);
await walletClient.execute('sendopen', ['test-ns']);
await walletClient.execute('sendopen', ['test-glue4']);
await walletClient.execute('sendopen', ['test-glue6']);
await walletClient.execute('sendopen', ['test-synth4']);
await walletClient.execute('sendopen', ['test-synth6']);
await walletClient.execute('sendopen', ['test-txt']);
await nodeClient.execute('generatetoaddress', [7, addr]);
console.log('bidding...');
await walletClient.execute('sendbid', ['test-ds', 0, 0.01]);
await walletClient.execute('sendbid', ['test-ns-glue', 0, 0.01]);
await walletClient.execute('sendbid', ['test-glue4-glue', 0, 0.01]);
await walletClient.execute('sendbid', ['test-glue6-glue', 0, 0.01]);
await walletClient.execute('sendbid', ['test-ns', 0, 0.01]);
await walletClient.execute('sendbid', ['test-glue4', 0, 0.01]);
await walletClient.execute('sendbid', ['test-glue6', 0, 0.01]);
await walletClient.execute('sendbid', ['test-synth4', 0, 0.01]);
await walletClient.execute('sendbid', ['test-synth6', 0, 0.01]);
await walletClient.execute('sendbid', ['test-txt', 0, 0.01]);
await nodeClient.execute('generatetoaddress', [7, addr]);
console.log('revealing...');
await walletClient.execute('sendreveal', []);
await nodeClient.execute('generatetoaddress', [10, addr]);
console.log('registering...');
await walletClient.execute('sendupdate', ['test-ds', {"records":[{"type":"DS","keyTag":57355,"algorithm":8,"digestType":2,"digest":"95a57c3bab7849dbcddf7c72ada71a88146b141110318ca5be672057e865c3e2"}]}]);
await walletClient.execute('sendupdate', ['test-ns-glue', {"records":[{"type":"NS","ns":"ns1.test-ns-glue."}]}]);
await walletClient.execute('sendupdate', ['test-glue4-glue', {"records":[{"type":"GLUE4","ns":"ns2.test-glue4-glue.","address":"10.20.30.40"}]}]);
await walletClient.execute('sendupdate', ['test-glue6-glue', {"records":[{"type":"GLUE6","ns":"ns2.test-glue6-glue.","address":"1111:2222:3333:4444:5555:6666:7777:8888"}]}]);
await walletClient.execute('sendupdate', ['test-ns', {"records":[{"type":"NS","ns":"ns1.hns."}]}]);
await walletClient.execute('sendupdate', ['test-glue4', {"records":[{"type":"GLUE4","ns":"ns2.hns.","address":"10.20.30.40"}]}]);
await walletClient.execute('sendupdate', ['test-glue6', {"records":[{"type":"GLUE6","ns":"ns2.hns.","address":"1111:2222:3333:4444:5555:6666:7777:8888"}]}]);
await walletClient.execute('sendupdate', ['test-synth4', {"records":[{"type":"SYNTH4","address":"50.60.70.80"}]}]);
await walletClient.execute('sendupdate', ['test-synth6', {"records":[{"type":"SYNTH6","address":"8888:7777:6666:5555:4444:3333:2222:1111"}]}]);
await walletClient.execute('sendupdate', ['test-txt', {"records":[{"type":"TXT","txt":["hello world", "how are you"]}]}]);
await nodeClient.execute('generatetoaddress', [10, addr]);
console.log('done, checking...');
nodeClient.execute('getnameresource', ['test-ds']).then(console.log);
nodeClient.execute('getnameresource', ['test-ns-glue']).then(console.log);
nodeClient.execute('getnameresource', ['test-glue4-glue']).then(console.log);
nodeClient.execute('getnameresource', ['test-glue6-glue']).then(console.log);
nodeClient.execute('getnameresource', ['test-ns']).then(console.log);
nodeClient.execute('getnameresource', ['test-glue4']).then(console.log);
nodeClient.execute('getnameresource', ['test-glue6']).then(console.log);
nodeClient.execute('getnameresource', ['test-synth4']).then(console.log);
nodeClient.execute('getnameresource', ['test-synth6']).then(console.log);
nodeClient.execute('getnameresource', ['test-txt']).then(console.log);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment