mirror of https://github.com/BTCPrivate/copay.git
open wallet working
This commit is contained in:
parent
65cbf5b46a
commit
341c9d8ffa
|
@ -66,12 +66,11 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-6 columns">
|
<div class="large-6 columns">
|
||||||
<h3>Open a Existing Wallet</h3>
|
<h3>Open a Existing Wallet</h3>
|
||||||
<select class="form-control" >
|
<select class="form-control" ng-model="selectedWalletId" ng-options="walletId for walletId in listWalletIds()">
|
||||||
<option ng-repeat="walletId in listWalletIds()" ng-model="sel" value="walletId">{{walletId}}</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-3 columns">
|
<div class="large-3 columns">
|
||||||
<button class="button primary expand round" type="button" ng-click="open(sel || $scope.sel)">Open</button>
|
<button class="button primary expand round" type="button" ng-click="open(selectedWalletId)">Open</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
@ -5,7 +5,7 @@ var config = {
|
||||||
network: {
|
network: {
|
||||||
apiKey: 'lwjd5qra8257b9',
|
apiKey: 'lwjd5qra8257b9',
|
||||||
maxPeers: 3,
|
maxPeers: 3,
|
||||||
debug: 0,
|
debug: 3,
|
||||||
},
|
},
|
||||||
wallet: {
|
wallet: {
|
||||||
requiredCopayers: 2,
|
requiredCopayers: 2,
|
||||||
|
@ -15,7 +15,7 @@ var config = {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 3001
|
port: 3001
|
||||||
},
|
},
|
||||||
verbose: 0,
|
verbose: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
var log = function () {
|
var log = function () {
|
||||||
|
|
|
@ -7,6 +7,8 @@ angular.module('copay.signin').controller('SigninController',
|
||||||
// $rootScope.peerId = peerData ? peerData.peerId : null;
|
// $rootScope.peerId = peerData ? peerData.peerId : null;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
|
|
||||||
|
$scope.selectedWalletId = false;
|
||||||
|
|
||||||
$scope.listWalletIds = function() {
|
$scope.listWalletIds = function() {
|
||||||
return copay.Wallet.factory.getWalletIds();
|
return copay.Wallet.factory.getWalletIds();
|
||||||
};
|
};
|
||||||
|
@ -23,12 +25,20 @@ angular.module('copay.signin').controller('SigninController',
|
||||||
|
|
||||||
$scope.open = function(walletId) {
|
$scope.open = function(walletId) {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
if (Network.openWallet(walletId)) {
|
|
||||||
|
Network.openWallet(walletId);
|
||||||
|
|
||||||
|
if ($rootScope.wallet && $rootScope.wallet.id) {
|
||||||
Network.init(function() {
|
Network.init(function() {
|
||||||
$location.path('peer');
|
$location.path('peer');
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$scope.loading = false;
|
||||||
|
$rootScope.flashMessage = {type:'error', message: 'Wallet not found'};
|
||||||
|
$location.path('signin');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.join = function(cid) {
|
$scope.join = function(cid) {
|
||||||
|
|
|
@ -23,5 +23,5 @@ angular.module('copay.transactions').controller('TransactionsController',
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
$scope.txsoutput = $rootScope.wallet.txProposals.txps;
|
$scope.txsoutput = $rootScope.wallet.getTxProposals();
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,11 +63,19 @@ Wallet.prototype.create = function(opts) {
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype._checkLoad = function(walletId) {
|
Wallet.prototype._checkLoad = function(walletId) {
|
||||||
return (
|
var ret = this.storage.get(walletId, 'publicKeyRing') &&
|
||||||
this.storage.get(walletId, 'publicKeyRing') &&
|
|
||||||
this.storage.get(walletId, 'txProposals') &&
|
this.storage.get(walletId, 'txProposals') &&
|
||||||
this.storage.get(walletId, 'privateKey')
|
this.storage.get(walletId, 'privateKey')
|
||||||
);
|
;
|
||||||
|
|
||||||
|
console.log('[Wallet.js.71]',
|
||||||
|
this.storage.get(walletId, 'publicKeyRing'),
|
||||||
|
this.storage.get(walletId, 'txProposals'),
|
||||||
|
this.storage.get(walletId, 'privateKey'));
|
||||||
|
|
||||||
|
console.log('[Wallet.js.73:ret:]',walletId, ret); //TODO
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet.prototype.load = function(walletId) {
|
Wallet.prototype.load = function(walletId) {
|
||||||
|
@ -138,6 +146,29 @@ Wallet.prototype.generateAddress = function() {
|
||||||
return addr;
|
return addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Wallet.prototype.getTxProposals = function() {
|
||||||
|
var ret = [];
|
||||||
|
this.txProposals.txps.forEach(function(txp) {
|
||||||
|
var i = {txp:txp};
|
||||||
|
i.signedByUs = txp.signedBy[this.privateKey.id]?true:false;
|
||||||
|
ret.push(i);
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Wallet.prototype.addSeenToTxProposals = function() {
|
||||||
|
var ret=false;
|
||||||
|
this.txProposals.txps.forEach(function(txp) {
|
||||||
|
if (!txp.seenBy[this.privateKey.id]) {
|
||||||
|
txp.seenBy[this.privateKey.id] = Date.now();
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
// // HERE? not sure
|
// // HERE? not sure
|
||||||
// Wallet.prototype.cleanPeers = function() {
|
// Wallet.prototype.cleanPeers = function() {
|
||||||
// this.storage.remove('peerData');
|
// this.storage.remove('peerData');
|
||||||
|
|
|
@ -114,8 +114,10 @@ angular.module('copay.network')
|
||||||
var recipients;
|
var recipients;
|
||||||
var inTxProposals = copay.TxProposals.fromObj(data.txProposals);
|
var inTxProposals = copay.TxProposals.fromObj(data.txProposals);
|
||||||
var mergeInfo = w.txProposals.merge(inTxProposals, true);
|
var mergeInfo = w.txProposals.merge(inTxProposals, true);
|
||||||
if ( mergeInfo.merged && !data.isBroadcast) {
|
|
||||||
log('### BROADCASTING txProposals');
|
var addSeen = w.addSeenToTxProposals();
|
||||||
|
if ((mergeInfo.merged && !data.isBroadcast) || addSeen) {
|
||||||
|
log('### BROADCASTING txProposals. ' );
|
||||||
recipients = null;
|
recipients = null;
|
||||||
shouldSend = true;
|
shouldSend = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue