Merge branch 'master' of github.com:bitpay/mystery into feature/stream-new-txs
Conflicts: public/css/common.css public/js/app.js
This commit is contained in:
commit
851dc06a09
|
@ -24,24 +24,38 @@ function spec() {
|
||||||
this.addrStr = addrStr;
|
this.addrStr = addrStr;
|
||||||
} catch(e){
|
} catch(e){
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Address.prototype.__defineGetter__('balance', function(){
|
Object.defineProperty(this, "totalSent", {
|
||||||
return parseFloat(this.balanceSat) / parseFloat(BitcoreUtil.COIN);
|
get: function() {
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Address.prototype.__defineGetter__('totalReceived', function(){
|
|
||||||
return parseFloat(this.totalReceivedSat) / parseFloat(BitcoreUtil.COIN);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Address.prototype.__defineGetter__('totalSent', function(){
|
|
||||||
return parseFloat(this.totalSentSat) / parseFloat(BitcoreUtil.COIN);
|
return parseFloat(this.totalSentSat) / parseFloat(BitcoreUtil.COIN);
|
||||||
|
},
|
||||||
|
set: function(i) {
|
||||||
|
totalSentSat = i * BitcoreUtil.COIN;
|
||||||
|
},
|
||||||
|
enumerable: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(this, "balance", {
|
||||||
|
get: function() {
|
||||||
|
return parseFloat(this.balanceSat) / parseFloat(BitcoreUtil.COIN);
|
||||||
|
},
|
||||||
|
set: function(i) {
|
||||||
|
balance = i * BitcoreUtil.COIN;
|
||||||
|
},
|
||||||
|
enumerable: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(this, "totalReceived", {
|
||||||
|
get: function() {
|
||||||
|
return parseFloat(this.totalReceivedSat) / parseFloat(BitcoreUtil.COIN);
|
||||||
|
},
|
||||||
|
set: function(i) {
|
||||||
|
totalReceived = i * BitcoreUtil.COIN;
|
||||||
|
},
|
||||||
|
enumerable: 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Address.prototype.update = function(next) {
|
Address.prototype.update = function(next) {
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
*/
|
*/
|
||||||
var mongoose = require('mongoose'),
|
var mongoose = require('mongoose'),
|
||||||
Schema = mongoose.Schema,
|
Schema = mongoose.Schema,
|
||||||
|
bignum = require('bignum'),
|
||||||
RpcClient = require('bitcore/RpcClient').class(),
|
RpcClient = require('bitcore/RpcClient').class(),
|
||||||
|
util = require('bitcore/util/util'),
|
||||||
|
BitcoreBlock= require('bitcore/Block').class(),
|
||||||
config = require('../../config/config')
|
config = require('../../config/config')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -26,7 +29,6 @@ var BlockSchema = new Schema({
|
||||||
fromP2P: Boolean,
|
fromP2P: Boolean,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validations
|
* Validations
|
||||||
*/
|
*/
|
||||||
|
@ -82,6 +84,8 @@ BlockSchema.methods.getInfo = function (next) {
|
||||||
|
|
||||||
that.info = blockInfo.result;
|
that.info = blockInfo.result;
|
||||||
|
|
||||||
|
that.info.reward = BitcoreBlock.getBlockValue(that.info.height) / util.COIN ;
|
||||||
|
|
||||||
//console.log("THAT", that);
|
//console.log("THAT", that);
|
||||||
return next(null, that.info);
|
return next(null, that.info);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,6 +10,7 @@ var mongoose = require('mongoose'),
|
||||||
RpcClient = require('bitcore/RpcClient').class(),
|
RpcClient = require('bitcore/RpcClient').class(),
|
||||||
Transaction = require('bitcore/Transaction').class(),
|
Transaction = require('bitcore/Transaction').class(),
|
||||||
Address = require('bitcore/Address').class(),
|
Address = require('bitcore/Address').class(),
|
||||||
|
BitcoreBlock= require('bitcore/Block').class(),
|
||||||
networks = require('bitcore/networks'),
|
networks = require('bitcore/networks'),
|
||||||
util = require('bitcore/util/util'),
|
util = require('bitcore/util/util'),
|
||||||
bignum = require('bignum'),
|
bignum = require('bignum'),
|
||||||
|
@ -296,9 +297,17 @@ TransactionSchema.methods.queryInfo = function (next) {
|
||||||
that.info.valueIn = valueIn / util.COIN;
|
that.info.valueIn = valueIn / util.COIN;
|
||||||
that.info.feeds = (valueIn - valueOut) / util.COIN;
|
that.info.feeds = (valueIn - valueOut) / util.COIN;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
var reward = BitcoreBlock.getBlockValue(that.info.height) / util.COIN;
|
||||||
|
that.info.vin[0].reward = reward;
|
||||||
|
that.info.valueIn = reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
that.info.size = b.length;
|
that.info.size = b.length;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return next(err, that.info);
|
return next(err, that.info);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,4 +38,5 @@ script(type='text/javascript', src='/js/controllers/header.js')
|
||||||
script(type='text/javascript', src='/js/controllers/blocks.js')
|
script(type='text/javascript', src='/js/controllers/blocks.js')
|
||||||
script(type='text/javascript', src='/js/controllers/transactions.js')
|
script(type='text/javascript', src='/js/controllers/transactions.js')
|
||||||
script(type='text/javascript', src='/js/controllers/address.js')
|
script(type='text/javascript', src='/js/controllers/address.js')
|
||||||
|
script(type='text/javascript', src='/js/controllers/search.js')
|
||||||
script(type='text/javascript', src='/js/init.js')
|
script(type='text/javascript', src='/js/init.js')
|
||||||
|
|
|
@ -48,6 +48,8 @@ body {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#search { width: 400px; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*Animations*/
|
/*Animations*/
|
||||||
|
|
|
@ -1,10 +1,24 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var app = angular.module('mystery', ['ngAnimate', 'ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mystery.system', 'mystery.index', 'mystery.blocks', 'mystery.transactions', 'monospaced.qrcode', 'mystery.address']);
|
var app = angular.module('mystery',
|
||||||
|
['ngAnimate',
|
||||||
|
'ngCookies',
|
||||||
|
'ngResource',
|
||||||
|
'ngRoute',
|
||||||
|
'ui.bootstrap',
|
||||||
|
'ui.route',
|
||||||
|
'mystery.system',
|
||||||
|
'mystery.index',
|
||||||
|
'mystery.blocks',
|
||||||
|
'mystery.transactions',
|
||||||
|
'monospaced.qrcode',
|
||||||
|
'mystery.address',
|
||||||
|
'mystery.search'
|
||||||
|
]);
|
||||||
|
|
||||||
angular.module('mystery.system', []);
|
angular.module('mystery.system', []);
|
||||||
angular.module('mystery.index', []);
|
angular.module('mystery.index', []);
|
||||||
angular.module('mystery.blocks', []);
|
angular.module('mystery.blocks', []);
|
||||||
angular.module('mystery.transactions', []);
|
angular.module('mystery.transactions', []);
|
||||||
angular.module('mystery.address', []);
|
angular.module('mystery.address', []);
|
||||||
|
angular.module('mystery.search', []);
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('mystery.search').controller('SearchController', ['$scope', '$routeParams', '$location', 'Global', 'Block', 'Transaction', 'Address', function ($scope, $routeParams, $location, Global, Block, Transaction, Address) {
|
||||||
|
$scope.global = Global;
|
||||||
|
|
||||||
|
$scope.search = function() {
|
||||||
|
var q = $scope.q;
|
||||||
|
var path;
|
||||||
|
|
||||||
|
$scope.badQuery = false;
|
||||||
|
$scope.q = '';
|
||||||
|
|
||||||
|
Block.get({
|
||||||
|
blockHash: q
|
||||||
|
}, function() {
|
||||||
|
$location.path('block/' + q);
|
||||||
|
}, function () { //block not found, search on TX
|
||||||
|
Transaction.get({
|
||||||
|
txId: q
|
||||||
|
}, function() {
|
||||||
|
$location.path('tx/' + q);
|
||||||
|
}, function () { //tx not found, search on Address
|
||||||
|
Address.get({
|
||||||
|
addrStr: q
|
||||||
|
}, function() {
|
||||||
|
$location.path('address/' + q);
|
||||||
|
}, function () { //address not found, fail :(
|
||||||
|
$scope.badQuery = true;
|
||||||
|
$scope.q = q;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
}]);
|
|
@ -3,6 +3,20 @@
|
||||||
angular.module('mystery.address').factory('Address', ['$resource', function($resource) {
|
angular.module('mystery.address').factory('Address', ['$resource', function($resource) {
|
||||||
return $resource('/api/addr/:addrStr', {
|
return $resource('/api/addr/:addrStr', {
|
||||||
addrStr: '@addStr'
|
addrStr: '@addStr'
|
||||||
|
}, {
|
||||||
|
get: {
|
||||||
|
method: 'GET',
|
||||||
|
interceptor: {
|
||||||
|
response: function (res) {
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
responseError: function (res) {
|
||||||
|
if (res.status === 404) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,20 @@
|
||||||
angular.module('mystery.blocks').factory('Block', ['$resource', function($resource) {
|
angular.module('mystery.blocks').factory('Block', ['$resource', function($resource) {
|
||||||
return $resource('/api/block/:blockHash', {
|
return $resource('/api/block/:blockHash', {
|
||||||
blockHash: '@blockHash'
|
blockHash: '@blockHash'
|
||||||
|
}, {
|
||||||
|
get: {
|
||||||
|
method: 'GET',
|
||||||
|
interceptor: {
|
||||||
|
response: function (res) {
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
responseError: function (res) {
|
||||||
|
if (res.status === 404) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,20 @@
|
||||||
angular.module('mystery.transactions').factory('Transaction', ['$resource', function($resource) {
|
angular.module('mystery.transactions').factory('Transaction', ['$resource', function($resource) {
|
||||||
return $resource('/api/tx/:txId', {
|
return $resource('/api/tx/:txId', {
|
||||||
txId: '@txId'
|
txId: '@txId'
|
||||||
|
}, {
|
||||||
|
get: {
|
||||||
|
method: 'GET',
|
||||||
|
interceptor: {
|
||||||
|
response: function (res) {
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
responseError: function (res) {
|
||||||
|
if (res.status === 404) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,13 @@
|
||||||
<a href="#!/{{item.link}}">{{item.title}}</a>
|
<a href="#!/{{item.link}}">{{item.title}}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div ng-controller="SearchController">
|
||||||
|
<form class="navbar-form navbar-left" role="search" ng-submit="search()">
|
||||||
|
<div class="form-group" ng-class="{'has-error': badQuery}">
|
||||||
|
<input id="search" type="text" class="form-control" ng-model="q" placeholder="Search for block, transaction or address">
|
||||||
|
</div>
|
||||||
|
<span class="text-danger" ng-show="badQuery">No matching records found!</span>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -40,6 +40,8 @@ describe('Address balances', function(){
|
||||||
if (v.balance) assert.equal(v.balance, a.balance);
|
if (v.balance) assert.equal(v.balance, a.balance);
|
||||||
if (v.totalReceived) assert.equal(v.totalReceived, a.totalReceived);
|
if (v.totalReceived) assert.equal(v.totalReceived, a.totalReceived);
|
||||||
if (v.totalSent) assert.equal(v.totalSent, a.totalSent);
|
if (v.totalSent) assert.equal(v.totalSent, a.totalSent);
|
||||||
|
|
||||||
|
|
||||||
if (v.transactions) {
|
if (v.transactions) {
|
||||||
|
|
||||||
v.transactions.forEach( function(tx) {
|
v.transactions.forEach( function(tx) {
|
||||||
|
|
Loading…
Reference in New Issue