comments explaining signing logic.
This commit is contained in:
parent
acbe4d0c2e
commit
1d210589c5
@ -283,9 +283,18 @@ Wallet.prototype.sign = function sign(tx, type, inputs, off) {
|
||||
if (!input.out.tx || !this.ownOutput(input.out.tx))
|
||||
return false;
|
||||
|
||||
// Get the previous output's subscript
|
||||
var s = input.out.tx.getSubscript(input.out.index);
|
||||
|
||||
// Get the hash of the current tx, minus the other inputs, plus the sighash.
|
||||
// `off` is used here in a case where we have multiple wallet objects
|
||||
// signing the same tx.
|
||||
var hash = tx.subscriptHash(off + i, s, type);
|
||||
|
||||
// Sign the transaction with our one input
|
||||
var signature = bcoin.ecdsa.sign(hash, this.key).toDER();
|
||||
|
||||
// Add the sighash as a single byte to the signature
|
||||
signature = signature.concat(bcoin.protocol.constants.hashType[type]);
|
||||
|
||||
// P2PKH and simple tx
|
||||
|
||||
Loading…
Reference in New Issue
Block a user