2014-08-14 11:34:25 -07:00
|
|
|
var is_browser = typeof process == 'undefined' || typeof process.versions === 'undefined';
|
2014-08-14 09:29:11 -07:00
|
|
|
if (is_browser) {
|
2014-08-14 08:51:56 -07:00
|
|
|
var copay = require('copay'); //browser
|
2014-08-14 09:29:11 -07:00
|
|
|
} else {
|
2014-08-14 08:51:56 -07:00
|
|
|
var copay = require('../copay'); //node
|
|
|
|
}
|
|
|
|
var Wallet = copay.Wallet;
|
2014-08-11 16:29:44 -07:00
|
|
|
|
2014-08-21 13:50:32 -07:00
|
|
|
var FakePrivateKey = function () {
|
|
|
|
};
|
|
|
|
|
|
|
|
FakePrivateKey.prototype.toObj = function() {
|
|
|
|
return extendedPublicKeyString = 'privHex';
|
|
|
|
};
|
2014-08-11 16:29:44 -07:00
|
|
|
|
2014-06-16 13:37:33 -07:00
|
|
|
var FakeWallet = function() {
|
|
|
|
this.id = 'testID';
|
|
|
|
this.balance = 10000;
|
|
|
|
this.safeBalance = 1000;
|
2014-06-24 11:46:07 -07:00
|
|
|
this.totalCopayers = 2;
|
|
|
|
this.requiredCopayers = 2;
|
2014-08-07 16:07:41 -07:00
|
|
|
this.isLocked = false;
|
2014-06-16 13:37:33 -07:00
|
|
|
this.balanceByAddr = {
|
|
|
|
'1CjPR7Z5ZSyWk6WtXvSFgkptmpoi4UM9BC': 1000
|
|
|
|
};
|
2014-06-16 13:40:59 -07:00
|
|
|
this.name = 'myTESTwullet';
|
2014-06-24 08:36:32 -07:00
|
|
|
this.addressBook = {
|
|
|
|
'2NFR2kzH9NUdp8vsXTB4wWQtTtzhpKxsyoJ': {
|
2014-06-19 10:21:38 -07:00
|
|
|
label: 'John',
|
|
|
|
copayerId: '026a55261b7c898fff760ebe14fd22a71892295f3b49e0ca66727bc0a0d7f94d03',
|
|
|
|
createdTs: 1403102115,
|
|
|
|
}
|
|
|
|
};
|
2014-08-14 11:34:25 -07:00
|
|
|
this.publicKeyRing = {
|
|
|
|
isComplete: function() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2014-08-21 13:50:32 -07:00
|
|
|
|
|
|
|
this.privateKey = new FakePrivateKey();
|
2014-06-12 13:42:26 -07:00
|
|
|
};
|
|
|
|
|
2014-06-24 11:46:07 -07:00
|
|
|
FakeWallet.prototype.createTx = function(toAddress, amountSatStr, comment, opts, cb) {
|
|
|
|
var callback = cb || opts;
|
|
|
|
callback({});
|
|
|
|
}
|
|
|
|
|
|
|
|
FakeWallet.prototype.sendTx = function(ntxid, cb) {
|
|
|
|
cb(8);
|
|
|
|
}
|
|
|
|
|
2014-06-16 13:37:33 -07:00
|
|
|
FakeWallet.prototype.set = function(balance, safeBalance, balanceByAddr) {
|
|
|
|
this.balance = balance;
|
2014-06-12 13:42:26 -07:00
|
|
|
this.safeBalance = safeBalance;
|
|
|
|
this.balanceByAddr = balanceByAddr;
|
|
|
|
};
|
|
|
|
|
2014-06-16 13:37:33 -07:00
|
|
|
FakeWallet.prototype.getAddressesInfo = function() {
|
2014-06-12 13:42:26 -07:00
|
|
|
var ret = [];
|
|
|
|
|
2014-06-16 13:37:33 -07:00
|
|
|
for (var ii in this.balanceByAddr) {
|
2014-06-12 13:42:26 -07:00
|
|
|
ret.push({
|
|
|
|
address: ii,
|
2014-06-25 07:12:38 -07:00
|
|
|
addressStr: ii,
|
2014-06-12 13:42:26 -07:00
|
|
|
isChange: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
2014-08-05 06:21:29 -07:00
|
|
|
FakeWallet.prototype.isShared = function() {
|
|
|
|
return this.totalCopayers > 1;
|
|
|
|
}
|
|
|
|
|
2014-07-31 12:13:27 -07:00
|
|
|
FakeWallet.prototype.isReady = function() {
|
|
|
|
return true;
|
2014-08-11 14:44:35 -07:00
|
|
|
};
|
|
|
|
|
2014-08-11 15:00:19 -07:00
|
|
|
FakeWallet.prototype.fetchPaymentTx = function(opts, cb) {
|
|
|
|
cb(null, {
|
|
|
|
pr: {
|
|
|
|
pd: {
|
|
|
|
expires: 12
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-08-11 14:44:35 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-08-11 16:29:44 -07:00
|
|
|
FakeWallet.prototype.createPaymentTx = Wallet.prototype.createPaymentTx;
|
2014-07-31 12:13:27 -07:00
|
|
|
|
2014-06-12 13:42:26 -07:00
|
|
|
|
2014-06-16 13:37:33 -07:00
|
|
|
FakeWallet.prototype.getBalance = function(cb) {
|
2014-06-12 13:42:26 -07:00
|
|
|
return cb(null, this.balance, this.balanceByAddr, this.safeBalance);
|
|
|
|
};
|
|
|
|
|
2014-06-16 13:37:33 -07:00
|
|
|
FakeWallet.prototype.setEnc = function(enc) {
|
|
|
|
this.enc = enc;
|
|
|
|
};
|
|
|
|
|
|
|
|
FakeWallet.prototype.toEncryptedObj = function() {
|
|
|
|
return this.enc;
|
|
|
|
};
|
|
|
|
|
|
|
|
FakeWallet.prototype.disconnect = function() {
|
|
|
|
this.disconnectCalled = 1;
|
|
|
|
};
|
|
|
|
|
2014-08-14 11:34:25 -07:00
|
|
|
// TODO a try catch was here
|
|
|
|
module.exports = FakeWallet;
|