-
Notifications
You must be signed in to change notification settings - Fork 12
Conversation
# Conflicts: # .gitignore
bin/run
Outdated
@@ -0,0 +1,6 @@ | |||
#!/usr/bin/env node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bin/mn?
lib/commands/getNewAddress.js
Outdated
const path = require('path'); | ||
const RpcClient = require('@dashevo/dashd-rpc/promise'); | ||
const compose = require('docker-compose'); | ||
const waitForCoreStart = require('../util/waitForCoreStart'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These things doesn’t looks like utils, more like business logic. Let’s put core stuff to lib/core/?
package.json
Outdated
@@ -0,0 +1,82 @@ | |||
{ | |||
"name": "mn-bootstrap", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dashevo/mn-bootstrap
options: [ | ||
'evonet', | ||
'local', | ||
'testnet', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it work?
const { Command, flags: flagTypes } = require('@oclif/command'); | ||
const getNewAddress = require('../../../lib/commands/getNewAddress'); | ||
|
||
class GetNewAddressCommand extends Command { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mn core generate-to-address <amount> --address
. Create a new wallet if address omitted
lib/commands/getNewAddress.js
Outdated
@@ -0,0 +1,91 @@ | |||
const path = require('path'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/core/wallet
lib/commands/getNewAddress.js
Outdated
if (preset !== 'local') { | ||
console.info('You need to wait at least 100 block before registering masternode'); | ||
} | ||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't use console in business logic. we need to handle errors in commands. use oclif error handling
lib/commands/registerMasternode.js
Outdated
@@ -0,0 +1,160 @@ | |||
const path = require('path'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/core/mn/
lib/commands/registerMasternode.js
Outdated
addresses: [fundSourceAddress], | ||
}); | ||
|
||
console.info(`Fund balance is ${balance / SATOSHI_MULTIPLIER}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
factory should accept logger
lib/commands/registerMasternode.js
Outdated
console.info(`Fund balance is ${balance / SATOSHI_MULTIPLIER}`); | ||
|
||
if (balance / SATOSHI_MULTIPLIER < MASTERNODE_DASH_AMOUNT) { | ||
console.error('Needs wallet with more than 1000 dash'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw exception
lib/commands/registerMasternode.js
Outdated
|
||
console.info(`Masternode registered with tx ${protx}`); | ||
console.info(`Add this bls private key to your config: ${operator.privateKey}`); | ||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
lib/commands/registerMasternode.js
Outdated
} finally { | ||
// close dash core | ||
await compose.stopOne('core', composeOptions); | ||
await compose.rm(composeOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not flag rm?
lib/docker-compose.yml
Outdated
@@ -0,0 +1,19 @@ | |||
version: '3.7' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's existing one with options
lib/util/generateLocalBlocks.js
Outdated
@@ -0,0 +1,20 @@ | |||
const { PrivateKey } = require('@dashevo/dashcore-lib'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/core/
lib/util/getInputsForAmount.js
Outdated
@@ -0,0 +1,30 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/core/wallet/
lib/util/waitForConfirmations.js
Outdated
@@ -0,0 +1,32 @@ | |||
const wait = require('./wait'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/src/core/
lib/util/waitForCoreStart.js
Outdated
@@ -0,0 +1,34 @@ | |||
const wait = require('./wait'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/core/
lib/util/waitForCoreStart.js
Outdated
do { | ||
try { | ||
// just any random request | ||
await coreClient.getBlockchainInfo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping?
lib/util/waitForCoreSync.js
Outdated
@@ -0,0 +1,21 @@ | |||
const wait = require('./wait'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/core/
package.json
Outdated
@@ -0,0 +1,82 @@ | |||
{ | |||
"name": "mn-bootstrap", | |||
"version": "0.12.0-dev.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.13.0-dev.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a tool for 0.12.x though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.12 is released and considering as stable (master branch) so just fixes should go there but new untested features should go to dev branch.
package.json
Outdated
{ | ||
"name": "mn-bootstrap", | ||
"version": "0.12.0-dev.1", | ||
"description": "Dash masternode bootstrap", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Distribution package for Dash Masternode installation
lib/commands/getNewAddress.js
Outdated
|
||
try { | ||
// start dash core | ||
await compose.upOne('core', composeOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use run?
lib/commands/getNewAddress.js
Outdated
|
||
if (preset === 'local') { | ||
// generate some blocks to unlock dash | ||
await generateLocalBlocks(coreClient, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's try to use coreClient.generate(100)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only for use on private devnets? Because it is almost certain to fail on Evonet (it may be possible to generate a few blocks, but not 100 all at once).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only for the local preset, i.e. regtest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep 🙈 😄
enabled: () => preset !== PRESETS.LOCAL, | ||
task: async (ctx) => ( | ||
new Observable(async (observer) => { | ||
await waitForConfirmations( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we reuse waitForBlocks
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, because your transaction could be included 5 blocks later, for example
src/commands/register.js
Outdated
task: async (ctx) => { | ||
ctx.coreService = await startCore(preset, { wallet: true }); | ||
|
||
process.on('SIGINT', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to do that on the exit event, not just Ctrl+C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Great work! 🎉
No description provided.