fix segfault on exit.

This commit is contained in:
Christopher Jeffrey 2014-12-12 11:00:24 -08:00
parent 70d19eb6d6
commit f552121fb2

View File

@ -139,10 +139,12 @@ Bitcoin.instances = {};
Bitcoin.prototype.instances = Bitcoin.instances; Bitcoin.prototype.instances = Bitcoin.instances;
Bitcoin.__defineGetter__('global', function() { Bitcoin.__defineGetter__('global', function() {
if (bitcoin.stopping) return;
return Bitcoin.instances[Object.keys(Bitcoin.instances)[0]]; return Bitcoin.instances[Object.keys(Bitcoin.instances)[0]];
}); });
Bitcoin.prototype.__defineGetter__('global', function() { Bitcoin.prototype.__defineGetter__('global', function() {
if (bitcoin.stopping) return;
return Bitcoin.global; return Bitcoin.global;
}); });
@ -370,6 +372,7 @@ Bitcoin.prototype.start = function(options, callback) {
}; };
Bitcoin.prototype.getBlock = function(blockhash, callback) { Bitcoin.prototype.getBlock = function(blockhash, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.getBlock(blockhash, function(err, block) { return bitcoindjs.getBlock(blockhash, function(err, block) {
if (err) return callback(err); if (err) return callback(err);
return callback(null, bitcoin.block(block)); return callback(null, bitcoin.block(block));
@ -377,6 +380,7 @@ Bitcoin.prototype.getBlock = function(blockhash, callback) {
}; };
Bitcoin.prototype.getBlockHeight = function(height, callback) { Bitcoin.prototype.getBlockHeight = function(height, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.getBlock(+height, function(err, block) { return bitcoindjs.getBlock(+height, function(err, block) {
if (err) return callback(err); if (err) return callback(err);
return callback(null, bitcoin.block(block)); return callback(null, bitcoin.block(block));
@ -385,6 +389,7 @@ Bitcoin.prototype.getBlockHeight = function(height, callback) {
Bitcoin.prototype.getTransaction = Bitcoin.prototype.getTransaction =
Bitcoin.prototype.getTx = function(txid, blockhash, callback) { Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
if (bitcoin.stopping) return;
if (typeof txid === 'object' && txid) { if (typeof txid === 'object' && txid) {
var options = txid; var options = txid;
callback = blockhash; callback = blockhash;
@ -415,6 +420,7 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
}; };
Bitcoin.prototype.getTransactionWithBlock = function(txid, blockhash, callback) { Bitcoin.prototype.getTransactionWithBlock = function(txid, blockhash, callback) {
if (bitcoin.stopping) return;
var slow = true; var slow = true;
if (typeof txid === 'object' && txid) { if (typeof txid === 'object' && txid) {
@ -459,34 +465,42 @@ Bitcoin.prototype.getTransactionWithBlock = function(txid, blockhash, callback)
}; };
Bitcoin.prototype.getInfo = function() { Bitcoin.prototype.getInfo = function() {
if (bitcoin.stopping) return;
return bitcoindjs.getInfo(); return bitcoindjs.getInfo();
}; };
Bitcoin.prototype.getPeerInfo = function() { Bitcoin.prototype.getPeerInfo = function() {
if (bitcoin.stopping) return;
return bitcoindjs.getPeerInfo(); return bitcoindjs.getPeerInfo();
}; };
Bitcoin.prototype.getAddresses = function() { Bitcoin.prototype.getAddresses = function() {
if (bitcoin.stopping) return;
return bitcoindjs.getAddresses(); return bitcoindjs.getAddresses();
}; };
Bitcoin.prototype.getProgress = function(callback) { Bitcoin.prototype.getProgress = function(callback) {
if (bitcoin.stopping) return;
return bitcoindjs.getProgress(callback); return bitcoindjs.getProgress(callback);
}; };
Bitcoin.prototype.setGenerate = function(options) { Bitcoin.prototype.setGenerate = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.setGenerate(options || {}); return bitcoindjs.setGenerate(options || {});
}; };
Bitcoin.prototype.getGenerate = function(options) { Bitcoin.prototype.getGenerate = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.getGenerate(options || {}); return bitcoindjs.getGenerate(options || {});
}; };
Bitcoin.prototype.getMiningInfo = function() { Bitcoin.prototype.getMiningInfo = function() {
if (bitcoin.stopping) return;
return bitcoindjs.getMiningInfo(); return bitcoindjs.getMiningInfo();
}; };
Bitcoin.prototype.getAddrTransactions = function(address, callback) { Bitcoin.prototype.getAddrTransactions = function(address, callback) {
if (bitcoin.stopping) return;
return bitcoin.db.get('addr-tx/' + address, function(err, records) { return bitcoin.db.get('addr-tx/' + address, function(err, records) {
var options = { var options = {
address: address, address: address,
@ -537,20 +551,24 @@ Bitcoin.prototype.getAddrTransactions = function(address, callback) {
}; };
Bitcoin.prototype.getBestBlock = function(callback) { Bitcoin.prototype.getBestBlock = function(callback) {
if (bitcoin.stopping) return;
var hash = bitcoindjs.getBestBlock(); var hash = bitcoindjs.getBestBlock();
return bitcoindjs.getBlock(hash, callback); return bitcoindjs.getBlock(hash, callback);
}; };
Bitcoin.prototype.getChainHeight = function() { Bitcoin.prototype.getChainHeight = function() {
if (bitcoin.stopping) return;
return bitcoindjs.getChainHeight(); return bitcoindjs.getChainHeight();
}; };
Bitcoin.prototype.__defineGetter__('chainHeight', function() { Bitcoin.prototype.__defineGetter__('chainHeight', function() {
if (bitcoin.stopping) return;
return this.getChainHeight(); return this.getChainHeight();
}); });
Bitcoin.prototype.getBlockByTxid = Bitcoin.prototype.getBlockByTxid =
Bitcoin.prototype.getBlockByTx = function(txid, callback) { Bitcoin.prototype.getBlockByTx = function(txid, callback) {
if (bitcoin.stopping) return;
return bitcoin.db.get('block-tx/' + txid, function(err, block) { return bitcoin.db.get('block-tx/' + txid, function(err, block) {
if (block) { if (block) {
return self.getBlock(block.hash, function(err, block) { return self.getBlock(block.hash, function(err, block) {
@ -571,6 +589,7 @@ Bitcoin.prototype.getBlockByTx = function(txid, callback) {
Bitcoin.prototype.getBlocksByDate = Bitcoin.prototype.getBlocksByDate =
Bitcoin.prototype.getBlocksByTime = function(options, callback) { Bitcoin.prototype.getBlocksByTime = function(options, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.getBlocksByTime(options, function(err, blocks) { return bitcoindjs.getBlocksByTime(options, function(err, blocks) {
if (err) return callback(err); if (err) return callback(err);
return callback(null, blocks.map(function(block) { return callback(null, blocks.map(function(block) {
@ -580,11 +599,13 @@ Bitcoin.prototype.getBlocksByTime = function(options, callback) {
}; };
Bitcoin.prototype.getLastFileIndex = function() { Bitcoin.prototype.getLastFileIndex = function() {
if (bitcoin.stopping) return;
return bitcoindjs.getLastFileIndex(); return bitcoindjs.getLastFileIndex();
}; };
Bitcoin.prototype.log = Bitcoin.prototype.log =
Bitcoin.prototype.info = function() { Bitcoin.prototype.info = function() {
if (bitcoin.stopping) return;
if (this.options.silent) return; if (this.options.silent) return;
if (typeof arguments[0] !== 'string') { if (typeof arguments[0] !== 'string') {
var out = util.inspect(arguments[0], null, 20, true); var out = util.inspect(arguments[0], null, 20, true);
@ -595,6 +616,7 @@ Bitcoin.prototype.info = function() {
}; };
Bitcoin.prototype.error = function() { Bitcoin.prototype.error = function() {
if (bitcoin.stopping) return;
if (this.options.silent) return; if (this.options.silent) return;
if (typeof arguments[0] !== 'string') { if (typeof arguments[0] !== 'string') {
var out = util.inspect(arguments[0], null, 20, true); var out = util.inspect(arguments[0], null, 20, true);
@ -606,6 +628,7 @@ Bitcoin.prototype.error = function() {
Bitcoin.prototype.stop = Bitcoin.prototype.stop =
Bitcoin.prototype.close = function(callback) { Bitcoin.prototype.close = function(callback) {
if (bitcoin.stopping) return;
var self = this; var self = this;
return bitcoindjs.stop(function(err, status) { return bitcoindjs.stop(function(err, status) {
if (err) { if (err) {
@ -618,6 +641,22 @@ Bitcoin.prototype.close = function(callback) {
}); });
}; };
Bitcoin.prototype.__defineGetter__('stopping', function() {
return bitcoindjs.stopping() || bitcoindjs.stopped();
});
Bitcoin.prototype.__defineGetter__('stopped', function() {
return bitcoindjs.stopped();
});
Bitcoin.__defineGetter__('stopping', function() {
return bitcoindjs.stopping() || bitcoindjs.stopped();
});
Bitcoin.__defineGetter__('stopped', function() {
return bitcoindjs.stopped();
});
/** /**
* Block * Block
*/ */
@ -635,6 +674,8 @@ function Block(data) {
return data; return data;
} }
if (bitcoin.stopping) return;
var self = this; var self = this;
Object.keys(data).forEach(function(key) { Object.keys(data).forEach(function(key) {
@ -661,14 +702,17 @@ Object.defineProperty(Block.prototype, '_blockFlag', {
}); });
Block.isBlock = function(block) { Block.isBlock = function(block) {
if (bitcoin.stopping) return;
return block._blockFlag === Block.prototype._blockFlag; return block._blockFlag === Block.prototype._blockFlag;
}; };
Block.fromHex = function(hex) { Block.fromHex = function(hex) {
if (bitcoin.stopping) return;
return bitcoin.block(bitcoindjs.blockFromHex(hex)); return bitcoin.block(bitcoindjs.blockFromHex(hex));
}; };
Block.prototype.getHash = function(enc) { Block.prototype.getHash = function(enc) {
if (bitcoin.stopping) return;
var data = bitcoindjs.getBlockHex(this); var data = bitcoindjs.getBlockHex(this);
if (!this.hash || this.hash !== data.hash) { if (!this.hash || this.hash !== data.hash) {
this.hash = data.hash; this.hash = data.hash;
@ -680,10 +724,12 @@ Block.prototype.getHash = function(enc) {
}; };
Block.prototype.verify = function() { Block.prototype.verify = function() {
if (bitcoin.stopping) return;
return this.verified = this.verified || bitcoindjs.verifyBlock(this); return this.verified = this.verified || bitcoindjs.verifyBlock(this);
}; };
Block.prototype.toHex = function() { Block.prototype.toHex = function() {
if (bitcoin.stopping) return;
var hex = Block.toHex(this); var hex = Block.toHex(this);
if (!this.hex || this.hex !== hex) { if (!this.hex || this.hex !== hex) {
this.hex = hex; this.hex = hex;
@ -692,15 +738,18 @@ Block.prototype.toHex = function() {
}; };
Block.toHex = function(block) { Block.toHex = function(block) {
if (bitcoin.stopping) return;
var data = bitcoindjs.getBlockHex(block); var data = bitcoindjs.getBlockHex(block);
return data.hex; return data.hex;
}; };
Block.prototype.toBinary = function() { Block.prototype.toBinary = function() {
if (bitcoin.stopping) return;
return Block.toBinary(this); return Block.toBinary(this);
}; };
Block.toBinary = function(block) { Block.toBinary = function(block) {
if (bitcoin.stopping) return;
var data = bitcoindjs.getBlockHex(block); var data = bitcoindjs.getBlockHex(block);
return new Buffer(data.hex, 'hex'); return new Buffer(data.hex, 'hex');
}; };
@ -722,6 +771,8 @@ function Transaction(data) {
return data; return data;
} }
if (bitcoin.stopping) return;
var self = this; var self = this;
Object.keys(data).forEach(function(key) { Object.keys(data).forEach(function(key) {
@ -745,24 +796,29 @@ Object.defineProperty(Transaction.prototype, '_txFlag', {
Transaction.isTransaction = Transaction.isTransaction =
Transaction.isTx = function(tx) { Transaction.isTx = function(tx) {
if (bitcoin.stopping) return;
return tx._txFlag === Transaction.prototype._txFlag; return tx._txFlag === Transaction.prototype._txFlag;
}; };
Transaction.fromHex = function(hex) { Transaction.fromHex = function(hex) {
if (bitcoin.stopping) return;
return bitcoin.tx(bitcoindjs.txFromHex(hex)); return bitcoin.tx(bitcoindjs.txFromHex(hex));
}; };
Transaction.prototype.verify = function() { Transaction.prototype.verify = function() {
if (bitcoin.stopping) return;
return this.verified = this.verified || bitcoindjs.verifyTransaction(this); return this.verified = this.verified || bitcoindjs.verifyTransaction(this);
}; };
Transaction.prototype.sign = Transaction.prototype.sign =
Transaction.prototype.fill = function(options) { Transaction.prototype.fill = function(options) {
if (bitcoin.stopping) return;
return Transaction.fill(this, options); return Transaction.fill(this, options);
}; };
Transaction.sign = Transaction.sign =
Transaction.fill = function(tx, options) { Transaction.fill = function(tx, options) {
if (bitcoin.stopping) return;
var isTx = bitcoin.tx.isTx(tx) var isTx = bitcoin.tx.isTx(tx)
, newTx; , newTx;
@ -784,6 +840,7 @@ Transaction.fill = function(tx, options) {
}; };
Transaction.prototype.getHash = function(enc) { Transaction.prototype.getHash = function(enc) {
if (bitcoin.stopping) return;
var data = bitcoindjs.getTxHex(this); var data = bitcoindjs.getTxHex(this);
if (!this.txid || this.txid !== data.hash) { if (!this.txid || this.txid !== data.hash) {
this.txid = data.hash; this.txid = data.hash;
@ -795,10 +852,12 @@ Transaction.prototype.getHash = function(enc) {
}; };
Transaction.prototype.isCoinbase = function() { Transaction.prototype.isCoinbase = function() {
if (bitcoin.stopping) return;
return this.vin.length === 1 && this.vin[0].coinbase; return this.vin.length === 1 && this.vin[0].coinbase;
}; };
Transaction.prototype.toHex = function() { Transaction.prototype.toHex = function() {
if (bitcoin.stopping) return;
var hex = Transaction.toHex(this); var hex = Transaction.toHex(this);
if (!this.hex || hex !== this.hex) { if (!this.hex || hex !== this.hex) {
this.hex = hex; this.hex = hex;
@ -807,20 +866,24 @@ Transaction.prototype.toHex = function() {
}; };
Transaction.toHex = function(tx) { Transaction.toHex = function(tx) {
if (bitcoin.stopping) return;
var data = bitcoindjs.getTxHex(tx); var data = bitcoindjs.getTxHex(tx);
return data.hex; return data.hex;
}; };
Transaction.prototype.toBinary = function() { Transaction.prototype.toBinary = function() {
if (bitcoin.stopping) return;
return Transaction.toBinary(this); return Transaction.toBinary(this);
}; };
Transaction.toBinary = function(tx) { Transaction.toBinary = function(tx) {
if (bitcoin.stopping) return;
var data = bitcoindjs.getTxHex(tx); var data = bitcoindjs.getTxHex(tx);
return new Buffer(data.hex, 'hex'); return new Buffer(data.hex, 'hex');
}; };
Transaction.broadcast = function(tx, options, callback) { Transaction.broadcast = function(tx, options, callback) {
if (bitcoin.stopping) return;
if (typeof tx === 'string') { if (typeof tx === 'string') {
tx = { hex: tx }; tx = { hex: tx };
} }
@ -859,6 +922,7 @@ Transaction.broadcast = function(tx, options, callback) {
}; };
Transaction.prototype.broadcast = function(options, callback) { Transaction.prototype.broadcast = function(options, callback) {
if (bitcoin.stopping) return;
if (!callback) { if (!callback) {
callback = options; callback = options;
options = null; options = null;
@ -879,6 +943,8 @@ function Addresses(data) {
return data; return data;
} }
if (bitcoin.stopping) return;
var self = this; var self = this;
Object.keys(data).forEach(function(key) { Object.keys(data).forEach(function(key) {
@ -898,6 +964,7 @@ Object.defineProperty(Transaction.prototype, '_addrFlag', {
Addresses.isAddresses = Addresses.isAddresses =
Addresses.isAddr = function(addr) { Addresses.isAddr = function(addr) {
if (bitcoin.stopping) return;
return addr._txFlag === Addresses.prototype._addrFlag; return addr._txFlag === Addresses.prototype._addrFlag;
}; };
@ -907,6 +974,7 @@ Addresses.isAddr = function(addr) {
*/ */
function Wallet() { function Wallet() {
if (bitcoin.stopping) return;
var obj = function() { var obj = function() {
return obj; return obj;
}; };
@ -917,74 +985,91 @@ function Wallet() {
} }
Wallet.prototype.createAddress = function(options) { Wallet.prototype.createAddress = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletNewAddress(options || {}); return bitcoindjs.walletNewAddress(options || {});
}; };
Wallet.prototype.getAccountAddress = function(options) { Wallet.prototype.getAccountAddress = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletGetAccountAddress(options || {}); return bitcoindjs.walletGetAccountAddress(options || {});
}; };
Wallet.prototype.setAccount = function(options) { Wallet.prototype.setAccount = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletSetAccount(options || {}); return bitcoindjs.walletSetAccount(options || {});
}; };
Wallet.prototype.getAccount = function(options) { Wallet.prototype.getAccount = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletGetAccount(options || {}); return bitcoindjs.walletGetAccount(options || {});
}; };
Wallet.prototype.getRecipients = function(options) { Wallet.prototype.getRecipients = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletGetRecipients(options || {}); return bitcoindjs.walletGetRecipients(options || {});
}; };
Wallet.prototype.getRecipient = function(options) { Wallet.prototype.getRecipient = function(options) {
if (bitcoin.stopping) return;
options = options || {}; options = options || {};
var label = options.label || label; var label = options.label || label;
return bitcoindjs.walletGetRecipients({ _label: label }); return bitcoindjs.walletGetRecipients({ _label: label });
}; };
Wallet.prototype.setRecipient = function(options) { Wallet.prototype.setRecipient = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletSetRecipient(options || {}); return bitcoindjs.walletSetRecipient(options || {});
}; };
Wallet.prototype.removeRecipient = function(options) { Wallet.prototype.removeRecipient = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletRemoveRecipient(options || {}); return bitcoindjs.walletRemoveRecipient(options || {});
}; };
Wallet.prototype.sendTo = function(options, callback) { Wallet.prototype.sendTo = function(options, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.walletSendTo(options || {}, callback); return bitcoindjs.walletSendTo(options || {}, callback);
}; };
Wallet.prototype.sendFrom = function(options, callback) { Wallet.prototype.sendFrom = function(options, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.walletSendFrom(options || {}, callback); return bitcoindjs.walletSendFrom(options || {}, callback);
}; };
Wallet.prototype.move = function(options) { Wallet.prototype.move = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletMove(options || {}); return bitcoindjs.walletMove(options || {});
}; };
Wallet.prototype.signMessage = function(options) { Wallet.prototype.signMessage = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletSignMessage(options || {}); return bitcoindjs.walletSignMessage(options || {});
}; };
Wallet.prototype.verifyMessage = function(options) { Wallet.prototype.verifyMessage = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletVerifyMessage(options || {}); return bitcoindjs.walletVerifyMessage(options || {});
}; };
Wallet.prototype.createMultiSigAddress = function(options) { Wallet.prototype.createMultiSigAddress = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletCreateMultiSigAddress(options || {}); return bitcoindjs.walletCreateMultiSigAddress(options || {});
}; };
Wallet.prototype.getBalance = function(options) { Wallet.prototype.getBalance = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletGetBalance(options || {}); return bitcoindjs.walletGetBalance(options || {});
}; };
Wallet.prototype.getUnconfirmedBalance = function(options) { Wallet.prototype.getUnconfirmedBalance = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletGetUnconfirmedBalance(options || {}); return bitcoindjs.walletGetUnconfirmedBalance(options || {});
}; };
// XXX Wallet Transactions // XXX Wallet Transactions
Wallet.prototype.listTransactions = Wallet.prototype.listTransactions =
Wallet.prototype.getTransactions = function(options, callback) { Wallet.prototype.getTransactions = function(options, callback) {
if (bitcoin.stopping) return;
var txs = bitcoindjs.walletListTransactions(options || {}); var txs = bitcoindjs.walletListTransactions(options || {});
if (callback) { if (callback) {
// Retrieve to regular TXs from disk: // Retrieve to regular TXs from disk:
@ -1007,16 +1092,19 @@ Wallet.prototype.getTransactions = function(options, callback) {
Wallet.prototype.listReceivedByAddress = Wallet.prototype.listReceivedByAddress =
Wallet.prototype.getReceivedByAddress = function(options) { Wallet.prototype.getReceivedByAddress = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletReceivedByAddress(options || {}); return bitcoindjs.walletReceivedByAddress(options || {});
}; };
Wallet.prototype.listAccounts = Wallet.prototype.listAccounts =
Wallet.prototype.getAccounts = function(options) { Wallet.prototype.getAccounts = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletListAccounts(options || {}); return bitcoindjs.walletListAccounts(options || {});
}; };
// XXX Wallet Transaction // XXX Wallet Transaction
Wallet.prototype.getTransaction = function(options, callback) { Wallet.prototype.getTransaction = function(options, callback) {
if (bitcoin.stopping) return;
var tx = bitcoindjs.walletGetTransaction(options || {}); var tx = bitcoindjs.walletGetTransaction(options || {});
if (callback) { if (callback) {
// Retrieve to regular TX from disk: // Retrieve to regular TX from disk:
@ -1031,76 +1119,94 @@ Wallet.prototype.getTransaction = function(options, callback) {
}; };
Wallet.prototype.backup = function(options) { Wallet.prototype.backup = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletBackup(options || {}); return bitcoindjs.walletBackup(options || {});
}; };
Wallet.prototype.decrypt = Wallet.prototype.decrypt =
Wallet.prototype.passphrase = function(options) { Wallet.prototype.passphrase = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletPassphrase(options || {}); return bitcoindjs.walletPassphrase(options || {});
}; };
Wallet.prototype.passphraseChange = function(options) { Wallet.prototype.passphraseChange = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletPassphraseChange(options || {}); return bitcoindjs.walletPassphraseChange(options || {});
}; };
Wallet.prototype.forgetPassphrase = Wallet.prototype.forgetPassphrase =
Wallet.prototype.lock = function(options) { Wallet.prototype.lock = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletLock(options || {}); return bitcoindjs.walletLock(options || {});
}; };
Wallet.prototype.encrypt = function(options) { Wallet.prototype.encrypt = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletEncrypt(options || {}); return bitcoindjs.walletEncrypt(options || {});
}; };
Wallet.prototype.encrypted = function() { Wallet.prototype.encrypted = function() {
if (bitcoin.stopping) return;
return bitcoindjs.walletEncrypted(); return bitcoindjs.walletEncrypted();
}; };
Wallet.prototype.isEncrypted = function() { Wallet.prototype.isEncrypted = function() {
if (bitcoin.stopping) return;
return this.encrypted().encrypted; return this.encrypted().encrypted;
}; };
Wallet.prototype.isLocked = function() { Wallet.prototype.isLocked = function() {
if (bitcoin.stopping) return;
return this.encrypted().locked; return this.encrypted().locked;
}; };
Wallet.prototype.dumpKey = function(options) { Wallet.prototype.dumpKey = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletDumpKey(options || {}); return bitcoindjs.walletDumpKey(options || {});
}; };
Wallet.prototype.importKey = function(options, callback) { Wallet.prototype.importKey = function(options, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.walletImportKey(options || {}, callback); return bitcoindjs.walletImportKey(options || {}, callback);
}; };
Wallet.prototype.keyPoolRefill = function(options) { Wallet.prototype.keyPoolRefill = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletKeyPoolRefill(options || {}); return bitcoindjs.walletKeyPoolRefill(options || {});
}; };
Wallet.prototype.setTxFee = function(options) { Wallet.prototype.setTxFee = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletSetTxFee(options || {}); return bitcoindjs.walletSetTxFee(options || {});
}; };
Wallet.prototype.dump = function(options, callback) { Wallet.prototype.dump = function(options, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.walletDumpWallet(options || {}, callback); return bitcoindjs.walletDumpWallet(options || {}, callback);
}; };
Wallet.prototype.import = function(options, callback) { Wallet.prototype.import = function(options, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.walletImportWallet(options || {}, callback); return bitcoindjs.walletImportWallet(options || {}, callback);
}; };
Wallet.prototype.changeLabel = function(options) { Wallet.prototype.changeLabel = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletChangeLabel(options || {}); return bitcoindjs.walletChangeLabel(options || {});
}; };
Wallet.prototype.deleteAccount = function(options) { Wallet.prototype.deleteAccount = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletDeleteAccount(options || {}); return bitcoindjs.walletDeleteAccount(options || {});
}; };
Wallet.prototype.isMine = function(options) { Wallet.prototype.isMine = function(options) {
if (bitcoin.stopping) return;
return bitcoindjs.walletIsMine(options || {}); return bitcoindjs.walletIsMine(options || {});
}; };
Wallet.prototype.rescan = function(options, callback) { Wallet.prototype.rescan = function(options, callback) {
if (bitcoin.stopping) return;
return bitcoindjs.walletRescan(options || {}, callback); return bitcoindjs.walletRescan(options || {}, callback);
}; };
@ -1113,6 +1219,7 @@ Wallet = new Wallet;
var utils = {}; var utils = {};
utils.forEach = function(obj, iter, done) { utils.forEach = function(obj, iter, done) {
if (bitcoin.stopping) return;
var pending = obj.length; var pending = obj.length;
if (!pending) return done(); if (!pending) return done();
var next = function() { var next = function() {