mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-26 00:55:08 +01:00
added extended key validator
This commit is contained in:
@@ -14,16 +14,11 @@ module.exports = {
|
||||
choices: utils._featureChoices()
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'cyphernode_rocks0',
|
||||
default: utils._getDefault( 'cyphernode_rocks0' ),
|
||||
message: 'Does cyphernode rock?'+'\n',
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'cyphernode_rocks1',
|
||||
default: utils._getDefault( 'cyphernode_rocks1' ),
|
||||
message: 'Does cyphernode rock?'+'\n',
|
||||
type: 'input',
|
||||
name: 'cyphernode_xpub',
|
||||
default: utils._getDefault( 'cyphernode_xpub' ),
|
||||
message: 'What is your xpub to watch?'+'\n',
|
||||
validate: utils._xkeyValidator
|
||||
}];
|
||||
},
|
||||
env: function( props ) {
|
||||
|
||||
@@ -6,6 +6,7 @@ const wrap = require('wordwrap')(86);
|
||||
const validator = require('validator');
|
||||
const path = require("path");
|
||||
const featureChoices = require(path.join(__dirname, "features.json"));
|
||||
const coinstring = require('coinstring');
|
||||
|
||||
let featurePromptModules = [];
|
||||
const normalizedPath = path.join(__dirname, "features");
|
||||
@@ -76,6 +77,16 @@ module.exports = class extends Generator {
|
||||
return validator.isIP((ip+"").trim());
|
||||
}
|
||||
|
||||
_xpubValidator( xpub ) {
|
||||
try {
|
||||
coinstring.decode(xpub);
|
||||
} catch( e ) {
|
||||
throw new Error('Invalid extended public key. Please check your input.');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
_trimFilter( input ) {
|
||||
return (input+"").trim();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^2.1.0",
|
||||
"coinstring": "^2.3.0",
|
||||
"validator": "^10.8.0",
|
||||
"wordwrap": "^1.0.0",
|
||||
"yeoman-generator": "^2.0.1"
|
||||
|
||||
Reference in New Issue
Block a user