Documentation ¶
Overview ¶
Copyright 2017. box.la authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2017. box.la authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- type APIConfig
- type AgentServiceConfig
- type ApplyRecord
- type ApprovalInfo
- type Approver
- type BTCAddrState
- type BitcoinConfig
- type BoxRecord
- type BtcRecord
- type CertHTTPConfig
- type CoinStatu
- type Config
- type DatabaseConfig
- type Ecr20Record
- type EmployeeFlow
- type EthereumConfig
- type GrpcStream
- type HashFlow
- type InitStage
- type KeyStoreStatu
- type LogConfig
- type MetaKey
- type NodeAuthorized
- type NodeConfig
- type Operate
- type SecretConfig
- type SignHashRecord
- type SignInfo
- type TokenInfo
- type VoucherStatus
Constants ¶
const ( SVRCERTSCRIPT = "server-cert.sh" CLTCERTSCRIPT = "client-cert.sh" DEFAULTSECRETLEN = 40 DEFAULTPASSLENT = 8 DEFAULTAPPNUM = 3 DEFAULTKEYPREFIX = "BOX" DEFAULTDBDIRNAME = "db" DEFAULTCERTSDIRNAME = "certs" DEFAULTSCRIPTDIRNAME = "scripts" DEFAULTLOGDIRNAME = "log/voucher.log" DEFAULTCONFIGFILENAME = "config.toml" )
const ( TYPE_CONTRACT = "contract" TYPE_SERVICE = "service" )
const ( HASH_LIST_PRIFIX = "v_hl_" //hash list WITHDRAW_APPLY_PRIFIX = "v_wa_" //withdraw apply PENDING_PRIDFIX = "p_" //pending ROUTER_PRIDFIX = "r_" //grpc router )
pri db key
const ( AES_KEY = "aes_key" APP_KEY_PRIFIX = "app_key_" STATAUS_KEY = "status_key" TOKEN_PRIFIX = "token_key_" )
const ( PUB_DB_BAK_PRIFIX = "pub_db_bak_" PUBKEY_ETH = "pub_key_eth" PUBKEY_BTC = "pub_key_btc" DEPOSIT_PRIFIX = "pub_dp_" WITHDRAW_PRIFIX = "pub_wd_" ALLOWKP_PRIFIX = "pub_al_" DISALLOW_PRIFIX = "pub_da_" WITHDRAW_TX_PRIFIX = "pub_wd_tx_" )
pub db key
const ( REQ_HASH = "hash" //REQ_HASH_DISALLOW = "disallow" REQ_CREATE = "create" REQ_DEPLOY = "deploy" REQ_START = "start" REQ_PAUSE = "pause" )
确认、禁用请求 已作废
const ( Err_OK = "0" //正确 Err_UNKONWN = "1" //未知的错误 Err_MARSHAL = "10" //josn打包失败 Err_DB = "11" //db失败 Err_SERVER = "12" //服务未启动 Err_SERVER_ON = "13" //服务已启动 Err_ADDR = "14" //addr不存在 Err_CONTRACT = "15" //合约未发布 Err_ETH = "100" //链处理失败 Err_UNENABLE_PREFIX = "101" //非法hash前缀 Err_UNENABLE_LENGTH = "102" //非法hash值长度 Err_KEY_RECOVER = "103" //生成key失败 Err_CODE_ROLE_NULL = "104" //code为空 Err_CODE_INCONS = "105" //code不一致 Err_BTC = "106" //BTC创建失败 )
const ( CHAN_MAX_SIZE = 100000 //chan 默认大小 POOL_SIZE = 2 //账户池大小 NONCE_PLUS = 1 //nonce值偏移值 )
const ( ROUTER_TYPE_WEB = "web" ROUTER_TYPE_GRPC = "grpc" )
const ( GRPC_HASH_ADD_REQ = "1" //hash add申请 GRPC_HASH_ADD_LOG = "2" //hans add 私链log GRPC_HASH_ENABLE_REQ = "3" //hash enable 申请 GRPC_HASH_ENABLE_LOG = "4" //hash enable 私链log GRPC_HASH_DISABLE_REQ = "5" //hash disable 申请 GRPC_HASH_DISABLE_LOG = "6" //hash disable 私链log GRPC_WITHDRAW_REQ = "7" //提现 申请 GRPC_WITHDRAW_LOG = "8" //提现 私链log GRPC_DEPOSIT_WEB = "9" //充值上报 GRPC_WITHDRAW_TX_WEB = "10" //提现tx上报 GRPC_WITHDRAW_WEB = "11" // 提现结果上报 GRPC_VOUCHER_OPR_REQ = "12" // 签名机操作处理 //GRPC_HASH_LIST_REQ = "13" // 审批流查询 //GRPC_HASH_LIST_WEB = "14" // 审批流上报 GRPC_TOKEN_LIST_WEB = "15" // token上报 GRPC_COIN_LIST_WEB = "16" //coin上报 GRPC_HASH_ENABLE_WEB = "17" //hash enable 公链log GRPC_HASH_DISABLE_WEB = "18" //hash enable 公链log GRPC_CHECK_KEY_WEB = "19" //密码验证 )
grpc流类型
const ( ECR20_TYPE_ALLOW = "1" ECR20_TYPE_DISALLOW = "2" ECR20_TYPE_APPROVE = "3" BTC_TYPE_APPROVE = ECR20_TYPE_APPROVE )
公链操作类型
const ( REP_ACCOUNT_ADD = "1" REP_DEPOSIT = "2" REP_WITHDRAW = "3" //提现tx成功上报 REP_WITHDRAW_TX = "4" //提现txid上报 )
上报
const ( VOUCHER_STATUS_UNCONNETED = 0 //未连接 VOUCHER_STATUS_UNCREATED = 1 //未创建 VOUCHER_STATUS_CREATED = 2 //已创建 VOUCHER_STATUS_DEPLOYED = 3 //已发布 VOUCHER_STATUS_STATED = 4 //已启动 VOUCHER_STATUS_PAUSED = 5 //已停止 )
签名机状态
const ( PASSWORD_STATUS_OK = 0 //成功 PASSWORD_STATUS_FAILED = 1 //密码错误 PASSWORD_CODE_FAILED = 2 //code不一致 PASSWORD_SYSTEM_FAILED = 3 //系统异常 )
关键句状态
const ( VOUCHER_OPERATE_ADDKEY = "0" //添加公钥 VOUCHER_OPERATE_CREATE = "1" //创建 VOUCHER_OPERATE_DEPLOY = "2" //发布 VOUCHER_OPERATE_START = "3" //启动 VOUCHER_OPERATE_PAUSE = "4" //停止 VOUCHER_OPERATE_HASH_ENABLE = "5" //hash同意 VOUCHER_OPERATE_HASH_DISABLE = "6" //hash拒绝 VOUCHER_OPERATE_HASH_LIST = "7" //hash list 查询 VOUCHER_OPERATE_TOKEN_ADD = "8" //token 添加 VOUCHER_OPERATE_TOKEN_DEL = "9" //token 删除 VOUCHER_OPERATE_TOKEN_LIST = "10" //token list 查询 VOUCHER_OPERATE_COIN = "11" //coin 操作 VOUCHER_OPERATE_CHECK_KEY = "12" //密码验证 )
const ( ACCOUNT_NO_USED = "0" ACCOUNT_USED = "1" ACCOUNT_BTC = "BTC" ACCOUNT_BTC_NO_USED = "BTC_0_" ACCOUNT_BTC_USED = "BTC_1_" ACCOUNT_BTC_COUNT = "countbtc" ACCOUNT_BTC_IMPORT = "importbtc" )
const ( BTC_DB_REC = "DBBTCREC_" //充值 BTC_DB_WITHDRAW = "DBBTCWD_" //WITHDRAW 提现,提币 BTC_DB_WITHDRAW_0 = "DBBTCWD_0_" //WITHDRAW 提现,提币 交易未被确认 BTC_DB_WITHDRAW_1 = "DBBTCWD_1_" //WITHDRAW 提现,提币 交易被确认 )
const ( ACCOUNT_TYPE_ETH = "0" ACCOUNT_TYPE_BTC = "1" )
const ( HASH_STATUS_APPLY = "1" //申请 HASH_STATUS_ENABLE = "2" //确认 HASH_STATUS_DISABLE = "3" //禁用 )
审批流状态
const ( COIN_NAME_BTC = "BTC" COIN_NAME_ETH = "ETH" CATEGORY_BTC int64 = 0 CATEGORY_ETH int64 = 1 COIN_DECIMALS_BTC int64 = 8 COIN_DECIMALS_ETH int64 = 18 )
TODO category
const (
BTC_CURSOR = "CURSORBTC"
)
const (
LAST_BLOCK_PRIFX = "lbp_" //block前缀
)
Variables ¶
var ( // 初始状态 // Init state INIT = MetaKey{0} // 服务器端的d // Server side secret key SECRET = MetaKey{1} // 一次性密码,计数 // One-time password PASS = MetaKey{2} // 当前区块号 // Current block BLKNUMBER = MetaKey{3} // 公链上的智能合约地址 // Address on public chain BANKADDRESS = MetaKey{5} PRIVATEKEYHASH = MetaKey{6} // bitcoin master pubkey addr BTCMASTERPUBADDRESS = MetaKey{7} Inited = InitStage{1} DefPubEthGasLimit = 3000000 //默认gaslimit DefAesKey = []byte("abcdefghijklmnop") )
var AccountImpChanBtc chan *BTCAddrState = make(chan *BTCAddrState, CHAN_MAX_SIZE)
var AccountMapBtc map[string]*BTCAddrState = make(map[string]*BTCAddrState)
var AccountUsedChan chan common.Address = make(chan common.Address, CHAN_MAX_SIZE)
var AccountUsedChanBtc chan string = make(chan string, CHAN_MAX_SIZE)
var BtcRecordChan chan *BtcRecord = make(chan *BtcRecord, CHAN_MAX_SIZE)
var Ecr20RecordChan chan *Ecr20Record = make(chan *Ecr20Record, CHAN_MAX_SIZE)
上公链操作
var OperateChan chan *Operate = make(chan *Operate, CHAN_MAX_SIZE)
var ReportedChan chan *GrpcStream = make(chan *GrpcStream, CHAN_MAX_SIZE)
[hash]txid
Functions ¶
This section is empty.
Types ¶
type AgentServiceConfig ¶
type AgentServiceConfig struct { Name string `toml:"name"` Alias string `toml:"alias"` CompanionName string `toml:"companionname"` IpAndPort string `toml:"ipandport"` Pattern string `toml:"pattern"` RPCAddr string `toml:"rpcapi"` ClientCertPath string `toml:"clientcert"` ClientKeyPath string `toml:"clientkey"` }
type ApplyRecord ¶
type ApprovalInfo ¶
type BTCAddrState ¶
BTC
type BitcoinConfig ¶
type BitcoinConfig struct { Type string `toml:"type"` Host string `toml:"host"` Rpcuser string `toml:"rpcuser"` Rpcpass string `toml:"rpcpass"` Clientcert string `toml:"clientcert"` Clientkey string `toml:"clientkey"` Confirmations int64 `toml:"confirmations"` Initusernum int `toml:initusernum` Initheight int64 `toml:initheight` BlockNoFilePath string `toml:blockNoFilePath` }
type CertHTTPConfig ¶
type CertHTTPConfig struct {
APIConfig
}
type Config ¶
type Config struct { Basedir string `toml:"basedir"` AgentSerCfg AgentServiceConfig `toml:"agentservice"` Secret SecretConfig `toml:"secret"` DB DatabaseConfig `toml:"database"` LogConfig LogConfig `toml:"log"` CertHTTPConfig CertHTTPConfig `toml:"service"` APIConfig APIConfig `toml:"api"` EthereumConfig EthereumConfig `toml:"ethereum"` BitcoinConfig BitcoinConfig `toml:"bitcoin"` }
type DatabaseConfig ¶
type DatabaseConfig struct { Filepath string `toml:"filePath"` Cache int `toml:"cache"` Openfiles int `toml:"openFiles"` Prefix string `toml:"prefix"` }
func (DatabaseConfig) String ¶
func (d DatabaseConfig) String() string
type Ecr20Record ¶
type EmployeeFlow ¶
type EthereumConfig ¶
type EthereumConfig struct { Scheme string `toml:"scheme"` DelayedBlocks int64 `toml:"delayedBlocks"` CursorBlocks int64 `toml:"cursorBlocks"` Retries int `toml:retries` GasLimit int `toml:gasLimit` AccountPoolSize int `toml:accountPoolSize` BlockNoFilePath string `toml:blockNoFilePath` NonceFilePath string `toml:nonceFilePath` CursorFilePath string `toml:cursorFilePath` }
type GrpcStream ¶
type GrpcStream struct { Type string BlockNumber uint64 //区块号 AppId string //申请人 Hash common.Hash WdHash common.Hash TxHash string Amount *big.Int Fee *big.Int Account string From string To string Category *big.Int Flow string //原始内容 Sign string //签名信息 WdFlow string //提现原始数据 Status string VoucherOperate *Operate ApplyTime time.Time //申请时间 TokenList []*TokenInfo SignInfos []*SignInfo }
grpc stream
type HashFlow ¶
type HashFlow struct { Flow_name string Single_limit string Approval_info []ApprovalInfo }
hash审批流配置模版信息
type KeyStoreStatu ¶
type NodeAuthorized ¶
type NodeConfig ¶
type NodeConfig struct { Name string `toml:"name"` RPCAddr string `toml:"rpcapi"` ClientCertPath string `toml:"clientcert"` ClientKeyPath string `toml:"clientkey"` }
NodeConfig - 私链连接配置
func (NodeConfig) String ¶
func (n NodeConfig) String() string
type Operate ¶
type Operate struct { Type string AppId string //appid AppName string //app别名 Hash string Password string ReqIpPort string Code string PublicKey string //加密后公钥 TokenName string Decimals int64 ContractAddr string CoinCategory int64 //币种分类 CoinUsed bool //币种使用 Sign string //签名 PassSign string //密码签名 }
私钥-签名机操作
type SecretConfig ¶
type SignHashRecord ¶
type VoucherStatus ¶
type VoucherStatus struct { ServerStatus int //系统状态 Status int //错误码状态 Total int //密钥数量 HashCount int //hash数量 TokenCount int //token数量 Address string //账户地址 ContractAddress string //合约地址 BtcAddress string //比特币地址 D string //随机数 NodesAuthorized []NodeAuthorized //授权情况 KeyStoreStatus []KeyStoreStatu //公约添加状态 CoinStatus []CoinStatu //币种使用状态 }
签名机状态
var RealTimeStatus *VoucherStatus = &VoucherStatus{}
实时状态