syscoin

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RPCServerCore     = 0 //RPC服务,bitcoin核心钱包
	RPCServerExplorer = 1 //RPC服务,insight-API
)
View Source
const (
	//币种
	Symbol    = "SYS"
	CurveType = owcrypt.ECC_CURVE_SECP256K1
	Decimals  = int32(8)
)

Variables

View Source
var (
	SYS_mainnetAddressP2PKH         = addressEncoder.AddressType{EncodeType: "base58", Alphabet: alphabet, ChecksumType: "doubleSHA256", HashType: "h160", HashLen: 20, Prefix: []byte{0x3f}, Suffix: nil}
	SYS_testnetAddressP2PKH         = addressEncoder.AddressType{EncodeType: "base58", Alphabet: alphabet, ChecksumType: "doubleSHA256", HashType: "h160", HashLen: 20, Prefix: []byte{0x41}, Suffix: nil}
	SYS_mainnetPrivateWIFCompressed = addressEncoder.AddressType{EncodeType: "base58", Alphabet: alphabet, ChecksumType: "doubleSHA256", HashType: "", HashLen: 32, Prefix: []byte{0x80}, Suffix: []byte{0x01}}
	SYS_testnetPrivateWIFCompressed = addressEncoder.AddressType{EncodeType: "base58", Alphabet: alphabet, ChecksumType: "doubleSHA256", HashType: "", HashLen: 32, Prefix: []byte{0xef}, Suffix: []byte{0x01}}
	SYS_mainnetAddressP2SH          = addressEncoder.AddressType{EncodeType: "base58", Alphabet: alphabet, ChecksumType: "doubleSHA256", HashType: "h160", HashLen: 20, Prefix: []byte{0x05}, Suffix: nil}
	SYS_testnetAddressP2SH          = addressEncoder.AddressType{EncodeType: "base58", Alphabet: alphabet, ChecksumType: "doubleSHA256", HashType: "h160", HashLen: 20, Prefix: []byte{0xc4}, Suffix: nil}
	SYS_mainnetAddressBech32V0      = addressEncoder.AddressType{EncodeType: "bech32", Alphabet: bech32Alphabet, ChecksumType: "sys", HashType: "h160", HashLen: 20, Prefix: []byte{0}, Suffix: nil}
	SYS_testnetAddressBech32V0      = addressEncoder.AddressType{EncodeType: "bech32", Alphabet: bech32Alphabet, ChecksumType: "tsys", HashType: "h160", HashLen: 20, Prefix: []byte{0}, Suffix: nil}
)
View Source
var (
	SYSMainnetAddressPrefix = btcTransaction.AddressPrefix{P2PKHPrefix: []byte{0x3f}, P2WPKHPrefix: []byte{0x05}, P2SHPrefix: nil, Bech32Prefix: "sys"}
	SYSTestnetAddressPrefix = btcTransaction.AddressPrefix{P2PKHPrefix: []byte{0x41}, P2WPKHPrefix: []byte{0xc4}, P2SHPrefix: nil, Bech32Prefix: "tsys"}
)

Functions

func BasicAuth added in v1.1.0

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.

func DecodeScript added in v1.1.0

func DecodeScript(script string) ([]byte, error)

Types

type AddressDecoderV2

type AddressDecoderV2 struct {
	*openwallet.AddressDecoderV2Base
	// contains filtered or unexported fields
}

AddressDecoderV2

func NewAddressDecoder

func NewAddressDecoder(wm *WalletManager) *AddressDecoderV2

NewAddressDecoder 地址解析器

func (*AddressDecoderV2) AddressDecode

func (dec *AddressDecoderV2) AddressDecode(addr string, opts ...interface{}) ([]byte, error)

AddressDecode 地址解析

func (*AddressDecoderV2) AddressEncode

func (dec *AddressDecoderV2) AddressEncode(hash []byte, opts ...interface{}) (string, error)

AddressEncode 地址编码

func (*AddressDecoderV2) AddressVerify

func (dec *AddressDecoderV2) AddressVerify(address string, opts ...interface{}) bool

AddressVerify 地址校验

func (*AddressDecoderV2) ScriptPubKeyToBech32Address

func (dec *AddressDecoderV2) ScriptPubKeyToBech32Address(scriptPubKey []byte) (string, error)

ScriptPubKeyToBech32Address scriptPubKey转Bech32地址

type BTCBlockScanNotificationObject added in v1.1.0

type BTCBlockScanNotificationObject interface {

	//BlockScanNotify 新区块扫描完成通知
	//@required
	BTCBlockScanNotify(block *Block, txs []*Transaction) error
}

BlockScanNotificationObject 扫描被通知对象

type BTCBlockScanner added in v1.1.0

type BTCBlockScanner struct {
	*openwallet.BlockScannerBase

	CurrentBlockHeight uint64 //当前区块高度

	IsScanMemPool        bool   //是否扫描交易池
	RescanLastBlockCount uint64 //重扫上N个区块数量

	//用于实现浏览器
	IsSkipFailedBlock bool                                    //是否跳过失败区块
	BTCBlockObservers map[BTCBlockScanNotificationObject]bool //观察者
	// contains filtered or unexported fields
}

BTCBlockScanner bitcoin的区块链扫描器

func NewBTCBlockScanner added in v1.1.0

func NewBTCBlockScanner(wm *WalletManager) *BTCBlockScanner

NewBTCBlockScanner 创建区块链扫描器

func (*BTCBlockScanner) BatchExtractTransaction added in v1.1.0

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

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

func (*BTCBlockScanner) DeleteUnscanRecord added in v1.1.0

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

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

func (*BTCBlockScanner) DeleteUnscanRecordNotFindTX added in v1.1.0

func (bs *BTCBlockScanner) DeleteUnscanRecordNotFindTX() error

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

func (*BTCBlockScanner) ExtractTransaction added in v1.1.0

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

ExtractTransaction 提取交易单

func (*BTCBlockScanner) ExtractTransactionData added in v1.1.0

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

func (*BTCBlockScanner) GetBalanceByAddress added in v1.1.0

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

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

func (*BTCBlockScanner) GetCurrentBlockHeader added in v1.1.0

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

GetCurrentBlockHeader 获取当前区块高度

func (*BTCBlockScanner) GetGlobalMaxBlockHeight added in v1.1.0

func (bs *BTCBlockScanner) GetGlobalMaxBlockHeight() uint64

func (*BTCBlockScanner) GetLocalBlock added in v1.1.0

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

GetLocalBlock 获取本地区块数据

func (*BTCBlockScanner) GetLocalNewBlock added in v1.1.0

func (bs *BTCBlockScanner) GetLocalNewBlock() (uint64, string, error)

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

func (*BTCBlockScanner) GetScannedBlockHeader added in v1.1.0

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

GetScannedBlockHeader 获取当前扫描的区块头

func (*BTCBlockScanner) GetScannedBlockHeight added in v1.1.0

func (bs *BTCBlockScanner) GetScannedBlockHeight() uint64

GetScannedBlockHeight 获取已扫区块高度

func (*BTCBlockScanner) GetTransactionsByAddress added in v1.1.0

func (bs *BTCBlockScanner) GetTransactionsByAddress(offset, limit int, coin openwallet.Coin, address ...string) ([]*openwallet.TxExtractData, error)

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

func (*BTCBlockScanner) GetUnscanRecords added in v1.1.0

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

获取未扫记录

func (*BTCBlockScanner) RescanFailedRecord added in v1.1.0

func (bs *BTCBlockScanner) RescanFailedRecord()

rescanFailedRecord 重扫失败记录

func (*BTCBlockScanner) Run added in v1.1.0

func (bs *BTCBlockScanner) Run() error

Run 运行

func (*BTCBlockScanner) SaveLocalBlock added in v1.1.0

func (bs *BTCBlockScanner) SaveLocalBlock(block *Block) error

SaveLocalBlock 记录本地新区块

func (*BTCBlockScanner) SaveLocalNewBlock added in v1.1.0

func (bs *BTCBlockScanner) SaveLocalNewBlock(blockHeight uint64, blockHash string) error

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

func (*BTCBlockScanner) SaveUnscanRecord added in v1.1.0

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

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

func (*BTCBlockScanner) ScanBlock added in v1.1.0

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

ScanBlock 扫描指定高度区块

func (*BTCBlockScanner) ScanBlockTask added in v1.1.0

func (bs *BTCBlockScanner) ScanBlockTask()

ScanBlockTask 扫描任务

func (*BTCBlockScanner) ScanTxMemPool added in v1.1.0

func (bs *BTCBlockScanner) ScanTxMemPool()

ScanTxMemPool 扫描交易内存池

func (*BTCBlockScanner) SetRescanBlockHeight added in v1.1.0

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

SetRescanBlockHeight 重置区块链扫描高度

func (*BTCBlockScanner) Stop added in v1.1.0

func (bs *BTCBlockScanner) Stop() error

//Stop 停止扫描

func (*BTCBlockScanner) SupportBlockchainDAI added in v1.1.0

func (bs *BTCBlockScanner) SupportBlockchainDAI() bool

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

type Block added in v1.1.0

type Block struct {
	Hash          string
	Confirmations uint64
	Merkleroot    string

	Previousblockhash string
	Height            uint64 `storm:"id"`
	Version           uint64
	Time              uint64
	Fork              bool
	// contains filtered or unexported fields
}

func (*Block) BlockHeader added in v1.1.0

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

BlockHeader 区块链头

type BlockchainInfo added in v1.1.0

type BlockchainInfo struct {
	Chain                string `json:"chain"`
	Blocks               uint64 `json:"blocks"`
	Headers              uint64 `json:"headers"`
	Bestblockhash        string `json:"bestblockhash"`
	Difficulty           string `json:"difficulty"`
	Mediantime           uint64 `json:"mediantime"`
	Verificationprogress string `json:"verificationprogress"`
	Chainwork            string `json:"chainwork"`
	Pruned               bool   `json:"pruned"`
}

BlockchainInfo 本地节点区块链信息

func NewBlockchainInfo added in v1.1.0

func NewBlockchainInfo(json *gjson.Result) *BlockchainInfo

type Client added in v1.1.0

type Client struct {
	BaseURL     string
	AccessToken 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 added in v1.1.0

func NewClient(url, token string, debug bool) *Client

func (*Client) Call added in v1.1.0

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 added in v1.1.0

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

type ContractDecoder added in v1.1.0

type ContractDecoder struct {
	*openwallet.SmartContractDecoderBase
	// contains filtered or unexported fields
}

func NewContractDecoder added in v1.1.0

func NewContractDecoder(wm *WalletManager) *ContractDecoder

NewContractDecoder 智能合约解析器

func (*ContractDecoder) GetTokenBalanceByAddress added in v1.1.0

func (decoder *ContractDecoder) GetTokenBalanceByAddress(contract openwallet.SmartContract, address ...string) ([]*openwallet.TokenBalance, error)

type Explorer added in v1.1.0

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

Explorer是由bitpay的insight-API提供区块数据查询接口 具体接口说明查看https://github.com/bitpay/insight-api

func NewExplorer added in v1.1.0

func NewExplorer(url string, debug bool) *Explorer

func (*Explorer) Call added in v1.1.0

func (b *Explorer) Call(path string, request interface{}, method string) (*gjson.Result, error)

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

type ExtractResult added in v1.1.0

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

ExtractResult 扫描完成的提取结果

type OmniTransaction added in v1.1.0

type OmniTransaction struct {
	TxID             string `json:"txid"`
	Fees             string `json:"fee"`
	SendingAddress   string `json:"sendingaddress"`
	ReferenceAddress string `json:"referenceaddress"`
	IsMine           string `json:"ismine"`
	Version          uint64 `json:"version"`
	TypeInt          uint64 `json:"type_int"`
	TypeStr          string `json:"type"`
	PropertyId       uint64 `json:"propertyid"`
	Divisible        bool   `json:"divisible"`
	Amount           string `json:"amount"`
	Valid            bool   `json:"valid"`
	BlockTime        int64  `json:"blocktime"`
	PositionInBlock  uint64 `json:"positioninblock"`
	BlockHash        string `json:"blockhash"`
	Block            uint64 `json:"block"`
	Confirmations    uint64 `json:"confirmations"`
}

func NewOmniTx added in v1.1.0

func NewOmniTx(json *gjson.Result) *OmniTransaction

type Response added in v1.1.0

type Response struct {
	Code    int         `json:"code,omitempty"`
	Error   interface{} `json:"error,omitempty"`
	Result  interface{} `json:"result,omitempty"`
	Message string      `json:"message,omitempty"`
	Id      string      `json:"id,omitempty"`
}

type SaveResult added in v1.1.0

type SaveResult struct {
	TxID        string
	BlockHeight uint64
	Success     bool
}

SaveResult 保存结果

type Transaction added in v1.1.0

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

	Vins  []*Vin
	Vouts []*Vout
}

type TransactionDecoder added in v1.1.0

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

func NewTransactionDecoder added in v1.1.0

func NewTransactionDecoder(wm *WalletManager) *TransactionDecoder

NewTransactionDecoder 交易单解析器

func (*TransactionDecoder) CreateBTCRawTransaction added in v1.1.0

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

CreateRawTransaction 创建交易单

func (*TransactionDecoder) CreateBTCSummaryRawTransaction added in v1.1.0

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

CreateBTCSummaryRawTransaction 创建BTC汇总交易

func (*TransactionDecoder) CreateOmniRawTransaction added in v1.1.0

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

CreateOmniRawTransaction 创建Omni交易单

func (*TransactionDecoder) CreateOmniSummaryRawTransaction added in v1.1.0

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

CreateOmniSummaryRawTransaction 创建Omni汇总交易

func (*TransactionDecoder) CreateRawTransaction added in v1.1.0

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

CreateRawTransaction 创建交易单

func (*TransactionDecoder) CreateSummaryRawTransaction added in v1.1.0

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

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

func (*TransactionDecoder) CreateSummaryRawTransactionWithError added in v1.1.0

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

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

func (*TransactionDecoder) GetRawTransactionFeeRate added in v1.1.0

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

GetRawTransactionFeeRate 获取交易单的费率

func (*TransactionDecoder) SignBTCRawTransaction added in v1.1.0

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

SignRawTransaction 签名交易单

func (*TransactionDecoder) SignOmniRawTransaction added in v1.1.0

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

SignOmniRawTransaction 签名交易单

func (*TransactionDecoder) SignRawTransaction added in v1.1.0

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

SignRawTransaction 签名交易单

func (*TransactionDecoder) SubmitRawTransaction added in v1.1.0

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

SendRawTransaction 广播交易单

func (*TransactionDecoder) VerifyBTCRawTransaction added in v1.1.0

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

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

func (*TransactionDecoder) VerifyOmniRawTransaction added in v1.1.0

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

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

func (*TransactionDecoder) VerifyRawTransaction added in v1.1.0

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

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

type Unspent added in v1.1.0

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        string `json:"amount"`
	Confirmations uint64 `json:"confirmations"`
	Spendable     bool   `json:"spendable"`
	Solvable      bool   `json:"solvable"`
	HDAddress     openwallet.Address
}

Unspent 未花记录

func NewUnspent added in v1.1.0

func NewUnspent(json *gjson.Result) *Unspent

type UnspentSort added in v1.1.0

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

func (UnspentSort) Len added in v1.1.0

func (s UnspentSort) Len() int

func (UnspentSort) Less added in v1.1.0

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

func (UnspentSort) Swap added in v1.1.0

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

type User added in v1.1.0

type User struct {
	UserKey string `storm:"id"`     // primary key
	Group   string `storm:"index"`  // this field will be indexed
	Email   string `storm:"unique"` // this field will be indexed with a unique constraint
	Name    string // this field will not be indexed
	Age     int    `storm:"index"`
}

type Vin added in v1.1.0

type Vin struct {
	Coinbase string
	TxID     string
	Vout     uint64
	N        uint64
	Addr     string
	Value    string
}

type Vout added in v1.1.0

type Vout struct {
	N            uint64
	Addr         string
	Value        string
	ScriptPubKey string
	Type         string
}

type WalletConfig added in v1.1.0

type WalletConfig struct {

	//币种
	Symbol    string
	MasterKey string

	//RPC认证账户名
	RpcUser string
	//RPC认证账户密码
	RpcPassword string
	//证书目录
	CertsDir string

	//rpc证书
	CertFileName string
	//区块链数据文件
	BlockchainFile string
	//是否测试网络
	IsTestNet bool
	// 核心钱包是否只做监听
	CoreWalletWatchOnly bool
	//最大的输入数量
	MaxTxInputs int
	//本地数据库文件路径
	DBPath string

	//钱包服务API
	ServerAPI string
	//钱包安装的路径
	NodeInstallPath string
	//钱包数据文件目录
	WalletDataPath string
	//汇总阀值
	Threshold decimal.Decimal
	//汇总地址
	SumAddress string
	//汇总执行间隔时间
	CycleSeconds time.Duration
	//默认配置内容
	DefaultConfig string
	//曲线类型
	CurveType uint32
	//核心钱包密码,配置有值用于自动解锁钱包
	WalletPassword string
	//后台数据源类型
	RPCServerType int
	//s是否支持隔离验证
	SupportSegWit bool
	//Omni代币转账最低成本
	OmniTransferCost string
	//OmniCore API
	OmniCoreAPI string
	//Omni rpc user
	OmniRPCUser string
	//Omni rpc password
	OmniRPCPassword string
	//是否支持omni
	OmniSupport bool
	//主网地址前缀
	MainNetAddressPrefix btcTransaction.AddressPrefix
	//测试网地址前缀
	TestNetAddressPrefix btcTransaction.AddressPrefix
	//小数位精度
	Decimals int32
	//最低手续费
	MinFees decimal.Decimal
	//数据目录
	DataDir string
	// contains filtered or unexported fields
}

func NewConfig added in v1.1.0

func NewConfig(symbol string, curveType uint32, decimals int32) *WalletConfig

func (*WalletConfig) InitConfig added in v1.1.0

func (wc *WalletConfig) InitConfig()

initConfig 初始化配置文件

func (*WalletConfig) PrintConfig added in v1.1.0

func (wc *WalletConfig) PrintConfig() error

printConfig Print config information

type WalletManager

type WalletManager struct {
	openwallet.AssetsAdapterBase

	Storage         *hdkeystore.HDKeystore        //秘钥存取
	WalletClient    *Client                       // 节点客户端
	OnmiClient      *Client                       // Omni代币节点客户端
	ExplorerClient  *Explorer                     // 浏览器API客户端
	Config          *WalletConfig                 //钱包管理配置
	WalletsInSum    map[string]*openwallet.Wallet //参与汇总的钱包
	Blockscanner    *BTCBlockScanner              //区块扫描器
	DecoderV2       openwallet.AddressDecoderV2   //地址编码器V2
	TxDecoder       openwallet.TransactionDecoder //交易单编码器
	Log             *log.OWLogger                 //日志工具
	ContractDecoder *ContractDecoder              //智能合约解析器
}

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) AddMultiSigAddress added in v1.1.0

func (wm *WalletManager) AddMultiSigAddress(required uint64, addresses []string) (string, string, error)

AddMultiSigAddress 创建多签地址

func (*WalletManager) AddWalletInSummary added in v1.1.0

func (wm *WalletManager) AddWalletInSummary(wid string, wallet *openwallet.Wallet)

AddWalletInSummary 添加汇总钱包账户

func (*WalletManager) BackupWallet added in v1.1.0

func (wm *WalletManager) BackupWallet(walletID string) (string, error)

BackupWallet 备份数据

func (*WalletManager) BackupWalletData added in v1.1.0

func (wm *WalletManager) BackupWalletData(dest string) error

BackupWalletData 备份钱包

func (*WalletManager) BuildTransaction added in v1.1.0

func (wm *WalletManager) BuildTransaction(utxos []*Unspent, to []string, change string, amount []decimal.Decimal, fees decimal.Decimal) (string, decimal.Decimal, error)

BuildTransaction 构建交易单

func (*WalletManager) CreateNewWallet added in v1.1.0

func (wm *WalletManager) CreateNewWallet(name, password string) (*openwallet.Wallet, string, error)

CreateNewWallet 创建钱包

func (*WalletManager) CreateReceiverAddress added in v1.1.0

func (wm *WalletManager) CreateReceiverAddress(account string) (string, error)

CreateReceiverAddress 给指定账户创建地址

func (*WalletManager) CurveType added in v1.1.0

func (wm *WalletManager) CurveType() uint32

CurveType 曲线类型

func (*WalletManager) Decimal added in v1.1.0

func (wm *WalletManager) Decimal() int32

小数位精度

func (*WalletManager) DumpWallet added in v1.1.0

func (wm *WalletManager) DumpWallet(filename string) error

DumpWallet 导出钱包所有私钥文件

func (*WalletManager) EncryptWallet added in v1.1.0

func (wm *WalletManager) EncryptWallet(password string) error

EncryptWallet 通过密码加密钱包,只在第一次加密码时才有效

func (*WalletManager) EstimateFee added in v1.1.0

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

EstimateFee 预估手续费

func (*WalletManager) EstimateFeeRate added in v1.1.0

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

EstimateFeeRate 预估的没KB手续费率

func (*WalletManager) FullName

func (wm *WalletManager) FullName() string

FullName 币种全名

func (*WalletManager) GenerateSeed added in v1.1.0

func (wm *WalletManager) GenerateSeed() []byte

generateSeed 创建种子

func (*WalletManager) GetAddressBalance added in v1.1.0

func (wm *WalletManager) GetAddressBalance(walletID, address string) string

GetAddressBalance 获取地址余额

func (*WalletManager) GetAddressDecoderV2 added in v1.1.0

func (wm *WalletManager) GetAddressDecoderV2() openwallet.AddressDecoderV2

AddressDecode 地址解析器

func (*WalletManager) GetAddressesByAccount added in v1.1.0

func (wm *WalletManager) GetAddressesByAccount(walletID string) ([]string, error)

func (*WalletManager) GetAssetsLogger added in v1.1.0

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

GetAssetsLogger 获取资产账户日志工具

func (*WalletManager) GetBlock added in v1.1.0

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

GetBlock 获取区块数据

func (*WalletManager) GetBlockChainInfo added in v1.1.0

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

GetBlockChainInfo 获取钱包区块链信息

func (*WalletManager) GetBlockHash added in v1.1.0

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

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

func (*WalletManager) GetBlockHeight added in v1.1.0

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

GetBlockHeight 获取区块链高度

func (*WalletManager) GetBlockScanner added in v1.1.0

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

GetBlockScanner 获取区块链

func (*WalletManager) GetCoreWalletinfo added in v1.1.0

func (wm *WalletManager) GetCoreWalletinfo() error

GetCoreWalletinfo 获取核心钱包节点信息

func (*WalletManager) GetNetworkInfo added in v1.1.0

func (wm *WalletManager) GetNetworkInfo() error

GetNetworkInfo 获取网络信息

func (*WalletManager) GetOmniBalance added in v1.1.0

func (wm *WalletManager) GetOmniBalance(propertyId uint64, address string) (decimal.Decimal, error)

func (*WalletManager) GetOmniBestBlockHash added in v1.1.0

func (wm *WalletManager) GetOmniBestBlockHash() (string, error)

GetOmniBestBlockHash

func (*WalletManager) GetOmniBlockHash added in v1.1.0

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

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

func (*WalletManager) GetOmniBlockHeight added in v1.1.0

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

GetOmniBlockHeight

func (*WalletManager) GetOmniInfo added in v1.1.0

func (wm *WalletManager) GetOmniInfo() (*gjson.Result, error)

GetOmniInfo

func (*WalletManager) GetOmniProperty added in v1.1.0

func (wm *WalletManager) GetOmniProperty(propertyId uint64) (*gjson.Result, error)

GetOmniProperty 获取Omni资产信息

func (*WalletManager) GetOmniTransaction added in v1.1.0

func (wm *WalletManager) GetOmniTransaction(txid string) (*OmniTransaction, error)

func (*WalletManager) GetSmartContractDecoder added in v1.1.0

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

GetSmartContractDecoder 获取智能合约解析器

func (*WalletManager) GetTransaction added in v1.1.0

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

GetTransaction 获取交易单

func (*WalletManager) GetTransactionDecoder added in v1.1.0

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

TransactionDecoder 交易单解析器

func (*WalletManager) GetTxIDsInMemPool added in v1.1.0

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

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

func (*WalletManager) GetTxOut added in v1.1.0

func (wm *WalletManager) GetTxOut(txid string, vout uint64) (*Vout, error)

GetTxOut 获取交易单输出信息,用于追溯交易单输入源头

func (*WalletManager) GetWalletBalance added in v1.1.0

func (wm *WalletManager) GetWalletBalance(accountID string) string

GetWalletBalance 获取钱包余额

func (*WalletManager) GetWalletInfo added in v1.1.0

func (wm *WalletManager) GetWalletInfo(walletID string) (*openwallet.Wallet, error)

GetWalletInfo 获取钱包列表

func (*WalletManager) GetWallets added in v1.1.0

func (wm *WalletManager) GetWallets() ([]*openwallet.Wallet, error)

GetWallets 获取钱包列表

func (*WalletManager) ImportAddress added in v1.1.0

func (wm *WalletManager) ImportAddress(address, account string) error

ImportAddress 导入地址核心钱包

func (*WalletManager) ImportMulti added in v1.1.0

func (wm *WalletManager) ImportMulti(addresses []*openwallet.Address, keys []string, watchOnly bool) ([]int, error)

ImportMulti 批量导入地址和私钥

func (*WalletManager) ImportPrivKey added in v1.1.0

func (wm *WalletManager) ImportPrivKey(wif, walletID string) error

ImportPrivKey 导入私钥

func (*WalletManager) ImportWallet added in v1.1.0

func (wm *WalletManager) ImportWallet(filename string) error

ImportWallet 导入钱包私钥文件

func (*WalletManager) InitAssetsConfig added in v1.1.0

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

InitAssetsConfig 初始化默认配置

func (*WalletManager) IsHaveOmniAssets added in v1.1.0

func (wm *WalletManager) IsHaveOmniAssets(address string) bool

IsHaveOmniAssets 是否拥有Omni资产

func (*WalletManager) KeyPoolRefill added in v1.1.0

func (wm *WalletManager) KeyPoolRefill(keyPoolSize uint64) error

KeyPoolRefill 重新填充私钥池

func (*WalletManager) ListAddresses

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

func (*WalletManager) ListUnspent added in v1.1.0

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

ListUnspent 获取未花记录

func (*WalletManager) ListUnspentFromLocalDB added in v1.1.0

func (wm *WalletManager) ListUnspentFromLocalDB(walletID string) ([]*Unspent, error)

ListUnspentFromLocalDB 查询本地数据库的未花记录

func (*WalletManager) LoadAssetsConfig added in v1.1.0

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

LoadAssetsConfig 加载外部配置

func (*WalletManager) LoadConfig added in v1.1.0

func (wm *WalletManager) LoadConfig() error

loadConfig 读取配置

func (*WalletManager) LockWallet added in v1.1.0

func (wm *WalletManager) LockWallet() error

LockWallet 锁钱包

func (*WalletManager) NewBlock added in v1.1.0

func (wm *WalletManager) NewBlock(json *gjson.Result) *Block

func (*WalletManager) RebuildWalletUnspent added in v1.1.0

func (wm *WalletManager) RebuildWalletUnspent(walletID string) error

RebuildWalletUnspent 批量插入未花记录到本地

func (*WalletManager) RestoreWallet added in v1.1.0

func (wm *WalletManager) RestoreWallet(keyFile, dbFile, datFile, password string) error

RestoreWallet 恢复钱包

func (*WalletManager) SendRawTransaction added in v1.1.0

func (wm *WalletManager) SendRawTransaction(txHex string) (string, error)

SendRawTransaction 广播交易

func (*WalletManager) SendToAddress added in v1.1.0

func (wm *WalletManager) SendToAddress(address string, amount uint64) (string, error)

SendToAddress

func (*WalletManager) SignRawTransactionInCoreWallet added in v1.1.0

func (wm *WalletManager) SignRawTransactionInCoreWallet(txHex, walletID string, key *hdkeystore.HDKey, utxos []*Unspent) (string, error)

SignRawTransactionInCoreWallet 钱包交易单

func (*WalletManager) Symbol added in v1.1.0

func (wm *WalletManager) Symbol() string

Symbol 币种标识

func (*WalletManager) UnlockWallet added in v1.1.0

func (wm *WalletManager) UnlockWallet(passphrase string, seconds int) error

UnlockWallet 解锁钱包

Jump to

Keyboard shortcuts

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