do not check for uncompressed keys for now.
This commit is contained in:
parent
abc1f2b610
commit
ca03911d80
@ -215,7 +215,7 @@ TX.prototype.scriptInput = function scriptInput(index, pub, redeem) {
|
|||||||
// Sign the now-built scriptSigs
|
// Sign the now-built scriptSigs
|
||||||
TX.prototype.signInput = function signInput(index, key, type) {
|
TX.prototype.signInput = function signInput(index, key, type) {
|
||||||
var input, s, hash, signature;
|
var input, s, hash, signature;
|
||||||
var len, redeem, m, n, keys, pub, pubn, pkh, pkhn, ki, signatures, i;
|
var len, redeem, m, n, keys, pub, pkh, ki, signatures, i;
|
||||||
|
|
||||||
if (typeof index !== 'number')
|
if (typeof index !== 'number')
|
||||||
index = this.inputs.indexOf(index);
|
index = this.inputs.indexOf(index);
|
||||||
@ -254,11 +254,9 @@ TX.prototype.signInput = function signInput(index, key, type) {
|
|||||||
// Add the sighash as a single byte to the signature
|
// Add the sighash as a single byte to the signature
|
||||||
signature = signature.concat(type);
|
signature = signature.concat(type);
|
||||||
|
|
||||||
// Get compressed and uncompressed pubkeys.
|
// Get pubkey and pubkey hash.
|
||||||
pub = key.getPublic(true, 'array');
|
pub = key.getPublic(true, 'array');
|
||||||
pubn = key.getPublic(false, 'array');
|
|
||||||
pkh = bcoin.wallet.key2hash(pub);
|
pkh = bcoin.wallet.key2hash(pub);
|
||||||
pkhn = bcoin.wallet.key2hash(pubn);
|
|
||||||
|
|
||||||
// Script length, needed for multisig
|
// Script length, needed for multisig
|
||||||
len = input.script.length;
|
len = input.script.length;
|
||||||
@ -273,14 +271,17 @@ TX.prototype.signInput = function signInput(index, key, type) {
|
|||||||
// Add signatures.
|
// Add signatures.
|
||||||
if (bcoin.script.isPubkey(s)) {
|
if (bcoin.script.isPubkey(s)) {
|
||||||
// P2PK
|
// P2PK
|
||||||
|
|
||||||
|
// Something is wrong. Abort.
|
||||||
if (!Array.isArray(input.script[0]))
|
if (!Array.isArray(input.script[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Already signed.
|
||||||
if (input.script[0].length)
|
if (input.script[0].length)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Make sure the pubkey is ours.
|
// Make sure the pubkey is ours.
|
||||||
if (!utils.isEqual(s[0], pub) && !utils.isEqual(s[0], pubn))
|
if (!utils.isEqual(pub, s[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
input.script[0] = signature;
|
input.script[0] = signature;
|
||||||
@ -288,17 +289,21 @@ TX.prototype.signInput = function signInput(index, key, type) {
|
|||||||
return true;
|
return true;
|
||||||
} else if (bcoin.script.isPubkeyhash(s)) {
|
} else if (bcoin.script.isPubkeyhash(s)) {
|
||||||
// P2PKH
|
// P2PKH
|
||||||
|
|
||||||
|
// Something is wrong. Abort.
|
||||||
if (!Array.isArray(input.script[0]))
|
if (!Array.isArray(input.script[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Already signed.
|
||||||
if (input.script[0].length)
|
if (input.script[0].length)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Make sure the pubkey hash is ours.
|
// Make sure the pubkey hash is ours.
|
||||||
if (!utils.isEqual(s[2], pkh) && !utils.isEqual(s[2], pkhn))
|
if (!utils.isEqual(pkh, s[2]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
input.script[0] = signature;
|
input.script[0] = signature;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (bcoin.script.isMultisig(s)) {
|
} else if (bcoin.script.isMultisig(s)) {
|
||||||
// Multisig
|
// Multisig
|
||||||
@ -344,7 +349,7 @@ TX.prototype.signInput = function signInput(index, key, type) {
|
|||||||
// Find the key index so we can place
|
// Find the key index so we can place
|
||||||
// the signature in the same index.
|
// the signature in the same index.
|
||||||
for (ki = 0; ki < keys.length; ki++) {
|
for (ki = 0; ki < keys.length; ki++) {
|
||||||
if (utils.isEqual(pub, keys[ki]) || utils.isEqual(pubn, keys[ki]))
|
if (utils.isEqual(pub, keys[ki]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user