|
|
@ -3,7 +3,7 @@ var _ = require('lodash'); |
|
|
|
var log = require('npmlog'); |
|
|
|
|
|
|
|
var Bitcore = require('bitcore'); |
|
|
|
var BitcoinUtils = require('../bitcoinutils') |
|
|
|
var WalletUtils = require('../walletutils') |
|
|
|
var SignUtils = require('../signutils'); |
|
|
|
|
|
|
|
/* |
|
|
@ -13,7 +13,7 @@ var SignUtils = require('../signutils'); |
|
|
|
function Verifier(opts) {}; |
|
|
|
|
|
|
|
Verifier.checkAddress = function(data, address) { |
|
|
|
var local = BitcoinUtils.deriveAddress(data.publicKeyRing, address.path, data.m, data.network); |
|
|
|
var local = WalletUtils.deriveAddress(data.publicKeyRing, address.path, data.m, data.network); |
|
|
|
return (local.address == address.address && JSON.stringify(local.publicKeys) == JSON.stringify(address.publicKeys)); |
|
|
|
}; |
|
|
|
|
|
|
@ -54,9 +54,9 @@ Verifier.checkCopayers = function(copayers, walletPrivKey, myXPrivKey, n) { |
|
|
|
|
|
|
|
|
|
|
|
Verifier.checkTxProposal = function(data, txp) { |
|
|
|
var header = txp.toAddress + '|' + txp.amount + '|' + (txp.message || ''); |
|
|
|
var hash = WalletUtils.getProposalHash(txp.toAddress, txp.amount, txp.message); |
|
|
|
var signingPubKey = Bitcore.PrivateKey.fromString(data.signingPrivKey).toPublicKey().toString(); |
|
|
|
if (!SignUtils.verify(header, txp.proposalSignature, signingPubKey)) return false; |
|
|
|
if (!SignUtils.verify(hash, txp.proposalSignature, signingPubKey)) return false; |
|
|
|
|
|
|
|
return Verifier.checkAddress(data, txp.changeAddress); |
|
|
|
}; |
|
|
|