wallet: sign refactor.

This commit is contained in:
Christopher Jeffrey 2016-08-17 23:45:00 -07:00
parent 990d5c2baf
commit d7ac63755f
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1395,6 +1395,7 @@ Wallet.prototype.scriptInputs = function scriptInputs(tx, callback) {
Wallet.prototype.sign = function sign(tx, options, callback) {
var self = this;
var passphrase, timeout, index, type;
if (typeof options === 'function') {
callback = options;
@ -1404,15 +1405,20 @@ Wallet.prototype.sign = function sign(tx, options, callback) {
if (typeof options === 'string' || Buffer.isBuffer(options))
options = { passphrase: options };
passphrase = options.passphrase;
timeout = options.timeout;
index = options.index;
type = options.type;
this.deriveInputs(tx, function(err, rings) {
if (err)
return callback(err);
self.unlock(options.passphrase, options.timeout, function(err, master) {
self.unlock(passphrase, timeout, function(err, master) {
if (err)
return callback(err);
self._sign(rings, master, tx, options.index, options.type, callback);
self._sign(rings, master, tx, index, type, callback);
});
});
};