Revert "Delete BuilderMockV0"
This is a combination of 3 commits: * Revertion of commitb39a683339. * Revertion of commit61aea8db3d. * Revertion of commit5f666aef66.
This commit is contained in:
parent
3b16eaabe7
commit
00774b62fd
5 changed files with 48 additions and 11 deletions
26
js/models/core/BuilderMockV0.js
Normal file
26
js/models/core/BuilderMockV0.js
Normal file
|
|
@ -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;
|
||||
|
|
@ -4,6 +4,7 @@ var bitcore = require('bitcore');
|
|||
var _ = require('underscore');
|
||||
var util = bitcore.util;
|
||||
var Transaction = bitcore.Transaction;
|
||||
var BuilderMockV0 = require('./BuilderMockV0');;
|
||||
var TransactionBuilder = bitcore.TransactionBuilder;
|
||||
var Script = bitcore.Script;
|
||||
var Key = bitcore.Key;
|
||||
|
|
@ -147,7 +148,12 @@ TxProposal.fromObj = function(o, forceOpts) {
|
|||
try {
|
||||
o.builder = TransactionBuilder.fromObj(o.builderObj);
|
||||
} catch (e) {
|
||||
throw new Error("Invalid or Incompatible Backup Detected.");
|
||||
|
||||
// backwards (V0) compatatibility fix.
|
||||
if (!o.version) {
|
||||
o.builder = new BuilderMockV0(o.builderObj);
|
||||
o.readonly = 1;
|
||||
};
|
||||
}
|
||||
return new TxProposal(o);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
var BuilderMockV0 = require('./BuilderMockV0');;
|
||||
var bitcore = require('bitcore');
|
||||
var util = bitcore.util;
|
||||
var Transaction = bitcore.Transaction;
|
||||
var TxProposal = require('./TxProposal');
|
||||
var BuilderMockV0 = require('./BuilderMockV0');;
|
||||
var TxProposal = require('./TxProposal');;
|
||||
var Script = bitcore.Script;
|
||||
var Key = bitcore.Key;
|
||||
var buffertools = bitcore.buffertools;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue