rpc: method refactor. getwork refactor.
This commit is contained in:
parent
78a4f379f5
commit
50d47dd5a6
1025
lib/http/rpc.js
1025
lib/http/rpc.js
File diff suppressed because it is too large
Load Diff
@ -560,6 +560,15 @@ MinerBlock.prototype.commit = function commit(nonce) {
|
||||
return this.block;
|
||||
};
|
||||
|
||||
/**
|
||||
* Snapshot the nonces.
|
||||
* @returns {Nonces}
|
||||
*/
|
||||
|
||||
MinerBlock.prototype.snapshot = function snapshot() {
|
||||
return new Nonces(this.nonce1, this.nonce2);
|
||||
};
|
||||
|
||||
/**
|
||||
* Send a progress report (emits `status`).
|
||||
*/
|
||||
@ -647,6 +656,58 @@ BlockEntry.fromEntry = function fromEntry(entry, attempt) {
|
||||
return item;
|
||||
};
|
||||
|
||||
/**
|
||||
* Nonces
|
||||
* @constructor
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
function Nonces(nonce1, nonce2) {
|
||||
this.nonce1 = nonce1;
|
||||
this.nonce2 = nonce2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject nonces into miner block.
|
||||
* @param {MinerBlock} attempt
|
||||
* @param {Number} nonce
|
||||
* @param {Number} ts
|
||||
*/
|
||||
|
||||
Nonces.prototype.inject = function inject(attempt, nonce, ts) {
|
||||
attempt.block.ts = ts;
|
||||
attempt.block.nonce = nonce;
|
||||
attempt.nonce1 = this.nonce1;
|
||||
attempt.nonce2 = this.nonce2;
|
||||
attempt.updateCoinbase();
|
||||
attempt.updateMerkle();
|
||||
};
|
||||
|
||||
/**
|
||||
* Attempt to verify POW.
|
||||
* @param {MinerBlock} attempt
|
||||
* @param {Number} nonce
|
||||
* @param {Number} ts
|
||||
*/
|
||||
|
||||
Nonces.prototype.verify = function verify(attempt, nonce, ts) {
|
||||
var block = attempt.block;
|
||||
var bts = block.ts;
|
||||
var bnonce = block.nonce;
|
||||
var nonce1 = attempt.nonce1;
|
||||
var nonce2 = attempt.nonce2;
|
||||
var result;
|
||||
|
||||
this.inject(attempt, nonce, ts);
|
||||
|
||||
if (consensus.verifyPOW(block.hash(), block.bits))
|
||||
return true;
|
||||
|
||||
this.inject(attempt, bnonce, bts);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/*
|
||||
* Expose
|
||||
*/
|
||||
|
||||
@ -351,7 +351,7 @@ Config.prototype.buf = function buf(key, fallback) {
|
||||
* @returns {String[]|null}
|
||||
*/
|
||||
|
||||
Config.prototype.list = function list(key, fallback) {
|
||||
Config.prototype.array = function array(key, fallback) {
|
||||
var value = this.get(key);
|
||||
|
||||
if (fallback === undefined)
|
||||
@ -385,18 +385,6 @@ Config.prototype.obj = function obj(key, fallback) {
|
||||
if (value === null)
|
||||
return fallback;
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (!value || typeof value !== 'object')
|
||||
throw new Error(key + ' must be an object.');
|
||||
return value;
|
||||
}
|
||||
|
||||
try {
|
||||
value = JSON.parse(value);
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
|
||||
if (!value || typeof value !== 'object')
|
||||
throw new Error(key + ' must be an object.');
|
||||
|
||||
@ -419,13 +407,10 @@ Config.prototype.func = function func(key, fallback) {
|
||||
if (value === null)
|
||||
return fallback;
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (!value || typeof value !== 'function')
|
||||
throw new Error(key + ' must be a function.');
|
||||
return value;
|
||||
}
|
||||
if (!value || typeof value !== 'function')
|
||||
throw new Error(key + ' must be a function.');
|
||||
|
||||
throw new Error(key + ' must be a function.');
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -459,7 +444,7 @@ Config.prototype.path = function path(key, fallback) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a config option (in MB).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
@ -477,37 +462,6 @@ Config.prototype.mb = function mb(key, fallback) {
|
||||
return value * 1024;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a bolean or path).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {String|null}
|
||||
*/
|
||||
|
||||
Config.prototype.boolpath = function boolpath(key, fallback) {
|
||||
var value = this.get(key);
|
||||
|
||||
if (fallback === undefined)
|
||||
fallback = null;
|
||||
|
||||
if (value === null)
|
||||
return fallback;
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (typeof value !== 'boolean' && typeof value !== 'string')
|
||||
throw new Error(key + ' must be a boolean or string.');
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value === 'true' || value === '1')
|
||||
return true;
|
||||
|
||||
if (value === 'false' || value === '0')
|
||||
return false;
|
||||
|
||||
return this.path(key, fallback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Grab network type from config data.
|
||||
* @private
|
||||
|
||||
@ -103,8 +103,8 @@ function FullNode(options) {
|
||||
proxy: this.config.str('proxy'),
|
||||
onion: this.config.bool('onion'),
|
||||
upnp: this.config.bool('upnp'),
|
||||
seeds: this.config.list('seeds'),
|
||||
nodes: this.config.list('nodes'),
|
||||
seeds: this.config.array('seeds'),
|
||||
nodes: this.config.array('nodes'),
|
||||
publicHost: this.config.str('public-host'),
|
||||
publicPort: this.config.num('public-port'),
|
||||
host: this.config.str('host'),
|
||||
@ -119,7 +119,7 @@ function FullNode(options) {
|
||||
chain: this.chain,
|
||||
mempool: this.mempool,
|
||||
fees: this.fees,
|
||||
address: this.config.list('payout-address'),
|
||||
address: this.config.array('payout-address'),
|
||||
coinbaseFlags: this.config.str('coinbase-flags'),
|
||||
preverify: this.config.bool('preverify'),
|
||||
maxWeight: this.config.num('max-weight'),
|
||||
|
||||
@ -351,7 +351,7 @@ Node.prototype.require = function require(name) {
|
||||
*/
|
||||
|
||||
Node.prototype.loadPlugins = function loadPlugins() {
|
||||
var plugins = this.config.list('plugins', []);
|
||||
var plugins = this.config.array('plugins', []);
|
||||
var loader = this.config.func('loader');
|
||||
var i, name, plugin;
|
||||
|
||||
|
||||
@ -64,8 +64,8 @@ function SPVNode(options) {
|
||||
proxy: this.config.str('proxy'),
|
||||
onion: this.config.bool('onion'),
|
||||
upnp: this.config.bool('upnp'),
|
||||
seeds: this.config.list('seeds'),
|
||||
nodes: this.config.list('nodes'),
|
||||
seeds: this.config.array('seeds'),
|
||||
nodes: this.config.array('nodes'),
|
||||
bip151: this.config.bool('bip151'),
|
||||
bip150: this.config.bool('bip150'),
|
||||
identityKey: this.config.buf('identity-key'),
|
||||
|
||||
@ -20,9 +20,9 @@ function Validator(data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether a config option is present.
|
||||
* @param {String} key
|
||||
* @returns {Boolean}
|
||||
* Initialize the validator.
|
||||
* @private
|
||||
* @param {Object} data
|
||||
*/
|
||||
|
||||
Validator.prototype.init = function init(data) {
|
||||
@ -35,7 +35,7 @@ Validator.prototype.init = function init(data) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Test whether a config option is present.
|
||||
* Test whether value is present.
|
||||
* @param {String} key
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
@ -57,7 +57,7 @@ Validator.prototype.has = function has(key) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option.
|
||||
* Get a value (no type validation).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Object|null}
|
||||
@ -99,7 +99,7 @@ Validator.prototype.get = function get(key, fallback) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a string).
|
||||
* Get a value (as a string).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {String|null}
|
||||
@ -115,13 +115,13 @@ Validator.prototype.str = function str(key, fallback) {
|
||||
return fallback;
|
||||
|
||||
if (typeof value !== 'string')
|
||||
throw new Error(key + ' must be a string.');
|
||||
throw new Error(fmt(key) + ' must be a string.');
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a value (as a number).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
@ -138,23 +138,23 @@ Validator.prototype.num = function num(key, fallback) {
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (typeof value !== 'number')
|
||||
throw new Error(key + ' must be a number.');
|
||||
throw new Error(fmt(key) + ' must be a number.');
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!/^\d+$/.test(value))
|
||||
throw new Error(key + ' must be a number.');
|
||||
throw new Error(fmt(key) + ' must be a number.');
|
||||
|
||||
value = parseInt(value, 10);
|
||||
|
||||
if (!isFinite(value))
|
||||
throw new Error(key + ' must be a number.');
|
||||
throw new Error(fmt(key) + ' must be a number.');
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a value (as a uint32).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
@ -170,13 +170,13 @@ Validator.prototype.u32 = function u32(key, fallback) {
|
||||
return fallback;
|
||||
|
||||
if (value % 1 !== 0 || value < 0 || value > 0xffffffff)
|
||||
throw new Error(key + ' must be a uint32.');
|
||||
throw new Error(fmt(key) + ' must be a uint32.');
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a value (as a uint64).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
@ -192,13 +192,13 @@ Validator.prototype.u64 = function u64(key, fallback) {
|
||||
return fallback;
|
||||
|
||||
if (value % 1 !== 0 || value < 0 || value > 0x1fffffffffffff)
|
||||
throw new Error(key + ' must be a uint64.');
|
||||
throw new Error(fmt(key) + ' must be a uint64.');
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a value (as a satoshi number or btc string).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
@ -215,28 +215,28 @@ Validator.prototype.amt = function amt(key, fallback) {
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (typeof value !== 'number')
|
||||
throw new Error(key + ' must be a number.');
|
||||
throw new Error(fmt(key) + ' must be a number.');
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!/^\d+(\.\d{0,8})?$/.test(value))
|
||||
throw new Error(key + ' must be a number.');
|
||||
throw new Error(fmt(key) + ' must be a number.');
|
||||
|
||||
value = parseFloat(value);
|
||||
|
||||
if (!isFinite(value))
|
||||
throw new Error(key + ' must be a number.');
|
||||
throw new Error(fmt(key) + ' must be a number.');
|
||||
|
||||
value *= 1e8;
|
||||
|
||||
if (value % 1 !== 0 || value < 0 || value > 0x1fffffffffffff)
|
||||
throw new Error(key + ' must be a uint64.');
|
||||
throw new Error(fmt(key) + ' must be a uint64.');
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a value (as a btc float).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
@ -254,16 +254,16 @@ Validator.prototype.btc = function btc(key, fallback) {
|
||||
value *= 1e8;
|
||||
|
||||
if (value % 1 !== 0 || value < 0 || value > 0x1fffffffffffff)
|
||||
throw new Error(key + ' must be a uint64.');
|
||||
throw new Error(fmt(key) + ' must be a uint64.');
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a value (as a reverse hash).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
* @returns {Hash|null}
|
||||
*/
|
||||
|
||||
Validator.prototype.hash = function hash(key, fallback) {
|
||||
@ -279,17 +279,17 @@ Validator.prototype.hash = function hash(key, fallback) {
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (!Buffer.isBuffer(value))
|
||||
throw new Error(key + ' must be a buffer.');
|
||||
throw new Error(fmt(key) + ' must be a buffer.');
|
||||
if (value.length !== 32)
|
||||
throw new Error(key + ' must be a buffer.');
|
||||
throw new Error(fmt(key) + ' must be a buffer.');
|
||||
return value.toString('hex');
|
||||
}
|
||||
|
||||
if (value.length !== 64)
|
||||
throw new Error(key + ' must be a hex string.');
|
||||
throw new Error(fmt(key) + ' must be a hex string.');
|
||||
|
||||
if (!/^[0-9a-f]+$/i.test(value))
|
||||
throw new Error(key + ' must be a hex string.');
|
||||
throw new Error(fmt(key) + ' must be a hex string.');
|
||||
|
||||
for (i = 0; i < value.length; i += 2)
|
||||
out = value.slice(i, i + 2) + out;
|
||||
@ -298,10 +298,10 @@ Validator.prototype.hash = function hash(key, fallback) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a value (as a number or reverse hash).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
* @returns {Number|Hash|null}
|
||||
*/
|
||||
|
||||
Validator.prototype.numhash = function numhash(key, fallback) {
|
||||
@ -317,10 +317,10 @@ Validator.prototype.numhash = function numhash(key, fallback) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a number).
|
||||
* Get a value (as a number or string).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Number|null}
|
||||
* @returns {Number|String|null}
|
||||
*/
|
||||
|
||||
Validator.prototype.numstr = function numstr(key, fallback) {
|
||||
@ -335,7 +335,7 @@ Validator.prototype.numstr = function numstr(key, fallback) {
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (typeof value !== 'number')
|
||||
throw new Error(key + ' must be a number or string.');
|
||||
throw new Error(fmt(key) + ' must be a number or string.');
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ Validator.prototype.numstr = function numstr(key, fallback) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a boolean).
|
||||
* Get a value (as a boolean).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Boolean|null}
|
||||
@ -364,8 +364,8 @@ Validator.prototype.bool = function bool(key, fallback) {
|
||||
return fallback;
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
assert(typeof value === 'boolean',
|
||||
'Passed in config option is of wrong type.');
|
||||
if (typeof value !== 'boolean')
|
||||
throw new Error(fmt(key) + ' must be a boolean.');
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -375,13 +375,14 @@ Validator.prototype.bool = function bool(key, fallback) {
|
||||
if (value === 'false' || value === '0')
|
||||
return false;
|
||||
|
||||
throw new Error(key + ' must be a boolean.');
|
||||
throw new Error(fmt(key) + ' must be a boolean.');
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a buffer).
|
||||
* Get a value (as a buffer).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @param {String?} enc
|
||||
* @returns {Buffer|null}
|
||||
*/
|
||||
|
||||
@ -399,24 +400,24 @@ Validator.prototype.buf = function buf(key, fallback, enc) {
|
||||
return fallback;
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
assert(Buffer.isBuffer(value),
|
||||
'Passed in config option is of wrong type.');
|
||||
if (!Buffer.isBuffer(value))
|
||||
throw new Error(fmt(key) + ' must be a buffer.');
|
||||
return value;
|
||||
}
|
||||
|
||||
data = new Buffer(value, enc);
|
||||
|
||||
if (data.length !== Buffer.byteLength(value, enc))
|
||||
throw new Error(key + ' must be a ' + enc + ' string.');
|
||||
throw new Error(fmt(key) + ' must be a ' + enc + ' string.');
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as an array of strings).
|
||||
* Get a value (as an array).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {String[]|null}
|
||||
* @returns {Array|String[]|null}
|
||||
*/
|
||||
|
||||
Validator.prototype.array = function array(key, fallback) {
|
||||
@ -430,7 +431,7 @@ Validator.prototype.array = function array(key, fallback) {
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (!Array.isArray(value))
|
||||
throw new Error(key + ' must be a list/array.');
|
||||
throw new Error(fmt(key) + ' must be a list/array.');
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -438,7 +439,7 @@ Validator.prototype.array = function array(key, fallback) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as an object).
|
||||
* Get a value (as an object).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Object|null}
|
||||
@ -453,45 +454,14 @@ Validator.prototype.obj = function obj(key, fallback) {
|
||||
if (value === null)
|
||||
return fallback;
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (!value || typeof value !== 'object')
|
||||
throw new Error(key + ' must be an object.');
|
||||
return value;
|
||||
}
|
||||
|
||||
try {
|
||||
value = JSON.parse(value);
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
|
||||
if (!value || typeof value !== 'object')
|
||||
throw new Error(key + ' must be an object.');
|
||||
throw new Error(fmt(key) + ' must be an object.');
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as an object).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Object|null}
|
||||
*/
|
||||
|
||||
Validator.prototype.next = function next(key, fallback) {
|
||||
var value = this.obj(key, fallback);
|
||||
|
||||
if (fallback === undefined)
|
||||
fallback = null;
|
||||
|
||||
if (value === null)
|
||||
return fallback;
|
||||
|
||||
return new Validator(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a config option (as a function).
|
||||
* Get a value (as a function).
|
||||
* @param {String} key
|
||||
* @param {Object?} fallback
|
||||
* @returns {Function|null}
|
||||
@ -506,15 +476,22 @@ Validator.prototype.func = function func(key, fallback) {
|
||||
if (value === null)
|
||||
return fallback;
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (typeof value !== 'function')
|
||||
throw new Error(key + ' must be a function.');
|
||||
return value;
|
||||
}
|
||||
if (typeof value !== 'function')
|
||||
throw new Error(fmt(key) + ' must be a function.');
|
||||
|
||||
throw new Error(key + ' must be a function.');
|
||||
return value;
|
||||
};
|
||||
|
||||
/*
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
function fmt(key) {
|
||||
if (typeof key === 'number')
|
||||
return 'Param #' + key;
|
||||
return key;
|
||||
}
|
||||
|
||||
/*
|
||||
* Expose
|
||||
*/
|
||||
|
||||
@ -23,15 +23,28 @@ common.isName = function isName(key) {
|
||||
if (typeof key !== 'string')
|
||||
return false;
|
||||
|
||||
if (key === '_admin')
|
||||
return false;
|
||||
|
||||
if (key === '__proto__')
|
||||
if (key.length === 0)
|
||||
return false;
|
||||
|
||||
if (!/^[\-\._0-9A-Za-z]+$/.test(key))
|
||||
return false;
|
||||
|
||||
// Prevents __proto__
|
||||
// from being used.
|
||||
switch (key[0]) {
|
||||
case '_':
|
||||
case '-':
|
||||
case '.':
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (key[key.length - 1]) {
|
||||
case '_':
|
||||
case '-':
|
||||
case '.':
|
||||
return false;
|
||||
}
|
||||
|
||||
return key.length >= 1 && key.length <= 40;
|
||||
};
|
||||
|
||||
|
||||
@ -44,14 +44,12 @@ function RPC(wdb) {
|
||||
|
||||
assert(wdb, 'RPC requires a WalletDB.');
|
||||
|
||||
this.wdb = wdb;
|
||||
this.network = wdb.network;
|
||||
this.logger = wdb.logger;
|
||||
this.client = wdb.client;
|
||||
this.wdb = wdb;
|
||||
|
||||
this.wallet = null;
|
||||
|
||||
this.locker = new Lock();
|
||||
|
||||
this.feeRate = null;
|
||||
|
||||
this.init();
|
||||
@ -60,55 +58,83 @@ function RPC(wdb) {
|
||||
util.inherits(RPC, RPCBase);
|
||||
|
||||
RPC.prototype.init = function init() {
|
||||
this.add('fundrawtransaction', this.fundrawtransaction);
|
||||
this.add('resendwallettransactions', this.resendwallettransactions);
|
||||
this.add('abandontransaction', this.abandontransaction);
|
||||
this.add('addmultisigaddress', this.addmultisigaddress);
|
||||
this.add('addwitnessaddress', this.addwitnessaddress);
|
||||
this.add('backupwallet', this.backupwallet);
|
||||
this.add('dumpprivkey', this.dumpprivkey);
|
||||
this.add('dumpwallet', this.dumpwallet);
|
||||
this.add('encryptwallet', this.encryptwallet);
|
||||
this.add('getaccountaddress', this.getaccountaddress);
|
||||
this.add('getaccount', this.getaccount);
|
||||
this.add('getaddressesbyaccount', this.getaddressesbyaccount);
|
||||
this.add('getbalance', this.getbalance);
|
||||
this.add('getnewaddress', this.getnewaddress);
|
||||
this.add('getrawchangeaddress', this.getrawchangeaddress);
|
||||
this.add('getreceivedbyaccount', this.getreceivedbyaccount);
|
||||
this.add('getreceivedbyaddress', this.getreceivedbyaddress);
|
||||
this.add('gettransaction', this.gettransaction);
|
||||
this.add('getunconfirmedbalance', this.getunconfirmedbalance);
|
||||
this.add('getwalletinfo', this.getwalletinfo);
|
||||
this.add('importprivkey', this.importprivkey);
|
||||
this.add('importwallet', this.importwallet);
|
||||
this.add('importaddress', this.importaddress);
|
||||
this.add('importprunedfunds', this.importprunedfunds);
|
||||
this.add('importpubkey', this.importpubkey);
|
||||
this.add('keypoolrefill', this.keypoolrefill);
|
||||
this.add('listaccounts', this.listaccounts);
|
||||
this.add('listaddressgroupings', this.listaddressgroupings);
|
||||
this.add('listlockunspent', this.listlockunspent);
|
||||
this.add('listreceivedbyaccount', this.listreceivedbyaccount);
|
||||
this.add('listreceivedbyaddress', this.listreceivedbyaddress);
|
||||
this.add('listsinceblock', this.listsinceblock);
|
||||
this.add('listtransactions', this.listtransactions);
|
||||
this.add('listunspent', this.listunspent);
|
||||
this.add('lockunspent', this.lockunspent);
|
||||
this.add('help', this.help);
|
||||
this.add('stop', this.stop);
|
||||
this.add('fundrawtransaction', this.fundRawTransaction);
|
||||
this.add('resendwallettransactions', this.resendWalletTransactions);
|
||||
this.add('abandontransaction', this.abandonTransaction);
|
||||
this.add('addmultisigaddress', this.addMultisigAddress);
|
||||
this.add('addwitnessaddress', this.addWitnessAddress);
|
||||
this.add('backupwallet', this.backupWallet);
|
||||
this.add('dumpprivkey', this.dumpPrivKey);
|
||||
this.add('dumpwallet', this.dumpWallet);
|
||||
this.add('encryptwallet', this.encryptWallet);
|
||||
this.add('getaccountaddress', this.getAccountAddress);
|
||||
this.add('getaccount', this.getAccount);
|
||||
this.add('getaddressesbyaccount', this.getAddressesByAccount);
|
||||
this.add('getbalance', this.getBalance);
|
||||
this.add('getnewaddress', this.getNewAddress);
|
||||
this.add('getrawchangeaddress', this.getRawChangeAddress);
|
||||
this.add('getreceivedbyaccount', this.getReceivedByAccount);
|
||||
this.add('getreceivedbyaddress', this.getReceivedByAddress);
|
||||
this.add('gettransaction', this.getTransaction);
|
||||
this.add('getunconfirmedbalance', this.getUnconfirmedBalance);
|
||||
this.add('getwalletinfo', this.getWalletInfo);
|
||||
this.add('importprivkey', this.importPrivKey);
|
||||
this.add('importwallet', this.importWallet);
|
||||
this.add('importaddress', this.importAddress);
|
||||
this.add('importprunedfunds', this.importPrunedFunds);
|
||||
this.add('importpubkey', this.importPubkey);
|
||||
this.add('keypoolrefill', this.keyPoolRefill);
|
||||
this.add('listaccounts', this.listAccounts);
|
||||
this.add('listaddressgroupings', this.listAddressGroupings);
|
||||
this.add('listlockunspent', this.listLockUnspent);
|
||||
this.add('listreceivedbyaccount', this.listReceivedByAccount);
|
||||
this.add('listreceivedbyaddress', this.listReceivedByAddress);
|
||||
this.add('listsinceblock', this.listSinceBlock);
|
||||
this.add('listtransactions', this.listTransactions);
|
||||
this.add('listunspent', this.listUnspent);
|
||||
this.add('lockunspent', this.lockUnspent);
|
||||
this.add('move', this.move);
|
||||
this.add('sendfrom', this.sendfrom);
|
||||
this.add('sendmany', this.sendmany);
|
||||
this.add('sendtoaddress', this.sendtoaddress);
|
||||
this.add('setaccount', this.setaccount);
|
||||
this.add('settxfee', this.settxfee);
|
||||
this.add('signmessage', this.signmessage);
|
||||
this.add('walletlock', this.walletlock);
|
||||
this.add('walletpassphrasechange', this.walletpassphrasechange);
|
||||
this.add('walletpassphrase', this.walletpassphrase);
|
||||
this.add('removeprunedfunds', this.removeprunedfunds);
|
||||
this.add('sendfrom', this.sendFrom);
|
||||
this.add('sendmany', this.sendMany);
|
||||
this.add('sendtoaddress', this.sendToAddress);
|
||||
this.add('setaccount', this.setAccount);
|
||||
this.add('settxfee', this.setTXFee);
|
||||
this.add('signmessage', this.signMessage);
|
||||
this.add('walletlock', this.walletLock);
|
||||
this.add('walletpassphrasechange', this.walletPassphraseChange);
|
||||
this.add('walletpassphrase', this.walletPassphrase);
|
||||
this.add('removeprunedfunds', this.removePrunedFunds);
|
||||
this.add('selectwallet', this.selectWallet);
|
||||
this.add('getmemory', this.getMemory);
|
||||
this.add('setloglevel', this.setLogLevel);
|
||||
};
|
||||
|
||||
RPC.prototype.fundrawtransaction = co(function* fundrawtransaction(args, help) {
|
||||
RPC.prototype.help = co(function* _help(args, help) {
|
||||
var json;
|
||||
|
||||
if (args.length === 0)
|
||||
return 'Select a command.';
|
||||
|
||||
json = {
|
||||
method: args[0],
|
||||
params: []
|
||||
};
|
||||
|
||||
return yield this.execute(json, true);
|
||||
});
|
||||
|
||||
RPC.prototype.stop = co(function* stop(args, help) {
|
||||
if (help || args.length !== 0)
|
||||
throw new RPCError('stop');
|
||||
|
||||
this.wdb.close();
|
||||
|
||||
return 'Stopping.';
|
||||
});
|
||||
|
||||
RPC.prototype.fundRawTransaction = co(function* fundRawTransaction(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var data = valid.buf(0);
|
||||
var options = valid.obj(1);
|
||||
@ -154,7 +180,7 @@ RPC.prototype.fundrawtransaction = co(function* fundrawtransaction(args, help) {
|
||||
* Wallet
|
||||
*/
|
||||
|
||||
RPC.prototype.resendwallettransactions = co(function* resendwallettransactions(args, help) {
|
||||
RPC.prototype.resendWalletTransactions = co(function* resendWalletTransactions(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var hashes = [];
|
||||
var i, tx, txs;
|
||||
@ -172,7 +198,7 @@ RPC.prototype.resendwallettransactions = co(function* resendwallettransactions(a
|
||||
return hashes;
|
||||
});
|
||||
|
||||
RPC.prototype.addmultisigaddress = co(function* addmultisigaddress(args, help) {
|
||||
RPC.prototype.addMultisigAddress = co(function* addMultisigAddress(args, help) {
|
||||
if (help || args.length < 2 || args.length > 3) {
|
||||
throw new RPCError('addmultisigaddress'
|
||||
+ ' nrequired ["key",...] ( "account" )');
|
||||
@ -182,7 +208,7 @@ RPC.prototype.addmultisigaddress = co(function* addmultisigaddress(args, help) {
|
||||
throw new Error('Not implemented.');
|
||||
});
|
||||
|
||||
RPC.prototype.addwitnessaddress = co(function* addwitnessaddress(args, help) {
|
||||
RPC.prototype.addWitnessAddress = co(function* addWitnessAddress(args, help) {
|
||||
if (help || args.length < 1 || args.length > 1)
|
||||
throw new RPCError('addwitnessaddress "address"');
|
||||
|
||||
@ -190,7 +216,7 @@ RPC.prototype.addwitnessaddress = co(function* addwitnessaddress(args, help) {
|
||||
throw new Error('Not implemented.');
|
||||
});
|
||||
|
||||
RPC.prototype.backupwallet = co(function* backupwallet(args, help) {
|
||||
RPC.prototype.backupWallet = co(function* backupWallet(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var dest = valid.str(0);
|
||||
|
||||
@ -202,7 +228,7 @@ RPC.prototype.backupwallet = co(function* backupwallet(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.dumpprivkey = co(function* dumpprivkey(args, help) {
|
||||
RPC.prototype.dumpPrivKey = co(function* dumpPrivKey(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var addr = valid.str(0, '');
|
||||
@ -223,7 +249,7 @@ RPC.prototype.dumpprivkey = co(function* dumpprivkey(args, help) {
|
||||
return ring.toSecret();
|
||||
});
|
||||
|
||||
RPC.prototype.dumpwallet = co(function* dumpwallet(args, help) {
|
||||
RPC.prototype.dumpWallet = co(function* dumpWallet(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var file = valid.str(0);
|
||||
@ -281,7 +307,7 @@ RPC.prototype.dumpwallet = co(function* dumpwallet(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.encryptwallet = co(function* encryptwallet(args, help) {
|
||||
RPC.prototype.encryptWallet = co(function* encryptWallet(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var passphrase = valid.str(0, '');
|
||||
@ -300,7 +326,7 @@ RPC.prototype.encryptwallet = co(function* encryptwallet(args, help) {
|
||||
return 'wallet encrypted; we do not need to stop!';
|
||||
});
|
||||
|
||||
RPC.prototype.getaccountaddress = co(function* getaccountaddress(args, help) {
|
||||
RPC.prototype.getAccountAddress = co(function* getAccountAddress(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var wallet = this.wallet;
|
||||
var name = valid.str(0, '');
|
||||
@ -320,7 +346,7 @@ RPC.prototype.getaccountaddress = co(function* getaccountaddress(args, help) {
|
||||
return account.receive.getAddress('base58');
|
||||
});
|
||||
|
||||
RPC.prototype.getaccount = co(function* getaccount(args, help) {
|
||||
RPC.prototype.getAccount = co(function* getAccount(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var addr = valid.str(0, '');
|
||||
@ -341,7 +367,7 @@ RPC.prototype.getaccount = co(function* getaccount(args, help) {
|
||||
return path.name;
|
||||
});
|
||||
|
||||
RPC.prototype.getaddressesbyaccount = co(function* getaddressesbyaccount(args, help) {
|
||||
RPC.prototype.getAddressesByAccount = co(function* getAddressesByAccount(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var name = valid.str(0, '');
|
||||
@ -366,7 +392,7 @@ RPC.prototype.getaddressesbyaccount = co(function* getaddressesbyaccount(args, h
|
||||
return addrs;
|
||||
});
|
||||
|
||||
RPC.prototype.getbalance = co(function* getbalance(args, help) {
|
||||
RPC.prototype.getBalance = co(function* getBalance(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var name = valid.str(0);
|
||||
@ -396,7 +422,7 @@ RPC.prototype.getbalance = co(function* getbalance(args, help) {
|
||||
return Amount.btc(value, true);
|
||||
});
|
||||
|
||||
RPC.prototype.getnewaddress = co(function* getnewaddress(args, help) {
|
||||
RPC.prototype.getNewAddress = co(function* getNewAddress(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var name = valid.str(0);
|
||||
@ -413,7 +439,7 @@ RPC.prototype.getnewaddress = co(function* getnewaddress(args, help) {
|
||||
return address.getAddress('base58');
|
||||
});
|
||||
|
||||
RPC.prototype.getrawchangeaddress = co(function* getrawchangeaddress(args, help) {
|
||||
RPC.prototype.getRawChangeAddress = co(function* getRawChangeAddress(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var address;
|
||||
|
||||
@ -425,7 +451,7 @@ RPC.prototype.getrawchangeaddress = co(function* getrawchangeaddress(args, help)
|
||||
return address.getAddress('base58');
|
||||
});
|
||||
|
||||
RPC.prototype.getreceivedbyaccount = co(function* getreceivedbyaccount(args, help) {
|
||||
RPC.prototype.getReceivedByAccount = co(function* getReceivedByAccount(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var name = valid.str(0);
|
||||
@ -473,7 +499,7 @@ RPC.prototype.getreceivedbyaccount = co(function* getreceivedbyaccount(args, hel
|
||||
return Amount.btc(total, true);
|
||||
});
|
||||
|
||||
RPC.prototype.getreceivedbyaddress = co(function* getreceivedbyaddress(args, help) {
|
||||
RPC.prototype.getReceivedByAddress = co(function* getReceivedByAddress(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var addr = valid.str(0, '');
|
||||
@ -581,7 +607,7 @@ RPC.prototype._toWalletTX = co(function* _toWalletTX(wtx) {
|
||||
};
|
||||
});
|
||||
|
||||
RPC.prototype.gettransaction = co(function* gettransaction(args, help) {
|
||||
RPC.prototype.getTransaction = co(function* getTransaction(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var hash = valid.hash(0);
|
||||
@ -602,7 +628,7 @@ RPC.prototype.gettransaction = co(function* gettransaction(args, help) {
|
||||
return yield this._toWalletTX(wtx, watchOnly);
|
||||
});
|
||||
|
||||
RPC.prototype.abandontransaction = co(function* abandontransaction(args, help) {
|
||||
RPC.prototype.abandonTransaction = co(function* abandonTransaction(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var hash = valid.hash(0);
|
||||
@ -622,7 +648,7 @@ RPC.prototype.abandontransaction = co(function* abandontransaction(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.getunconfirmedbalance = co(function* getunconfirmedbalance(args, help) {
|
||||
RPC.prototype.getUnconfirmedBalance = co(function* getUnconfirmedBalance(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var balance;
|
||||
|
||||
@ -634,7 +660,7 @@ RPC.prototype.getunconfirmedbalance = co(function* getunconfirmedbalance(args, h
|
||||
return Amount.btc(balance.unconfirmed, true);
|
||||
});
|
||||
|
||||
RPC.prototype.getwalletinfo = co(function* getwalletinfo(args, help) {
|
||||
RPC.prototype.getWalletInfo = co(function* getWalletInfo(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var balance;
|
||||
|
||||
@ -658,7 +684,7 @@ RPC.prototype.getwalletinfo = co(function* getwalletinfo(args, help) {
|
||||
};
|
||||
});
|
||||
|
||||
RPC.prototype.importprivkey = co(function* importprivkey(args, help) {
|
||||
RPC.prototype.importPrivKey = co(function* importPrivKey(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var secret = valid.str(0);
|
||||
@ -678,7 +704,7 @@ RPC.prototype.importprivkey = co(function* importprivkey(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.importwallet = co(function* importwallet(args, help) {
|
||||
RPC.prototype.importWallet = co(function* importWallet(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var file = valid.str(0);
|
||||
@ -732,7 +758,7 @@ RPC.prototype.importwallet = co(function* importwallet(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.importaddress = co(function* importaddress(args, help) {
|
||||
RPC.prototype.importAddress = co(function* importAddress(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var addr = valid.str(0, '');
|
||||
@ -765,7 +791,7 @@ RPC.prototype.importaddress = co(function* importaddress(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.importpubkey = co(function* importpubkey(args, help) {
|
||||
RPC.prototype.importPubkey = co(function* importPubkey(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var data = valid.buf(0);
|
||||
@ -788,13 +814,13 @@ RPC.prototype.importpubkey = co(function* importpubkey(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.keypoolrefill = co(function* keypoolrefill(args, help) {
|
||||
RPC.prototype.keyPoolRefill = co(function* keyPoolRefill(args, help) {
|
||||
if (help || args.length > 1)
|
||||
throw new RPCError('keypoolrefill ( newsize )');
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.listaccounts = co(function* listaccounts(args, help) {
|
||||
RPC.prototype.listAccounts = co(function* listAccounts(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var minconf = valid.u32(0, 0);
|
||||
@ -825,13 +851,13 @@ RPC.prototype.listaccounts = co(function* listaccounts(args, help) {
|
||||
return map;
|
||||
});
|
||||
|
||||
RPC.prototype.listaddressgroupings = co(function* listaddressgroupings(args, help) {
|
||||
RPC.prototype.listAddressGroupings = co(function* listAddressGroupings(args, help) {
|
||||
if (help)
|
||||
throw new RPCError('listaddressgroupings');
|
||||
throw new Error('Not implemented.');
|
||||
});
|
||||
|
||||
RPC.prototype.listlockunspent = co(function* listlockunspent(args, help) {
|
||||
RPC.prototype.listLockUnspent = co(function* listLockUnspent(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var i, outpoints, outpoint, out;
|
||||
|
||||
@ -852,7 +878,7 @@ RPC.prototype.listlockunspent = co(function* listlockunspent(args, help) {
|
||||
return out;
|
||||
});
|
||||
|
||||
RPC.prototype.listreceivedbyaccount = co(function* listreceivedbyaccount(args, help) {
|
||||
RPC.prototype.listReceivedByAccount = co(function* listReceivedByAccount(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var minconf = valid.u32(0, 0);
|
||||
var includeEmpty = valid.bool(1, false);
|
||||
@ -866,7 +892,7 @@ RPC.prototype.listreceivedbyaccount = co(function* listreceivedbyaccount(args, h
|
||||
return yield this._listReceived(minconf, includeEmpty, watchOnly, true);
|
||||
});
|
||||
|
||||
RPC.prototype.listreceivedbyaddress = co(function* listreceivedbyaddress(args, help) {
|
||||
RPC.prototype.listReceivedByAddress = co(function* listReceivedByAddress(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var minconf = valid.u32(0, 0);
|
||||
var includeEmpty = valid.bool(1, false);
|
||||
@ -980,7 +1006,7 @@ RPC.prototype._listReceived = co(function* _listReceived(minconf, empty, watchOn
|
||||
return result;
|
||||
});
|
||||
|
||||
RPC.prototype.listsinceblock = co(function* listsinceblock(args, help) {
|
||||
RPC.prototype.listSinceBlock = co(function* listSinceBlock(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var chainHeight = this.wdb.state.height;
|
||||
var valid = new Validator([args]);
|
||||
@ -1108,7 +1134,7 @@ RPC.prototype._toListTX = co(function* _toListTX(wtx) {
|
||||
};
|
||||
});
|
||||
|
||||
RPC.prototype.listtransactions = co(function* listtransactions(args, help) {
|
||||
RPC.prototype.listTransactions = co(function* listTransactions(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var name = valid.str(0);
|
||||
@ -1145,7 +1171,7 @@ RPC.prototype.listtransactions = co(function* listtransactions(args, help) {
|
||||
return out;
|
||||
});
|
||||
|
||||
RPC.prototype.listunspent = co(function* listunspent(args, help) {
|
||||
RPC.prototype.listUnspent = co(function* listUnspent(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var minDepth = valid.u32(0, 1);
|
||||
@ -1221,7 +1247,7 @@ RPC.prototype.listunspent = co(function* listunspent(args, help) {
|
||||
return out;
|
||||
});
|
||||
|
||||
RPC.prototype.lockunspent = co(function* lockunspent(args, help) {
|
||||
RPC.prototype.lockUnspent = co(function* lockUnspent(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var unlock = valid.bool(0, false);
|
||||
@ -1271,7 +1297,7 @@ RPC.prototype.move = co(function* move(args, help) {
|
||||
throw new Error('Not implemented.');
|
||||
});
|
||||
|
||||
RPC.prototype.sendfrom = co(function* sendfrom(args, help) {
|
||||
RPC.prototype.sendFrom = co(function* sendFrom(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var name = valid.str(0);
|
||||
@ -1310,7 +1336,7 @@ RPC.prototype.sendfrom = co(function* sendfrom(args, help) {
|
||||
return tx.txid();
|
||||
});
|
||||
|
||||
RPC.prototype.sendmany = co(function* sendmany(args, help) {
|
||||
RPC.prototype.sendMany = co(function* sendMany(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var name = valid.str(0);
|
||||
@ -1369,7 +1395,7 @@ RPC.prototype.sendmany = co(function* sendmany(args, help) {
|
||||
return tx.txid();
|
||||
});
|
||||
|
||||
RPC.prototype.sendtoaddress = co(function* sendtoaddress(args, help) {
|
||||
RPC.prototype.sendToAddress = co(function* sendToAddress(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var addr = valid.str(0);
|
||||
@ -1403,7 +1429,7 @@ RPC.prototype.sendtoaddress = co(function* sendtoaddress(args, help) {
|
||||
return tx.txid();
|
||||
});
|
||||
|
||||
RPC.prototype.setaccount = co(function* setaccount(args, help) {
|
||||
RPC.prototype.setAccount = co(function* setAccount(args, help) {
|
||||
if (help || args.length < 1 || args.length > 2)
|
||||
throw new RPCError('setaccount "bitcoinaddress" "account"');
|
||||
|
||||
@ -1411,7 +1437,7 @@ RPC.prototype.setaccount = co(function* setaccount(args, help) {
|
||||
throw new Error('Not implemented.');
|
||||
});
|
||||
|
||||
RPC.prototype.settxfee = co(function* settxfee(args, help) {
|
||||
RPC.prototype.setTXFee = co(function* setTXFee(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var rate = valid.btc(0);
|
||||
|
||||
@ -1426,7 +1452,7 @@ RPC.prototype.settxfee = co(function* settxfee(args, help) {
|
||||
return true;
|
||||
});
|
||||
|
||||
RPC.prototype.signmessage = co(function* signmessage(args, help) {
|
||||
RPC.prototype.signMessage = co(function* signMessage(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var addr = valid.str(0, '');
|
||||
@ -1457,7 +1483,7 @@ RPC.prototype.signmessage = co(function* signmessage(args, help) {
|
||||
return sig.toString('base64');
|
||||
});
|
||||
|
||||
RPC.prototype.walletlock = co(function* walletlock(args, help) {
|
||||
RPC.prototype.walletLock = co(function* walletLock(args, help) {
|
||||
var wallet = this.wallet;
|
||||
|
||||
if (help || (wallet.master.encrypted && args.length !== 0))
|
||||
@ -1471,7 +1497,7 @@ RPC.prototype.walletlock = co(function* walletlock(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.walletpassphrasechange = co(function* walletpassphrasechange(args, help) {
|
||||
RPC.prototype.walletPassphraseChange = co(function* walletPassphraseChange(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var old = valid.str(0, '');
|
||||
@ -1493,7 +1519,7 @@ RPC.prototype.walletpassphrasechange = co(function* walletpassphrasechange(args,
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.walletpassphrase = co(function* walletpassphrase(args, help) {
|
||||
RPC.prototype.walletPassphrase = co(function* walletPassphrase(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var passphrase = valid.str(0, '');
|
||||
@ -1516,7 +1542,7 @@ RPC.prototype.walletpassphrase = co(function* walletpassphrase(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.importprunedfunds = co(function* importprunedfunds(args, help) {
|
||||
RPC.prototype.importPrunedFunds = co(function* importPrunedFunds(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var tx = valid.buf(0);
|
||||
var block = valid.buf(1);
|
||||
@ -1557,7 +1583,7 @@ RPC.prototype.importprunedfunds = co(function* importprunedfunds(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.removeprunedfunds = co(function* removeprunedfunds(args, help) {
|
||||
RPC.prototype.removePrunedFunds = co(function* removePrunedFunds(args, help) {
|
||||
var wallet = this.wallet;
|
||||
var valid = new Validator([args]);
|
||||
var hash = valid.hash(0);
|
||||
@ -1574,7 +1600,7 @@ RPC.prototype.removeprunedfunds = co(function* removeprunedfunds(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.selectwallet = co(function* selectwallet(args, help) {
|
||||
RPC.prototype.selectWallet = co(function* selectWallet(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var id = valid.str(0);
|
||||
var wallet;
|
||||
@ -1592,6 +1618,25 @@ RPC.prototype.selectwallet = co(function* selectwallet(args, help) {
|
||||
return null;
|
||||
});
|
||||
|
||||
RPC.prototype.getMemory = co(function* getMemory(args, help) {
|
||||
if (help || args.length !== 0)
|
||||
throw new RPCError('getmemory');
|
||||
|
||||
return util.memoryUsage();
|
||||
});
|
||||
|
||||
RPC.prototype.setLogLevel = co(function* setLogLevel(args, help) {
|
||||
var valid = new Validator([args]);
|
||||
var level = valid.str(0, '');
|
||||
|
||||
if (help || args.length !== 1)
|
||||
throw new RPCError('setloglevel "level"');
|
||||
|
||||
this.logger.setLevel(level);
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
/*
|
||||
* Expose
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user