Merge pull request #274 from greggzigler/bug/simpleProposalHash

proposals with explicit type = simple need legacy header
This commit is contained in:
Ivan Socolsky 2015-07-13 13:56:18 -03:00
commit 6e9630e0df
3 changed files with 19 additions and 17 deletions

View File

@ -157,7 +157,8 @@ TxProposal.prototype.getBitcoreTx = function() {
};
TxProposal.prototype.getNetworkName = function() {
return Bitcore.Address(this.toAddress).toObject().network;
var someAddress = this.toAddress || this.outputs[0].toAddress;
return Bitcore.Address(someAddress).toObject().network;
};
TxProposal.prototype.getRawTx = function() {

View File

@ -903,9 +903,10 @@ WalletService.prototype.createTx = function(opts, cb) {
var copayer = wallet.getCopayer(self.copayerId);
var hash;
if (!opts.type) {
if (!opts.type || opts.type == Model.TxProposal.Types.SIMPLE) {
hash = WalletUtils.getProposalHash(opts.toAddress, opts.amount, opts.message, opts.payProUrl);
} else {
// should match bwc api _computeProposalSignature
var header = {
outputs: _.map(opts.outputs, function(output) {
return _.pick(output, ['toAddress', 'amount', 'message']);

View File

@ -221,22 +221,22 @@ helpers.createProposalOpts = function(type, outputs, message, signingKey, feePer
};
if (feePerKb) opts.feePerKb = feePerKb;
switch (type) {
case Model.TxProposal.Types.SIMPLE:
var hash;
if (type == Model.TxProposal.Types.SIMPLE) {
opts.toAddress = outputs[0].toAddress;
opts.amount = outputs[0].amount;
break;
case Model.TxProposal.Types.MULTIPLEOUTPUTS:
opts.outputs = outputs;
break;
hash = WalletUtils.getProposalHash(opts.toAddress, opts.amount,
opts.message, opts.payProUrl);
}
else if (type == Model.TxProposal.Types.MULTIPLEOUTPUTS) {
opts.outputs = outputs;
var header = {
outputs: outputs,
message: opts.message,
payProUrl: opts.payProUrl
};
var hash = WalletUtils.getProposalHash(header);
hash = WalletUtils.getProposalHash(header);
}
try {
opts.proposalSignature = WalletUtils.signMessage(hash, signingKey);