diff --git a/DevelopmentNotes.md b/DevelopmentNotes.md index b2580d6..37b41c5 100644 --- a/DevelopmentNotes.md +++ b/DevelopmentNotes.md @@ -29,4 +29,6 @@ other - mantain connection with wallet using websockets -- num address evolution throught time \ No newline at end of file +- num address evolution throught time + +- Error in Tx model. exploreBlockchain.go line 174 diff --git a/README.md b/README.md index 46061d0..ff3a9ac 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Wait until the entire blockchain is downloaded. ``` ./goBlockchainDataAnalysis -continue ``` - + 3.2. If don't want to fill the database, can just run: ``` ./goBlockchainDataAnalysis @@ -102,6 +102,8 @@ Webapp will run on 127.0.0.1:8080 ### Some screenshots Some screenshots can be old, and can contain errors. +![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis00_new.png "goBlockchainDataAnalysis") + ![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis00.png "goBlockchainDataAnalysis") ![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis06.gif "goBlockchainDataAnalysis") diff --git a/exploreBlockchain.go b/exploreBlockchain.go index be39c7c..f6395d8 100644 --- a/exploreBlockchain.go +++ b/exploreBlockchain.go @@ -171,6 +171,7 @@ func explore(client *rpcclient.Client, blockHash string) { } } + //ERROR! need to make array with all Vin and array with Vout, with addresses and amount values saveTx(newTx) } else { originAddresses = append(originAddresses, "origin") diff --git a/goBlockchainDataAnalysis b/goBlockchainDataAnalysis index 50e4f87..ddaf02e 100755 Binary files a/goBlockchainDataAnalysis and b/goBlockchainDataAnalysis differ diff --git a/mongoModels.go b/mongoModels.go index 553d0c8..594dc92 100644 --- a/mongoModels.go +++ b/mongoModels.go @@ -3,9 +3,11 @@ package main import "time" type AddressModel struct { - Hash string `json:"hash"` - Amount float64 `json:"amount"` - InBittrex bool `json:"inbittrex"` + Hash string `json:"hash"` + Amount float64 `json:"amount"` + InBittrex bool `json:"inbittrex"` + Txs []TxModel `json:"txs"` + Blocks []BlockModel `json:"blocks"` } type DateModel struct { Hour int `json:"hour"` @@ -26,7 +28,7 @@ type TxModel struct { BlockHash string `json:"blockhash"` BlockHeight string `json:"blockheight"` Time int64 `json:"time"` - DateT time.Time `json:"datef"` //date formated + DateT time.Time `json:"datet"` //date formated Date DateModel } type BlockModel struct { @@ -40,7 +42,7 @@ type BlockModel struct { PreviousHash string `json:"previoushash"` NextHash string `json:"nexthash"` Time int64 `json:"time"` - DateT time.Time `json:"datef"` //date formated + DateT time.Time `json:"datet"` //date formated Date DateModel } diff --git a/screenshots/goBlockchainDataAnalysis00_new.png b/screenshots/goBlockchainDataAnalysis00_new.png new file mode 100644 index 0000000..a210cb2 Binary files /dev/null and b/screenshots/goBlockchainDataAnalysis00_new.png differ diff --git a/serverRoutes.go b/serverRoutes.go index 6464bff..2f59613 100644 --- a/serverRoutes.go +++ b/serverRoutes.go @@ -52,6 +52,12 @@ var routes = Routes{ "/address/network/{address}", AddressNetwork, }, + Route{ + "Address", + "GET", + "/address/{hash}", + Address, + }, Route{ "AddressSankey", "GET", @@ -179,6 +185,36 @@ func AddressNetwork(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, string(jNetwork)) } } +func Address(w http.ResponseWriter, r *http.Request) { + ipFilter(w, r) + + vars := mux.Vars(r) + hash := vars["hash"] + if hash == "undefined" { + fmt.Fprintln(w, "not valid hash") + } else { + address := AddressModel{} + err := addressCollection.Find(bson.M{"hash": hash}).One(&address) + + txs := []TxModel{} + err = txCollection.Find(bson.M{"$or": []bson.M{bson.M{"from": hash}, bson.M{"to": hash}}}).All(&txs) + address.Txs = txs + + for _, tx := range address.Txs { + blocks := []BlockModel{} + err = blockCollection.Find(bson.M{"hash": tx.BlockHash}).All(&blocks) + for _, block := range blocks { + address.Blocks = append(address.Blocks, block) + } + } + + //convert []resp struct to json + jsonResp, err := json.Marshal(address) + check(err) + + fmt.Fprintln(w, string(jsonResp)) + } +} func AddressSankey(w http.ResponseWriter, r *http.Request) { ipFilter(w, r) vars := mux.Vars(r) @@ -376,8 +412,10 @@ func GetLast7DayHourAnalysis(w http.ResponseWriter, r *http.Request) { for _, d := range hourCount { dayData = append(dayData, d.Count) } - resp.Series = append(resp.Series, txs[0].Date.Day) - resp.Data = append(resp.Data, dayData) + if len(txs) > 0 { + resp.Series = append(resp.Series, txs[0].Date.Day) + resp.Data = append(resp.Data, dayData) + } } hourLabels := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"} resp.Labels = hourLabels diff --git a/web/app.js b/web/app.js index d1f024b..7594bae 100644 --- a/web/app.js +++ b/web/app.js @@ -13,6 +13,7 @@ angular.module('webApp', [ 'app.main', 'app.network', 'app.addressNetwork', + 'app.address', 'app.sankey', 'app.dateAnalysis' ]). diff --git a/web/css/bootstrapMaterialDarkOverwrite.css b/web/css/bootstrapMaterialDarkOverwrite.css new file mode 100644 index 0000000..8709439 --- /dev/null +++ b/web/css/bootstrapMaterialDarkOverwrite.css @@ -0,0 +1,29 @@ + +/* bootstrap overwrite dark */ + +body { + background: #424242!important; +} +.panel-heading { + border-radius: 0px!important; +} +.panel-title a { + background: rgba(0,0,0,0)!important; + text-decoration: none; +} +.panel-body { + background: #212121; + color: #ffffff; +} +.list-group-item { + background: rgba(0,0,0,0)!important; +} +.list-group-item:hover { + background: rgba(255, 255, 255, 0.2)!important; +} +.list-group-item p, a{ + color: #ffffff!important; +} +.table-hover tbody tr:hover { + background-color: rgba(245, 245, 245, 0.2)!important; +} diff --git a/web/css/colors.css b/web/css/colors.css index f82929e..148c641 100644 --- a/web/css/colors.css +++ b/web/css/colors.css @@ -463,6 +463,11 @@ color: #ffffff!important; } +.c_black{ + background: #000000!important; + color: #ffffff!important; +} + /* blue grey */ diff --git a/web/css/style.css b/web/css/style.css index 5433452..e3a3690 100644 --- a/web/css/style.css +++ b/web/css/style.css @@ -30,15 +30,23 @@ /* sidebar */ -.o_sidebar a{ + +.o_sidebar a { color: white; padding: 10px; } -.o_sidebar a:hover{ + +.o_sidebar a:hover { background: #9E9E9E!important; color: white; } -.o_sidebarIcon{ + +.o_sidebarIcon { font-size: 180%; margin-right: 10px; -} \ No newline at end of file +} + +.o_textRoundProgress { + margin-left: 30%; + margin-top: -15%; +} diff --git a/web/index.html b/web/index.html index d5c29f2..117c9eb 100644 --- a/web/index.html +++ b/web/index.html @@ -16,6 +16,7 @@ + @@ -77,6 +78,7 @@ + diff --git a/web/views/address/address.html b/web/views/address/address.html new file mode 100644 index 0000000..4a836a2 --- /dev/null +++ b/web/views/address/address.html @@ -0,0 +1,56 @@ +
+
+
+
+

{{address.hash}}

+
+
+ {{address.amount}} +
+
+ +
+
+

Blocks where address appears

+
+
+ Block Height: {{block.height}} +
+ Hash: {{block.Hash}} +
+ {{block.datet}} +
+ {{block.Size}} +
+
+
+
+
+
+

Tx where address appears

+
+
+ + + + + + + + + + + + + + + + + + + +
BlockHeightFromToAmount
{{tx.blockheight}}{{tx.from}}{{tx.to}}{{tx.amount}}View
+
+
+
+
diff --git a/web/views/address/address.js b/web/views/address/address.js new file mode 100644 index 0000000..9d6934d --- /dev/null +++ b/web/views/address/address.js @@ -0,0 +1,21 @@ +'use strict'; + +angular.module('app.address', ['ngRoute']) + + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/address/:hash', { + templateUrl: 'views/address/address.html', + controller: 'AddressCtrl' + }); + }]) + + .controller('AddressCtrl', function($scope, $http, $routeParams) { + $scope.address = {}; + $http.get(urlapi + 'address/' + $routeParams.hash) + .then(function(data, status, headers, config) { + console.log(data); + $scope.address = data.data; + }, function(data, status, headers, config) { + console.log('data error'); + }); + }); diff --git a/web/views/dateAnalysis/dateAnalysis.html b/web/views/dateAnalysis/dateAnalysis.html index 0f27ce5..1196c0d 100644 --- a/web/views/dateAnalysis/dateAnalysis.html +++ b/web/views/dateAnalysis/dateAnalysis.html @@ -1,6 +1,6 @@
-
+

Last 7 Days Tx/Day

@@ -9,7 +9,7 @@
-
+

Last 24 hours Tx/Hour

@@ -18,9 +18,10 @@
+
-
+

Last 7 Days Tx/Hour

@@ -28,4 +29,4 @@
-
\ No newline at end of file +
diff --git a/web/views/main/main.html b/web/views/main/main.html index 7edcb75..29055a4 100644 --- a/web/views/main/main.html +++ b/web/views/main/main.html @@ -4,7 +4,7 @@

{{stats.realblockcount}}/{{stats.blockcount}} Blocks with content

-
+
@@ -14,7 +14,7 @@

{{stats.txcount}} Txs

-
+
@@ -24,7 +24,7 @@

{{stats.addrcount}} Addr

-
+
@@ -35,7 +35,7 @@ {{current}}/{{max}} +
{{ current }}/{{ max }}
@@ -54,11 +55,11 @@
{{current}}/{{max}} +
25%
@@ -73,9 +75,9 @@
-
+

Last 24 hours Tx/Hour - View more

+ View more
@@ -84,7 +86,7 @@
-
+

Tx/Day Last 7 Days

@@ -95,9 +97,9 @@
-
+

Last 7 days Tx/Hour - View more

+ View more
@@ -109,13 +111,13 @@
-
+

Last addresses used

-

{{address.hash}}

+ {{address.hash}}
@@ -124,11 +126,11 @@
-
+

Last Tx with amount