mtx: clean up signing methods.
This commit is contained in:
parent
e68538633d
commit
5dfdbfb8b1
@ -10,7 +10,6 @@
|
|||||||
module.exports = MTX;
|
module.exports = MTX;
|
||||||
|
|
||||||
var utils = require('../utils/utils');
|
var utils = require('../utils/utils');
|
||||||
var crypto = require('../crypto/crypto');
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var constants = require('../protocol/constants');
|
var constants = require('../protocol/constants');
|
||||||
var Network = require('../protocol/network');
|
var Network = require('../protocol/network');
|
||||||
@ -482,13 +481,12 @@ MTX.prototype.signInput = function signInput(index, ring, type) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
MTX.prototype.signVector = function signVector(prev, vector, sig, ring) {
|
MTX.prototype.signVector = function signVector(prev, vector, sig, ring) {
|
||||||
var pub = ring.publicKey;
|
|
||||||
var i, m, n, keys, keyIndex, total;
|
var i, m, n, keys, keyIndex, total;
|
||||||
|
|
||||||
// P2PK
|
// P2PK
|
||||||
if (prev.isPubkey()) {
|
if (prev.isPubkey()) {
|
||||||
// Make sure the pubkey is ours.
|
// Make sure the pubkey is ours.
|
||||||
if (!utils.equal(pub, prev.get(0)))
|
if (!utils.equal(ring.keyHash, prev.get(0)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Already signed.
|
// Already signed.
|
||||||
@ -507,7 +505,7 @@ MTX.prototype.signVector = function signVector(prev, vector, sig, ring) {
|
|||||||
// P2PKH
|
// P2PKH
|
||||||
if (prev.isPubkeyhash()) {
|
if (prev.isPubkeyhash()) {
|
||||||
// Make sure the pubkey hash is ours.
|
// Make sure the pubkey hash is ours.
|
||||||
if (!utils.equal(crypto.hash160(pub), prev.get(2)))
|
if (!utils.equal(ring.keyHash, prev.get(2)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Already signed.
|
// Already signed.
|
||||||
@ -563,7 +561,7 @@ MTX.prototype.signVector = function signVector(prev, vector, sig, ring) {
|
|||||||
|
|
||||||
// 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.
|
||||||
keyIndex = utils.indexOf(keys, pub);
|
keyIndex = utils.indexOf(keys, ring.publicKey);
|
||||||
|
|
||||||
// Our public key is not in the prev_out
|
// Our public key is not in the prev_out
|
||||||
// script. We tried to sign a transaction
|
// script. We tried to sign a transaction
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user