coin filling.

This commit is contained in:
Christopher Jeffrey 2016-05-31 06:10:42 -07:00
parent 512f3de412
commit 4058bba907
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -457,32 +457,43 @@ Wallet.prototype.fill = function fill(tx, options, callback) {
if (!this.initialized)
return callback(new Error('Wallet is not initialized.'));
this.getCoins(options.account, function(err, coins) {
this.getAccount(options.account, function(err, account) {
if (err)
return callback(err);
try {
tx.fill(coins, {
selection: options.selection || 'age',
round: options.round,
confirmed: options.confirmed,
free: options.free,
fee: options.fee,
subtractFee: options.subtractFee,
changeAddress: self.account.changeAddress.getAddress(),
height: self.network.height,
rate: options.rate != null
? options.rate
: self.network.getRate(),
wallet: self,
m: self.m,
n: self.n
});
} catch (e) {
return callback(e);
if (!account) {
if (options.account != null)
return callback(new Error('Account not found.'));
account = self.account;
}
return callback();
self.getCoins(options.account, function(err, coins) {
if (err)
return callback(err);
try {
tx.fill(coins, {
selection: options.selection || 'age',
round: options.round,
confirmed: options.confirmed,
free: options.free,
fee: options.fee,
subtractFee: options.subtractFee,
changeAddress: account.changeAddress.getAddress(),
height: self.network.height,
rate: options.rate != null
? options.rate
: self.network.getRate(),
wallet: self,
m: self.m,
n: self.n
});
} catch (e) {
return callback(e);
}
return callback();
});
});
};