bbrpc

package module
v1.2.0-beta.16 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: BSD-3-Clause Imports: 24 Imported by: 1

README

bbrpc

BigBang blockchain (https://github.com/bigbangcore/BigBang) RPC client for golang! BigBang RPC >> bbrpc.

Notice

使用这个库您需要自行承担潜在的bug带来的风险

TODO

  • more rpc method support
  • websocket rpc support
  • full rpc method test
  • performance test
  • full field match verify
  • CI

测试

需要bigbang 在$PATH 下,即可以直接从命令行运行bigbang

基本测测试思路:go 启动bigbang,通过rpc交互,验证逻辑符合bibang规则

使用

client, err := bbrpc.NewClient(&bbrpc.ConnConfig{...})
tShouldNil(t, err, "failed to new rpc client")
defer client.Shutdown() //建议在系统关闭时调用shutdown

api 参考 https://github.com/bigbangcore/BigBang/wiki/JSON-RPC

Suggestion Strong rpc password, EnableTLS better, Allowed ip from server side(bigbang)

Features

  • majority of JSON-RPC API
  • run bigbang server in golang (test usage)
  • JSON-RPC data structures
  • http.Client reuse,safe for concurrent use by multiple goroutines
  • zero dependency
  • TLS support

version

主要的版本跟着BigBangCore 走,semantic version

建议的方式是选择与你的BigBang-server一致的版本,比如你的bigbang为 0.9.1 建议选择 v0.9.x

QA

  • http层如何复用http.Client的?

    • 每个bbrpc.Client 有一个http.Client,所有的请求发送到一个内部chan req (cap 100) ,内部有一个goroutine for select 这个chan req,一直处理请求直到shutdown,每个请求返回的结果写入到req 的chan resp 里。参考client.go
  • JSON RPC request id 如何生成的?

    • atomic.AddUint64(&c.id, 1) 自增
  • Why testing(make test) slow?

    • 目前暂时没有找到bigbang缩短出块周期的方法,有些测试需要等待出块,这个是主要的时间耗费
    • 暂时没有考虑t.Parallel(),这个需要对测试端口进行无冲突的管理分配
    • 启动bigbang后会等待1s

PR

该项目非bigbang核心团队实现,作者根据自己的需求实现了部分RPC。但代码设计成容易的添加新的RPC,只需要简单的添加数据结构(基本参考官方RPC Wiki),参考现有的代码即可快速实现。

欢迎提交PR.

LICENSE

TBD

(目前暂时没有限制,你可以按照你喜欢的方式使用代码)

Documentation

Index

Constants

View Source
const (
	TransactionTypeWork          = "work"
	TransactionTypeToken         = "token"
	TransactionTypeStake         = "stake"
	TransactionTypeGenesis       = "genesis"
	TransactionTypeCertification = "certification"
)

transaction types

View Source
const (
	TDefaultPort        = 19900
	TDefaultRPCPort     = 19906
	TDefaultPort2       = 19901
	TDefaultRPCPort2    = 19907
	TDefaultRPCUser     = "rpcusr"
	TDefaultRPCPassword = "pwd"
)

一些测试用常量

Variables

View Source
var (
	// ErrInvalidAuth is an error to describe the condition where the client
	// is either unable to authenticate or the specified endpoint is
	// incorrect.
	ErrInvalidAuth = errors.New("authentication failure")

	// ErrClientShutdown is an error to describe the condition where the
	// client is either already shutdown, or in the process of shutting
	// down.  Any outstanding futures when a client shutdown occurs will
	// return this error as will any new requests.
	ErrClientShutdown = errors.New("the client has been shutdown")
)
View Source
var (
	TCryptonightAddr = AddrKeypair{
		Keypair: Keypair{Privkey: "eadae10eb384b4d090c10bf2469ee359e32c179026f616ebdf38318ccda5a068", Pubkey: "639ddcfda6e7357cb6543ecb328d6abd130daedaa26beb09bf0e34260f583d77"},
		Address: "1ewyng3s66g7by2fbdehdnbgd2eypn39jscz59dkw6qktdzewknhsmk4t"}
	TCryptonightKey = AddrKeypair{
		Keypair: Keypair{Privkey: "174c4fabefc9573c9cd506dff7f6cb0c54ecaaa63cc0d9f53da7e9c133a01c3a", Pubkey: "ea34707897e6a9ec8e4038179a75fb29d1204a3a5bc4bd07c1c6454d3feac3f7"},
		Address: "1yz1ymftd8q3c21xxrhdkmjh0t4mzpxct2ww413qcn7k9ey3g6knfswbw"}

	//几组地址
	TAddr0 = AddrKeypair{
		Keypair: Keypair{Privkey: "195cd69eff4580ad2430f92d2c86865c596e72edb33f40df5d41c97883241c7c", Pubkey: "a7386f6cbe769fda91462637393970850ae7528d2cee5214c26cc4b27c014a65"},
		Address: "1cn502z5jrhpc452jxrp8tmq71a2q0e9s6wk4d4etkxvbwv3f72ksbkdn"}
	TAddr1 = AddrKeypair{
		Keypair: Keypair{Privkey: "3de774bfb200a46f6d969f5e080572859bc5d7b297fdb34471f55be3326b2153", Pubkey: "1fb8c0c79a506fd8fcca12065331110ae4aedceb2eac38f75379174c6a5b1bff"},
		Address: "1zwdnptjc2xwn7xsrngqeqq5ewg512cak0r9cnz6rdx89nhy0q0fstv2y"}
	TAddr2 = AddrKeypair{
		Keypair: Keypair{Privkey: "8c49b0f3788e07025303ef763e55d14781c09d43cb749628d26280f8f6912336", Pubkey: "5910534ab7629ccb73659df42afc3c382597223a9caa4040a687dbebbe1aa88a"},
		Address: "1ham1nfqbve3tcg20nae3m8mq4mw3sz1ayjepawybkhhbejjk21cvjnx3"}
	TAddr3 = AddrKeypair{
		Keypair: Keypair{Privkey: "5dd0705adf24f1177cedf2795521748358ec08b2d46ddb659f4f68e870433e60", Pubkey: "e4dcb0b8282298a43d5f8c5cbdd3bc27e7f6a44bf0be04e38301655c09038fdb"},
		Address: "1ve7g62awcm0r7rr4qvr4q97pwwkvsmxxbj65yfd4k0h2he5gvkj3d8dz"}
)

一些测试用数据

Functions

func DefaultDebugBBArgs

func DefaultDebugBBArgs() map[string]*string

DefaultDebugBBArgs debug BigBang args testnet,listen4,debug,port=19900,rpcport=19906,rpcuser=rpcusr,rpcpassword=pwd

func GetIdlePort

func GetIdlePort() (int, error)

GetIdlePort 随机获取一个空闲的端口

func Pstring

func Pstring(s string) *string

Pstring .

func RunBigBangServer

func RunBigBangServer(optionsPtr *RunBigBangOptions) (func(), error)

RunBigBangServer run bigbang server,print out to stdout, require bigbang in the $PATH, this func is used for testing BigBang in local test env return func() to kill bigbang server usage:

		killBigbang, err := RunBigBangServer(options)
 	defer killBigBang()

func UtilDataEncoding

func UtilDataEncoding(data string) string

UtilDataEncoding 将tx data 进行编码

func Wait4balanceReach

func Wait4balanceReach(addr string, balance float64, client *Client, msg ...string) error

Wait4balanceReach 每次休眠1s,等待地址的余额达到

func Wait4nBlocks

func Wait4nBlocks(n int, client *Client) error

Wait4nBlocks 每次休眠1s,直到出了n个块

Types

type AddnewtemplateParam

type AddnewtemplateParam interface {
	TemplateType() string
	ParamName() string
}

AddnewtemplateParam .

type AddnewtemplateParamDelegate

type AddnewtemplateParamDelegate struct {
	Delegate string `json:"delegate,omitempty"` //(string, required) delegate public key
	Owner    string `json:"owner,omitempty"`    //(string, required) owner address
}

AddnewtemplateParamDelegate .

func (AddnewtemplateParamDelegate) ParamName

func (p AddnewtemplateParamDelegate) ParamName() string

ParamName .

func (AddnewtemplateParamDelegate) TemplateType

func (p AddnewtemplateParamDelegate) TemplateType() string

TemplateType .

type AddnewtemplateParamDexBBCMap

type AddnewtemplateParamDexBBCMap struct {
	Owner string `json:"owner,omitempty"` //(string, required) owner address
}

AddnewtemplateParamDexBBCMap .

func (AddnewtemplateParamDexBBCMap) ParamName

func (p AddnewtemplateParamDexBBCMap) ParamName() string

ParamName .

func (AddnewtemplateParamDexBBCMap) TemplateType

func (p AddnewtemplateParamDexBBCMap) TemplateType() string

TemplateType .

type AddnewtemplateParamMint

type AddnewtemplateParamMint struct {
	Mint  string `json:"mint,omitempty"`  //mint public key
	Spent string `json:"spent,omitempty"` //spent address
}

AddnewtemplateParamMint .

func (AddnewtemplateParamMint) ParamName

func (p AddnewtemplateParamMint) ParamName() string

ParamName .

func (AddnewtemplateParamMint) TemplateType

func (p AddnewtemplateParamMint) TemplateType() string

TemplateType .

type AddnewtemplateParamMultisig

type AddnewtemplateParamMultisig struct {
	Required int      `json:"required,omitempty"`
	Pubkeys  []string `json:"pubkeys,omitempty"`
}

AddnewtemplateParamMultisig .

func (AddnewtemplateParamMultisig) ParamName

func (p AddnewtemplateParamMultisig) ParamName() string

ParamName .

func (AddnewtemplateParamMultisig) TemplateType

func (p AddnewtemplateParamMultisig) TemplateType() string

TemplateType .

type AddnewtemplateParamVote

type AddnewtemplateParamVote struct {
	Delegate string `json:"delegate,omitempty"` //(string, required) delegate public key
	Owner    string `json:"owner,omitempty"`    //(string, required) owner address
}

AddnewtemplateParamVote .

func (AddnewtemplateParamVote) ParamName

func (p AddnewtemplateParamVote) ParamName() string

ParamName .

func (AddnewtemplateParamVote) TemplateType

func (p AddnewtemplateParamVote) TemplateType() string

TemplateType .

type AddrKeypair

type AddrKeypair struct {
	Keypair
	Address string
}

AddrKeypair address and keypair

type AddressData

type AddressData struct {
	Address string `json:"address,omitempty"` //(string, required) wallet address
	Ismine  bool   `json:"ismine,omitempty"`  //(bool, required) is mine
	Type    string `json:"type,omitempty"`    //(string, required) type, pubkey or template
	// (if type=pubkey)
	Pubkey *string `json:"pubkey,omitempty"` //(string, required) public key
	// (if type=template)
	Template *string `json:"template,omitempty"` //(string, required) template type name
	// (if type=template && ismine=true)
	Templatedata *TemplateData `json:"templatedata,omitempty"` //(object, required) template data
}

AddressData .

type AddressInfo

type AddressInfo struct {
	Isvalid bool `json:"isvalid,omitempty"` //": true|false,               (bool, required) is valid
	//    (if isvalid=true)
	Addressdata *AddressData `json:"addressdata,omitempty"` //(object, required) address data
}

AddressInfo .

type BalanceInfo

type BalanceInfo struct {
	Address     string  `json:"address,omitempty"`     //(string, required) wallet address
	Avail       float64 `json:"avail,omitempty"`       //(double, required) balance available amount
	Locked      float64 `json:"locked,omitempty"`      //(double, required) locked amount
	Unconfirmed float64 `json:"unconfirmed,omitempty"` //(double, required) unconfirmed amount
}

BalanceInfo .

type BlockDetail

type BlockDetail struct {
	Hash     string                      `json:"hash,omitempty"`     //(string, required) block hash
	HashPrev string                      `json:"hashPrev,omitempty"` //(string, required) block prev hash
	Version  uint                        `json:"version,omitempty"`  //(uint, required) version
	Type     string                      `json:"type,omitempty"`     //(string, required) block type
	Time     uint                        `json:"time,omitempty"`     //(uint, required) block time
	Bits     uint                        `json:"bits,omitempty"`     //(uint, required) nBits
	Fork     string                      `json:"fork,omitempty"`     //(string, required) fork hash
	Height   uint                        `json:"height,omitempty"`   //(uint, required) block height
	Prev     string                      `json:"prev,omitempty"`     //(string, optional) previous block hash
	Txmint   NoneSerializedTransaction   `json:"txmint,omitempty"`   // (object, required) transaction mint data
	Tx       []NoneSerializedTransaction `json:"tx,omitempty"`
}

BlockDetail 区块详细信息

type BlockInfo

type BlockInfo struct {
	Hash    string   `json:"hash"`    //(string, required) block hash
	Version uint     `json:"version"` //(uint, required) version
	Type    string   `json:"type"`    //(string, required) block type
	Time    uint     `json:"time"`    //(uint, required) block time
	Fork    string   `json:"fork"`    //(string, required) fork hash
	Height  uint     `json:"height"`  //(uint, required) block height
	Txmint  string   `json:"txmint"`  //(string, required) transaction mint hash
	Prev    string   `json:"prev"`    //(string, optional) previous block hash
	Tx      []string `json:"tx"`      //(string, required) transaction hash
}

BlockInfo 块信息

type Client

type Client struct {
	Debug bool //print some debug log when true
	// contains filtered or unexported fields
}

Client .

func NewClient

func NewClient(config *ConnConfig) (*Client, error)

NewClient .

func NewClientWith

func NewClientWith(config *ConnConfig, httpClient *http.Client) (*Client, error)

NewClientWith .

func TesttoolRunServerAndBeginMint

func TesttoolRunServerAndBeginMint(t *testing.T, opts ...RunBigBangOptions) (func(), *Client, string)

TesttoolRunServerAndBeginMint (测试中)启动bigbang,使用预置的私钥开始挖矿, opts 作为可选参数只使用第一个值(如果有) 返回:killBigbang(), Client, 挖矿模版地址

func (*Client) CallJSONRPC

func (c *Client) CallJSONRPC(method string, params map[string]interface{}, result interface{}) ([]byte, error)

CallJSONRPC any rpc

func (*Client) Exportkey

func (c *Client) Exportkey(pubkey string) (string, error)

Exportkey https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#exportkey

func (*Client) Getbalance

func (c *Client) Getbalance(fork *string, address *string) ([]BalanceInfo, error)

Getbalance https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#getbalance

func (*Client) GetblockByHeight

func (c *Client) GetblockByHeight(height uint64, fork *string) (*BlockInfo, error)

GetblockByHeight .

func (*Client) Getblockcount

func (c *Client) Getblockcount(fork *string) (*int, error)

Getblockcount https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#getblockcount

func (*Client) Getblockdetail

func (c *Client) Getblockdetail(blockHash string) (*BlockDetail, error)

Getblockdetail https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#getblockdetail

func (*Client) Getblockhash

func (c *Client) Getblockhash(height int, fork *string) ([]string, error)

Getblockhash https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#getblockhash

func (*Client) Getforkheight

func (c *Client) Getforkheight(fork *string) (h int, err error)

Getforkheight https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#getforkheight

func (*Client) Getnewkey

func (c *Client) Getnewkey(passphrase string) (string, error)

Getnewkey https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#getnewkey

func (*Client) Getpubkeyaddress

func (c *Client) Getpubkeyaddress(pubkey string, reversal *string) (*string, error)

Getpubkeyaddress https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#getpubkeyaddress

func (*Client) Gettransaction

func (c *Client) Gettransaction(txid string, serialized *bool) (*TransactionDetail, error)

Gettransaction https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#gettransaction

func (*Client) Importkey

func (c *Client) Importkey(pubkey string, syncTx *bool) (string, error)

Importkey https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#importkey

func (*Client) Importprivkey

func (c *Client) Importprivkey(privkey, passphrase string, syncTx *bool) (*string, error)

Importprivkey https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#importprivkey

func (*Client) Importpubkey

func (c *Client) Importpubkey(pubkey string) (*string, error)

Importpubkey https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#importpubkey

func (*Client) Importtemplate

func (c *Client) Importtemplate(data string) (*string, error)

Importtemplate https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#importtemplate

func (*Client) ListBlockDetailsBetween

func (c *Client) ListBlockDetailsBetween(fork *string, fromHeight, toHeight int) ([]BlockDetail, error)

ListBlockDetailsBetween 列出[from,to]内所有区块详情 return: blockDetails, error

func (*Client) ListBlockDetailsSince

func (c *Client) ListBlockDetailsSince(fork *string, targetBlockHash string, count int) (int, []BlockDetail, error)

ListBlockDetailsSince 列出自某个区块以来的所有区块详情,不包含targetBlock的交易 return: topBlockHeight, blockDetails, error

func (*Client) ListTransactionsSinceBlock

func (c *Client) ListTransactionsSinceBlock(targetBlockHash string, count int) (string, []TransactionDetail, error)

ListTransactionsSinceBlock 列出自某个区块以来的所有交易,不包含targetBlock的交易 return: scan2BlockHash, tx, error

func (*Client) Listdelegate

func (c *Client) Listdelegate(count int) (ret []Delegate, error error)

func (*Client) Listfork

func (c *Client) Listfork(all bool) (ret []ForkProfile, err error)

Listfork https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#listfork

func (*Client) Listtransaction

func (c *Client) Listtransaction(count *uint, offset *int) ([]Transaction, error)

Listtransaction https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#listtransaction

func (*Client) Listunspent

func (c *Client) Listunspent(address string, fork *string, max uint) (*UnspentTotal, error)

Listunspent https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#listunspent

func (*Client) NextID

func (c *Client) NextID() uint64

NextID returns the next id to be used when sending a JSON-RPC message. This ID allows responses to be associated with particular requests per the JSON-RPC specification. Typically the consumer of the client does not need to call this function, however, if a custom request is being created and used this function should be used to ensure the ID is unique amongst all requests being made.

func (*Client) PendingPostCount

func (c *Client) PendingPostCount() int

PendingPostCount current post request count waiting for process

func (*Client) Sendtransaction

func (c *Client) Sendtransaction(txdata string) (*string, error)

Sendtransaction https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#sendtransaction

func (*Client) Shutdown

func (c *Client) Shutdown()

Shutdown shuts down the client by disconnecting any connections associated with the client and, when automatic reconnect is enabled, preventing future attempts to reconnect. It also stops all goroutines.

func (*Client) Signrawtransactionwithwallet

func (c *Client) Signrawtransactionwithwallet(addrIn, txdata string) (*SigntransactionResult, error)

Signrawtransactionwithwallet https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#signrawtransactionwithwallet

func (*Client) Unlockkey

func (c *Client) Unlockkey(pubkey, passphrase string, timeout *int64) (*string, error)

Unlockkey https://github.com/bigbangcore/BigBang/wiki/JSON-RPC#unlockkey

type ClusterNode

type ClusterNode struct {
	IsMiner      bool
	MinerAddress string
	Client       *Client
	RPCPort      int
}

ClusterNode .

func TesttoolRunClusterWith2nodes

func TesttoolRunClusterWith2nodes(t *testing.T) (func(), []ClusterNode)

TesttoolRunClusterWith2nodes 运行2个节点,返回的第一个节点为矿工节点,发生错误则终止测试,矿工节点的日志会打印出来

type CmdCreatetransaction

type CmdCreatetransaction struct {
	From   string   `json:"from,omitempty"`   //(string, required) from address
	To     string   `json:"to,omitempty"`     //(string, required) to address
	Amount float64  `json:"amount,omitempty"` //(double, required) amount
	Txfee  *float64 `json:"txfee,omitempty"`  //(double, optional) transaction fee
	Fork   *string  `json:"fork,omitempty"`   //(string, optional) fork hash
	Data   *string  `json:"data,omitempty"`   //(string, optional) output data
}

CmdCreatetransaction .

type CmdSendfrom

type CmdSendfrom struct {
	From       string   `json:"from"`                 //(string, required) from address
	To         string   `json:"to"`                   //(string, required) to address
	Amount     float64  `json:"amount"`               //(double, required) amount
	Txfee      *float64 `json:"txfee,omitempty"`      //(double, optional) transaction fee
	Fork       *string  `json:"fork,omitempty"`       //(string, optional) fork hash
	Data       *string  `json:"data,omitempty"`       //(string, optional) output data
	SignM      *string  `json:"sign_m,omitempty"`     //(string, optional) exchange sign m
	SignS      *string  `json:"sign_s,omitempty"`     //(string, optional) exchange sign s
	Sendtodata *string  `json:"sendtodata,omitempty"` //(string, optional) If the 'to' address of transaction is a template, this option allows to save the template hex data. The hex data is equal output of RPC 'exporttemplate'
	Type       *uint    `json:"type,omitempty"`       //(uint, optional, default=0) 0: common token tx, 2: defi relation tx
}

CmdSendfrom .

type ConnConfig

type ConnConfig struct {
	// Host is the IP address and port of the RPC server you want to connect
	// to.
	Host string

	// User is the username to use to authenticate to the RPC server.
	User string

	// Pass is the passphrase to use to authenticate to the RPC server.
	Pass string

	// DisableTLS specifies whether transport layer security should be
	// disabled.  It is recommended to always use TLS if the RPC server
	// supports it as otherwise your username and password is sent across
	// the wire in cleartext.
	DisableTLS bool

	// Certificates are the bytes for a PEM-encoded certificate chain used
	// for the TLS connection.  It has no effect if the DisableTLS parameter
	// is true.
	Certificates []byte
}

ConnConfig describes the connection configuration parameters for the client. This

func DefaultDebugConnConfig

func DefaultDebugConnConfig() *ConnConfig

DefaultDebugConnConfig .

type DataDetail

type DataDetail struct {
	UUID     string
	UnixTime uint32
	Data     string
}

DataDetail .

func UtilDataDecoding

func UtilDataDecoding(data string) (DataDetail, error)

UtilDataDecoding .

type Delegate

type Delegate struct {
	Address string  `json:"address,omitempty"`
	Votes   float64 `json:"votes,omitempty"`
}

Delegate .

type DockerCore

type DockerCore struct {
	Client         *Client
	MinerAddress   string //矿工地址(资金来源)
	MinerOwnerPubk string //矿工owner address 公钥
	UnlockPass     string //已有地址解锁密码
	Conf           ConnConfig
}

func CmdRunDockerDevCore

func CmdRunDockerDevCore(imageName string) (func(), DockerCore, error)

CmdRunDockerDevCore 运行1个bbc core

func MustDockerRunDevCore

func MustDockerRunDevCore(t *testing.T, imageName string) DockerCore

MustDockerRunDevCore 运行1个bbc core, 运行失败时t.Fatal, 自动注册 cleanup func

type ForkProfile

type ForkProfile struct {
	Fork       string  `json:"fork,omitempty"`       //(string, required) fork id with hex system
	Name       string  `json:"name,omitempty"`       //(string, required) fork name
	Symbol     string  `json:"symbol,omitempty"`     //(string, required) fork symbol
	Amount     float64 `json:"amount,omitempty"`     //(double, required) amount
	Reward     float64 `json:"reward,omitempty"`     //(double, required) mint reward
	Halvecycle uint64  `json:"halvecycle,omitempty"` //(uint, required) halve cycle: 0: fixed reward, >0: blocks of halve cycle
	Isolated   bool    `json:"isolated,omitempty"`   //(bool, required) is isolated
	Private    bool    `json:"private,omitempty"`    //(bool, required) is private
	Enclosed   bool    `json:"enclosed,omitempty"`   //(bool, required) is enclosed
	Owner      string  `json:"owner,omitempty"`      //(string, required) owner's address
}

ForkProfile .

type Keypair

type Keypair struct {
	Privkey string
	Pubkey  string
}

Keypair .

type NoneSerializedTransaction

type NoneSerializedTransaction struct {
	Txid          string     `json:"txid,omitempty"`          //(string, required) transaction hash
	Version       uint       `json:"version,omitempty"`       //(uint, required) version
	Type          string     `json:"type,omitempty"`          //(string, required) transaction type
	Time          uint       `json:"time,omitempty"`          //(uint, required) transaction timestamp
	Lockuntil     uint       `json:"lockuntil,omitempty"`     //(uint, required) unlock time
	Anchor        string     `json:"anchor,omitempty"`        //(string, required) anchor hash
	Blockhash     string     `json:"blockhash"`               //block hash
	Sendfrom      string     `json:"sendfrom,omitempty"`      //(string, required) send from address
	Sendto        string     `json:"sendto,omitempty"`        //(string, required) send to address
	Amount        float64    `json:"amount,omitempty"`        //(double, required) amount
	Txfee         float64    `json:"txfee,omitempty"`         //(double, required) transaction fee
	Data          string     `json:"data,omitempty"`          //(string, required) data
	Sig           string     `json:"sig,omitempty"`           //(string, required) sign
	Fork          string     `json:"fork,omitempty"`          //(string, required) fork hash
	Confirmations *int       `json:"confirmations,omitempty"` //(int, optional) confirmations
	Vin           []VinPoint `json:"vin,omitempty"`           //(object, required) vin struct
}

NoneSerializedTransaction .

type PeerInfo

type PeerInfo struct {
	Address  string `json:"address,omitempty"`  //(string, required) peer address
	Services string `json:"services,omitempty"` //(string, required) service
	Lastsend string `json:"lastsend,omitempty"` //(int, required) last send time
	Lastrecv string `json:"lastrecv,omitempty"` //(int, required) last receive time
	Conntime string `json:"conntime,omitempty"` //(int, required) active time
	Pingtime int    `json:"pingtime"`           //(int, required) ping pong time
	Version  string `json:"version,omitempty"`  //(string, required) version
	Subver   string `json:"subver,omitempty"`   //(string, required) sub version
	Inbound  bool   `json:"inbound,omitempty"`  //(bool, required) accept multiple connection or not
	Height   int    `json:"height,omitempty"`   //(int, required) starting height
	Banscore int    `json:"banscore,omitempty"` //(int, required) ban score
}

PeerInfo .

type PubkeyInfo

type PubkeyInfo struct {
	Key     string `json:"key,omitempty"` //public key with hex system
	Version int64  `json:"version,omitempty"`
	Locked  bool   `json:"locked,omitempty"`
	Timeout *int64 `json:"timeout,omitempty"` //public key timeout locked
}

PubkeyInfo .

type Request

type Request struct {
	Jsonrpc string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"`
	ID      interface{}     `json:"id"`
}

Request is a type for raw JSON-RPC 1.0 requests. The Method field identifies the specific command type which in turns leads to different parameters. Callers typically will not use this directly since this package provides a statically typed command infrastructure which handles creation of these requests, however this struct it being exported in case the caller wants to construct raw requests for some reason.

type RunBigBangOptions

type RunBigBangOptions struct {
	NewTmpDir        bool               //创建并使用新的临时目录作为datadir
	TmpDirTag        string             //tag会作为临时路径的前缀
	KeepTmpDirInKill bool               //kill func中保留临时目录
	Args             map[string]*string //k-v ,v 为nil时为flag
	NotPrint2stdout  bool               //不打印到stdout
}

RunBigBangOptions .

type SigntransactionResult

type SigntransactionResult struct {
	Hex       string `json:"hex,omitempty"`       //(string, required) hex of transaction data
	Completed bool   `json:"completed,omitempty"` //(bool, required) transaction completed or not
}

SigntransactionResult .

type TW

type TW struct {
	*testing.T
	// contains filtered or unexported fields
}

TW testing.T wrap

func (*TW) AllNotZero

func (tw *TW) AllNotZero(msg string, values ...interface{}) *TW

AllNotZero all values should not be zero

func (*TW) Continue

func (tw *TW) Continue(_continue bool) *TW

Continue 断言失败时是否继续测试(不执行FailNow)

func (*TW) Copy

func (tw *TW) Copy() *TW

Copy .

func (*TW) Equal

func (tw *TW) Equal(expected, actual interface{}, args ...interface{}) *TW

Equal reflect.DeepEqual

func (*TW) IsZero

func (tw *TW) IsZero(v interface{}, args ...interface{}) *TW

IsZero if flag == false, fatal

func (*TW) Nil

func (tw *TW) Nil(x interface{}, args ...interface{}) *TW

Nil if x not nil, fatal

func (*TW) NotZero

func (tw *TW) NotZero(v interface{}, args ...interface{}) *TW

NotZero if flag == false, fatal

func (*TW) True

func (tw *TW) True(flag bool, args ...interface{}) *TW

True if flag == false, fatal

type TemplateData

type TemplateData struct {
	Type string `json:"type,omitempty"` //(string, required) template type
	Hex  string `json:"hex,omitempty"`  //(string, required) temtplate data
	//   (if type=delegate)
	Delegate *struct {
		Delegate string `json:"delegate,omitempty"` //(string, required) delegate public key
		Owner    string `json:"owner,omitempty"`    //(string, required) owner address
	} `json:"delegate,omitempty"`
	//   (if type=vote)
	Vote *struct {
		Delegate string `json:"delegate,omitempty"` //(string, required) delegate public key
		Owner    string `json:"owner,omitempty"`    //(string, required) owner address
	} `json:"vote,omitempty"`
	//   (if type=fork)
	Fork *struct {
		Redeem string `json:"redeem,omitempty"` //(string, required) redeem address
		Fork   string `json:"fork,omitempty"`   //(string, required) fork hash
	} `json:"fork,omitempty"`
	//   (if type=mint)
	Mint *struct {
		Mint  string `json:"mint,omitempty"`  //(string, required) mint public key
		Spent string `json:"spent,omitempty"` //(string, required) spent address
	} `json:"mint,omitempty"`
	//   (if type=multisig)
	Multisig *struct {
		Required  int64    `json:"required,omitempty"`  //(int, required) required weight
		Addresses []string `json:"addresses,omitempty"` //(string, required) public key
	} `json:"multisig,omitempty"`
	//   (if type=exchange)
	Exchange *struct {
		SpendS  string `json:"spend_s,omitempty"`  //(string, required) spend_s
		SpendM  string `json:"spend_m,omitempty"`  //(string, required) spend_m
		HeightM int64  `json:"height_m,omitempty"` //(int, required) height m
		HeightS int64  `json:"height_s,omitempty"` //(int, required) height s
		ForkM   string `json:"fork_m,omitempty"`   //(string, required) fork m
		ForkS   string `json:"fork_s,omitempty"`   //(string, required) fork s
	} `json:"exchange,omitempty"`
	//   (if type=weighted)
	Weighted *struct {
		Required int64 `json:"required,omitempty"` //(int, required) required weight
		Pubkey   []struct {
			Key    string `json:"key,omitempty"`    //(string, required) public key
			Weight int64  `json:"weight,omitempty"` //(int, required) weight
		} `json:"pubkey,omitempty"`
	} `json:"weighted,omitempty"`
	Dexbbcmap *struct {
		Owner string `json:"owner"`
	} `json:"dexbbcmap,omitempty"`
}

TemplateData .

type Transaction

type Transaction struct {
	Txid        string  `json:"txid,omitempty"`        //(string, required) transaction hash
	Fork        string  `json:"fork,omitempty"`        //(string, required) fork hash
	Type        string  `json:"type,omitempty"`        //(string, required) transaction type
	Time        uint    `json:"time,omitempty"`        //(uint, required) transaction timestamp
	Send        bool    `json:"send,omitempty"`        //(bool, required) is from me
	To          string  `json:"to,omitempty"`          //(string, required) to address
	Amount      float64 `json:"amount,omitempty"`      //(double, required) transaction amount
	Fee         float64 `json:"fee,omitempty"`         //(double, required) transaction fee
	Lockuntil   uint    `json:"lockuntil,omitempty"`   //(uint, required) lockuntil
	Blockheight *int    `json:"blockheight,omitempty"` //(int, optional) block height
	From        *string `json:"from,omitempty"`        //(string, optional) from address
}

Transaction .

type TransactionDetail

type TransactionDetail struct {
	// (if serialized=true)
	Serialization *string `json:"serialization,omitempty"` //(string, optional) transaction hex data
	//    (if serialized=false)
	Transaction *NoneSerializedTransaction `json:"transaction,omitempty"` //(object, optional) transaction data
}

TransactionDetail .

type UnspentTotal

type UnspentTotal struct {
	Total     decimal.Decimal `json:"total,omitempty"`
	Addresses []struct {
		Address  string `json:"address,omitempty"`
		Unspents []struct {
			Txid      string          `json:"txid,omitempty"`
			Out       uint            `json:"out,omitempty"`
			Amount    decimal.Decimal `json:"amount,omitempty"`
			Time      int64           `json:"time,omitempty"`
			Lockuntil int64           `json:"lockuntil,omitempty"`
		} `json:"unspents,omitempty"`
		Sum decimal.Decimal `json:"sum,omitempty"`
	} `json:"addresses,omitempty"`
}

UnspentTotal .

type VinPoint

type VinPoint struct {
	Txid string `json:"txid,omitempty"` //(string, required) pre-vout transaction hash
	Vout uint   `json:"vout,omitempty"` //(uint, required) pre-vout number
}

VinPoint .

Jump to

Keyboard shortcuts

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