txproposal.js -> txproposal_legacy.js
This commit is contained in:
parent
ebce4629ff
commit
563ee14dc1
|
@ -2,7 +2,7 @@ var Model = {};
|
|||
|
||||
Model.Wallet = require('./wallet');
|
||||
Model.Copayer = require('./copayer');
|
||||
Model.TxProposal = require('./txproposal');
|
||||
Model.TxProposalLegacy = require('./txproposal_legacy');
|
||||
Model.Address = require('./address');
|
||||
Model.Notification = require('./notification');
|
||||
Model.Preferences = require('./preferences');
|
||||
|
|
|
@ -924,7 +924,7 @@ WalletService.prototype._computeBytesToSendMax = function(utxos, cb) {
|
|||
self.getWallet({}, function(err, wallet) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var txp = Model.TxProposal.create({
|
||||
var txp = Model.TxProposalLegacy.create({
|
||||
walletId: self.walletId,
|
||||
requiredSignatures: wallet.m,
|
||||
walletN: wallet.n,
|
||||
|
@ -1244,8 +1244,8 @@ WalletService.prototype.createTx = function(opts, cb) {
|
|||
if (!Utils.checkRequired(opts, ['outputs', 'proposalSignature']))
|
||||
return cb(new ClientError('Required argument missing'));
|
||||
|
||||
var type = opts.type || Model.TxProposal.Types.SIMPLE;
|
||||
if (!Model.TxProposal.isTypeSupported(type))
|
||||
var type = opts.type || Model.TxProposalLegacy.Types.SIMPLE;
|
||||
if (!Model.TxProposalLegacy.isTypeSupported(type))
|
||||
return cb(new ClientError('Invalid proposal type'));
|
||||
|
||||
var feePerKb = opts.feePerKb || Defaults.DEFAULT_FEE_PER_KB;
|
||||
|
@ -1259,7 +1259,7 @@ WalletService.prototype.createTx = function(opts, cb) {
|
|||
|
||||
var copayer = wallet.getCopayer(self.copayerId);
|
||||
var hash;
|
||||
if (!opts.type || opts.type == Model.TxProposal.Types.SIMPLE) {
|
||||
if (!opts.type || opts.type == Model.TxProposalLegacy.Types.SIMPLE) {
|
||||
hash = WalletService._getProposalHash(opts.toAddress, opts.amount, opts.message, opts.payProUrl);
|
||||
} else {
|
||||
// should match bwc api _computeProposalSignature
|
||||
|
@ -1281,7 +1281,7 @@ WalletService.prototype.createTx = function(opts, cb) {
|
|||
if (err) return cb(err);
|
||||
if (!canCreate) return cb(Errors.TX_CANNOT_CREATE);
|
||||
|
||||
if (type != Model.TxProposal.Types.EXTERNAL) {
|
||||
if (type != Model.TxProposalLegacy.Types.EXTERNAL) {
|
||||
var validationError = self._validateOutputs(opts, wallet);
|
||||
if (validationError) {
|
||||
return cb(validationError);
|
||||
|
@ -1315,7 +1315,7 @@ WalletService.prototype.createTx = function(opts, cb) {
|
|||
txOpts.proposalSignaturePubKeySig = signingKey.signature;
|
||||
}
|
||||
|
||||
var txp = Model.TxProposal.create(txOpts);
|
||||
var txp = Model.TxProposalLegacy.create(txOpts);
|
||||
|
||||
if (!self._clientSupportsTXPv2()) {
|
||||
txp.version = '1.0.1';
|
||||
|
|
|
@ -183,7 +183,7 @@ Storage.prototype.fetchTx = function(walletId, txProposalId, cb) {
|
|||
}, function(err, result) {
|
||||
if (err) return cb(err);
|
||||
if (!result) return cb();
|
||||
return self._completeTxData(walletId, Model.TxProposal.fromObj(result), cb);
|
||||
return self._completeTxData(walletId, Model.TxProposalLegacy.fromObj(result), cb);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -196,7 +196,7 @@ Storage.prototype.fetchTxByHash = function(hash, cb) {
|
|||
if (err) return cb(err);
|
||||
if (!result) return cb();
|
||||
|
||||
return self._completeTxData(result.walletId, Model.TxProposal.fromObj(result), cb);
|
||||
return self._completeTxData(result.walletId, Model.TxProposalLegacy.fromObj(result), cb);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -214,7 +214,7 @@ Storage.prototype.fetchLastTxs = function(walletId, creatorId, limit, cb) {
|
|||
if (err) return cb(err);
|
||||
if (!result) return cb();
|
||||
var txs = _.map(result, function(tx) {
|
||||
return Model.TxProposal.fromObj(tx);
|
||||
return Model.TxProposalLegacy.fromObj(tx);
|
||||
});
|
||||
return cb(null, txs);
|
||||
});
|
||||
|
@ -234,7 +234,7 @@ Storage.prototype.fetchPendingTxs = function(walletId, cb) {
|
|||
if (err) return cb(err);
|
||||
if (!result) return cb();
|
||||
var txs = _.map(result, function(tx) {
|
||||
return Model.TxProposal.fromObj(tx);
|
||||
return Model.TxProposalLegacy.fromObj(tx);
|
||||
});
|
||||
return self._completeTxData(walletId, txs, cb);
|
||||
});
|
||||
|
@ -271,7 +271,7 @@ Storage.prototype.fetchTxs = function(walletId, opts, cb) {
|
|||
if (err) return cb(err);
|
||||
if (!result) return cb();
|
||||
var txs = _.map(result, function(tx) {
|
||||
return Model.TxProposal.fromObj(tx);
|
||||
return Model.TxProposalLegacy.fromObj(tx);
|
||||
});
|
||||
return self._completeTxData(walletId, txs, cb);
|
||||
});
|
||||
|
|
|
@ -356,7 +356,7 @@ helpers.createSimpleProposalOpts = function(toAddress, amount, signingKey, opts)
|
|||
toAddress: toAddress,
|
||||
amount: amount,
|
||||
}];
|
||||
return helpers.createProposalOpts(Model.TxProposal.Types.SIMPLE, outputs, signingKey, opts);
|
||||
return helpers.createProposalOpts(Model.TxProposalLegacy.Types.SIMPLE, outputs, signingKey, opts);
|
||||
};
|
||||
|
||||
helpers.createExternalProposalOpts = function(toAddress, amount, signingKey, moreOpts, inputs) {
|
||||
|
@ -368,7 +368,7 @@ helpers.createExternalProposalOpts = function(toAddress, amount, signingKey, mor
|
|||
inputs = moreOpts;
|
||||
moreOpts = null;
|
||||
}
|
||||
return helpers.createProposalOpts(Model.TxProposal.Types.EXTERNAL, outputs, signingKey, moreOpts, inputs);
|
||||
return helpers.createProposalOpts(Model.TxProposalLegacy.Types.EXTERNAL, outputs, signingKey, moreOpts, inputs);
|
||||
};
|
||||
|
||||
helpers.createProposalOpts = function(type, outputs, signingKey, moreOpts, inputs) {
|
||||
|
@ -394,12 +394,12 @@ helpers.createProposalOpts = function(type, outputs, signingKey, moreOpts, input
|
|||
});
|
||||
|
||||
var hash;
|
||||
if (type == Model.TxProposal.Types.SIMPLE) {
|
||||
if (type == Model.TxProposalLegacy.Types.SIMPLE) {
|
||||
opts.toAddress = outputs[0].toAddress;
|
||||
opts.amount = outputs[0].amount;
|
||||
hash = WalletService._getProposalHash(opts.toAddress, opts.amount,
|
||||
opts.message, opts.payProUrl);
|
||||
} else if (type == Model.TxProposal.Types.MULTIPLEOUTPUTS || type == Model.TxProposal.Types.EXTERNAL) {
|
||||
} else if (type == Model.TxProposalLegacy.Types.MULTIPLEOUTPUTS || type == Model.TxProposalLegacy.Types.EXTERNAL) {
|
||||
opts.outputs = outputs;
|
||||
var header = {
|
||||
outputs: outputs,
|
||||
|
|
|
@ -2150,7 +2150,7 @@ describe('Wallet service', function() {
|
|||
amount: 75,
|
||||
message: 'message #2'
|
||||
}];
|
||||
var txOpts = helpers.createProposalOpts(Model.TxProposal.Types.MULTIPLEOUTPUTS, outputs, TestData.copayers[0].privKey_1H_0, {
|
||||
var txOpts = helpers.createProposalOpts(Model.TxProposalLegacy.Types.MULTIPLEOUTPUTS, outputs, TestData.copayers[0].privKey_1H_0, {
|
||||
message: 'some message'
|
||||
});
|
||||
server.createTx(txOpts, function(err, tx) {
|
||||
|
@ -2173,7 +2173,7 @@ describe('Wallet service', function() {
|
|||
amount: max - 1,
|
||||
message: 'message #2'
|
||||
}];
|
||||
var txOpts = helpers.createProposalOpts(Model.TxProposal.Types.MULTIPLEOUTPUTS, outputs, TestData.copayers[0].privKey_1H_0, {
|
||||
var txOpts = helpers.createProposalOpts(Model.TxProposalLegacy.Types.MULTIPLEOUTPUTS, outputs, TestData.copayers[0].privKey_1H_0, {
|
||||
message: 'some message'
|
||||
});
|
||||
server.createTx(txOpts, function(err, txp) {
|
||||
|
@ -2199,7 +2199,7 @@ describe('Wallet service', function() {
|
|||
amount: 90,
|
||||
message: 'message #2'
|
||||
}];
|
||||
var txOpts = helpers.createProposalOpts(Model.TxProposal.Types.MULTIPLEOUTPUTS, outputs, TestData.copayers[0].privKey_1H_0, {
|
||||
var txOpts = helpers.createProposalOpts(Model.TxProposalLegacy.Types.MULTIPLEOUTPUTS, outputs, TestData.copayers[0].privKey_1H_0, {
|
||||
message: 'some message'
|
||||
});
|
||||
server.createTx(txOpts, function(err, tx) {
|
||||
|
@ -4021,7 +4021,7 @@ describe('Wallet service', function() {
|
|||
amount: 30,
|
||||
message: 'message #2'
|
||||
}];
|
||||
var txOpts = helpers.createProposalOpts(Model.TxProposal.Types.MULTIPLEOUTPUTS, outputs, TestData.copayers[0].privKey_1H_0, {
|
||||
var txOpts = helpers.createProposalOpts(Model.TxProposalLegacy.Types.MULTIPLEOUTPUTS, outputs, TestData.copayers[0].privKey_1H_0, {
|
||||
message: 'some message'
|
||||
});
|
||||
server.createTx(txOpts, function(err, tx) {
|
||||
|
@ -4074,7 +4074,7 @@ describe('Wallet service', function() {
|
|||
tx.actions.length.should.equal(1);
|
||||
tx.actions[0].type.should.equal('accept');
|
||||
tx.actions[0].copayerName.should.equal('copayer 1');
|
||||
tx.proposalType.should.equal(Model.TxProposal.Types.MULTIPLEOUTPUTS);
|
||||
tx.proposalType.should.equal(Model.TxProposalLegacy.Types.MULTIPLEOUTPUTS);
|
||||
tx.outputs[0].address.should.equal(external);
|
||||
tx.outputs[0].amount.should.equal(helpers.toSatoshi(50));
|
||||
should.not.exist(tx.outputs[0].message);
|
||||
|
|
|
@ -4,7 +4,7 @@ var _ = require('lodash');
|
|||
var chai = require('chai');
|
||||
var sinon = require('sinon');
|
||||
var should = chai.should();
|
||||
var TxProposal = require('../../lib/model/txproposal');
|
||||
var TxProposal = require('../../lib/model/txproposal_legacy');
|
||||
var Bitcore = require('bitcore-lib');
|
||||
|
||||
describe('TXProposal', function() {
|
|
@ -7,7 +7,7 @@ var should = chai.should();
|
|||
var TxProposal = require('../../lib/model/txproposalv3');
|
||||
var Bitcore = require('bitcore-lib');
|
||||
|
||||
describe.only('TxProposal v3', function() {
|
||||
describe('TxProposal v3', function() {
|
||||
describe('#create', function() {
|
||||
it('should create a TxProposal', function() {
|
||||
var txp = TxProposal.create(aTxpOpts());
|
||||
|
|
|
@ -141,7 +141,7 @@ describe('Storage', function() {
|
|||
should.not.exist(err);
|
||||
|
||||
proposals = _.map(_.range(4), function(i) {
|
||||
var tx = Model.TxProposal.create({
|
||||
var tx = Model.TxProposalLegacy.create({
|
||||
walletId: '123',
|
||||
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||
creatorId: wallet.copayers[0].id,
|
||||
|
@ -182,7 +182,7 @@ describe('Storage', function() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should fetch all pending txs', function(done) {
|
||||
storage.fetchPendingTxs('123', function(err, txs) {
|
||||
should.not.exist(err);
|
||||
|
|
Loading…
Reference in New Issue