mirror of
https://github.com/number571/blockchain.git
synced 2026-09-12 19:50:00 +05:00
add interface.pdf
This commit is contained in:
parent
eb2cb3a027
commit
eb07f8a186
Binary file not shown.
BIN
_example/interface.pdf
Normal file
BIN
_example/interface.pdf
Normal file
Binary file not shown.
10
gclient.go
10
gclient.go
@ -180,6 +180,7 @@ func transactionPage(w http.ResponseWriter, r *http.Request) {
|
||||
t.Execute(w, data)
|
||||
return
|
||||
}
|
||||
flag := false
|
||||
for _, addr := range Addresses {
|
||||
res := nt.Send(addr, &nt.Package{
|
||||
Option: GET_LHASH,
|
||||
@ -192,6 +193,15 @@ func transactionPage(w http.ResponseWriter, r *http.Request) {
|
||||
Option: ADD_TRNSX,
|
||||
Data: bc.SerializeTX(tx),
|
||||
})
|
||||
if res == nil || res.Data != "ok" {
|
||||
continue
|
||||
}
|
||||
flag = true
|
||||
}
|
||||
if !flag {
|
||||
data.Error = "TX failed"
|
||||
} else {
|
||||
data.Error = "TX success"
|
||||
}
|
||||
}
|
||||
t.Execute(w, data)
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
{{define "title"}}
|
||||
Account
|
||||
Account
|
||||
{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
<div class="col-md-9 mx-auto">
|
||||
<div class="col-md-9 mx-auto">
|
||||
<div class="jumbotron">
|
||||
<div class="col-12 mx-auto">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<input id="address" readonly class="form-control bg-light" type="text" name="coins" value="Address: {{ .Address }};">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input disabled class="form-control bg-light" type="text" name="coins" value="Balance: {{ if .Balance }} {{ .Balance }} {{ else }} 0 {{ end }} coins;">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 mx-auto">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<input id="address" readonly class="form-control bg-light" type="text" name="coins" value="Address: {{ .Address }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input disabled class="form-control bg-light" type="text" name="coins" value="Balance: {{ if .Balance }} {{ .Balance }} {{ else }} 0 {{ end }} coins;">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@ -1,41 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
{{block "title" .}}
|
||||
Title
|
||||
{{end}}
|
||||
</title>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css">
|
||||
<title>
|
||||
{{block "title" .}}
|
||||
Title
|
||||
{{end}}
|
||||
</title>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container">
|
||||
<a href="/" class="navbar-brand" exact><h4>Home</h4></a>
|
||||
<a href="/" class="navbar-brand" exact><h4>Home</h4></a>
|
||||
<div class="navbar-collapse">
|
||||
<ul class="navbar-nav">
|
||||
<a href="/blockchain" class="nav-link"><h5>Blockchain</h5></a>
|
||||
</ul>
|
||||
<ul class="navbar-nav ml-auto">
|
||||
{{ if (not .User) }}
|
||||
<a href="/signup" class="nav-link"><h5>Signup</h5></a>
|
||||
<a href="/login" class="nav-link"><h5>Login</h5></a>
|
||||
{{ else }}
|
||||
<a href="/transaction" class="nav-link"><h5>Transaction</h5></a>
|
||||
<a href="/account" class="nav-link"><h5>Account</h5></a>
|
||||
<a href="/logout" class="nav-link"><h5>Logout</h5></a>
|
||||
{{ end }}
|
||||
<a href="/signup" class="nav-link"><h5>Signup</h5></a>
|
||||
<a href="/login" class="nav-link"><h5>Login</h5></a>
|
||||
{{ else }}
|
||||
<a href="/transaction" class="nav-link"><h5>Transaction</h5></a>
|
||||
<a href="/account" class="nav-link"><h5>Account</h5></a>
|
||||
<a href="/logout" class="nav-link"><h5>Logout</h5></a>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
{{block "content" .}}
|
||||
Content
|
||||
{{end}}
|
||||
</main>
|
||||
</header>
|
||||
<main>
|
||||
{{block "content" .}}
|
||||
Content
|
||||
{{end}}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,35 +1,35 @@
|
||||
{{define "title"}}
|
||||
BlockChain
|
||||
BlockChain
|
||||
{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
<div class="col-md-9 mx-auto">
|
||||
<div class="col-md-9 mx-auto">
|
||||
<div class="jumbotron">
|
||||
<div class="col-12 mx-auto">
|
||||
<form method="POST" action="/blockchain">
|
||||
<div class="form-group">
|
||||
{{ if .Address }}
|
||||
<input disabled class="form-control bg-light" type="text" name="coins" value="Address: {{ .Address }};">
|
||||
<input disabled class="form-control bg-light" type="text" name="coins" value="Balance: {{ .Balance }} coins;">
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="address" placeholder="Address">
|
||||
</div>
|
||||
<input type="submit" class="btn btn-success w-100" nname="submit" value="Balance">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="jumbotron">
|
||||
{{ if .Error }}
|
||||
Error: {{ .Error }}
|
||||
{{ else }}
|
||||
{{ range $i, $e := .Size }}
|
||||
<div class="card">
|
||||
<a class="btn btn-info" href="/blockchain/{{$i}}">[Block {{ $i }}]</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 mx-auto">
|
||||
<form method="POST" action="/blockchain">
|
||||
<div class="form-group">
|
||||
{{ if .Address }}
|
||||
<input readonly class="form-control bg-light" type="text" name="coins" value="Address: {{ .Address }}">
|
||||
<input disabled class="form-control bg-light" type="text" name="coins" value="Balance: {{ .Balance }} coins;">
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="address" placeholder="Address">
|
||||
</div>
|
||||
<input type="submit" class="btn btn-success w-100" name="submit" value="Balance">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="jumbotron">
|
||||
{{ if .Error }}
|
||||
Error: {{ .Error }}
|
||||
{{ else }}
|
||||
{{ range $i, $e := .Size }}
|
||||
<div class="card">
|
||||
<a class="btn btn-info" href="/blockchain/{{$i}}">[Block {{ $i }}]</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@ -1,94 +1,94 @@
|
||||
{{define "title"}}
|
||||
Block
|
||||
Block
|
||||
{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
{{ if .Error }}
|
||||
Error: {{ .Error }}
|
||||
{{ else }}
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Nonce</th>
|
||||
<td width="100%">{{ .Block.Nonce }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Difficulty</th>
|
||||
<td width="100%">{{ .Block.Difficulty }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>CurrHash</th>
|
||||
<td width="100%">{{ .Block.CurrHash }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>PrevHash</th>
|
||||
<td width="100%">{{ .Block.PrevHash }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Miner</th>
|
||||
<td width="100%">{{ .Block.Miner }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Signature</th>
|
||||
<td width="100%">{{ .Block.Signature }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>TimeStamp</th>
|
||||
<td width="100%">{{ .Block.TimeStamp }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Transactions</th>
|
||||
<td>
|
||||
{{ range .Block.Transactions }}
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>RandBytes</th>
|
||||
<td width="100%">{{ .RandBytes }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>PrevBlock</th>
|
||||
<td width="100%">{{ .PrevBlock }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sender</th>
|
||||
<td width="100%">{{ .Sender }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Receiver</th>
|
||||
<td width="100%">{{ .Receiver }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Value</th>
|
||||
<td width="100%">{{ .Value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>ToStorage</th>
|
||||
<td width="100%">{{ .ToStorage }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>CurrHash</th>
|
||||
<td width="100%">{{ .CurrHash }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Signature</th>
|
||||
<td width="100%">{{ .Signature }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Mapping</th>
|
||||
<td>
|
||||
{{ range $k, $e := .Block.Mapping }}
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th width="100%">{{ $k }}</th>
|
||||
<td>{{ $e }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{ end }}
|
||||
{{ if .Error }}
|
||||
Error: {{ .Error }}
|
||||
{{ else }}
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Nonce</th>
|
||||
<td width="100%">{{ .Block.Nonce }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Difficulty</th>
|
||||
<td width="100%">{{ .Block.Difficulty }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>CurrHash</th>
|
||||
<td width="100%">{{ .Block.CurrHash }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>PrevHash</th>
|
||||
<td width="100%">{{ .Block.PrevHash }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Miner</th>
|
||||
<td width="100%">{{ .Block.Miner }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Signature</th>
|
||||
<td width="100%">{{ .Block.Signature }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>TimeStamp</th>
|
||||
<td width="100%">{{ .Block.TimeStamp }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Transactions</th>
|
||||
<td>
|
||||
{{ range .Block.Transactions }}
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>RandBytes</th>
|
||||
<td width="100%">{{ .RandBytes }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>PrevBlock</th>
|
||||
<td width="100%">{{ .PrevBlock }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sender</th>
|
||||
<td width="100%">{{ .Sender }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Receiver</th>
|
||||
<td width="100%">{{ .Receiver }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Value</th>
|
||||
<td width="100%">{{ .Value }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>ToStorage</th>
|
||||
<td width="100%">{{ .ToStorage }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>CurrHash</th>
|
||||
<td width="100%">{{ .CurrHash }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Signature</th>
|
||||
<td width="100%">{{ .Signature }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Mapping</th>
|
||||
<td>
|
||||
{{ range $k, $e := .Block.Mapping }}
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th width="100%">{{ $k }}</th>
|
||||
<td>{{ $e }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{ end }}
|
||||
{{end}}
|
||||
|
||||
@ -9,6 +9,3 @@
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
<!-- MIIBOwIBAAJBALigDLTLTIuMr8dn+IFYBq4PY80ocRDSGujRWT7uw9dmdpl3rJMyECsM59M6saxnoMGfQIlPmdGzu7laiwO8zkUCAwEAAQJBALNdmrqSwBzbY3LBCebvVB4KiZUpcx86YDZMHP5NDSrXk2BQwPnFMUHmtNIDZUPjKnYw+puxBcP5DuVi89ZCssECIQDKTvKQgG4Fwo3lbm3dyh2F4C0sXyj+foyypQ0e8c+LWQIhAOmfr8OyDOiEXjSPwbmuAIxfVkSm6FX4omuRwgbIbPjNAiEAv1pVDGCtsD0JQc1llbaqngogMCwB9lV0dzSuaGqHyGECIHY5rku9NdUQ709wFFwvlu1ybYiuYlLnUOJYz7R5BtRdAiBxNu3fbTGaDcw6qbHlwP9ZBE8GNoamsNl6N06vjllPJQ== -->
|
||||
|
||||
<!-- MEgCQQC4oAy0y0yLjK/HZ/iBWAauD2PNKHEQ0hro0Vk+7sPXZnaZd6yTMhArDOfTOrGsZ6DBn0CJT5nRs7u5WosDvM5FAgMBAAE= -->
|
||||
@ -1,21 +1,21 @@
|
||||
{{define "title"}}
|
||||
Login
|
||||
Login
|
||||
{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
{{ if .Error }}
|
||||
<p> {{ .Error }} </p>
|
||||
{{ end }}
|
||||
<div class="col-md-8 mx-auto">
|
||||
{{ if .Error }}
|
||||
<p> {{ .Error }} </p>
|
||||
{{ end }}
|
||||
<div class="col-md-8 mx-auto">
|
||||
<div class="jumbotron">
|
||||
<div class="col-10 mx-auto">
|
||||
<form method="POST" action="/login">
|
||||
<div class="form-group">
|
||||
<input type="password" class="form-control" name="private" placeholder="Private Key">
|
||||
</div>
|
||||
<input type="submit" class="btn btn-success w-100" name="login" value="Login">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-10 mx-auto">
|
||||
<form method="POST" action="/login">
|
||||
<div class="form-group">
|
||||
<input type="password" class="form-control" name="private" placeholder="Private Key">
|
||||
</div>
|
||||
<input type="submit" class="btn btn-success w-100" name="login" value="Login">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
{{define "title"}}
|
||||
Signup
|
||||
Signup
|
||||
{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
<div class="col-md-8 mx-auto">
|
||||
<div class="col-md-8 mx-auto">
|
||||
<div class="jumbotron">
|
||||
<div class="col-10 mx-auto">
|
||||
<form method="POST" action="/signup">
|
||||
<div class="form-group">
|
||||
{{ if .PrivateKey }}
|
||||
<input readonly type="text" class="form-control bg-light" value="{{ .PrivateKey }}" id="private">
|
||||
{{ end }}
|
||||
</div>
|
||||
<input type="submit" class="btn btn-success w-100" name="generate" value="Generate Private Key">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-10 mx-auto">
|
||||
<form method="POST" action="/signup">
|
||||
<div class="form-group">
|
||||
{{ if .PrivateKey }}
|
||||
<input readonly type="text" class="form-control bg-light" value="{{ .PrivateKey }}" id="private">
|
||||
{{ end }}
|
||||
</div>
|
||||
<input type="submit" class="btn btn-success w-100" name="generate" value="Generate Private Key">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@ -1,21 +1,26 @@
|
||||
{{define "title"}}
|
||||
Transaction
|
||||
Transaction
|
||||
{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
<div class="col-md-8 mx-auto">
|
||||
<div class="col-md-8 mx-auto">
|
||||
<div class="jumbotron">
|
||||
<div class="col-10 mx-auto">
|
||||
<form method="POST" action="/transaction">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="receiver" placeholder="Receiver">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="number" class="form-control" name="value" placeholder="Value">
|
||||
</div>
|
||||
<input type="submit" class="btn btn-success w-100" name="submit" value="Send">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-10 mx-auto">
|
||||
<form method="POST" action="/transaction">
|
||||
<div class="form-group">
|
||||
{{ if .Error }}
|
||||
<input disabled class="form-control bg-light" type="text" name="state" value="{{ .Error }};">
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="receiver" placeholder="Receiver">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="number" class="form-control" name="value" placeholder="Value">
|
||||
</div>
|
||||
<input type="submit" class="btn btn-success w-100" name="submit" value="Send">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user