fiiicoin

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//币种
	Symbol    = "FIII"
	CurveType = owcrypt.ECC_CURVE_ED25519
	Decimals  = int32(8)
)

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(username, password string) string

See 2 (end of page 4) http://www.ietf.org/rfc/rfc2617.txt "To receive authorization, the client sends the userid and password, separated by a single colon (":") character, within a base64 encoded string in the credentials." It is not meant to be urlencoded.

Types

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) ScriptPubKeyToBech32Address

func (decoder *AddressDecoder) ScriptPubKeyToBech32Address(scriptPubKey []byte) (string, error)

ScriptPubKeyToBech32Address scriptPubKey转Bech32地址

func (*AddressDecoder) WIFToPrivateKey

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

WIFToPrivateKey WIF转私钥

type Block

type Block struct {
	Hash              string
	Merkleroot        string
	Previousblockhash string
	Height            uint64 `storm:"id"`
	Version           uint64
	Time              uint64
	Fork              bool
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(json *gjson.Result) *Block

func (*Block) BlockHeader

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

BlockHeader 区块链头

type BlockchainInfo

type BlockchainInfo struct {
	IsRunning               bool   // P2P网络是否运行
	Connections             uint64 // 当前连接的节点数
	LocalLastBlockHeight    uint64 // 本地节点最新的区块高度
	LocalLastBlockTime      uint64 // 本地节点最新的区块时间
	TempBlockCount          uint64 //本地节点中临时区块的数量
	TempBlockHeights        string //本地节点中临时区块的区块高度集合,高度按升序排序,以逗号连接,比如 "1,2,3"
	RemoteLatestBlockHeight uint64 // 网络上最新的区块高度
	TimeOffset              int64  // 当前节点与网络上最新区块的时间差

}

BlockchainInfo 本地节点区块链信息

func NewBlockchainInfo

func NewBlockchainInfo(json *gjson.Result) *BlockchainInfo

type Client

type Client struct {
	BaseURL string
	Debug   bool
	// contains filtered or unexported fields
}

A Client is a Bitcoin RPC client. It performs RPCs over HTTP using JSON request and responses. A Client must be configured with a secret token to authenticate with other Cores on the network.

func NewClient

func NewClient(url string, debug bool) *Client

func (*Client) Call

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

Call calls a remote procedure on another node, specified by the path.

type ClientInterface

type ClientInterface interface {
	Call(path string, request []interface{}) (*gjson.Result, error)
}

type ExtractResult

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

ExtractResult 扫描完成的提取结果

type FIIIBlockScanner

type FIIIBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

	IsScanMemPool        bool   //是否扫描交易池
	RescanLastBlockCount uint64 //重扫上N个区块数量
	// contains filtered or unexported fields
}

FIIIBlockScanner fiiicoin的区块链扫描器

func NewFIIIBlockScanner

func NewFIIIBlockScanner(wm *WalletManager) *FIIIBlockScanner

NewFIIIBlockScanner 创建区块链扫描器

func (*FIIIBlockScanner) BatchExtractTransaction

func (bs *FIIIBlockScanner) BatchExtractTransaction(blockHeight uint64, blockHash string, txs []string) error

BatchExtractTransaction 批量提取交易单 fiiicoin 1M的区块链可以容纳3000笔交易,批量多线程处理,速度更快

func (*FIIIBlockScanner) DeleteUnscanRecord added in v1.1.0

func (bs *FIIIBlockScanner) DeleteUnscanRecord(height uint64) error

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

func (*FIIIBlockScanner) ExtractTransaction

func (bs *FIIIBlockScanner) ExtractTransaction(blockHeight uint64, blockHash string, txid string, scanAddressFunc openwallet.BlockScanAddressFunc) ExtractResult

ExtractTransaction 提取交易单

func (*FIIIBlockScanner) ExtractTransactionData

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

func (*FIIIBlockScanner) GetBalanceByAddress

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

GetAssetsAccountBalanceByAddress 查询账户相关地址的交易记录

func (*FIIIBlockScanner) GetCurrentBlockHeader

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

GetCurrentBlockHeader 获取当前区块高度

func (*FIIIBlockScanner) GetGlobalMaxBlockHeight

func (bs *FIIIBlockScanner) GetGlobalMaxBlockHeight() uint64

func (*FIIIBlockScanner) GetLocalBlock added in v1.1.0

func (bs *FIIIBlockScanner) GetLocalBlock(height uint64) (*Block, error)

GetLocalBlock 获取本地区块数据

func (*FIIIBlockScanner) GetLocalBlockHead added in v1.1.0

func (bs *FIIIBlockScanner) GetLocalBlockHead() (uint64, string, error)

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

func (*FIIIBlockScanner) GetScannedBlockHeader

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

GetScannedBlockHeader 获取当前扫描的区块头

func (*FIIIBlockScanner) GetScannedBlockHeight

func (bs *FIIIBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*FIIIBlockScanner) GetUnscanRecords added in v1.1.0

func (bs *FIIIBlockScanner) GetUnscanRecords() ([]*openwallet.UnscanRecord, error)

func (*FIIIBlockScanner) RescanFailedRecord

func (bs *FIIIBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*FIIIBlockScanner) SaveLocalBlock added in v1.1.0

func (bs *FIIIBlockScanner) SaveLocalBlock(blockHeader *Block) error

SaveLocalBlock 记录本地新区块

func (*FIIIBlockScanner) SaveLocalBlockHead added in v1.1.0

func (bs *FIIIBlockScanner) SaveLocalBlockHead(blockHeight uint64, blockHash string) error

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

func (*FIIIBlockScanner) SaveUnscanRecord

func (bs *FIIIBlockScanner) SaveUnscanRecord(record *openwallet.UnscanRecord) error

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

func (*FIIIBlockScanner) ScanBlock

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

ScanBlock 扫描指定高度区块

func (*FIIIBlockScanner) ScanBlockTask

func (bs *FIIIBlockScanner) ScanBlockTask()

ScanBlockTask 扫描任务

func (*FIIIBlockScanner) ScanTxMemPool

func (bs *FIIIBlockScanner) ScanTxMemPool()

ScanTxMemPool 扫描交易内存池

func (*FIIIBlockScanner) SetRescanBlockHeight

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

SetRescanBlockHeight 重置区块链扫描高度

func (*FIIIBlockScanner) SupportBlockchainDAI added in v1.1.0

func (bs *FIIIBlockScanner) SupportBlockchainDAI() bool

SupportBlockchainDAI 支持外部设置区块链数据访问接口 @optional

type SaveResult

type SaveResult struct {
	TxID        string
	BlockHeight uint64
	Success     bool
}

SaveResult 保存结果

type Transaction

type Transaction struct {
	TxID          string
	Size          uint64
	Version       uint64
	LockTime      int64
	Hex           string
	BlockHash     string
	BlockHeight   uint64
	Confirmations uint64
	Blocktime     int64
	Fees          uint64
	Decimals      int32
	Timestamp     int64
	ExpiredTime   int64
	IsDiscarded   bool

	Vins  []*Vin
	Vouts []*Vout
}

type TransactionDecoder

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

func NewTransactionDecoder

func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder

NewTransactionDecoder 交易单解析器

func (*TransactionDecoder) CreateFIIIRawTransaction

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

CreateRawTransaction 创建交易单

func (*TransactionDecoder) CreateFIIISummaryRawTransaction

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

CreateFIIISummaryRawTransaction 创建BTC汇总交易

func (*TransactionDecoder) CreateRawTransaction

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

CreateRawTransaction 创建交易单

func (*TransactionDecoder) CreateSummaryRawTransaction

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

CreateSummaryRawTransaction 创建汇总交易,返回原始交易单数组

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) SignFIIIRawTransaction

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

SignRawTransaction 签名交易单

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) VerifyFIIIRawTransaction

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

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

func (*TransactionDecoder) VerifyRawTransaction

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

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

type Unspent

type Unspent struct {

	/*
			{
		        "txid" : "d54994ece1d11b19785c7248868696250ab195605b469632b7bd68130e880c9a",
		        "vout" : 1,
		        "address" : "mgnucj8nYqdrPFh2JfZSB1NmUThUGnmsqe",
		        "account" : "test label",
		        "scriptPubKey" : "76a9140dfc8bafc8419853b34d5e072ad37d1a5159f58488ac",
		        "amount" : 0.00010000,
		        "confirmations" : 6210,
		        "spendable" : true,
		        "solvable" : true
		    }
	*/
	Key           string `storm:"id"`
	TxID          string `json:"txid"`
	Vout          uint64 `json:"vout"`
	Address       string `json:"address"`
	AccountID     string `json:"account" storm:"index"`
	ScriptPubKey  string `json:"scriptPubKey"`
	Amount        uint64 `json:"amount"`
	Confirmations uint64 `json:"confirmations"`
	Spendable     bool   `json:"spendable"`
	Solvable      bool   `json:"solvable"`
}

Unspent 未花记录

func NewUnspent

func NewUnspent(json *gjson.Result) *Unspent

type UnspentSort

type UnspentSort struct {
	Values     []*Unspent
	Comparator func(a, b *Unspent) int
}

func (UnspentSort) Len

func (s UnspentSort) Len() int

func (UnspentSort) Less

func (s UnspentSort) Less(i, j int) bool

func (UnspentSort) Swap

func (s UnspentSort) Swap(i, j int)

type Vin

type Vin struct {
	TxID   string
	Vout   uint64
	N      uint64
	Addr   string
	Amount uint64
	Size   uint64
}

type Vout

type Vout struct {
	Vout        uint64
	Addr        string
	Amount      uint64
	LockScript  string
	Spent       bool
	IsDiscarded bool
}

type WalletConfig

type WalletConfig struct {

	//币种
	Symbol string

	//钱包服务API
	ServerAPI string
	//默认配置内容
	DefaultConfig string
	//曲线类型
	CurveType uint32
	//是否测试网
	IsTestNet bool
	//最大的输入数量
	MaxTxInputs int
	//数据目录
	DataDir string
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(symbol string) *WalletConfig

type WalletManager

type WalletManager struct {
	openwallet.AssetsAdapterBase

	WalletClient *Client                       // 节点客户端
	Config       *WalletConfig                 //钱包管理配置
	Blockscanner *FIIIBlockScanner             //区块扫描器
	Decoder      *AddressDecoder               //地址编码器
	TxDecoder    openwallet.TransactionDecoder //交易单编码器
	Log          *log.OWLogger                 //日志工具
}

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) AddWatchOnlyAddress

func (wm *WalletManager) AddWatchOnlyAddress(publickey string) error

AddWatchOnlyAddress 导入地址核心钱包

func (*WalletManager) BroadcastTransaction

func (wm *WalletManager) BroadcastTransaction(msg interface{}) error

BroadcastTransaction 广播交易

func (*WalletManager) CreateRawTransaction

func (wm *WalletManager) CreateRawTransaction(senders []Unspent, receivers map[string]uint64, changeAddress string, feeRate uint64) (*gjson.Result, error)

func (*WalletManager) CurveType

func (wm *WalletManager) CurveType() uint32

CurveType 曲线类型

func (*WalletManager) Decimal

func (wm *WalletManager) Decimal() int32

小数位精度

func (*WalletManager) EstimateFee

func (wm *WalletManager) EstimateFee(inputs, outputs int64, feeRate decimal.Decimal) (decimal.Decimal, error)

EstimateFee 预估手续费

func (*WalletManager) EstimateFeeRate

func (wm *WalletManager) EstimateFeeRate() (decimal.Decimal, error)

EstimateFeeRate 预估的没KB手续费率

func (*WalletManager) ExportAddresses

func (wm *WalletManager) ExportAddresses() ([]string, error)

ExportAddresses 导入地址核心钱包

func (*WalletManager) FullName

func (wm *WalletManager) FullName() string

FullName 币种全名

func (*WalletManager) GetAccountByAddress

func (wm *WalletManager) GetAccountByAddress(address string) (uint64, error)

GetAccountByAddress

func (*WalletManager) GetAddressDecode

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

AddressDecode 地址解析器

func (*WalletManager) GetAddressesByTag

func (wm *WalletManager) GetAddressesByTag(tag string) ([]string, error)

func (*WalletManager) GetAssetsLogger

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

GetAssetsLogger 获取资产账户日志工具

func (*WalletManager) GetBlock

func (wm *WalletManager) GetBlock(hash string) (*Block, error)

GetBlock 获取区块数据

func (*WalletManager) GetBlockChainInfo

func (wm *WalletManager) GetBlockChainInfo() (*BlockchainInfo, error)

GetBlockChainInfo 获取钱包区块链信息

func (*WalletManager) GetBlockHash

func (wm *WalletManager) GetBlockHash(height uint64) (string, error)

GetBlockHash 根据区块高度获得区块hash

func (*WalletManager) GetBlockHeight

func (wm *WalletManager) GetBlockHeight() (uint64, error)

GetBlockHeight 获取区块链高度

func (*WalletManager) GetBlockScanner

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

GetBlockScanner 获取区块链

func (*WalletManager) GetTransaction

func (wm *WalletManager) GetTransaction(txid string) (*Transaction, error)

GetTransaction 获取交易单

func (*WalletManager) GetTransactionDecoder

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

TransactionDecoder 交易单解析器

func (*WalletManager) GetTxIDsInMemPool

func (wm *WalletManager) GetTxIDsInMemPool() ([]string, error)

GetTxIDsInMemPool 获取待处理的交易池中的交易单IDs

func (*WalletManager) InitAssetsConfig

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

InitAssetsConfig 初始化默认配置

func (*WalletManager) ListUnspent

func (wm *WalletManager) ListUnspent(min uint64, addresses ...string) ([]*Unspent, error)

ListUnspent 获取未花记录

func (*WalletManager) LoadAssetsConfig

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

LoadAssetsConfig 加载外部配置

func (*WalletManager) Symbol

func (wm *WalletManager) Symbol() string

Symbol 币种标识

Jump to

Keyboard shortcuts

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