/
config.go
104 lines (89 loc) · 2.22 KB
/
config.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2018 The openwallet Authors
* This file is part of the openwallet library.
*
* The openwallet library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The openwallet library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
package fiiicoin
import (
"github.com/blocktree/go-owcrypt"
"github.com/blocktree/openwallet/common/file"
"path/filepath"
"strings"
)
const (
//币种
Symbol = "FIII"
CurveType = owcrypt.ECC_CURVE_ED25519
Decimals = int32(8)
//默认配置内容
defaultConfig = `
# RPC api url
serverAPI = ""
isTestNet = false
`
)
type WalletConfig struct {
//币种
Symbol string
//配置文件路径
configFilePath string
//配置文件名
configFileName string
//区块链数据文件
//BlockchainFile string
//本地数据库文件路径
dbPath string
//钱包服务API
ServerAPI string
//默认配置内容
DefaultConfig string
//曲线类型
CurveType uint32
//是否测试网
IsTestNet bool
//最大的输入数量
MaxTxInputs int
//数据目录
DataDir string
}
func NewConfig(symbol string) *WalletConfig {
c := WalletConfig{}
//币种
c.Symbol = symbol
c.CurveType = CurveType
//配置文件路径
c.configFilePath = filepath.Join("conf")
//配置文件名
c.configFileName = c.Symbol + ".ini"
//区块链数据文件
//c.BlockchainFile = "blockchain.db"
//本地数据库文件路径
c.dbPath = filepath.Join("data", strings.ToLower(c.Symbol), "db")
//钱包服务API
c.ServerAPI = ""
//最大的输入数量
c.MaxTxInputs = 50
//创建目录
//file.MkdirAll(c.dbPath)
return &c
}
//创建文件夹
func (wc *WalletConfig) makeDataDir() {
if len(wc.DataDir) == 0 {
//默认路径当前文件夹./data
wc.DataDir = "data"
}
//本地数据库文件路径
wc.dbPath = filepath.Join(wc.DataDir, strings.ToLower(wc.Symbol), "db")
//创建目录
file.MkdirAll(wc.dbPath)
}