fix private key encryption. style changes.
This commit is contained in:
parent
75afb6d953
commit
b20bcf701b
@ -261,9 +261,9 @@ Block.fromJSON = function fromJSON(json) {
|
||||
|
||||
parser = new bcoin.protocol.parser();
|
||||
|
||||
data = json.subtype === 'merkleblock' ?
|
||||
parser.parseMerkleBlock(raw) :
|
||||
parser.parseBlock(raw);
|
||||
data = json.subtype === 'merkleblock'
|
||||
? parser.parseMerkleBlock(raw)
|
||||
: parser.parseBlock(raw);
|
||||
|
||||
data._network = json._network;
|
||||
|
||||
|
||||
@ -587,10 +587,6 @@ HDPub.prototype.deriveString = function(path) {
|
||||
return this.pair.verify.apply(this.pair, arguments);
|
||||
};
|
||||
|
||||
// HD.prototype.inspect = function inspect() {
|
||||
// return this.pair.inspect.apply(this.pair, arguments);
|
||||
// };
|
||||
|
||||
HD.prototype.__defineGetter__('pub', function() {
|
||||
return this.pair.pub;
|
||||
});
|
||||
|
||||
@ -24,19 +24,20 @@ function Wallet(options, passphrase) {
|
||||
|
||||
EventEmitter.call(this);
|
||||
|
||||
// bcoin.wallet('scope', 'password')
|
||||
if (typeof options === 'string' && typeof passphrase === 'string') {
|
||||
options = {
|
||||
scope: options,
|
||||
passphrase: passphrase
|
||||
};
|
||||
}
|
||||
|
||||
if (!options)
|
||||
options = {};
|
||||
|
||||
this.options = options;
|
||||
this.compressed = typeof options.compressed !== 'undefined' ?
|
||||
options.compressed : true;
|
||||
this.compressed = typeof options.compressed !== 'undefined'
|
||||
? options.compressed
|
||||
: true;
|
||||
this.storage = options.storage;
|
||||
this.label = options.label || '';
|
||||
this.key = null;
|
||||
@ -164,9 +165,6 @@ Wallet.prototype.multisig = function multisig(options) {
|
||||
|
||||
if (this.keys.length > this.n)
|
||||
throw new Error('No more than ' + this.n + ' are necessary');
|
||||
|
||||
// if (this.keys.length < this.m)
|
||||
// throw new Error(this.m + ' public keys required');
|
||||
};
|
||||
|
||||
Wallet.prototype.addKey = function addKey(key) {
|
||||
@ -324,6 +322,7 @@ Wallet.hash2addr = function hash2addr(hash, prefix) {
|
||||
hash = [ prefix ].concat(hash);
|
||||
|
||||
addr = hash.concat(utils.checksum(hash));
|
||||
|
||||
return utils.toBase58(addr);
|
||||
};
|
||||
|
||||
@ -350,6 +349,7 @@ Wallet.addr2hash = function addr2hash(addr, prefix) {
|
||||
|
||||
if (addr.length !== 25)
|
||||
return [];
|
||||
|
||||
if (addr[0] !== prefix)
|
||||
return [];
|
||||
|
||||
@ -576,9 +576,6 @@ Wallet.prototype.fill = function fill(tx, cb) {
|
||||
};
|
||||
|
||||
Wallet.prototype.toJSON = function toJSON(encrypt) {
|
||||
encrypt = encrypt || function(msg) {
|
||||
return msg;
|
||||
};
|
||||
return {
|
||||
v: 1,
|
||||
type: 'wallet',
|
||||
@ -615,10 +612,11 @@ Wallet.prototype.toJSON = function toJSON(encrypt) {
|
||||
Wallet.fromJSON = function fromJSON(json, decrypt) {
|
||||
assert.equal(json.v, 1);
|
||||
assert.equal(json.type, 'wallet');
|
||||
|
||||
if (json.network)
|
||||
assert.equal(json.network, network.type);
|
||||
|
||||
if (decrypt)
|
||||
if (json.encrypted && decrypt)
|
||||
json.priv = decrypt(json.priv);
|
||||
|
||||
var priv, pub, compressed, key, w;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user