diff --git a/DevelopmentNotes.md b/DevelopmentNotes.md
index 37b41c5..3c0ef67 100644
--- a/DevelopmentNotes.md
+++ b/DevelopmentNotes.md
@@ -30,5 +30,3 @@ other
- mantain connection with wallet using websockets
- num address evolution throught time
-
-- Error in Tx model. exploreBlockchain.go line 174
diff --git a/exploreBlockchain.go b/exploreBlockchain.go
index f6395d8..d5912f1 100644
--- a/exploreBlockchain.go
+++ b/exploreBlockchain.go
@@ -79,6 +79,17 @@ func explore(client *rpcclient.Client, blockHash string) {
nodeTx.Type = "tx"
saveNode(nodeCollection, nodeTx)
+ //Tx save
+ var newTx TxModel
+ newTx.Hex = blockTx.Hex
+ newTx.Txid = blockTx.Txid
+ newTx.Hash = blockTx.Hash
+ newTx.BlockHash = block.Hash
+ newTx.BlockHeight = strconv.FormatInt(block.Height, 10)
+ newTx.Time = blockTx.Time
+ newTx.DateT = unixTimeToTime(block.Time)
+ newTx.Date.Year, newTx.Date.Month, newTx.Date.Day, newTx.Date.Hour = decomposeDate(block.Time)
+
var originAddresses []string
var outputAddresses []string
var outputAmount []float64
@@ -101,6 +112,11 @@ func explore(client *rpcclient.Client, blockHash string) {
addr.Hash = outputAddr
addr.InBittrex = false
saveAddress(addr)
+
+ var newVout Vout
+ newVout.Value = Vo.Value
+ newVout.Address = outputAddr
+ newTx.Vout = append(newTx.Vout, newVout)
}
}
for _, Vi := range blockTx.Vin {
@@ -108,24 +124,20 @@ func explore(client *rpcclient.Client, blockHash string) {
check(err)
txVi, err := client.GetRawTransactionVerbose(th)
check(err)
+
if len(txVi.Vout[Vi.Vout].ScriptPubKey.Addresses) > 0 {
//add tx to newBlock
newBlock.Tx = append(newBlock.Tx, blockTx.Txid)
//Tx save
- var newTx TxModel
- newTx.Hex = blockTx.Hex
- newTx.Txid = blockTx.Txid
- newTx.Hash = blockTx.Hash
- newTx.BlockHash = block.Hash
- newTx.BlockHeight = strconv.FormatInt(block.Height, 10)
- newTx.Time = blockTx.Time
- newTx.DateT = unixTimeToTime(block.Time)
- newTx.Date.Year, newTx.Date.Month, newTx.Date.Day, newTx.Date.Hour = decomposeDate(block.Time)
for _, originAddr := range txVi.Vout[Vi.Vout].ScriptPubKey.Addresses {
originAddresses = append(originAddresses, originAddr)
- newTx.From = originAddr
+ var newVin Vin
+ newVin.Txid = blockTx.Txid
+ newVin.Amount = txVi.Vout[Vi.Vout].Value
+ newVin.Address = originAddr
+ newTx.Vin = append(newTx.Vin, newVin)
var n1 NodeModel
n1.Id = originAddr
@@ -167,11 +179,10 @@ func explore(client *rpcclient.Client, blockHash string) {
//hour analysis
hourAnalysis(eIn, blockTx.Time)
- newTx.To = outputAddr
+ //newTx.To = outputAddr
}
}
- //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/mongoModels.go b/mongoModels.go
index 594dc92..652a93f 100644
--- a/mongoModels.go
+++ b/mongoModels.go
@@ -18,12 +18,24 @@ type DateModel struct {
BlockHash string `json:"blockhash"`
BlockHeight string `json:"blockheight"`*/
}
+type Vin struct {
+ Txid string `json:"txid"`
+ Vout uint32 `json:"vout"`
+ Amount float64 `json:"amount"`
+ Address string `json:"address"`
+}
+type Vout struct {
+ Value float64 `json:"value"`
+ Address string `json:"address"`
+}
type TxModel struct {
- Hex string `json:"hex"`
- Txid string `json:"txid"`
- Hash string `json:"hash"`
- From string `json:"from"` //hash of address
- To string `json:"to"` //hash of address
+ Hex string `json:"hex"`
+ Txid string `json:"txid"`
+ Hash string `json:"hash"`
+ /*From string `json:"from"` //hash of address
+ To string `json:"to"` //hash of address*/
+ Vin []Vin `json:"vin"`
+ Vout []Vout `json:"vout"`
Amount float64 `json:"amount"`
BlockHash string `json:"blockhash"`
BlockHeight string `json:"blockheight"`
@@ -39,6 +51,7 @@ type BlockModel struct {
//Amount float64 `json:"amount"`
//Fee float64 `json:"fee"`
Tx []string `json:"txid"` //txid of the TxModel
+ Txs []TxModel `json:"txs"`
PreviousHash string `json:"previoushash"`
NextHash string `json:"nexthash"`
Time int64 `json:"time"`
diff --git a/serverRoutes.go b/serverRoutes.go
index 2f59613..f874e76 100644
--- a/serverRoutes.go
+++ b/serverRoutes.go
@@ -47,10 +47,10 @@ var routes = Routes{
GetLastTx,
},
Route{
- "AddressNetwork",
+ "Block",
"GET",
- "/address/network/{address}",
- AddressNetwork,
+ "/block/{height}",
+ Block,
},
Route{
"Address",
@@ -58,6 +58,12 @@ var routes = Routes{
"/address/{hash}",
Address,
},
+ Route{
+ "AddressNetwork",
+ "GET",
+ "/address/network/{address}",
+ AddressNetwork,
+ },
Route{
"AddressSankey",
"GET",
@@ -167,22 +173,36 @@ func GetLastTx(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, string(jsonData))
}
-func AddressNetwork(w http.ResponseWriter, r *http.Request) {
+func Block(w http.ResponseWriter, r *http.Request) {
ipFilter(w, r)
vars := mux.Vars(r)
- address := vars["address"]
- if address == "undefined" {
- fmt.Fprintln(w, "not valid address")
+ var heightString string
+ heightString = vars["height"]
+ height, err := strconv.ParseInt(heightString, 10, 64)
+ if err != nil {
+ fmt.Fprintln(w, "not valid height")
} else {
- network := addressTree(address)
- network.Nodes[0].Shape = "triangle"
+ block := BlockModel{}
+ err := blockCollection.Find(bson.M{"height": height}).One(&block)
+
+ txs := []TxModel{}
+ err = txCollection.Find(bson.M{"blockheight": heightString}).All(&txs)
+ block.Txs = txs
+
+ /*for _, tx := range address.Txs {
+ blocks := []BlockModel{}
+ err = blockCollection.Find(bson.M{"blockheight": tx.BlockHash}).All(&blocks)
+ for _, block := range blocks {
+ address.Blocks = append(address.Blocks, block)
+ }
+ }*/
//convert []resp struct to json
- jNetwork, err := json.Marshal(network)
+ jsonResp, err := json.Marshal(block)
check(err)
- fmt.Fprintln(w, string(jNetwork))
+ fmt.Fprintln(w, string(jsonResp))
}
}
func Address(w http.ResponseWriter, r *http.Request) {
@@ -215,6 +235,24 @@ func Address(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, string(jsonResp))
}
}
+func AddressNetwork(w http.ResponseWriter, r *http.Request) {
+ ipFilter(w, r)
+
+ vars := mux.Vars(r)
+ address := vars["address"]
+ if address == "undefined" {
+ fmt.Fprintln(w, "not valid address")
+ } else {
+ network := addressTree(address)
+ network.Nodes[0].Shape = "triangle"
+
+ //convert []resp struct to json
+ jNetwork, err := json.Marshal(network)
+ check(err)
+
+ fmt.Fprintln(w, string(jNetwork))
+ }
+}
func AddressSankey(w http.ResponseWriter, r *http.Request) {
ipFilter(w, r)
vars := mux.Vars(r)
diff --git a/web/app.js b/web/app.js
index 7594bae..258f655 100644
--- a/web/app.js
+++ b/web/app.js
@@ -11,9 +11,10 @@ angular.module('webApp', [
'angular-svg-round-progressbar',
'app.navbar',
'app.main',
+ 'app.block',
+ 'app.address',
'app.network',
'app.addressNetwork',
- 'app.address',
'app.sankey',
'app.dateAnalysis'
]).
diff --git a/web/css/bootstrapMaterialDarkOverwrite.css b/web/css/bootstrapMaterialDarkOverwrite.css
index 8709439..87f4e1f 100644
--- a/web/css/bootstrapMaterialDarkOverwrite.css
+++ b/web/css/bootstrapMaterialDarkOverwrite.css
@@ -21,9 +21,15 @@ body {
.list-group-item:hover {
background: rgba(255, 255, 255, 0.2)!important;
}
-.list-group-item p, a{
+.list-group-item p {
color: #ffffff!important;
}
+.list-group-item a {
+ color: #512DA8!important;
+}
+.list-group-item-text {
+ color: #9575CD!important;
+}
.table-hover tbody tr:hover {
background-color: rgba(245, 245, 245, 0.2)!important;
}
diff --git a/web/index.html b/web/index.html
index 117c9eb..dd19dde 100644
--- a/web/index.html
+++ b/web/index.html
@@ -76,9 +76,10 @@
+
+
-