-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.go
61 lines (50 loc) · 1.43 KB
/
account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package account
import (
"encoding/hex"
"lurcury/db"
eddsa "lurcury/crypto/eddsa"
crypto "lurcury/crypto"
"lurcury/types"
)
func GenesisAccount(core_arg types.CoreStruct,address string,balance string,tokenName []string, tokenBalance []string)(bool){
s := types.AccountData{
Nonce:0,
Balance:balance,
Token:map[string]string{"kaman": "0"},
}
for i:=0; i<len(tokenName); i++{
s.Token[tokenName[i]] = tokenBalance[i]
}
s.Token["wen"] = "300000000000000"
db.AccountHexPut(core_arg.Db, address, s)
return true
}
func NewAccount()(string, string, string){
pri ,pub := eddsa.EddsaGenerateKey()
addr := crypto.KeyToAddress(pub)
return hex.EncodeToString(pri), hex.EncodeToString(pub), (hex.EncodeToString(addr))
}
func Account_exp()(types.AccountData){
s := types.AccountData{
Address:"264411884d6d2aca8ca2d2a77c9dc95ffdcee529",
Nonce:0,
Balance:"1000000000000000000",
Token: make(map[string]string),
Transaction:[]types.TransactionJson{},
}
s.Token["def"] = "1000000"
s.Token["deh"] = "1000000"
//fmt.Println(b,s)
return s
}
func InitAccount(address string, tokenName string, amount string)(types.AccountData){
s := types.AccountData{
Address:address,
Nonce:0,
Balance:"0",
Token:make(map[string]string),
Transaction:[]types.TransactionJson{},
}
s.Token[tokenName] = amount
return s
}