refactor: style.

This commit is contained in:
Christopher Jeffrey 2016-10-03 07:58:12 -07:00
parent 51b526b7fb
commit 0f74292082
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
9 changed files with 112 additions and 112 deletions

View File

@ -378,7 +378,7 @@ HTTPServer.prototype._init = function _init() {
next();
});
this.use(con(function *(req, res, send, next) {
this.use(con(function* (req, res, send, next) {
var wallet;
if (req.path.length < 2 || req.path[0] !== 'wallet') {
@ -420,7 +420,7 @@ HTTPServer.prototype._init = function _init() {
}));
// JSON RPC
this.post('/', con(function *(req, res, send, next) {
this.post('/', con(function* (req, res, send, next) {
var json;
if (!this.rpc) {
@ -478,7 +478,7 @@ HTTPServer.prototype._init = function _init() {
});
// UTXO by address
this.get('/coin/address/:address', con(function *(req, res, send, next) {
this.get('/coin/address/:address', con(function* (req, res, send, next) {
var coins = yield this.node.getCoinsByAddress(req.options.address);
send(200, coins.map(function(coin) {
return coin.toJSON();
@ -486,7 +486,7 @@ HTTPServer.prototype._init = function _init() {
}));
// UTXO by id
this.get('/coin/:hash/:index', con(function *(req, res, send, next) {
this.get('/coin/:hash/:index', con(function* (req, res, send, next) {
var coin = yield this.node.getCoin(req.options.hash, req.options.index);
if (!coin)
@ -496,7 +496,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Bulk read UTXOs
this.post('/coin/address', con(function *(req, res, send, next) {
this.post('/coin/address', con(function* (req, res, send, next) {
var coins = yield this.node.getCoinsByAddress(req.options.address);
send(200, coins.map(function(coin) {
return coin.toJSON();
@ -504,7 +504,7 @@ HTTPServer.prototype._init = function _init() {
}));
// TX by hash
this.get('/tx/:hash', con(function *(req, res, send, next) {
this.get('/tx/:hash', con(function* (req, res, send, next) {
var tx = yield this.node.getTX(req.options.hash);
if (!tx)
@ -516,7 +516,7 @@ HTTPServer.prototype._init = function _init() {
}));
// TX by address
this.get('/tx/address/:address', con(function *(req, res, send, next) {
this.get('/tx/address/:address', con(function* (req, res, send, next) {
var txs = yield this.node.getTXByAddress(req.options.address);
var i, tx;
@ -531,7 +531,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Bulk read TXs
this.post('/tx/address', con(function *(req, res, send, next) {
this.post('/tx/address', con(function* (req, res, send, next) {
var txs = yield this.node.getTXByAddress(req.options.address);
var i, tx;
@ -546,7 +546,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Block by hash/height
this.get('/block/:hash', con(function *(req, res, send, next) {
this.get('/block/:hash', con(function* (req, res, send, next) {
var hash = req.options.hash || req.options.height;
var block = yield this.node.getFullBlock(hash);
@ -557,7 +557,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Mempool snapshot
this.get('/mempool', con(function *(req, res, send, next) {
this.get('/mempool', con(function* (req, res, send, next) {
var i, txs, tx;
if (!this.mempool)
@ -576,7 +576,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Broadcast TX
this.post('/broadcast', con(function *(req, res, send, next) {
this.post('/broadcast', con(function* (req, res, send, next) {
yield this.node.sendTX(req.options.tx);
send(200, { success: true });
}));
@ -599,19 +599,19 @@ HTTPServer.prototype._init = function _init() {
});
// Create wallet
this.post('/wallet/:id?', con(function *(req, res, send, next) {
this.post('/wallet/:id?', con(function* (req, res, send, next) {
var wallet = yield this.walletdb.create(req.options);
send(200, wallet.toJSON());
}));
// List accounts
this.get('/wallet/:id/account', con(function *(req, res, send, next) {
this.get('/wallet/:id/account', con(function* (req, res, send, next) {
var accounts = yield req.wallet.getAccounts();
send(200, accounts);
}));
// Get account
this.get('/wallet/:id/account/:account', con(function *(req, res, send, next) {
this.get('/wallet/:id/account/:account', con(function* (req, res, send, next) {
var account = yield req.wallet.getAccount(req.options.account);
if (!account)
@ -621,7 +621,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Create/get account
this.post('/wallet/:id/account/:account?', con(function *(req, res, send, next) {
this.post('/wallet/:id/account/:account?', con(function* (req, res, send, next) {
var account = yield req.wallet.createAccount(req.options);
if (!account)
@ -631,7 +631,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Change passphrase
this.post('/wallet/:id/passphrase', con(function *(req, res, send, next) {
this.post('/wallet/:id/passphrase', con(function* (req, res, send, next) {
var options = req.options;
var old = options.old;
var new_ = options.passphrase;
@ -640,21 +640,21 @@ HTTPServer.prototype._init = function _init() {
}));
// Generate new token
this.post('/wallet/:id/retoken', con(function *(req, res, send, next) {
this.post('/wallet/:id/retoken', con(function* (req, res, send, next) {
var options = req.options;
var token = yield req.wallet.retoken(options.passphrase);
send(200, { token: token.toString('hex') });
}));
// Send TX
this.post('/wallet/:id/send', con(function *(req, res, send, next) {
this.post('/wallet/:id/send', con(function* (req, res, send, next) {
var options = req.options;
var tx = yield req.wallet.send(options);
send(200, tx.toJSON());
}));
// Create TX
this.post('/wallet/:id/create', con(function *(req, res, send, next) {
this.post('/wallet/:id/create', con(function* (req, res, send, next) {
var options = req.options;
var tx = yield req.wallet.createTX(options);
yield req.wallet.sign(tx, options);
@ -662,7 +662,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Sign TX
this.post('/wallet/:id/sign', con(function *(req, res, send, next) {
this.post('/wallet/:id/sign', con(function* (req, res, send, next) {
var options = req.options;
var tx = req.options.tx;
yield req.wallet.sign(tx, options);
@ -670,14 +670,14 @@ HTTPServer.prototype._init = function _init() {
}));
// Fill TX
this.post('/wallet/:id/fill', con(function *(req, res, send, next) {
this.post('/wallet/:id/fill', con(function* (req, res, send, next) {
var tx = req.options.tx;
yield req.wallet.fillHistory(tx);
send(200, tx.toJSON());
}));
// Zap Wallet TXs
this.post('/wallet/:id/zap', con(function *(req, res, send, next) {
this.post('/wallet/:id/zap', con(function* (req, res, send, next) {
var account = req.options.account;
var age = req.options.age;
yield req.wallet.zap(account, age);
@ -685,14 +685,14 @@ HTTPServer.prototype._init = function _init() {
}));
// Abandon Wallet TX
this.del('/wallet/:id/tx/:hash', con(function *(req, res, send, next) {
this.del('/wallet/:id/tx/:hash', con(function* (req, res, send, next) {
var hash = req.options.hash;
yield req.wallet.abandon(hash);
send(200, { success: true });
}));
// Add key
this.put('/wallet/:id/key', con(function *(req, res, send, next) {
this.put('/wallet/:id/key', con(function* (req, res, send, next) {
var account = req.options.account;
var key = req.options.key;
yield req.wallet.addKey(account, key);
@ -700,7 +700,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Remove key
this.del('/wallet/:id/key', con(function *(req, res, send, next) {
this.del('/wallet/:id/key', con(function* (req, res, send, next) {
var account = req.options.account;
var key = req.options.key;
yield req.wallet.removeKey(account, key);
@ -708,21 +708,21 @@ HTTPServer.prototype._init = function _init() {
}));
// Create address
this.post('/wallet/:id/address', con(function *(req, res, send, next) {
this.post('/wallet/:id/address', con(function* (req, res, send, next) {
var account = req.options.account;
var address = yield req.wallet.createReceive(account);
send(200, address.toJSON());
}));
// Create nested address
this.post('/wallet/:id/nested', con(function *(req, res, send, next) {
this.post('/wallet/:id/nested', con(function* (req, res, send, next) {
var account = req.options.account;
var address = yield req.wallet.createNested(account);
send(200, address.toJSON());
}));
// Wallet Balance
this.get('/wallet/:id/balance', con(function *(req, res, send, next) {
this.get('/wallet/:id/balance', con(function* (req, res, send, next) {
var account = req.options.account;
var balance = yield req.wallet.getBalance(account);
@ -733,7 +733,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Wallet UTXOs
this.get('/wallet/:id/coin', con(function *(req, res, send, next) {
this.get('/wallet/:id/coin', con(function* (req, res, send, next) {
var account = req.options.account;
var coins = yield req.wallet.getCoins(account);
send(200, coins.map(function(coin) {
@ -742,7 +742,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Wallet Coin
this.get('/wallet/:id/coin/:hash/:index', con(function *(req, res, send, next) {
this.get('/wallet/:id/coin/:hash/:index', con(function* (req, res, send, next) {
var hash = req.options.hash;
var index = req.options.index;
var coin = yield req.wallet.getCoin(hash, index);
@ -754,7 +754,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Wallet TXs
this.get('/wallet/:id/tx/history', con(function *(req, res, send, next) {
this.get('/wallet/:id/tx/history', con(function* (req, res, send, next) {
var account = req.options.account;
var txs = yield req.wallet.getHistory(account);
var details = yield req.wallet.toDetails(txs);
@ -764,7 +764,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Wallet Pending TXs
this.get('/wallet/:id/tx/unconfirmed', con(function *(req, res, send, next) {
this.get('/wallet/:id/tx/unconfirmed', con(function* (req, res, send, next) {
var account = req.options.account;
var txs = yield req.wallet.getUnconfirmed(account);
var details = yield req.wallet.toDetails(txs);
@ -774,7 +774,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Wallet TXs within time range
this.get('/wallet/:id/tx/range', con(function *(req, res, send, next) {
this.get('/wallet/:id/tx/range', con(function* (req, res, send, next) {
var account = req.options.account;
var options = req.options;
var txs = yield req.wallet.getRange(account, options);
@ -785,7 +785,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Last Wallet TXs
this.get('/wallet/:id/tx/last', con(function *(req, res, send, next) {
this.get('/wallet/:id/tx/last', con(function* (req, res, send, next) {
var account = req.options.account;
var limit = req.options.limit;
var txs = yield req.wallet.getLast(account, limit);
@ -796,7 +796,7 @@ HTTPServer.prototype._init = function _init() {
}));
// Wallet TX
this.get('/wallet/:id/tx/:hash', con(function *(req, res, send, next) {
this.get('/wallet/:id/tx/:hash', con(function* (req, res, send, next) {
var hash = req.options.hash;
var tx = yield req.wallet.getTX(hash);
var details;

View File

@ -212,7 +212,7 @@ Peer.prototype._init = function init() {
self.parser.feed(chunk);
});
this.parser.on('packet', co(function *(packet) {
this.parser.on('packet', co(function* (packet) {
try {
yield self._onPacket(packet);
} catch (e) {

View File

@ -1072,7 +1072,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
self.addLoader();
});
peer.on('merkleblock', co(function *(block) {
peer.on('merkleblock', co(function* (block) {
if (!self.options.spv)
return;
@ -1094,7 +1094,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
}
}));
peer.on('block', co(function *(block) {
peer.on('block', co(function* (block) {
if (self.options.spv)
return;
@ -1157,7 +1157,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
}
});
peer.on('tx', co(function *(tx) {
peer.on('tx', co(function* (tx) {
try {
yield self._handleTX(tx, peer);
} catch (e) {
@ -1195,7 +1195,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
self.fillPeers();
});
peer.on('txs', co(function *(txs) {
peer.on('txs', co(function* (txs) {
var i, hash;
self.emit('txs', txs, peer);
@ -1227,7 +1227,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
self.emit('version', version, peer);
});
peer.on('headers', co(function *(headers) {
peer.on('headers', co(function* (headers) {
if (!self.syncing)
return;
@ -1238,7 +1238,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
}
}));
peer.on('blocks', co(function *(hashes) {
peer.on('blocks', co(function* (hashes) {
if (!self.syncing)
return;

View File

@ -106,7 +106,7 @@ var updateEndian = co(function* updateEndian() {
console.log('Migrated endianness.');
});
co.spawn(function *() {
co.spawn(function* () {
yield db.open();
console.log('Opened %s.', file);
yield checkVersion();

View File

@ -294,7 +294,7 @@ function keyFromRaw(data, network) {
return ring;
}
co.spawn(function *() {
co.spawn(function* () {
yield db.open();
batch = db.batch();
console.log('Opened %s.', file);

View File

@ -70,23 +70,23 @@ describe('Chain', function() {
tx.inputs[i].coin = null;
}
it('should open chain and miner', cob(function *() {
it('should open chain and miner', cob(function* () {
miner.mempool = null;
constants.tx.COINBASE_MATURITY = 0;
yield node.open();
}));
it('should open walletdb', cob(function *() {
it('should open walletdb', cob(function* () {
wallet = yield walletdb.create();
miner.address = wallet.getAddress();
}));
it('should mine a block', cob(function *() {
it('should mine a block', cob(function* () {
var block = yield miner.mineBlock();
assert(block);
}));
it('should mine competing chains', cob(function *() {
it('should mine competing chains', cob(function* () {
var i, block1, block2;
for (i = 0; i < 10; i++) {
@ -125,7 +125,7 @@ describe('Chain', function() {
assert.equal(balance.total, 500 * 1e8);
}));
it('should handle a reorg', cob(function *() {
it('should handle a reorg', cob(function* () {
var entry, block, forked;
assert.equal(walletdb.height, chain.height);
@ -152,7 +152,7 @@ describe('Chain', function() {
assert(chain.tip.chainwork.cmp(tip1.chainwork) > 0);
}));
it('should have correct balance', cob(function *() {
it('should have correct balance', cob(function* () {
var balance;
yield co.timeout(100);
@ -163,12 +163,12 @@ describe('Chain', function() {
assert.equal(balance.total, 1050 * 1e8);
}));
it('should check main chain', cob(function *() {
it('should check main chain', cob(function* () {
var result = yield tip1.isMainChain();
assert(!result);
}));
it('should mine a block after a reorg', cob(function *() {
it('should mine a block after a reorg', cob(function* () {
var block, entry, result;
block = yield mineBlock(null, cb2);
@ -183,7 +183,7 @@ describe('Chain', function() {
assert(result);
}));
it('should fail to mine a block with coins on an alternate chain', cob(function *() {
it('should fail to mine a block with coins on an alternate chain', cob(function* () {
var block = yield mineBlock(null, cb1);
var err;
@ -199,7 +199,7 @@ describe('Chain', function() {
assert.equal(err.reason, 'bad-txns-inputs-missingorspent');
}));
it('should get coin', cob(function *() {
it('should get coin', cob(function* () {
var block, tx, output, coin;
block = yield mineBlock();
@ -215,7 +215,7 @@ describe('Chain', function() {
assert.deepEqual(coin.toRaw(), output.toRaw());
}));
it('should get balance', cob(function *() {
it('should get balance', cob(function* () {
var balance, txs;
yield co.timeout(100);
@ -235,7 +235,7 @@ describe('Chain', function() {
assert.equal(txs.length, 44);
}));
it('should rescan for transactions', cob(function *() {
it('should rescan for transactions', cob(function* () {
var total = 0;
var hashes = yield walletdb.getHashes();
@ -247,7 +247,7 @@ describe('Chain', function() {
assert.equal(total, 25);
}));
it('should cleanup', cob(function *() {
it('should cleanup', cob(function* () {
constants.tx.COINBASE_MATURITY = 100;
yield node.close();
}));

View File

@ -50,17 +50,17 @@ describe('HTTP', function() {
node.on('error', function() {});
it('should open node', cob(function *() {
it('should open node', cob(function* () {
constants.tx.COINBASE_MATURITY = 0;
yield node.open();
}));
it('should create wallet', cob(function *() {
it('should create wallet', cob(function* () {
var info = yield wallet.create({ id: 'test' });
assert.equal(info.id, 'test');
}));
it('should get info', cob(function *() {
it('should get info', cob(function* () {
var info = yield wallet.client.getInfo();
assert.equal(info.network, node.network.type);
assert.equal(info.version, constants.USER_VERSION);
@ -68,14 +68,14 @@ describe('HTTP', function() {
assert.equal(info.height, 0);
}));
it('should get wallet info', cob(function *() {
it('should get wallet info', cob(function* () {
var info = yield wallet.getInfo();
assert.equal(info.id, 'test');
addr = info.account.receiveAddress;
assert.equal(typeof addr, 'string');
}));
it('should fill with funds', cob(function *() {
it('should fill with funds', cob(function* () {
var balance, receive, details;
// Coinbase
@ -115,14 +115,14 @@ describe('HTTP', function() {
assert.equal(details.hash, t1.rhash);
}));
it('should get balance', cob(function *() {
it('should get balance', cob(function* () {
var balance = yield wallet.getBalance();
assert.equal(utils.satoshi(balance.confirmed), 0);
assert.equal(utils.satoshi(balance.unconfirmed), 201840);
assert.equal(utils.satoshi(balance.total), 201840);
}));
it('should send a tx', cob(function *() {
it('should send a tx', cob(function* () {
var options = {
rate: 10000,
outputs: [{
@ -140,30 +140,30 @@ describe('HTTP', function() {
hash = tx.hash;
}));
it('should get a tx', cob(function *() {
it('should get a tx', cob(function* () {
var tx = yield wallet.getTX('default', hash);
assert(tx);
assert.equal(tx.hash, hash);
}));
it('should generate new api key', cob(function *() {
it('should generate new api key', cob(function* () {
var t = wallet.token.toString('hex');
var token = yield wallet.retoken(null);
assert(token.length === 64);
assert.notEqual(token, t);
}));
it('should get balance', cob(function *() {
it('should get balance', cob(function* () {
var balance = yield wallet.getBalance();
assert.equal(utils.satoshi(balance.total), 199570);
}));
it('should execute an rpc call', cob(function *() {
it('should execute an rpc call', cob(function* () {
var info = yield wallet.client.rpc.call('getblockchaininfo', []);
assert.equal(info.blocks, 0);
}));
it('should cleanup', cob(function *() {
it('should cleanup', cob(function* () {
constants.tx.COINBASE_MATURITY = 100;
yield wallet.close();
yield node.close();

View File

@ -55,20 +55,20 @@ describe('Mempool', function() {
verify: true
});
it('should open mempool', cob(function *() {
it('should open mempool', cob(function* () {
yield mempool.open();
chain.state.flags |= constants.flags.VERIFY_WITNESS;
}));
it('should open walletdb', cob(function *() {
it('should open walletdb', cob(function* () {
yield walletdb.open();
}));
it('should open wallet', cob(function *() {
it('should open wallet', cob(function* () {
wallet = yield walletdb.create();
}));
it('should handle incoming orphans and TXs', cob(function *() {
it('should handle incoming orphans and TXs', cob(function* () {
var kp = bcoin.keyring.generate();
var w = wallet;
var t1, t2, t3, t4, f1, fake, prev, sig, balance, txs;
@ -173,7 +173,7 @@ describe('Mempool', function() {
}));
}));
it('should handle locktime', cob(function *() {
it('should handle locktime', cob(function* () {
var w = wallet;
var kp = bcoin.keyring.generate();
var tx, prev, prevHash, sig;
@ -199,7 +199,7 @@ describe('Mempool', function() {
chain.tip.height = 0;
}));
it('should handle invalid locktime', cob(function *() {
it('should handle invalid locktime', cob(function* () {
var w = wallet;
var kp = bcoin.keyring.generate();
var tx, prev, prevHash, sig, err;
@ -230,7 +230,7 @@ describe('Mempool', function() {
chain.tip.height = 0;
}));
it('should not cache a malleated wtx with mutated sig', cob(function *() {
it('should not cache a malleated wtx with mutated sig', cob(function* () {
var w = wallet;
var kp = bcoin.keyring.generate();
var tx, prev, prevHash, prevs, sig, tx, err;
@ -263,7 +263,7 @@ describe('Mempool', function() {
assert(!mempool.hasReject(tx.hash()));
}));
it('should not cache a malleated tx with unnecessary witness', cob(function *() {
it('should not cache a malleated tx with unnecessary witness', cob(function* () {
var w = wallet;
var kp = bcoin.keyring.generate();
var tx, prev, prevHash, sig, tx, err;
@ -292,7 +292,7 @@ describe('Mempool', function() {
assert(!mempool.hasReject(tx.hash()));
}));
it('should not cache a malleated wtx with wit removed', cob(function *() {
it('should not cache a malleated wtx with wit removed', cob(function* () {
var w = wallet;
var kp = bcoin.keyring.generate();
var tx, prev, prevHash, tx, err;
@ -321,7 +321,7 @@ describe('Mempool', function() {
assert(!mempool.hasReject(tx.hash()));
}));
it('should cache non-malleated tx without sig', cob(function *() {
it('should cache non-malleated tx without sig', cob(function* () {
var w = wallet;
var kp = bcoin.keyring.generate();
var tx, prev, prevHash, tx, err;
@ -349,7 +349,7 @@ describe('Mempool', function() {
cached = tx;
}));
it('should clear reject cache', cob(function *() {
it('should clear reject cache', cob(function* () {
var w = wallet;
var tx, input, tx, block;
@ -378,7 +378,7 @@ describe('Mempool', function() {
assert(!mempool.hasReject(cached.hash()));
}));
it('should destroy mempool', cob(function *() {
it('should destroy mempool', cob(function* () {
yield mempool.close();
}));
});

View File

@ -51,12 +51,12 @@ describe('Wallet', function() {
this.timeout(5000);
it('should open walletdb', cob(function *() {
it('should open walletdb', cob(function* () {
constants.tx.COINBASE_MATURITY = 0;
yield walletdb.open();
}));
it('should generate new key and address', cob(function *() {
it('should generate new key and address', cob(function* () {
var w = yield walletdb.create();
var addr = w.getAddress('base58');
assert(addr);
@ -71,7 +71,7 @@ describe('Wallet', function() {
assert(!bcoin.address.validate('1KQ1wMNwXHUYj1nv2xzsRcKUH8gVFpTFUc'));
});
it('should create and get wallet', cob(function *() {
it('should create and get wallet', cob(function* () {
var w1, w2;
w1 = yield walletdb.create();
@ -124,19 +124,19 @@ describe('Wallet', function() {
assert(tx.verify(flags));
});
it('should sign/verify pubkeyhash tx', cob(function *() {
it('should sign/verify pubkeyhash tx', cob(function* () {
yield p2pkh(false, false);
}));
it('should sign/verify witnesspubkeyhash tx', cob(function *() {
it('should sign/verify witnesspubkeyhash tx', cob(function* () {
yield p2pkh(true, false);
}));
it('should sign/verify witnesspubkeyhash tx with bullshit nesting', cob(function *() {
it('should sign/verify witnesspubkeyhash tx with bullshit nesting', cob(function* () {
yield p2pkh(true, true);
}));
it('should multisign/verify TX', cob(function *() {
it('should multisign/verify TX', cob(function* () {
var w, k, keys, src, tx, maxSize;
w = yield walletdb.create({
@ -179,7 +179,7 @@ describe('Wallet', function() {
assert(tx.verify());
}));
it('should have TX pool and be serializable', cob(function *() {
it('should have TX pool and be serializable', cob(function* () {
var w = yield walletdb.create();
var f = yield walletdb.create();
var t1, t2, t3, t4, f1, fake, balance, txs;
@ -284,7 +284,7 @@ describe('Wallet', function() {
}));
}));
it('should cleanup spenders after double-spend', cob(function *() {
it('should cleanup spenders after double-spend', cob(function* () {
var w = doubleSpendWallet;
var tx, txs, total, balance;
@ -319,7 +319,7 @@ describe('Wallet', function() {
assert.equal(total, 56000);
}));
it('should fill tx with inputs', cob(function *() {
it('should fill tx with inputs', cob(function* () {
var w1 = yield walletdb.create();
var w2 = yield walletdb.create();
var t1, t2, t3, err;
@ -361,7 +361,7 @@ describe('Wallet', function() {
assert.equal(err.requiredFunds, 25000);
}));
it('should fill tx with inputs with accurate fee', cob(function *() {
it('should fill tx with inputs with accurate fee', cob(function* () {
var w1 = yield walletdb.create({ master: KEY1 });
var w2 = yield walletdb.create({ master: KEY2 });
var t1, t2, t3, balance, err;
@ -418,7 +418,7 @@ describe('Wallet', function() {
assert(balance.total === 5460);
}));
it('should sign multiple inputs using different keys', cob(function *() {
it('should sign multiple inputs using different keys', cob(function* () {
var w1 = yield walletdb.create();
var w2 = yield walletdb.create();
var to = yield walletdb.create();
@ -636,19 +636,19 @@ describe('Wallet', function() {
assert.equal(send.getFee(), 10000);
});
it('should verify 2-of-3 scripthash tx', cob(function *() {
it('should verify 2-of-3 scripthash tx', cob(function* () {
yield multisig(false, false);
}));
it('should verify 2-of-3 witnessscripthash tx', cob(function *() {
it('should verify 2-of-3 witnessscripthash tx', cob(function* () {
yield multisig(true, false);
}));
it('should verify 2-of-3 witnessscripthash tx with bullshit nesting', cob(function *() {
it('should verify 2-of-3 witnessscripthash tx with bullshit nesting', cob(function* () {
yield multisig(true, true);
}));
it('should fill tx with account 1', cob(function *() {
it('should fill tx with account 1', cob(function* () {
var w1 = yield walletdb.create();
var w2 = yield walletdb.create();
var account, accounts, rec, t1, t2, t3, err;
@ -701,7 +701,7 @@ describe('Wallet', function() {
assert.deepEqual(accounts, ['default', 'foo']);
}));
it('should fail to fill tx with account 1', cob(function *() {
it('should fail to fill tx with account 1', cob(function* () {
var w = yield walletdb.create();
var acc, account, t1, t2, err;
@ -766,7 +766,7 @@ describe('Wallet', function() {
yield w.fund(t2, { rate: 10000, round: true, account: 'foo' });
}));
it('should fill tx with inputs when encrypted', cob(function *() {
it('should fill tx with inputs when encrypted', cob(function* () {
var w = yield walletdb.create({ passphrase: 'foo' });
var t1, t2, err;
@ -804,7 +804,7 @@ describe('Wallet', function() {
assert(t2.verify());
}));
it('should fill tx with inputs with subtract fee', cob(function *() {
it('should fill tx with inputs with subtract fee', cob(function* () {
var w1 = yield walletdb.create();
var w2 = yield walletdb.create();
var t1, t2;
@ -833,7 +833,7 @@ describe('Wallet', function() {
assert.equal(t2.getFee(), 10000);
}));
it('should fill tx with inputs with subtract fee with create tx', cob(function *() {
it('should fill tx with inputs with subtract fee with create tx', cob(function* () {
var w1 = yield walletdb.create();
var w2 = yield walletdb.create();
var options, t1, t2;
@ -868,19 +868,19 @@ describe('Wallet', function() {
assert.equal(t2.getFee(), 10000);
}));
it('should get range of txs', cob(function *() {
it('should get range of txs', cob(function* () {
var w = wallet;
var txs = yield w.getRange({ start: 0xdeadbeef - 1000 });
assert.equal(txs.length, 1);
}));
it('should get range of txs from account', cob(function *() {
it('should get range of txs from account', cob(function* () {
var w = wallet;
var txs = yield w.getRange('foo', { start: 0xdeadbeef - 1000 });
assert.equal(txs.length, 1);
}));
it('should not get range of txs from non-existent account', cob(function *() {
it('should not get range of txs from non-existent account', cob(function* () {
var w = wallet;
var txs, err;
@ -894,13 +894,13 @@ describe('Wallet', function() {
assert.equal(err.message, 'Account not found.');
}));
it('should get account balance', cob(function *() {
it('should get account balance', cob(function* () {
var w = wallet;
var balance = yield w.getBalance('foo');
assert.equal(balance.total, 21840);
}));
it('should import privkey', cob(function *() {
it('should import privkey', cob(function* () {
var key = bcoin.keyring.generate();
var w = yield walletdb.create({ passphrase: 'test' });
var options, k, t1, t2, tx;
@ -943,7 +943,7 @@ describe('Wallet', function() {
ekey = key;
}));
it('should import pubkey', cob(function *() {
it('should import pubkey', cob(function* () {
var priv = bcoin.keyring.generate();
var key = new bcoin.keyring(priv.publicKey);
var w = yield walletdb.create({ watchOnly: true });
@ -959,7 +959,7 @@ describe('Wallet', function() {
assert(k);
}));
it('should import address', cob(function *() {
it('should import address', cob(function* () {
var key = bcoin.keyring.generate();
var w = yield walletdb.create({ watchOnly: true });
var options, k, t1, t2, tx;
@ -974,14 +974,14 @@ describe('Wallet', function() {
assert(!k);
}));
it('should get details', cob(function *() {
it('should get details', cob(function* () {
var w = wallet;
var txs = yield w.getRange('foo', { start: 0xdeadbeef - 1000 });
var details = yield w.toDetails(txs);
assert.equal(details[0].toJSON().outputs[0].path.name, 'foo');
}));
it('should rename wallet', cob(function *() {
it('should rename wallet', cob(function* () {
var w = wallet;
yield wallet.rename('test');
var txs = yield w.getRange('foo', { start: 0xdeadbeef - 1000 });
@ -989,7 +989,7 @@ describe('Wallet', function() {
assert.equal(details[0].toJSON().id, 'test');
}));
it('should handle changed passphrase with encrypted imports', cob(function *() {
it('should handle changed passphrase with encrypted imports', cob(function* () {
var w = ewallet;
var addr = ekey.getAddress();
var path, d1, d2, k;
@ -1028,7 +1028,7 @@ describe('Wallet', function() {
assert.equal(k.getHash('hex'), addr.getHash('hex'));
}));
it('should cleanup', cob(function *() {
it('should cleanup', cob(function* () {
var records = yield walletdb.dump();
constants.tx.COINBASE_MATURITY = 100;
}));