diff --git a/js/models/core/BuilderMockV0.js b/js/models/core/BuilderMockV0.js new file mode 100644 index 000000000..be3926d10 --- /dev/null +++ b/js/models/core/BuilderMockV0.js @@ -0,0 +1,26 @@ +'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/TxProposals.js b/js/models/core/TxProposals.js index 5ae9c9312..e91efb7f1 100644 --- a/js/models/core/TxProposals.js +++ b/js/models/core/TxProposals.js @@ -6,6 +6,7 @@ var bitcore = require('bitcore'); var util = bitcore.util; var Transaction = bitcore.Transaction; var Builder = bitcore.TransactionBuilder; +var BuilderMockV0 = require('./BuilderMockV0');; var Script = bitcore.Script; var buffertools = bitcore.buffertools; @@ -45,8 +46,11 @@ TxProposal.fromObj = function(o) { try { t.builder = new Builder.fromObj(o.builderObj); } catch (e) { - if (!process.version) - console.log('Ignoring incompatible stored TxProposal:' + JSON.stringify(o.builderObj)); + if (!o.version) { + console.log('Importing old TxProposal V0' + JSON.stringify(o.builderObj)); + t.builder = new BuilderMockV0(o.builderObj); + t.readonly = 1; + }; } return t; }; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index f48c7d64e..00a1db9bc 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -488,7 +488,10 @@ Wallet.prototype.getTxProposals = function() { txp.finallyRejected = true; } - ret.push(txp); + if (txp.readonly && !txp.finallyRejected && !txp.sentTs) { + } else { + ret.push(txp); + } } return ret; };