mirror of https://github.com/BTCPrivate/copay.git
fix conflicts
This commit is contained in:
commit
2c0b733025
|
@ -45,6 +45,7 @@ public/css/main.css
|
|||
|
||||
README.html
|
||||
|
||||
lib
|
||||
lib/*
|
||||
!lib/socket.io.js
|
||||
|
||||
js/copayBundle.js
|
||||
|
|
116
index.html
116
index.html
|
@ -17,8 +17,9 @@
|
|||
<img src="./img/logo-negative.svg" alt="" width="130">
|
||||
</figure>
|
||||
<div class="text-right" ng-show="$root.wallet">
|
||||
<h5>Company Funds</h5>
|
||||
<p>4.324 BTC</p>
|
||||
<h5 ng-show="$root.wallet.id">Wallet ID:{{$root.wallet.id}}</h5>
|
||||
<p ng-show="totalBalance">{{totalBalance}} BTC</p>
|
||||
<p ng-show="!totalBalance">0 BTC</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -47,9 +48,27 @@
|
|||
<div ng-if='$root.flashMessage.message' class="panel callout radius" style="color:red" >
|
||||
{{$root.flashMessage.type}}:
|
||||
{{$root.flashMessage.message}}
|
||||
<a href="#" ng-click="clearFlashMessage()" class="button tiny">Dismiss</a>
|
||||
<a ng-click="clearFlashMessage()" class="button tiny">Dismiss</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-if='$root.wallet && !$root.wallet.publicKeyRing.isComplete() && !loading' class="panel radius" >
|
||||
|
||||
<p class="panel panel-sign"> <i class="fi-alert size-40"></i>
|
||||
NOTE: Your wallet is not complete yet.
|
||||
<span ng-show="$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers()>1">
|
||||
{{$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers() }} keys are
|
||||
</span>
|
||||
<span ng-show="$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers()==1">
|
||||
One key is
|
||||
</span>
|
||||
|
||||
missing. Ask your copayers to join your session: <b>{{$root.wallet.network.peerId}}</b>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@ -63,17 +82,6 @@
|
|||
Connecting to wallet...
|
||||
</div>
|
||||
<div ng-show="!loading">
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<h3>Open a Existing Wallet</h3>
|
||||
<select class="form-control" ng-model="selectedWalletId" ng-options="walletId for walletId in listWalletIds()">
|
||||
</select>
|
||||
</div>
|
||||
<div class="large-3 columns">
|
||||
<button class="button primary expand round" type="button" ng-click="open(selectedWalletId)">Open</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<h3>Join a Network Wallet</h3>
|
||||
|
@ -83,15 +91,44 @@
|
|||
<button class="button primary expand round" type="button" ng-click="join(connectionId)">Join</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<h3>Create a New Wallet</h3>
|
||||
<div ng-show="!walletIds.length">
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<h3>Create a New Wallet</h3>
|
||||
</div>
|
||||
<div class="large-3 columns">
|
||||
<button class="button secondary expand round" ng-click="create()">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="large-3 columns">
|
||||
<button class="button secondary expand round" ng-click="create()">Create</button>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="text-center">
|
||||
<a ng-click="import()">Import from file</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-show="walletIds.length>0">
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<h3>Open a Existing Wallet</h3>
|
||||
<select class="form-control" ng-model="selectedWalletId" ng-options="walletId for walletId in walletIds">
|
||||
</select>
|
||||
</div>
|
||||
<div class="large-3 columns">
|
||||
<button class="button primary expand round" type="button" ng-click="open(selectedWalletId)">Open</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="text-center">
|
||||
<a ng-click="create()">Create a new wallet</a>
|
||||
· <a ng-click="import()">Import from file</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
@ -126,6 +163,11 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="text-center">
|
||||
<a href="#signin">Go back</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
@ -142,28 +184,23 @@
|
|||
<p class="panel panel-sign"> <i class="fi-page-copy size-22"></i> </p>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="no-bullet" style="font-size: 0.7rem;">
|
||||
<li> [DEBUG] Pubkeys that you have: {{$root.wallet.publicKeyRing.registeredCopayers()}}
|
||||
<li> [DEBUG] WalletId: {{$root.wallet.id}}
|
||||
<li class="panel" style="word-wrap: break-word;" ng-repeat="pub in $root.wallet.publicKeyRing.copayersBIP32">
|
||||
${{pub.extendedPublicKeyString()}}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="large-6 columns p70l">
|
||||
<h3 class="panel-title">Copayers ({{$root.wallet.network.connectedPeers.length}}/{{$root.wallet.publicKeyRing.requiredCopayers}})</h3>
|
||||
<h3 class="panel-title">Online Copayers: {{$root.wallet.network.connectedPeers.length}}</h3>
|
||||
|
||||
<p class="panel panel-sign" ng-show="$root.wallet.publicKeyRing.requiredCopayers > $root.wallet.network.connectedPeers.length"> <i class="fi-alert size-28"></i>
|
||||
{{$root.wallet.publicKeyRing.requiredCopayers}} copayers needed for signning transactions
|
||||
|
||||
|
||||
<ul class="no-bullet">
|
||||
<li class="panel" ng-repeat="copayer in $root.wallet.network.connectedPeers">
|
||||
<span ng-if="copayer == $root.peerId"> You ({{$root.peerId}})<i class="fi-check size-24"></i></span>
|
||||
<span ng-if="copayer != $root.peerId">{{copayer}}</span>
|
||||
<span ng-if="copayer == $root.wallet.network.peerId"> You ({{copayer}})<i class="fi-check size-24"></i></span>
|
||||
<span ng-if="copayer !== $root.wallet.network.peerId">{{copayer}}</span>
|
||||
<span>
|
||||
<i class="fi-check size-16 panel-sign right p5h br100"></i>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="text-center">
|
||||
<button href="#/home" class="button secondary round right">Go to home</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
@ -173,6 +210,7 @@
|
|||
<!-- HOME -->
|
||||
<script type="text/ng-template" id="home.html">
|
||||
<div class="home" data-ng-controller="HomeController">
|
||||
<div ng-show='$root.wallet.publicKeyRing.isComplete()'>
|
||||
<h3>Address</h3>
|
||||
|
||||
<div class="row">
|
||||
|
@ -181,7 +219,7 @@
|
|||
</div>
|
||||
<div class="large-3 columns line-dashed-v text-center">
|
||||
<qrcode size="160" data="{{selectedAddr}}"></qrcode>
|
||||
<p class="m10t"> <strong> 2.5432 BTC </strong> </p>
|
||||
<p class="m10t" ng-repeat="addr in addrs" ng-if="selectedAddr==addr"> <strong> {{addrBalance[addr]}} BTC </strong> </p>
|
||||
</div>
|
||||
<div class="large-1 columns"> </div>
|
||||
<div class="large-2 columns">
|
||||
|
@ -189,6 +227,7 @@
|
|||
<button class="secondary round expand" ng-click="newAddr()"> Create </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
@ -196,8 +235,7 @@
|
|||
<!-- TRANSACTIONS -->
|
||||
<script type="text/ng-template" id="transactions.html">
|
||||
<div class="transactions" data-ng-controller="TransactionsController">
|
||||
|
||||
<div class="row">
|
||||
<div class="row" ng-show='$root.wallet.publicKeyRing.isComplete()'>
|
||||
<div class="large-12 columns">
|
||||
<h3>Pending Transactions <small>({{txsoutput.length}})</small></h3>
|
||||
<div class="panel pending" ng-repeat="txp in txsoutput">
|
||||
|
@ -260,8 +298,7 @@
|
|||
<!-- SEND -->
|
||||
<script type="text/ng-template" id="send.html">
|
||||
<div class="send" data-ng-controller="SendController">
|
||||
<h3>{{title}}</h3>
|
||||
<div class="row">
|
||||
<div class="row" ng-show='$root.wallet.publicKeyRing.isComplete()'>
|
||||
<div class="large-8 columns">
|
||||
<form>
|
||||
<label for="address">To
|
||||
|
@ -308,6 +345,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- / <div class="large-4 columns box-backup">Backup to Dropbox</div>
|
||||
// <div class="large-4 columns box-backup">Backup to email</div> -->
|
||||
<!-- NOT FOUND -->
|
||||
|
@ -327,15 +365,17 @@
|
|||
<script src="lib/bitcore.js"></script>
|
||||
<script src="lib/crypto-js/rollups/aes.js"></script>
|
||||
<script src="lib/file-saver/FileSaver.js"></script>
|
||||
<script src="lib/socket.io.js"></script>
|
||||
<script src="js/copayBundle.js"></script>
|
||||
|
||||
|
||||
<script src="js/app.js"></script>
|
||||
<script src="js/config.js"></script>
|
||||
<script src="js/routes.js"></script>
|
||||
<script src="js/directives.js"></script>
|
||||
<script src="js/filters.js"></script>
|
||||
<script src="js/services/socket.js"></script>
|
||||
<script src="js/services/walletFactory.js"></script>
|
||||
<script src="js/services/controllerUtils.js"></script>
|
||||
|
||||
<script src="js/controllers/header.js"></script>
|
||||
<script src="js/controllers/home.js"></script>
|
||||
|
|
|
@ -11,6 +11,8 @@ angular.module('copay',[
|
|||
'copay.backup',
|
||||
'copay.walletFactory',
|
||||
'copay.signin',
|
||||
'copay.socket',
|
||||
'copay.controllerUtils',
|
||||
'copay.setup',
|
||||
'copay.peer'
|
||||
]);
|
||||
|
@ -21,7 +23,9 @@ angular.module('copay.transactions', []);
|
|||
angular.module('copay.send', []);
|
||||
angular.module('copay.backup', []);
|
||||
angular.module('copay.walletFactory', []);
|
||||
angular.module('copay.controllerUtils', []);
|
||||
angular.module('copay.signin', []);
|
||||
angular.module('copay.setup', []);
|
||||
angular.module('copay.peer', []);
|
||||
angular.module('copay.socket', []);
|
||||
|
||||
|
|
17
js/config.js
17
js/config.js
|
@ -3,7 +3,12 @@
|
|||
var config = {
|
||||
networkName: 'testnet',
|
||||
network: {
|
||||
apiKey: 'lwjd5qra8257b9',
|
||||
key: 'lwjd5qra8257b9',
|
||||
// This is for running local peerJs with params: ./peerjs -p 10009 -k 'sdfjhwefh'
|
||||
// key: 'sdfjhwefh',
|
||||
// host: 'localhost',
|
||||
// port: 10009,
|
||||
// path: '/',
|
||||
maxPeers: 3,
|
||||
debug: 3,
|
||||
},
|
||||
|
@ -18,10 +23,12 @@ var config = {
|
|||
verbose: 1,
|
||||
},
|
||||
blockchain: {
|
||||
host: 'test.insight.is',
|
||||
port: 80
|
||||
// host: 'localhost',
|
||||
// port: 3001
|
||||
host: 'localhost',
|
||||
port: 3001
|
||||
},
|
||||
socket: {
|
||||
host: 'localhost',
|
||||
port: 3001
|
||||
},
|
||||
verbose: 1,
|
||||
};
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.backup').controller('BackupController',
|
||||
function($scope, $rootScope, $location, $window, $timeout) {
|
||||
|
||||
if (!$rootScope.wallet.id) {
|
||||
function($scope, $rootScope, $location, $window, $timeout, Socket, controllerUtils) {
|
||||
if (!$rootScope.wallet || !$rootScope.wallet.id) {
|
||||
$location.path('signin');
|
||||
}
|
||||
else {
|
||||
var socket = Socket($scope);
|
||||
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
|
||||
}
|
||||
|
||||
$scope.title = 'Backup';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.header').controller('HeaderController',
|
||||
function($scope, $rootScope, $location, walletFactory) {
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
|
||||
$scope.menu = [{
|
||||
'title': 'Home',
|
||||
'icon': 'fi-home',
|
||||
|
@ -24,7 +24,7 @@ angular.module('copay.header').controller('HeaderController',
|
|||
'link': '#/backup'
|
||||
}];
|
||||
|
||||
if (!$rootScope.peerId) {
|
||||
if (!$rootScope.wallet || !$rootScope.wallet.id) {
|
||||
$location.path('signin');
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,12 @@ angular.module('copay.header').controller('HeaderController',
|
|||
var w = $rootScope.wallet;
|
||||
if (w) {
|
||||
w.disconnect();
|
||||
delete $rootScope['wallet'];
|
||||
$location.path('signin');
|
||||
controllerUtils.logout();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.clearFlashMessage = function() {
|
||||
$rootScope.flashMessage = {};
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.home').controller('HomeController',
|
||||
function($scope, $rootScope, $location) {
|
||||
function($scope, $rootScope, $location, Socket, controllerUtils) {
|
||||
$scope.title = 'Home';
|
||||
|
||||
$scope.oneAtATime = true;
|
||||
|
@ -9,8 +9,7 @@ angular.module('copay.home').controller('HomeController',
|
|||
|
||||
var _getBalance = function() {
|
||||
$scope.addrs.forEach(function(addr) {
|
||||
$rootScope.wallet.blockchain.listUnspent([addr], function(unspent) {
|
||||
var balance = $rootScope.wallet.blockchain.getBalance(unspent);
|
||||
$rootScope.wallet.getBalance([addr], function(balance) {
|
||||
$scope.addrBalance[addr] = balance;
|
||||
$scope.$digest();
|
||||
});
|
||||
|
@ -24,13 +23,17 @@ angular.module('copay.home').controller('HomeController',
|
|||
$scope.selectedAddr = $scope.addrs[0];
|
||||
|
||||
_getBalance();
|
||||
|
||||
var socket = Socket($scope);
|
||||
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
|
||||
}
|
||||
|
||||
$scope.newAddr = function() {
|
||||
var a = $rootScope.wallet.generateAddress().toString();
|
||||
$scope.addrs.push(a);
|
||||
|
||||
_getBalance();
|
||||
var socket = Socket($scope);
|
||||
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
|
||||
};
|
||||
|
||||
$scope.selectAddr = function(addr) {
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.peer').controller('PeerController',
|
||||
function($scope, $rootScope, $location, $routeParams) {
|
||||
function($scope, $rootScope, $location, $routeParams, Socket, controllerUtils) {
|
||||
|
||||
$scope.init = function() {
|
||||
//Network.connect($rootScope.masterId);
|
||||
};
|
||||
|
||||
if (!$rootScope.wallet || !$rootScope.wallet.id) {
|
||||
$location.path('signin');
|
||||
}
|
||||
else {
|
||||
var socket = Socket($scope);
|
||||
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.send').controller('SendController',
|
||||
function($scope, $rootScope, $location) {
|
||||
function($scope, $rootScope, $location, Socket, controllerUtils) {
|
||||
$scope.title = 'Send';
|
||||
|
||||
if (!$rootScope.wallet.id) {
|
||||
if (!$rootScope.wallet || !$rootScope.wallet.id) {
|
||||
$location.path('signin');
|
||||
}
|
||||
else {
|
||||
var socket = Socket($scope);
|
||||
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
|
||||
|
||||
}
|
||||
|
||||
$scope.sendTest = function() {
|
||||
var w = $rootScope.wallet;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.setup').controller('SetupController',
|
||||
function($scope, $rootScope, $location, walletFactory) {
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
|
||||
|
||||
$scope.loading = false;
|
||||
|
||||
|
@ -32,16 +32,7 @@ angular.module('copay.setup').controller('SetupController',
|
|||
totalCopayers: totalCopayers
|
||||
};
|
||||
var w = walletFactory.create(opts);
|
||||
w.on('created', function(){
|
||||
$location.path('peer');
|
||||
$rootScope.wallet = w;
|
||||
$rootScope.$digest();
|
||||
});
|
||||
w.on('openError', function(){
|
||||
$scope.loading = false;
|
||||
$rootScope.flashMessage = {type:'error', message: 'Wallet not found'};
|
||||
$location.path('signin');
|
||||
});
|
||||
controllerUtils.setupUxHandlers(w);
|
||||
w.netStart();
|
||||
};
|
||||
|
||||
|
|
|
@ -1,36 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
|
||||
angular.module('copay.signin').controller('SigninController',
|
||||
function($scope, $rootScope, $location, walletFactory) {
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
|
||||
|
||||
// var peerData = Storage.get($rootScope.walletId, 'peerData');
|
||||
// $rootScope.peerId = peerData ? peerData.peerId : null;
|
||||
$scope.loading = false;
|
||||
|
||||
$scope.selectedWalletId = false;
|
||||
$scope.walletIds = walletFactory.getWalletIds();
|
||||
|
||||
$scope.listWalletIds = function() {
|
||||
return walletFactory.getWalletIds();
|
||||
};
|
||||
|
||||
var _setupUxHandlers = function(w) {
|
||||
w.on('created', function() {
|
||||
$location.path('peer');
|
||||
$rootScope.wallet = w;
|
||||
$rootScope.$digest();
|
||||
});
|
||||
w.on('refresh', function() {
|
||||
|
||||
console.log('[signin.js.23] RECEIVED REFRESH'); //TODO
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
w.on('openError', function(){
|
||||
$scope.loading = false;
|
||||
$rootScope.flashMessage = {type:'error', message: 'Wallet not found'};
|
||||
$location.path('signin');
|
||||
});
|
||||
};
|
||||
$scope.selectedWalletId = $scope.walletIds.length ? $scope.walletIds[0]:null;
|
||||
|
||||
$scope.create = function() {
|
||||
$location.path('setup');
|
||||
|
@ -40,16 +21,18 @@ console.log('[signin.js.23] RECEIVED REFRESH'); //TODO
|
|||
$scope.loading = true;
|
||||
|
||||
var w = walletFactory.open(walletId);
|
||||
_setupUxHandlers(w);
|
||||
controllerUtils.setupUxHandlers(w);
|
||||
w.netStart();
|
||||
};
|
||||
|
||||
$scope.join = function(cid) {
|
||||
console.log('[signin.js.42:join:]'); //TODO
|
||||
$scope.loading = true;
|
||||
walletFactory.network.on('openError', function() {
|
||||
controllerUtils.onError($scope);
|
||||
$rootScope.$digest();
|
||||
});
|
||||
walletFactory.connectTo(cid, function(w) {
|
||||
console.log('[signin.js.50]'); //TODO
|
||||
_setupUxHandlers(w);
|
||||
controllerUtils.setupUxHandlers(w);
|
||||
w.netStart();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,29 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.transactions').controller('TransactionsController',
|
||||
function($scope, $rootScope, $location) {
|
||||
function($scope, $rootScope, $location, Socket, controllerUtils) {
|
||||
$scope.title = 'Transactions';
|
||||
|
||||
$scope.oneAtATime = true;
|
||||
|
||||
if (!$rootScope.wallet.id) {
|
||||
if (!$rootScope.wallet || !$rootScope.wallet.id) {
|
||||
$location.path('signin');
|
||||
}
|
||||
else {
|
||||
$scope.txsinput = [
|
||||
{
|
||||
fromAddr: "n3zUqNR7Bbbc4zJhPVj1vG2Lx66K3Xhzvb",
|
||||
toAddr: "msvv2mDfE298s7boXwALq4Dqv77K3TWRZ1",
|
||||
amount: 23.9982
|
||||
},
|
||||
{
|
||||
fromAddr: "my9wnLwwUrwpNfEgSrWY62ymEGf1edKf4J",
|
||||
toAddr: "monCusNiDuptf68rtr58hEjKpJt6cW6zwS",
|
||||
amount: 2.22
|
||||
}
|
||||
];
|
||||
|
||||
$scope.txsinput = [
|
||||
{
|
||||
fromAddr: "n3zUqNR7Bbbc4zJhPVj1vG2Lx66K3Xhzvb",
|
||||
toAddr: "msvv2mDfE298s7boXwALq4Dqv77K3TWRZ1",
|
||||
amount: 23.9982
|
||||
},
|
||||
{
|
||||
fromAddr: "my9wnLwwUrwpNfEgSrWY62ymEGf1edKf4J",
|
||||
toAddr: "monCusNiDuptf68rtr58hEjKpJt6cW6zwS",
|
||||
amount: 2.22
|
||||
$scope.txsoutput = $rootScope.wallet.getTxProposals();
|
||||
|
||||
var socket = Socket($scope);
|
||||
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
|
||||
}
|
||||
];
|
||||
|
||||
$scope.txsoutput = $rootScope.wallet.getTxProposals();
|
||||
|
||||
$scope.sign = function (ntxid) {
|
||||
var w = $rootScope.wallet;
|
||||
|
|
|
@ -29,15 +29,6 @@ function _asyncForEach(array, fn, callback) {
|
|||
}
|
||||
};
|
||||
|
||||
Insight.prototype.getBalance = function(unspent) {
|
||||
var balance = 0;
|
||||
for(var i=0;i<unspent.length; i++) {
|
||||
balance = balance + unspent[i].amount;
|
||||
}
|
||||
|
||||
return balance;
|
||||
};
|
||||
|
||||
Insight.prototype.listUnspent = function(addresses, cb) {
|
||||
var self = this;
|
||||
|
||||
|
|
|
@ -166,10 +166,7 @@ PublicKeyRing.prototype.getAddress = function (index, isChange) {
|
|||
this._checkIndexRange(index, isChange);
|
||||
|
||||
var script = this.getRedeemScript(index,isChange);
|
||||
var hash = coinUtil.sha256ripe160(script.getBuffer());
|
||||
var version = this.network.P2SHVersion;
|
||||
var addr = new Address(version, hash);
|
||||
return addr;
|
||||
return Address.fromScript(script, this.network.name);
|
||||
};
|
||||
|
||||
PublicKeyRing.prototype.getScriptPubKeyHex = function (index, isChange) {
|
||||
|
@ -185,10 +182,11 @@ PublicKeyRing.prototype.generateAddress = function(isChange) {
|
|||
|
||||
var ret =
|
||||
this.getAddress(isChange ? this.changeAddressIndex : this.addressIndex, isChange);
|
||||
if (isChange)
|
||||
if (isChange) {
|
||||
this.changeAddressIndex++;
|
||||
else
|
||||
} else {
|
||||
this.addressIndex++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -96,11 +96,12 @@ Wallet.prototype._handleTxProposals = function(senderId, data, isInbound) {
|
|||
|
||||
Wallet.prototype._handleData = function(senderId, data, isInbound) {
|
||||
|
||||
if (this.id !== data.walletId)
|
||||
throw new Error('wrong message received: Bad wallet ID');
|
||||
|
||||
if (this.id !== data.walletId) {
|
||||
this.emit('badMessage',senderId);
|
||||
this.log('badMessage FROM:', senderId); //TODO
|
||||
return;
|
||||
}
|
||||
this.log('[Wallet.js.98]' , data.type); //TODO
|
||||
|
||||
switch(data.type) {
|
||||
case 'publicKeyRing':
|
||||
this._handlePublicKeyRing(senderId, data, isInbound);
|
||||
|
@ -108,18 +109,17 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
|
|||
case 'txProposals':
|
||||
this._handleTxProposals(senderId, data, isInbound);
|
||||
break;
|
||||
case 'abort':
|
||||
this.emit('abort');
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
Wallet.prototype._handleNetworkChange = function(newPeer) {
|
||||
if (!newPeer) return;
|
||||
this.log('#### Setting new PEER:', newPeer);
|
||||
this.sendWalletId(newPeer);
|
||||
this.sendPublicKeyRing(newPeer);
|
||||
this.sendTxProposals(newPeer);
|
||||
if (newPeer) {
|
||||
this.log('#### Setting new PEER:', newPeer);
|
||||
this.sendWalletId(newPeer);
|
||||
this.sendPublicKeyRing(newPeer);
|
||||
this.sendTxProposals(newPeer);
|
||||
}
|
||||
this.emit('refresh');
|
||||
};
|
||||
|
||||
Wallet.prototype._optsToObj = function () {
|
||||
|
@ -136,10 +136,17 @@ Wallet.prototype._optsToObj = function () {
|
|||
Wallet.prototype.netStart = function() {
|
||||
var self = this;
|
||||
var net = this.network;
|
||||
net.removeAllListeners();
|
||||
net.on('networkChange', self._handleNetworkChange.bind(self) );
|
||||
net.on('data', self._handleData.bind(self) );
|
||||
net.on('open', function() {}); // TODO
|
||||
net.on('close', function() {}); // TODO
|
||||
net.on('openError', function() {
|
||||
this.log('[Wallet.js.132:openError:] GOT openError'); //TODO
|
||||
self.emit('openError');
|
||||
});
|
||||
net.on('close', function() {
|
||||
self.emit('close');
|
||||
});
|
||||
net.start(function(peerId) {
|
||||
self.emit('created');
|
||||
});
|
||||
|
@ -211,6 +218,7 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
|||
this.emit('publicKeyRingUpdated', this.publicKeyRing);
|
||||
};
|
||||
|
||||
|
||||
Wallet.prototype.generateAddress = function() {
|
||||
var addr = this.publicKeyRing.generateAddress();
|
||||
this.store();
|
||||
|
@ -303,10 +311,34 @@ Wallet.prototype.getAddressesStr = function() {
|
|||
return ret;
|
||||
};
|
||||
|
||||
Wallet.prototype.getTotalBalance = function(cb) {
|
||||
this.getBalance(this.getAddressesStr(), function(balance) {
|
||||
return cb(balance);
|
||||
});
|
||||
};
|
||||
|
||||
Wallet.prototype.getBalance = function(addrs, cb) {
|
||||
var balance = 0;
|
||||
this.listUnspent(addrs, function(utxos) {
|
||||
for(var i=0;i<utxos.length; i++) {
|
||||
balance = balance + utxos[i].amount;
|
||||
}
|
||||
if (balance) {
|
||||
if (balance === parseInt(balance)) {
|
||||
balance = balance;
|
||||
}
|
||||
else {
|
||||
balance = balance.toFixed(8);
|
||||
}
|
||||
}
|
||||
return cb(balance);
|
||||
});
|
||||
};
|
||||
|
||||
Wallet.prototype.listUnspent = function(cb) {
|
||||
this.blockchain.listUnspent(this.getAddressesStr(), cb);
|
||||
Wallet.prototype.listUnspent = function(addrs, cb) {
|
||||
this.blockchain.listUnspent(addrs, function(utxos) {
|
||||
return cb(utxos);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
@ -326,7 +358,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
|
|||
opts.remainderOut={ address: this.publicKeyRing.generateAddress(true).toString()};
|
||||
}
|
||||
|
||||
self.listUnspent(function(utxos) {
|
||||
self.listUnspent(self.getAddressesStr(), function(utxos) {
|
||||
// TODO check enough funds, etc.
|
||||
self.createTxSync(toAddress, amountSatStr, utxos, opts);
|
||||
self.store();
|
||||
|
|
|
@ -148,12 +148,14 @@ WalletFactory.prototype.openRemote = function(peedId) {
|
|||
opts.storage = this.storage;
|
||||
opts.network = this.network;
|
||||
opts.blockchain = this.blockchain;
|
||||
opts.spendUnconfirmed = opts.spendUnconfirmed || this.walletDefaults.spendUnconfirmed;
|
||||
|
||||
opts.spendUnconfirmed = typeof opts.spendUnconfirmed === undefined
|
||||
?this.walletDefaults.spendUnconfirmed : opts.spendUnconfirmed;
|
||||
|
||||
opts.requiredCopayers = requiredCopayers;
|
||||
opts.totalCopayers = totalCopayers;
|
||||
var w = new Wallet(opts);
|
||||
w.store();
|
||||
this.addWalletId(w.id);
|
||||
return w;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,11 +16,18 @@ var EventEmitter= imports.EventEmitter || require('events').EventEmitter;
|
|||
*/
|
||||
|
||||
function Network(opts) {
|
||||
var self = this;
|
||||
opts = opts || {};
|
||||
this.peerId = opts.peerId;
|
||||
this.apiKey = opts.apiKey || 'lwjd5qra8257b9';
|
||||
this.debug = opts.debug || 3;
|
||||
this.maxPeers = opts.maxPeers || 5;
|
||||
this.opts = { key: opts.key };
|
||||
|
||||
// For using your own peerJs server
|
||||
['port', 'host', 'path', 'debug'].forEach(function(k) {
|
||||
if (opts[k]) self.opts[k]=opts[k];
|
||||
});
|
||||
this.connectedPeers = [];
|
||||
}
|
||||
|
||||
|
@ -61,14 +68,9 @@ Network._arrayRemove = function(el, array) {
|
|||
return array;
|
||||
};
|
||||
|
||||
// DEBUG
|
||||
Network.prototype._showConnectedPeers = function() {
|
||||
// console.log("### CONNECTED PEERS", this.connectedPeers);
|
||||
};
|
||||
|
||||
Network.prototype._onClose = function(peerId) {
|
||||
this.connectedPeers = Network._arrayRemove(peerId, this.connectedPeers);
|
||||
this._notify();
|
||||
this._notifyNetworkChange();
|
||||
};
|
||||
|
||||
Network.prototype._connectToPeers = function(peerIds) {
|
||||
|
@ -97,7 +99,7 @@ Network.prototype._onData = function(data, isInbound) {
|
|||
switch(obj.data.type) {
|
||||
case 'peerList':
|
||||
this._connectToPeers(obj.data.peers);
|
||||
this._notify();
|
||||
this._notifyNetworkChange();
|
||||
break;
|
||||
case 'disconnect':
|
||||
this._onClose(obj.sender);
|
||||
|
@ -133,6 +135,13 @@ Network.prototype._addPeer = function(peerId, isInbound) {
|
|||
}
|
||||
};
|
||||
|
||||
Network.prototype._checkAnyPeer = function() {
|
||||
if (!this.connectedPeers.length) {
|
||||
console.log('EMIT openError: no more peers, not even you!');
|
||||
this.emit('openError');
|
||||
}
|
||||
}
|
||||
|
||||
Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) {
|
||||
|
||||
var self=this;
|
||||
|
@ -144,7 +153,7 @@ Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) {
|
|||
dataConn.peer, isInbound);
|
||||
|
||||
self._addPeer(dataConn.peer, isInbound);
|
||||
self._notify( isInbound ? dataConn.peer : null);
|
||||
self._notifyNetworkChange( isInbound ? dataConn.peer : null);
|
||||
this.emit('open');
|
||||
}
|
||||
});
|
||||
|
@ -155,19 +164,19 @@ Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) {
|
|||
|
||||
dataConn.on('error', function(e) {
|
||||
console.log('### DATA ERROR',e ); //TODO
|
||||
self.emit('dataError');
|
||||
});
|
||||
|
||||
dataConn.on('close', function() {
|
||||
if (self.closing) return;
|
||||
self.closing=1;
|
||||
console.log('### CLOSE RECV FROM:', dataConn.peer);
|
||||
self._onClose(dataConn.peer);
|
||||
this.emit('close');
|
||||
self._checkAnyPeer();
|
||||
});
|
||||
};
|
||||
|
||||
Network.prototype._notify = function(newPeer) {
|
||||
this._showConnectedPeers();
|
||||
Network.prototype._notifyNetworkChange = function(newPeer) {
|
||||
console.log('[WebRTC.js.164:_notifyNetworkChange:]', newPeer); //TODO
|
||||
this.emit('networkChange', newPeer);
|
||||
};
|
||||
|
||||
|
@ -178,7 +187,7 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
|
|||
p.on('open', function(peerId) {
|
||||
self.peerId = peerId;
|
||||
self.connectedPeers = [peerId];
|
||||
self._notify();
|
||||
self._notifyNetworkChange();
|
||||
return openCallback(peerId);
|
||||
});
|
||||
|
||||
|
@ -187,7 +196,7 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
|
|||
self.peer.disconnect();
|
||||
self.peer.destroy();
|
||||
self.peer = null;
|
||||
this.emit('abort');
|
||||
self._checkAnyPeer();
|
||||
});
|
||||
|
||||
p.on('connection', function(dataConn) {
|
||||
|
@ -210,11 +219,7 @@ Network.prototype.start = function(openCallback) {
|
|||
// Start PeerJS Peer
|
||||
if (this.peer) return openCallback(); // This is for connectTo-> peer is started before
|
||||
|
||||
this.peer = new Peer(this.peerId, {
|
||||
key: this.apiKey, // TODO: we need our own PeerServer KEY (http://peerjs.com/peerserver)
|
||||
debug: this.debug,
|
||||
});
|
||||
|
||||
this.peer = new Peer(this.peerId, this.opts);
|
||||
this._setupPeerHandlers(openCallback);
|
||||
};
|
||||
|
||||
|
@ -239,6 +244,7 @@ Network.prototype._sendToOne = function(peerId, data, cb) {
|
|||
|
||||
Network.prototype.send = function(peerIds, data, cb) {
|
||||
var self=this;
|
||||
console.log('[WebRTC.js.242] SENDING ', data.type); //TODO
|
||||
if (!peerIds) {
|
||||
peerIds = this.connectedPeers;
|
||||
data.isBroadcast = 1;
|
||||
|
@ -248,6 +254,7 @@ Network.prototype.send = function(peerIds, data, cb) {
|
|||
var l = peerIds.length;
|
||||
var i = 0;
|
||||
peerIds.forEach(function(peerId) {
|
||||
console.log('[WebRTC.js.258:peerId:]',peerId); //TODO
|
||||
self._sendToOne(peerId, data, function () {
|
||||
if (++i === l && typeof cb === 'function') cb();
|
||||
});
|
||||
|
@ -263,7 +270,6 @@ Network.prototype.connectTo = function(peerId) {
|
|||
console.log('### STARTING TO CONNECT TO:' + peerId );
|
||||
|
||||
var dataConn = this.peer.connect(peerId, {
|
||||
// label: 'wallet',
|
||||
serialization: 'none',
|
||||
reliable: true,
|
||||
metadata: { message: 'hi copayer!' }
|
||||
|
@ -276,7 +282,6 @@ Network.prototype.connectTo = function(peerId) {
|
|||
Network.prototype.disconnect = function(cb) {
|
||||
var self = this;
|
||||
self.closing = 1;
|
||||
|
||||
this.send(null, { type: 'disconnect' }, function() {
|
||||
self.connectedPeers = [];
|
||||
self.peerId = null;
|
||||
|
|
|
@ -54,13 +54,17 @@ Storage.prototype.remove = function(walletId, k) {
|
|||
|
||||
Storage.prototype.getWalletIds = function() {
|
||||
var walletIds = [];
|
||||
var uniq = {};
|
||||
|
||||
for (var i = 0; i < localStorage.length; i++) {
|
||||
var key = localStorage.key(i);
|
||||
var split = key.split('::');
|
||||
if (split.length == 2) {
|
||||
var walletId = split[0];
|
||||
walletIds.push(walletId);
|
||||
if (typeof uniq[walletId] === 'undefined' ) {
|
||||
walletIds.push(walletId);
|
||||
uniq[walletId] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.controllerUtils').factory('controllerUtils', function ($rootScope, $location, Socket) {
|
||||
var root = {};
|
||||
|
||||
root.logout = function(scope) {
|
||||
delete $rootScope['wallet'];
|
||||
$rootScope.totalBalance = 0;
|
||||
$location.path('signin');
|
||||
};
|
||||
|
||||
root.onError = function(scope) {
|
||||
if (scope) scope.loading = false;
|
||||
$rootScope.flashMessage = {type:'error', message: 'Could not connect to peer'};
|
||||
root.logout();
|
||||
}
|
||||
|
||||
|
||||
root.onErrorDigest = function(scope) {
|
||||
root.onError(scope);
|
||||
$rootScope.$digest();
|
||||
}
|
||||
|
||||
|
||||
root.setupUxHandlers = function(w) {
|
||||
|
||||
w.on('badMessage', function(peerId) {
|
||||
$rootScope.flashMessage = {type:'error', message: 'Received wrong message from peer id:' + peerId};
|
||||
});
|
||||
|
||||
w.on('created', function() {
|
||||
$location.path('peer');
|
||||
$rootScope.wallet = w;
|
||||
|
||||
// Initial getBalance
|
||||
$rootScope.wallet.getTotalBalance(function(balance) {
|
||||
$rootScope.totalBalance = balance;
|
||||
$rootScope.$digest();
|
||||
});
|
||||
});
|
||||
w.on('refresh', function() {
|
||||
console.log('[controllerUtils.js] Refreshing'); //TODO
|
||||
$rootScope.$digest();
|
||||
});
|
||||
w.on('openError', root.onErrorDigest);
|
||||
w.on('close', root.onErrorDigest);
|
||||
};
|
||||
|
||||
root.handleTransactionByAddress = function(scope) {
|
||||
var socket = Socket(scope);
|
||||
var addrs = $rootScope.wallet.getAddressesStr();
|
||||
socket.emit('subscribe', 'inv');
|
||||
for(var i=0;i<addrs.length;i++) {
|
||||
socket.emit('subscribe', addrs[i]);
|
||||
}
|
||||
addrs.forEach(function(addr) {
|
||||
socket.on(addr, function(txid) {
|
||||
console.log('Received!', txid);
|
||||
$rootScope.wallet.getTotalBalance(function(balance) {
|
||||
scope.$apply(function() {
|
||||
$rootScope.totalBalance = balance;
|
||||
});
|
||||
console.log('New balance:', balance);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
'use strict';
|
||||
|
||||
var ScopedSocket = function(socket, $rootScope) {
|
||||
this.socket = socket;
|
||||
this.$rootScope = $rootScope;
|
||||
this.listeners = [];
|
||||
};
|
||||
|
||||
ScopedSocket.prototype.removeAllListeners = function(opts) {
|
||||
if (!opts) opts = {};
|
||||
for (var i = 0; i < this.listeners.length; i++) {
|
||||
var details = this.listeners[i];
|
||||
if (opts.skipConnect && details.event === 'connect') {
|
||||
continue;
|
||||
}
|
||||
this.socket.removeListener(details.event, details.fn);
|
||||
}
|
||||
this.listeners = [];
|
||||
};
|
||||
|
||||
ScopedSocket.prototype.on = function(event, callback) {
|
||||
var socket = this.socket;
|
||||
var $rootScope = this.$rootScope;
|
||||
|
||||
var wrapped_callback = function() {
|
||||
var args = arguments;
|
||||
$rootScope.$apply(function() {
|
||||
callback.apply(socket, args);
|
||||
});
|
||||
};
|
||||
socket.on(event, wrapped_callback);
|
||||
|
||||
this.listeners.push({
|
||||
event: event,
|
||||
fn: wrapped_callback
|
||||
});
|
||||
};
|
||||
|
||||
ScopedSocket.prototype.emit = function(event, data, callback) {
|
||||
var socket = this.socket;
|
||||
var $rootScope = this.$rootScope;
|
||||
|
||||
socket.emit(event, data, function() {
|
||||
var args = arguments;
|
||||
$rootScope.$apply(function() {
|
||||
if (callback) {
|
||||
callback.apply(socket, args);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
angular.module('copay.socket').factory('Socket',
|
||||
function($rootScope) {
|
||||
var server = 'http://' + config.socket.host + ':' + config.socket.port;
|
||||
var socket = io.connect(server, {
|
||||
'reconnect': true,
|
||||
'reconnection delay': 500,
|
||||
});
|
||||
return function(scope) {
|
||||
var scopedSocket = new ScopedSocket(socket, $rootScope);
|
||||
scope.$on('$destroy', function() {
|
||||
scopedSocket.removeAllListeners();
|
||||
});
|
||||
socket.on('connect', function() {
|
||||
scopedSocket.removeAllListeners({
|
||||
skipConnect: true
|
||||
});
|
||||
});
|
||||
return scopedSocket;
|
||||
};
|
||||
});
|
File diff suppressed because it is too large
Load Diff
|
@ -56,7 +56,7 @@ describe('PublicKeyRing model', function() {
|
|||
w2.registeredCopayers().should.equal(0);
|
||||
w2.isComplete().should.equal(false);
|
||||
|
||||
w2.getAddress.bind(false).should.throw();
|
||||
(function() {w2.getAddress(0, false);}).should.throw();
|
||||
});
|
||||
|
||||
it('should add and check when adding shared pub keys', function () {
|
||||
|
@ -65,19 +65,25 @@ describe('PublicKeyRing model', function() {
|
|||
var copayers = k.copayers;
|
||||
|
||||
w.isComplete().should.equal(true);
|
||||
w.addCopayer.bind().should.throw();
|
||||
for(var i =0; i<5; i++)
|
||||
w.addCopayer.bind(copayers[i]).should.throw();
|
||||
w.addCopayer.should.throw();
|
||||
for(var i =0; i<5; i++) {
|
||||
(function() {w.addCopayer(copayers[i])}).should.throw();
|
||||
}
|
||||
});
|
||||
|
||||
it('show be able to tostore and read', function () {
|
||||
var k = createW();
|
||||
var w = k.w;
|
||||
var copayers = k.copayers;
|
||||
for(var i=0; i<3; i++)
|
||||
var changeN = 2;
|
||||
var addressN = 2;
|
||||
var start = new Date().getTime();
|
||||
for(var i=0; i<changeN; i++) {
|
||||
w.generateAddress(true);
|
||||
for(var i=0; i<5; i++)
|
||||
}
|
||||
for(var i=0; i<addressN; i++) {
|
||||
w.generateAddress(false);
|
||||
}
|
||||
|
||||
var data = w.toObj();
|
||||
should.exist(data);
|
||||
|
@ -85,12 +91,13 @@ describe('PublicKeyRing model', function() {
|
|||
var w2 = PublicKeyRing.fromObj(data);
|
||||
w2.walletId.should.equal(w.walletId);
|
||||
w2.isComplete().should.equal(true);
|
||||
w2.addCopayer.bind().should.throw();
|
||||
for(var i =0; i<5; i++)
|
||||
w2.addCopayer.bind(copayers[i]).should.throw();
|
||||
w2.addCopayer.should.throw();
|
||||
for(var i =0; i<5; i++) {
|
||||
(function() {w.addCopayer(copayers[i])}).should.throw();
|
||||
}
|
||||
|
||||
w2.changeAddressIndex.should.equal(3);
|
||||
w2.addressIndex.should.equal(5);
|
||||
w2.changeAddressIndex.should.equal(changeN);
|
||||
w2.addressIndex.should.equal(addressN);
|
||||
});
|
||||
|
||||
|
||||
|
@ -99,7 +106,7 @@ describe('PublicKeyRing model', function() {
|
|||
var w = k.w;
|
||||
|
||||
for(var isChange=0; isChange<2; isChange++) {
|
||||
for(var i=0; i<5; i++) {
|
||||
for(var i=0; i<2; i++) {
|
||||
var a = w.generateAddress(isChange);
|
||||
a.isValid().should.equal(true);
|
||||
a.isScript().should.equal(true);
|
||||
|
@ -121,11 +128,11 @@ describe('PublicKeyRing model', function() {
|
|||
a.length.should.equal(0);
|
||||
|
||||
for(var isChange=0; isChange<2; isChange++)
|
||||
for(var i=0; i<6; i++)
|
||||
for(var i=0; i<2; i++)
|
||||
w.generateAddress(isChange);
|
||||
|
||||
var as = w.getAddresses();
|
||||
as.length.should.equal(12);
|
||||
as.length.should.equal(4);
|
||||
for(var j in as) {
|
||||
var a = as[j];
|
||||
a.isValid().should.equal(true);
|
||||
|
@ -138,11 +145,11 @@ describe('PublicKeyRing model', function() {
|
|||
|
||||
for(var i=0; i<3; i++)
|
||||
w.generateAddress(true);
|
||||
for(var i=0; i<5; i++)
|
||||
for(var i=0; i<2; i++)
|
||||
w.generateAddress(false);
|
||||
|
||||
w.changeAddressIndex.should.equal(3);
|
||||
w.addressIndex.should.equal(5);
|
||||
w.addressIndex.should.equal(2);
|
||||
});
|
||||
|
||||
it('#merge index tests', function () {
|
||||
|
@ -279,11 +286,11 @@ describe('PublicKeyRing model', function() {
|
|||
|
||||
for(var i=0; i<2; i++)
|
||||
w.generateAddress(true);
|
||||
for(var i=0; i<3; i++)
|
||||
for(var i=0; i<2; i++)
|
||||
w.generateAddress(false);
|
||||
|
||||
var m = w.getRedeemScriptMap();
|
||||
Object.keys(m).length.should.equal(5);
|
||||
Object.keys(m).length.should.equal(4);
|
||||
Object.keys(m).forEach(function (k) {
|
||||
should.exist(m[k]);
|
||||
});
|
||||
|
|
|
@ -109,6 +109,7 @@ describe('TxProposals model', function() {
|
|||
var w = new TxProposals({
|
||||
networkName: config.networkName,
|
||||
});
|
||||
var start = new Date().getTime();
|
||||
var pkr=createPKR([priv.getBIP32()]);
|
||||
var ts = Date.now();
|
||||
var isChange=0;
|
||||
|
|
|
@ -61,12 +61,6 @@ describe('Insight model', function() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should return balance', function () {
|
||||
var w = new Insight();
|
||||
var b = w.getBalance(unspent);
|
||||
should.exist(b);
|
||||
b.should.equal(91);
|
||||
});
|
||||
it.skip('should return txid', function (done) {
|
||||
var w = new Insight();
|
||||
w.sendRawTransaction(rawtx, function(a) {
|
||||
|
|
Loading…
Reference in New Issue