triam

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2019 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//币种
	Symbol    = "RIA"
	CurveType = owcrypt.ECC_CURVE_ED25519
	Decimal   = 7
)

Variables

This section is empty.

Functions

func NewSimpleAccount2

func NewSimpleAccount2(accountID string, sequence int64) txnbuild.SimpleAccount

Types

type AddrBalance

type AddrBalance struct {
	Address      string
	Balance      string
	TokenBalance string
	Index        int
}

func NewAddrAssetsBalance

func NewAddrAssetsBalance(b *openwallet.TokenBalance) *AddrBalance

func NewAddrBalance

func NewAddrBalance(b *openwallet.Balance) *AddrBalance

func (*AddrBalance) GetAddress

func (this *AddrBalance) GetAddress() string

func (*AddrBalance) ValidTokenBalance

func (this *AddrBalance) ValidTokenBalance() bool

type AddrBalanceInf

type AddrBalanceInf interface {
	SetTokenBalance(b *big.Int)
	GetAddress() string
	ValidTokenBalance() bool
}

type AddressDecoder

type AddressDecoder struct {
	// contains filtered or unexported fields
}

func NewAddressDecoder

func NewAddressDecoder(wm *WalletManager) *AddressDecoder

NewAddressDecoder 地址解析器

func (*AddressDecoder) PrivateKeyToWIF

func (decoder *AddressDecoder) PrivateKeyToWIF(priv []byte, isTestnet bool) (string, error)

PrivateKeyToWIF 私钥转WIF

func (*AddressDecoder) PublicKeyToAddress

func (decoder *AddressDecoder) PublicKeyToAddress(pub []byte, isTestnet bool) (string, error)

PublicKeyToAddress 公钥转地址

func (*AddressDecoder) RedeemScriptToAddress

func (decoder *AddressDecoder) RedeemScriptToAddress(pubs [][]byte, required uint64, isTestnet bool) (string, error)

RedeemScriptToAddress 多重签名赎回脚本转地址

func (*AddressDecoder) WIFToPrivateKey

func (decoder *AddressDecoder) WIFToPrivateKey(wif string, isTestnet bool) ([]byte, error)

WIFToPrivateKey WIF转私钥

type Block

type Block struct {
	Hash            string
	PrevBlockHash   string
	Time            int64
	Height          uint64
	TransactionsCnt uint64
	Transactions    []string
}

func NewBlock

func NewBlock(block hProtocol.Ledger) *Block

func (*Block) BlockHeader

func (b *Block) BlockHeader(symbol string) *openwallet.BlockHeader

BlockHeader 区块链头

type Client

type Client struct {
	BaseURL string
	Debug   bool
}

func (*Client) Get

func (c *Client) Get(path string, queryparams []interface{}) (*gjson.Result, error)

type ExtractResult

type ExtractResult struct {
	TxID        string
	BlockHeight uint64
	Success     bool
	// contains filtered or unexported fields
}

ExtractResult 扫描完成的提取结果

type SaveResult

type SaveResult struct {
	TxID        string
	BlockHeight uint64
	Success     bool
}

SaveResult result

type Transaction

type Transaction struct {
	Type        string `json:"type"`
	BlockHash   string
	BlockHeight uint64
	BlockTime   int64
	GenesisID   string                         `json:"genesisID"`
	Fee         uint64                         `json:"fee"`
	TxID        string                         `json:"tx"`
	From        string                         `json:"from"`
	Note        []byte                         `json:"note"`
	Payment     *models.PaymentTransactionType `json:"payment,omitempty"`
}

func NewTransaction

func NewTransaction(tx models.Transaction) *Transaction

type TransactionDecoder

type TransactionDecoder struct {
	openwallet.TransactionDecoderBase
	// contains filtered or unexported fields
}

func NewTransactionDecoder

func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder

NewTransactionDecoder 交易单解析器

func (*TransactionDecoder) CreateAssetsSummaryRawTransaction

func (decoder *TransactionDecoder) CreateAssetsSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)

汇总资产

func (*TransactionDecoder) CreateRawAssetsTransaction

func (decoder *TransactionDecoder) CreateRawAssetsTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

CreateRawTransaction 创建交易单

func (*TransactionDecoder) CreateRawSimpleTransaction

func (decoder *TransactionDecoder) CreateRawSimpleTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

CreateRawTransaction 创建交易单

func (*TransactionDecoder) CreateRawTransaction

func (decoder *TransactionDecoder) CreateRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

func (*TransactionDecoder) CreateSimpleSummaryRawTransaction

func (decoder *TransactionDecoder) CreateSimpleSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)

CreateSummaryRawTransaction 创建RIA汇总交易

func (*TransactionDecoder) CreateSummaryRawTransaction

func (decoder *TransactionDecoder) CreateSummaryRawTransaction(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransaction, error)

汇总币种

func (*TransactionDecoder) CreateSummaryRawTransactionWithError

func (decoder *TransactionDecoder) CreateSummaryRawTransactionWithError(wrapper openwallet.WalletDAI, sumRawTx *openwallet.SummaryRawTransaction) ([]*openwallet.RawTransactionWithError, error)

CreateSummaryRawTransactionWithError 创建汇总交易,返回能原始交易单数组(包含带错误的原始交易单)

func (*TransactionDecoder) GetRawTransactionFeeRate

func (decoder *TransactionDecoder) GetRawTransactionFeeRate() (feeRate string, unit string, err error)

GetRawTransactionFeeRate 获取交易单的费率

func (*TransactionDecoder) SignRawTransaction

func (decoder *TransactionDecoder) SignRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

SignRawTransaction 签名交易单

func (*TransactionDecoder) SubmitRawTransaction

func (decoder *TransactionDecoder) SubmitRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) (*openwallet.Transaction, error)

SendRawTransaction 广播交易单

func (*TransactionDecoder) VerifyRawTransaction

func (decoder *TransactionDecoder) VerifyRawTransaction(wrapper openwallet.WalletDAI, rawTx *openwallet.RawTransaction) error

VerifyRawTransaction 验证交易单,验证交易单并返回加入签名后的交易单

type TriamBlockScanner

type TriamBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

	RescanLastBlockCount uint64 //重扫上N个区块数量
	// contains filtered or unexported fields
}

TriamBlockScanner Algo block scanner

func NewTriamBlockScanner

func NewTriamBlockScanner(wm *WalletManager) *TriamBlockScanner

NewEOSBlockScanner create a block scanner

func (*TriamBlockScanner) AccountExists

func (bs *TriamBlockScanner) AccountExists(account string) bool

检查账户是否存在

func (*TriamBlockScanner) BatchExtractTransaction

func (bs *TriamBlockScanner) BatchExtractTransaction(blockHeight uint64, blockHash string, blockTime int64) error

BatchExtractTransaction 批量提取交易单 直接获取区块 Payment 操作

func (*TriamBlockScanner) ExtractTransaction

func (bs *TriamBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, tx horizon.Transaction, scanTargetFunc openwallet.BlockScanTargetFunc) ExtractResult

提取交易单

func (*TriamBlockScanner) ExtractTransactionData

func (bs *TriamBlockScanner) ExtractTransactionData(txid string, scanAddressFunc openwallet.BlockScanTargetFunc) (map[string][]*openwallet.TxExtractData, error)

ExtractTransactionData

func (*TriamBlockScanner) GetAssetBalance

func (bs *TriamBlockScanner) GetAssetBalance(accountId, assetsCode, issuerAccountId string) (string, error)

返回资产assets balance

func (*TriamBlockScanner) GetBalanceByAddress

func (bs *TriamBlockScanner) GetBalanceByAddress(address ...string) ([]*openwallet.Balance, error)

GetBalanceByAddress 查询地址余额

func (*TriamBlockScanner) GetBlockByHeight

func (bs *TriamBlockScanner) GetBlockByHeight(height uint64) (*Block, error)

func (*TriamBlockScanner) GetBlockHeight

func (bs *TriamBlockScanner) GetBlockHeight() (uint64, error)

GetBlockHeight 获取区块链高度

func (*TriamBlockScanner) GetCurrentBlock

func (bs *TriamBlockScanner) GetCurrentBlock() (*Block, error)

GetCurrentBlock 获取当前最新区块

func (*TriamBlockScanner) GetCurrentBlockHeader

func (bs *TriamBlockScanner) GetCurrentBlockHeader() (*openwallet.BlockHeader, error)

GetCurrentBlockHeader 获取当前区块高度

func (*TriamBlockScanner) GetGlobalMaxBlockHeight

func (bs *TriamBlockScanner) GetGlobalMaxBlockHeight() uint64

GetGlobalMaxBlockHeight 获取区块链全网最大高度

func (*TriamBlockScanner) GetNativeAssetBalance

func (bs *TriamBlockScanner) GetNativeAssetBalance(accountId string) (string, error)

返回主币balance

func (*TriamBlockScanner) GetOperationsByBlock

func (bs *TriamBlockScanner) GetOperationsByBlock(blockHeight uint64) ([]operations.Payment, int, error)

获取一个区块所有payment Operations 和 所有Operations的数量

func (*TriamBlockScanner) GetPayOperationByTx

func (bs *TriamBlockScanner) GetPayOperationByTx(txHash string) ([]operations.Payment, int, error)

获取一个区块所有transaction

func (*TriamBlockScanner) GetScannedBlockHeader

func (bs *TriamBlockScanner) GetScannedBlockHeader() (*openwallet.BlockHeader, error)

GetScannedBlockHeader 获取当前扫描的区块头

func (*TriamBlockScanner) GetScannedBlockHeight

func (bs *TriamBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*TriamBlockScanner) GetTransaction

func (bs *TriamBlockScanner) GetTransaction(hash string) (*Transaction, error)

GetTransaction

func (*TriamBlockScanner) GetTransactionByBlock

func (bs *TriamBlockScanner) GetTransactionByBlock(blockHeight uint64) ([]horizon.Transaction, error)

获取一个区块所有transaction

func (*TriamBlockScanner) InitExtractResult

func (bs *TriamBlockScanner) InitExtractResult(payment operations.Payment, feePayed string, memo string, blockHeight uint64, blockHash string, sourceKey string, result *ExtractResult, operate int64)

InitTronExtractResult operate = 0: 输入输出提取,1: 输入提取,2:输出提取

func (*TriamBlockScanner) RescanFailedRecord

func (bs *TriamBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*TriamBlockScanner) SaveUnscanRecord

func (bs *TriamBlockScanner) SaveUnscanRecord(record *UnscanRecord) error

SaveTxToWalletDB 保存交易记录到钱包数据库

func (*TriamBlockScanner) ScanBlock

func (bs *TriamBlockScanner) ScanBlock(height uint64) error

ScanBlock 扫描指定高度区块

func (*TriamBlockScanner) ScanBlockTask

func (bs *TriamBlockScanner) ScanBlockTask()

ScanBlockTask 扫描任务

func (*TriamBlockScanner) SetRescanBlockHeight

func (bs *TriamBlockScanner) SetRescanBlockHeight(height uint64) error

SetRescanBlockHeight 重置区块链扫描高度

type UnscanRecord

type UnscanRecord struct {
	ID          string `storm:"id"` // primary key
	BlockHeight uint64
	TxID        string
	Reason      string
}

UnscanRecords 扫描失败的区块及交易

func NewUnscanRecord

func NewUnscanRecord(height uint64, txID, reason string) *UnscanRecord

type WalletConfig

type WalletConfig struct {

	//币种
	Symbol string
	//精度
	Decimal int32

	//区块链数据文件
	BlockchainFile string

	//钱包服务API
	ServerAPI string

	//默认配置内容
	DefaultConfig string
	//曲线类型
	CurveType uint32
	//链ID
	Network string
	//固定手续费
	FixFees string

	AddressRetainAmount string
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(symbol string) *WalletConfig

type WalletManager

type WalletManager struct {
	openwallet.AssetsAdapterBase

	Config          *WalletConfig                   // 节点配置
	Decoder         openwallet.AddressDecoder       //地址编码器
	TxDecoder       openwallet.TransactionDecoder   //交易单编码器
	Log             *log.OWLogger                   //日志工具
	ContractDecoder openwallet.SmartContractDecoder //智能合约解析器
	Blockscanner    *TriamBlockScanner              //区块扫描器
	// contains filtered or unexported fields
}

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) BalanceModelType

func (wm *WalletManager) BalanceModelType() openwallet.BalanceModelType

BalanceModelType 余额模型类别

func (*WalletManager) CurveType

func (wm *WalletManager) CurveType() uint32

CurveType 曲线类型

func (*WalletManager) Decimal

func (wm *WalletManager) Decimal() int32

Decimal 小数位精度

func (*WalletManager) DeleteUnscanRecord

func (wm *WalletManager) DeleteUnscanRecord(height uint64) error

DeleteUnscanRecord 删除指定高度的未扫记录

func (*WalletManager) DeleteUnscanRecordNotFindTX

func (wm *WalletManager) DeleteUnscanRecordNotFindTX() error

DeleteUnscanRecordNotFindTX 删除未没有找到交易记录的重扫记录

func (*WalletManager) FullName

func (wm *WalletManager) FullName() string

FullName 币种全名

func (*WalletManager) GetAddressDecode

func (wm *WalletManager) GetAddressDecode() openwallet.AddressDecoder

GetAddressDecode 地址解析器

func (*WalletManager) GetAssetsLogger

func (wm *WalletManager) GetAssetsLogger() *log.OWLogger

GetAssetsLogger 获取资产账户日志工具

func (*WalletManager) GetBlockScanner

func (wm *WalletManager) GetBlockScanner() openwallet.BlockScanner

GetBlockScanner 获取区块链

func (*WalletManager) GetLocalBlock

func (wm *WalletManager) GetLocalBlock(height uint64) (*Block, error)

GetLocalBlock 获取本地区块数据

func (*WalletManager) GetLocalNewBlock

func (wm *WalletManager) GetLocalNewBlock() (uint64, string)

GetLocalNewBlock 获取本地记录的区块高度和hash

func (*WalletManager) GetSmartContractDecoder

func (wm *WalletManager) GetSmartContractDecoder() openwallet.SmartContractDecoder

GetSmartContractDecoder 获取智能合约解析器

func (*WalletManager) GetTransactionDecoder

func (wm *WalletManager) GetTransactionDecoder() openwallet.TransactionDecoder

GetTransactionDecoder 交易单解析器

func (*WalletManager) GetUnscanRecords

func (wm *WalletManager) GetUnscanRecords() ([]*UnscanRecord, error)

获取未扫记录

func (*WalletManager) InitAssetsConfig

func (wm *WalletManager) InitAssetsConfig() (config.Configer, error)

InitAssetsConfig 初始化默认配置

func (*WalletManager) LoadAssetsConfig

func (wm *WalletManager) LoadAssetsConfig(c config.Configer) error

LoadAssetsConfig 加载外部配置

func (*WalletManager) SaveLocalBlock

func (wm *WalletManager) SaveLocalBlock(block *Block)

SaveLocalBlock 记录本地新区块

func (*WalletManager) SaveLocalNewBlock

func (wm *WalletManager) SaveLocalNewBlock(blockHeight uint64, blockHash string)

SaveLocalNewBlock 记录区块高度和hash到本地

func (*WalletManager) Symbol

func (wm *WalletManager) Symbol() string

Symbol 币种标识

Directories

Path Synopsis
Package txnbuild implements transactions and operations on the Stellar network.
Package txnbuild implements transactions and operations on the Stellar network.
cmd/demo
Demo is an interactive demonstration of the Go SDK using the Stellar TestNet.
Demo is an interactive demonstration of the Go SDK using the Stellar TestNet.
cmd/demo/operations
Package demo is an interactive demonstration of the Go SDK using the Stellar TestNet.
Package demo is an interactive demonstration of the Go SDK using the Stellar TestNet.
examplehorizonclient
Package examplehorizonclient provides a dummy client for use with the GoDoc examples.
Package examplehorizonclient provides a dummy client for use with the GoDoc examples.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL