Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecrypt(crypted, key []byte) ([]byte, error)
- func AesEncrypt(origData, key []byte) ([]byte, error)
- func GenerateRandomNumber(start int, end int, count int) []int
- func Init()
- func InitAddressDB(dsn string)
- func InitAllContarctServer(ctx context.Context, exit chan<- struct{})
- func InitAllNode(url []string)
- func InitConfig()
- func InitContract(contracts []Contract)
- func InitDB()
- func InitLog()
- func InitMainAndFee()
- func InitMainNode(url string)
- func InitSeed()
- func InitWalletInfo()
- func IsContract(contract string) bool
- func NewPrivateKey() (int, *ecdsa.PrivateKey, error)
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func RunCollect()
- func RunTransaction()
- func Serv(ctx context.Context, rpcSev Service) *http.Server
- type Account
- type Balance
- type Client
- type Collection
- type Contract
- type DB
- func (db *DB) Close()
- func (db *DB) GetAccount(from int) ([]Account, error)
- func (db *DB) GetAccountMaxIndex() int
- func (db *DB) GetAccountWithAddr(addr string) (*Account, error)
- func (db *DB) GetAccountWithBalance(startid int64, count int) ([]Account, error)
- func (db *DB) GetAccountWithContractBalance(contract string, minAmount, startid int64, count int) ([]Balance, error)
- func (db *DB) GetCollestTransactions(sTime, eTime int64, contract string) ([]Transactions, error)
- func (db *DB) GetSumContractBalance(contract string) (map[string]int64, error)
- func (db *DB) GetTransactions(contract, addr string, count, skip int) ([]Transactions, error)
- func (db *DB) InsertAccount(account *Account) (int64, error)
- func (db *DB) InsertBalance(account *Balance) (int64, error)
- func (db *DB) InsertLastBlockHeight(num int64) (err error)
- func (db *DB) InsertTransactions(transactions *Transactions) (int64, error)
- func (db *DB) LoadLastBlockHeight() (int64, error)
- func (db *DB) SearchBalance(contract, address string) (*Balance, error)
- func (db *DB) SearchTransactions(txid string) (*Transactions, error)
- func (db *DB) Session() *xorm.Session
- func (db *DB) Sync() error
- func (db *DB) UpdateAccount(account *Account) (int64, error)
- type GlobalConf
- type OtherParam
- type Scantraderecord
- type Service
- func (as Service) GetNewAddress() (string, error)
- func (as Service) GetRecords(sTime, eTime int64) ([]util.SummaryData, error)
- func (as Service) Getinfo() util.Info
- func (s Service) Invoke(ctx context.Context, method string, params json.RawMessage) zenrpc.Response
- func (as Service) ListTransactions(addr string, count, skip int) ([]util.Transactions, error)
- func (Service) SMD() smd.ServiceInfo
- func (as Service) SendToAddress(addr string, amount json.Number) (string, error)
- func (as Service) ValidateAddress(addr string) util.ValidateAddress
- type Transactions
Constants ¶
const ( Trx string = "trx" Trc10 string = "trc10" Trc20 string = "trc20" )
const ( Send = "send" // 提币 即 主地址提币到其他地址 Receive = "receive" // 本平台地址 分配的用户地址收到的 ReceiveOther = "receive_other" // 主地址收到的外来地址转帐 Collect = "collect" // 本平台地址归集到主地址 CollectOwn = "collect_own" // 站内转账 CollectSend = "collect_send" // 本平台地址提币到站外 异常的 )
Variables ¶
var IsMulti bool // 是否采用外部多链地址
var RPC = struct { Service struct{ Getinfo, GetNewAddress, ValidateAddress, ListTransactions, SendToAddress, GetRecords string } }{ Service: struct{ Getinfo, GetNewAddress, ValidateAddress, ListTransactions, SendToAddress, GetRecords string }{ Getinfo: "getinfo", GetNewAddress: "getnewaddress", ValidateAddress: "validateaddress", ListTransactions: "listtransactions", SendToAddress: "sendtoaddress", GetRecords: "getrecords", }, }
Functions ¶
func AesDecrypt ¶
func AesEncrypt ¶
func GenerateRandomNumber ¶
GenerateRandomNumber 生成count个[start,end)结束的不重复的随机数 为了用户抽奖 TODO
func InitAddressDB ¶
func InitAddressDB(dsn string)
func InitAllContarctServer ¶
InitAllContarctServer 初始化所有节点
func InitAllNode ¶
func InitAllNode(url []string)
func InitConfig ¶
func InitConfig()
func InitMainNode ¶
func InitMainNode(url string)
func NewPrivateKey ¶
func NewPrivateKey() (int, *ecdsa.PrivateKey, error)
func PKCS7Padding ¶
func PKCS7UnPadding ¶
Types ¶
type Account ¶
type Account struct { ID int64 `xorm:"'id' pk autoincr"` Address string `xorm:"'address' unique DEFAULT '' "` // 唯一索引 PublicKey string `xorm:"'public_key'" json:"publickey"` // 公钥新版字段 如果有就是新版 PrivateKey string `xorm:"'private_key'" sql:"comment:'地址私钥'"` // 地址私钥 Index int `xorm:"'index' DEFAULT 0" sql:"comment:'位置'"` // 唯一 User string `xorm:"'user'"` Ctime int64 `xorm:"'ctime'"` // 创建时间 Amount int64 `xorm:"'amount' index INTEGER DEFAULT 0"` // 主链币种余额 }
Account 账户分配的地址
func SearchAccount ¶
type Balance ¶
type Balance struct { ID int64 `xorm:"'id' pk autoincr"` Address string `xorm:"'address' DEFAULT '' "` Contract string `xorm:"'contract' index"` // 哪种合约 Amount int64 `xorm:"'amount' index INTEGER DEFAULT 0"` }
Balance 代币余额
type Client ¶
type Client struct { NodeTrx string `toml:"nodeTrx"` // 超级节点url 主节点 NodeUrl []string `toml:"nodeUrl"` // 其他节点url Password string `toml:"password"` // 主钱包密码 加密后的 MainAddr string `toml:"main_addr"` // 主钱包地址 MainPri string `toml:"main_pri"` // 主钱包私钥 Seed string `toml:"seed"` // 私钥种子base64 SeedPri string `toml:"seed_pri"` // 私钥种子密码 Password1 string `toml:"password1"` // 主钱包密码 加密后的2 MainAddr1 string `toml:"main_addr1"` // 主钱包地址2 MainPri1 string `toml:"main_pri1"` // 主钱包私钥 DBAddr string `toml:"db_addr"` // sqlite 地址 DBAddrMulti string `toml:"db_addr_multi"` // 多链地址保存mysql数据库地址 KeyStore string `toml:"key_store"` // 用户钱包保存路径 Port string `toml:"port"` // 监听端口 trx LogLevel string `toml:"logLevel"` // 日志等级 Count int64 `toml:"count"` // 批量查询交易记录个数 Feelimit int64 `toml:"feelimit"` // 转账合约消耗sun个数 建议设置5000000 PerFee decimal.Decimal `toml:"perfee"` // 每次归集每个合约需要手续费消耗 MinFee decimal.Decimal `toml:"minfee"` // 每个地址至少保留多少trx手续费 IsMulti bool `toml:"is_multi"` // 是否采用外部地址 }
Client 钱包节点
type Collection ¶
type Collection struct { TimeIntervalMin int64 `toml:"time_interval_min"` // 所有代币归集扫描间隔 MinAmount decimal.Decimal `toml:"min_amount"` // trx 最小归集数目 }
Collection 归集配置
type Contract ¶
type Contract struct { Port string `toml:"port"` // rpc 监听端口 Name string `toml:"name"` // USDT BTT Type string `toml:"type"` // TRC20 和 TRC10 Contract string `toml:"contract"` // 合约地址或者合约ID Issuer string `toml:"issuer"` // 合约创建者 Decimal int32 `toml:"decimal"` // 合约小数位 CollectionMinAmount decimal.Decimal `toml:"min_amount"` // 代币最小归集数目 }
Contract 合约 TRC20 和 TRC10
type DB ¶
DB .
func (*DB) GetAccountMaxIndex ¶
func (*DB) GetAccountWithAddr ¶
GetAccountWithAddr 搜索地址是否存在
func (*DB) GetAccountWithBalance ¶
GetAccountWithBalance 获取大于minAmount的所有账户
func (*DB) GetAccountWithContractBalance ¶
func (db *DB) GetAccountWithContractBalance(contract string, minAmount, startid int64, count int) ([]Balance, error)
GetAccountWithContractBalance 获取大于minAmount的所有账户合约余额
func (*DB) GetCollestTransactions ¶
func (db *DB) GetCollestTransactions(sTime, eTime int64, contract string) ([]Transactions, error)
GetCollestTransactions 获取指定时间段内归集交易记录
func (*DB) GetSumContractBalance ¶
GetSumContractBalance 获取合约总余额
func (*DB) GetTransactions ¶
func (db *DB) GetTransactions(contract, addr string, count, skip int) ([]Transactions, error)
GetTransactions 获取最近交易记录
func (*DB) InsertAccount ¶
InsertAccount 插入数据
func (*DB) InsertBalance ¶
InsertBalance 插入数据
func (*DB) InsertLastBlockHeight ¶
InsertLastBlockHeight 更新最后一次扫描高度
func (*DB) InsertTransactions ¶
func (db *DB) InsertTransactions(transactions *Transactions) (int64, error)
InsertTransactions 插入数据
func (*DB) LoadLastBlockHeight ¶
LoadLastBlockHeight 获取最后一次扫描高度 已经扫描到这个高度
func (*DB) SearchBalance ¶
SearchBalance 搜索余额记录是否存在
func (*DB) SearchTransactions ¶
func (db *DB) SearchTransactions(txid string) (*Transactions, error)
SearchTransactions 搜索交易记录是否存在
type GlobalConf ¶
type GlobalConf struct { Client `toml:"client"` // 钱包相关配置 Scantraderecord `toml:"scantraderecord"` // 扫描交易记录配置 Collection `toml:"collection"` // 钱包归集配置 Contracts []Contract `toml:"contract"` // 合约 }
GlobalConf .
type OtherParam ¶
OtherParam .
type Scantraderecord ¶
type Scantraderecord struct { TimeIntervalSec int64 `toml:"time_interval_sec"` // 扫描间隔 GoroutineNum int64 `toml:"goroutine_num"` // 扫描协程数 MinScanBlock int64 `toml:"min_scan_block"` // 扫描交易记录起始位置 如果配置为正数 取最大值开始扫描 如果为负数 则取绝对值 从绝对值位置开始扫描,不取最大值开始扫描 }
Scantraderecord 扫描交易记录配置
type Service ¶
Service Trx 钱包信息
func (Service) GetNewAddress ¶
GetNewAddress 获取新地址
func (Service) GetRecords ¶
func (as Service) GetRecords(sTime, eTime int64) ([]util.SummaryData, error)
GetRecords 归集交易记录 中转记录
func (Service) ListTransactions ¶
ListTransactions 获取指定地址最近的交易记录
func (Service) SMD ¶
func (Service) SMD() smd.ServiceInfo
func (Service) SendToAddress ¶
SendToAddress 提币请求
func (Service) ValidateAddress ¶
func (as Service) ValidateAddress(addr string) util.ValidateAddress
ValidateAddress 校验地址
type Transactions ¶
type Transactions struct { ID int64 `xorm:"'id' pk autoincr" json:"-"` TxID string `xorm:"'tx_id'" json:"txid"` BlockHeight int64 `xorm:"'block_height'" json:"blockheight"` PublicKey string `xorm:"'public_key'" json:"publickey"` // 公钥新版字段 如果有就是新版 Address string `xorm:"'address' index" json:""` FromAddress string `xorm:"'from_address'" json:"fromaddress"` Contract string `xorm:"'contract' index"` // 哪种合约 Amount string `xorm:"'amount'" json:"amount"` Fee string `xorm:"'fee'" json:"fee"` // 保留字段 Timestamp int64 `xorm:"'timestamp'"` Type string `xorm:"'type'"` // send recive collect }
Transactions .