Skip to content

Instantly share code, notes, and snippets.

@educationofjon
Created March 9, 2018 21:25
Show Gist options
  • Save educationofjon/94f2a7e91e91d599dfeb00d9c7429197 to your computer and use it in GitHub Desktop.
Save educationofjon/94f2a7e91e91d599dfeb00d9c7429197 to your computer and use it in GitHub Desktop.
Regtest Blocks
'use strict';
process.title = 'bcoin';
const assert = require('assert');
const FullNode = require('bcoin/lib/node/fullnode');
const plugin = require('bcoin/lib/wallet/plugin');
const node = new FullNode({
network: 'regtest',
db: 'memory',
prefix: '/home/rojikku/.bcoin',
apiKey: 'bikeshed',
nodes: '127.0.0.1',
port: 48444,
logConsole: true,
logLevel: 'debug',
env: true,
workers: true,
plugins: [plugin]
});
process.on('unhandledRejection', (err, promise) => {
throw err;
});
(async function connection() {
await node.open();
await node.connect();
await node.pool.connect();
await node.pool.startSync();
})().then(async function mining() {
const wdb = node.require('walletdb');
await node.miner.addAddress(wdb.primary.getReceive());
for (let i = 0; i < 1024; i++) {
const block = await node.miner.mineBlock();
await node.chain.add(block);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment