Skip to content

Instantly share code, notes, and snippets.

@pinheadmz
Created June 7, 2022 17:18
Show Gist options
  • Save pinheadmz/bacbc3f0e7c14a1eb7a0078ee6da4240 to your computer and use it in GitHub Desktop.
Save pinheadmz/bacbc3f0e7c14a1eb7a0078ee6da4240 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]);
const name = await nodeClient.execute('grindname', []);
console.log('opening...');
await walletClient.execute('sendopen', [name]);
await nodeClient.execute('generatetoaddress', [7, addr]);
console.log('bidding...');
await walletClient.execute('sendbid', [name, 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...');
let count = 0;
while (count < 179) {
console.log(count);
await walletClient.execute('sendupdate', [name, {
'records': [{ 'type': 'NS', 'ns': `${count++}.`}]
}]);
await nodeClient.execute('generatetoaddress', [1, addr]);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment