coin filling.
This commit is contained in:
parent
512f3de412
commit
4058bba907
@ -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();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user