From 5f666aef668d8de1ae402491ce40e0a69563de80 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Tue, 2 Sep 2014 18:29:02 -0300 Subject: [PATCH 1/3] Remove BuilderMockV0 --- js/models/core/BuilderMockV0.js | 26 -------------------------- js/models/core/TxProposal.js | 8 +------- js/models/core/TxProposals.js | 4 +--- 3 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 js/models/core/BuilderMockV0.js diff --git a/js/models/core/BuilderMockV0.js b/js/models/core/BuilderMockV0.js deleted file mode 100644 index be3926d10..000000000 --- a/js/models/core/BuilderMockV0.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - - -var bitcore = require('bitcore'); -var Transaction = bitcore.Transaction; - -function BuilderMockV0 (data) { - this.vanilla = data; - this.tx = new Transaction(); - this.tx.parse(new Buffer(data.tx, 'hex')); -}; - -BuilderMockV0.prototype.build = function() { - return this.tx; -}; - - -BuilderMockV0.prototype.getSelectedUnspent = function() { - return []; -}; - -BuilderMockV0.prototype.toObj = function() { - return this.vanilla; -}; - -module.exports = BuilderMockV0; diff --git a/js/models/core/TxProposal.js b/js/models/core/TxProposal.js index 2c7b6d02b..88046ca62 100644 --- a/js/models/core/TxProposal.js +++ b/js/models/core/TxProposal.js @@ -3,7 +3,6 @@ var bitcore = require('bitcore'); var util = bitcore.util; var Transaction = bitcore.Transaction; -var BuilderMockV0 = require('./BuilderMockV0');; var TransactionBuilder = bitcore.TransactionBuilder; var Script = bitcore.Script; var Key = bitcore.Key; @@ -136,12 +135,7 @@ TxProposal.fromObj = function(o, forceOpts) { } o.builder = TransactionBuilder.fromObj(o.builderObj); } catch (e) { - - // backwards (V0) compatatibility fix. - if (!o.version) { - o.builder = new BuilderMockV0(o.builderObj); - o.readonly = 1; - }; + throw new Error("Old version of wallet detected."); } return new TxProposal(o); }; diff --git a/js/models/core/TxProposals.js b/js/models/core/TxProposals.js index 11d9ad3b8..6f4cbc625 100644 --- a/js/models/core/TxProposals.js +++ b/js/models/core/TxProposals.js @@ -1,11 +1,9 @@ 'use strict'; -var BuilderMockV0 = require('./BuilderMockV0');; var bitcore = require('bitcore'); var util = bitcore.util; var Transaction = bitcore.Transaction; -var BuilderMockV0 = require('./BuilderMockV0');; -var TxProposal = require('./TxProposal');; +var TxProposal = require('./TxProposal'); var Script = bitcore.Script; var Key = bitcore.Key; var buffertools = bitcore.buffertools; From 61aea8db3d26d3ad02433ce344ed92037c738360 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Tue, 2 Sep 2014 18:43:40 -0300 Subject: [PATCH 2/3] Fix tests --- test/test.TxProposal.js | 2 +- test/test.WalletFactory.js | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/test/test.TxProposal.js b/test/test.TxProposal.js index 9ad7fe2a8..3e22e130c 100644 --- a/test/test.TxProposal.js +++ b/test/test.TxProposal.js @@ -133,7 +133,7 @@ describe('TxProposal', function() { builderObj: b.toObj(), inputChainPaths: ['m/1'], }); - }).should.throw('Invalid'); + }).should.throw('Invalid or Incompatible Backup Detected'); }); diff --git a/test/test.WalletFactory.js b/test/test.WalletFactory.js index b79bdcd5c..058f91c9b 100644 --- a/test/test.WalletFactory.js +++ b/test/test.WalletFactory.js @@ -432,16 +432,13 @@ describe('WalletFactory model', function() { wf.network.start.getCall(0).args[0].privkey.length.should.equal(64); //privkey is hex of private key buffer }); }); - describe('dont break backwards compatibility of wallets', function() { - it('should be able to import unencrypted legacy wallet TxProposal: v0', function() { - var wf = new WalletFactory(config, '0.0.5'); - var w = wf.fromObj(JSON.parse(legacyO)); + describe('break backwards compatibility with older versions', function() { + it('should\'nt be able to import unencrypted legacy wallet TxProposal: v0', function() { - should.exist(w); - w.id.should.equal('55d4bd062d32f90a'); - should.exist(w.publicKeyRing.getCopayerId); - should.exist(w.txProposals.toObj()); - should.exist(w.privateKey.toObj()); + (function() { + var wf = new WalletFactory(config, '0.0.5'); + var w = wf.fromObj(JSON.parse(legacyO)); + }).should.throw('Invalid or Incompatible Backup Detected'); }); it('should be able to import simple 1-of-1 encrypted legacy testnet wallet', function(done) { From b39a6833392ce44ca9d8b6e495e621c94208d049 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Tue, 2 Sep 2014 18:44:54 -0300 Subject: [PATCH 3/3] Fix error message --- js/models/core/TxProposal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/models/core/TxProposal.js b/js/models/core/TxProposal.js index 88046ca62..b9206a4c9 100644 --- a/js/models/core/TxProposal.js +++ b/js/models/core/TxProposal.js @@ -135,7 +135,7 @@ TxProposal.fromObj = function(o, forceOpts) { } o.builder = TransactionBuilder.fromObj(o.builderObj); } catch (e) { - throw new Error("Old version of wallet detected."); + throw new Error("Invalid or Incompatible Backup Detected."); } return new TxProposal(o); };