mirror of https://github.com/BTCPrivate/copay.git
WIP wallet working again
This commit is contained in:
parent
fcf5b13af2
commit
a187726fca
1
copay.js
1
copay.js
|
@ -15,4 +15,3 @@ module.exports.Wallet = require('soop').load('./js/models/core/Wallet',{
|
|||
Storage: StoragePlain,
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,10 @@ var config = {
|
|||
p2pApiKey: 'lwjd5qra8257b9',
|
||||
p2pDebug: 3,
|
||||
maxPeers: 5,
|
||||
requiredCopayers: 2,
|
||||
totalCopayers: 3,
|
||||
wallet: {
|
||||
requiredCopayers: 2,
|
||||
totalCopayers: 3,
|
||||
},
|
||||
insight: {
|
||||
host: 'localhost',
|
||||
port: 3001
|
||||
|
|
|
@ -13,12 +13,10 @@ var Blockchain = imports.Blockchain;
|
|||
|
||||
var copay = copay || require('../../../copay');
|
||||
|
||||
|
||||
function Wallet(config) {
|
||||
this._startInterface(config);
|
||||
}
|
||||
|
||||
|
||||
Wallet.prototype._startInterface = function(config) {
|
||||
this.storage = new Storage(config.storage);
|
||||
this.network = new Network(config.network);
|
||||
|
@ -77,6 +75,13 @@ Wallet.prototype._load = function(config, walletId) {
|
|||
};
|
||||
|
||||
|
||||
|
||||
Wallet.prototype.store = function() {
|
||||
this.storage.set(this.id,'publicKeyRing', this.publicKeyRing.toObj());
|
||||
this.storage.set(this.id,'txProposals', this.txProposals.toObj());
|
||||
this.storage.set(this.id,'privateKey', this.privateKey.toObj());
|
||||
};
|
||||
|
||||
// CONSTRUCTORS
|
||||
Wallet.read = function(config, walletId) {
|
||||
var w = new Wallet(config);
|
||||
|
@ -92,6 +97,7 @@ Wallet.create = function(config, opts) {
|
|||
return w;
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
Wallet.getRandomId = function() {
|
||||
var r = buffertools.toHex(coinUtil.generateNonce());
|
||||
return r;
|
||||
|
@ -121,6 +127,9 @@ WalletFactory.prototype.remove = function(walletId) {
|
|||
// TODO remove wallet contents, not only the id (Wallet.remove?)
|
||||
this._delWalletId(walletId);
|
||||
};
|
||||
=======
|
||||
module.exports = require('soop')(Wallet);
|
||||
>>>>>>> WIP wallet working again
|
||||
|
||||
WalletFactory.prototype._addWalletId = function(walletId) {
|
||||
var ids = this._getWalletIds();
|
||||
|
|
|
@ -6,15 +6,15 @@ function Storage() {
|
|||
}
|
||||
|
||||
// get value by key
|
||||
Storage.prototype.get = function(k) {
|
||||
Storage.prototype.get = function(walletId,k) {
|
||||
};
|
||||
|
||||
// set value for key
|
||||
Storage.prototype.set = function(k,v) {
|
||||
Storage.prototype.set = function(walletId,v) {
|
||||
};
|
||||
|
||||
// remove value for key
|
||||
Storage.prototype.remove = function(k) {
|
||||
Storage.prototype.remove = function(walletId, k) {
|
||||
};
|
||||
|
||||
// remove all values
|
||||
|
|
|
@ -6,19 +6,23 @@ function Storage() {
|
|||
this.data = {};
|
||||
}
|
||||
|
||||
// get value by key
|
||||
Storage.prototype.get = function(k) {
|
||||
return JSON.parse(localStorage.getItem(k));
|
||||
Storage.prototype._key = function(walletId, k) {
|
||||
return walletId + '::' + k;
|
||||
};
|
||||
// get value by key
|
||||
Storage.prototype.get = function(walletId, k) {
|
||||
return JSON.parse(localStorage.getItem(this._key(walletId,k)));
|
||||
};
|
||||
|
||||
|
||||
// set value for key
|
||||
Storage.prototype.set = function(k,v) {
|
||||
localStorage.setItem(k, JSON.stringify(v));
|
||||
localStorage.setItem(this._key(walletId,k), JSON.stringify(v));
|
||||
};
|
||||
|
||||
// remove value for key
|
||||
Storage.prototype.remove = function(k) {
|
||||
localStorage.removeItem(k);
|
||||
localStorage.removeItem(this._key(walletId,k));
|
||||
};
|
||||
|
||||
// remove all values
|
||||
|
|
|
@ -20,7 +20,6 @@ angular.module('copay.network')
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
// set new inbound connections
|
||||
var _setNewPeer = function(newPeer) {
|
||||
var cp = $rootScope.cp;
|
||||
|
@ -51,15 +50,12 @@ angular.module('copay.network')
|
|||
// TODO -> probably not in network.js
|
||||
var createWallet = function(walletId) {
|
||||
|
||||
opts.walletId = walletId;
|
||||
var w = new copay.Wallet(opts, config);
|
||||
var w = new copay.Wallet.create(config, {walletId: walletId});
|
||||
|
||||
// Store it on rootScope
|
||||
$rootScope.walletId = pkr.id;
|
||||
$rootScope.wallet = w;
|
||||
|
||||
//TODO
|
||||
// w.store();
|
||||
$rootScope.walletId = w.id;
|
||||
w.store();
|
||||
};
|
||||
|
||||
var openWallet = function (walletId) {
|
||||
|
|
Loading…
Reference in New Issue