fill coins before signing.
This commit is contained in:
parent
29d79e57ad
commit
dd9fb535fa
@ -703,30 +703,40 @@ Wallet.prototype.getInputPaths = function getInputPaths(tx, callback) {
|
|||||||
var paths = [];
|
var paths = [];
|
||||||
var hashes;
|
var hashes;
|
||||||
|
|
||||||
|
function done() {
|
||||||
|
utils.forEachSerial(hashes, function(hash, next, i) {
|
||||||
|
self.getPath(hash, function(err, path) {
|
||||||
|
if (err)
|
||||||
|
return next(err);
|
||||||
|
|
||||||
|
if (path)
|
||||||
|
paths.push(path);
|
||||||
|
|
||||||
|
return next();
|
||||||
|
});
|
||||||
|
}, function(err) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
|
return callback(null, paths);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (tx instanceof bcoin.input) {
|
if (tx instanceof bcoin.input) {
|
||||||
if (!tx.coin)
|
if (!tx.coin)
|
||||||
return callback(new Error('Not all coins available.'));
|
return callback(new Error('Not all coins available.'));
|
||||||
hashes = [tx.coin.getHash()];
|
hashes = [tx.coin.getHash()];
|
||||||
} else {
|
return done();
|
||||||
if (!tx.hasCoins())
|
|
||||||
return callback(new Error('Not all coins available.'));
|
|
||||||
hashes = tx.getInputHashes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.forEachSerial(hashes, function(hash, next, i) {
|
this.fillCoins(tx, function(err) {
|
||||||
self.getPath(hash, function(err, path) {
|
|
||||||
if (err)
|
|
||||||
return next(err);
|
|
||||||
|
|
||||||
if (path)
|
|
||||||
paths.push(path);
|
|
||||||
|
|
||||||
return next();
|
|
||||||
});
|
|
||||||
}, function(err) {
|
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return callback(err);
|
||||||
return callback(null, paths);
|
|
||||||
|
if (!tx.hasCoins())
|
||||||
|
return callback(new Error('Not all coins available.'));
|
||||||
|
|
||||||
|
hashes = tx.getInputHashes();
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1013,7 +1023,7 @@ Wallet.prototype.sign = function sign(tx, options, callback) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Wallet.prototype.fillCoins = function fillCoins(tx, callback) {
|
Wallet.prototype.fillCoins = function fillCoins(tx, callback) {
|
||||||
return this.db.fillHistory(tx, callback);
|
return this.db.fillCoins(tx, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user