wallet: allow inputs and offset to be passed into wallet.sign.
This commit is contained in:
parent
24ccb7926b
commit
28abd09845
@ -207,13 +207,16 @@ Wallet.prototype.ownInput = function ownInput(tx, index) {
|
||||
return inputs;
|
||||
};
|
||||
|
||||
Wallet.prototype.sign = function sign(tx, type) {
|
||||
Wallet.prototype.sign = function sign(tx, type, inputs, off) {
|
||||
if (!type)
|
||||
type = 'all';
|
||||
assert.equal(type, 'all');
|
||||
|
||||
if (!off)
|
||||
off = 0;
|
||||
|
||||
// Filter inputs that this wallet own
|
||||
var inputs = tx.inputs.filter(function(input) {
|
||||
var inputs = inputs || tx.inputs.filter(function(input) {
|
||||
return input.out.tx && this.ownOutput(input.out.tx);
|
||||
}, this);
|
||||
var pub = this.getPublicKey();
|
||||
@ -221,7 +224,7 @@ Wallet.prototype.sign = function sign(tx, type) {
|
||||
// Add signature script to each input
|
||||
inputs.forEach(function(input, i) {
|
||||
var s = input.out.tx.getSubscript(input.out.index);
|
||||
var hash = tx.subscriptHash(i, s, type);
|
||||
var hash = tx.subscriptHash(off + i, s, type);
|
||||
var signature = bcoin.ecdsa.sign(hash, this.key).toDER();
|
||||
signature = signature.concat(bcoin.protocol.constants.hashType[type]);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user