Browse Source

Merge pull request #274 from greggzigler/bug/simpleProposalHash

proposals with explicit type = simple need legacy header
activeAddress
Ivan Socolsky 10 years ago
parent
commit
6e9630e0df
  1. 3
      lib/model/txproposal.js
  2. 3
      lib/server.js
  3. 30
      test/integration/server.js

3
lib/model/txproposal.js

@ -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() {

3
lib/server.js

@ -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']);

30
test/integration/server.js

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

Loading…
Cancel
Save