json

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: ISC Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyString   = &decError{"empty hex string"}
	ErrSyntax        = &decError{"invalid hex string"}
	ErrMissingPrefix = &decError{"hex string without 0x prefix"}
	ErrOddLength     = &decError{"hex string of odd length"}
	ErrEmptyNumber   = &decError{"hex string \"0x\""}
	ErrLeadingZero   = &decError{"hex number with leading zero digits"}
	ErrUint64Range   = &decError{"hex number > 64 bits"}
	ErrUintRange     = &decError{fmt.Sprintf("hex number > %d bits", uintBits)}
	ErrBig256Range   = &decError{"hex number > 256 bits"}
)

Errors

Functions

func UnmarshalFixedJSON

func UnmarshalFixedJSON(typ reflect.Type, input, out []byte) error

UnmarshalFixedJSON decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalJSON method for fixed-size types.

func UnmarshalFixedText

func UnmarshalFixedText(typname string, input, out []byte) error

UnmarshalFixedText decodes the input as a string. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.

func UnmarshalFixedUnprefixedText

func UnmarshalFixedUnprefixedText(typname string, input, out []byte) error

UnmarshalFixedUnprefixedText decodes the input as a string with optional 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.

Types

type AcctInfo

type AcctInfo struct {
	Mode    bool     `json:"mode"`
	Version uint32   `json:"version"`
	Total   uint32   `json:"total"`
	Watcher uint32   `json:"watcher"`
	Addrs   []string `json:"addrs,omitempty"`
}

type AdreesAmount

type AdreesAmount map[string]Amout

type Amounts

type Amounts map[string]uint64 //{\"address\":amount,...}

type Amout

type Amout struct {
	CoinId uint16 `json:"coinid"`
	Amount int64  `json:"amount"`
}

type BlockResult

type BlockResult struct {
	Hash          string    `json:"hash"`
	Txsvalid      bool      `json:"txsvalid"`
	Confirmations int64     `json:"confirmations"`
	Version       int32     `json:"version"`
	Weight        int64     `json:"weight"`
	Height        int64     `json:"height"`
	TxRoot        string    `json:"txRoot"`
	Order         int64     `json:"order,omitempty"`
	Tx            []string  `json:"transactions,omitempty"`
	TxFee         int64     `json:"transactionfee,omitempty"`
	StateRoot     string    `json:"stateRoot"`
	Bits          string    `json:"bits"`
	Difficulty    uint32    `json:"difficulty"`
	PowResult     PowResult `json:"pow"`
	Time          string    `json:"timestamp"`
	ParentRoot    string    `json:"parentroot"`
	Parents       []string  `json:"parents"`
	Children      []string  `json:"children"`
}

type BlockVerboseResult

type BlockVerboseResult struct {
	Hash          string        `json:"hash"`
	Txsvalid      bool          `json:"txsvalid"`
	Confirmations int64         `json:"confirmations"`
	Version       int32         `json:"version"`
	Weight        int64         `json:"weight"`
	Height        int64         `json:"height"`
	TxRoot        string        `json:"txRoot"`
	Order         int64         `json:"order,omitempty"`
	Tx            []TxRawResult `json:"transactions,omitempty"`
	TxFee         int64         `json:"transactionfee,omitempty"`
	StateRoot     string        `json:"stateRoot"`
	Bits          string        `json:"bits"`
	Difficulty    uint32        `json:"difficulty"`
	PowResult     PowResult     `json:"pow"`
	Time          string        `json:"timestamp"`
	ParentRoot    string        `json:"parentroot"`
	Parents       []string      `json:"parents"`
	Children      []string      `json:"children"`
}

type ConsensusDeploymentDesc

type ConsensusDeploymentDesc struct {
	Status      string `json:"status"`
	StartHeight int64  `json:"startHeight,omitempty"`
}

type DecodeRawTransactionResult

type DecodeRawTransactionResult struct {
	Order      uint64 `json:"order"`
	BlockHash  string `json:"blockhash"`
	Txvalid    bool   `json:"txvalid"`
	Duplicate  bool   `json:"duplicate,omitempty"`
	IsCoinbase bool   `json:"is_coinbase"`
	Confirms   uint64 `json:"confirms"`
	IsBlue     bool   `json:"is_blue"`
	Txid       string `json:"txid"`
	Hash       string `json:"txhash"`
	Version    uint32 `json:"version"`
	LockTime   uint32 `json:"locktime"`
	Time       string `json:"timestamp"`
	Vin        []Vin  `json:"vin"`
	Vout       []Vout `json:"vout"`
}

type GetBanlistResult

type GetBanlistResult struct {
	ID   string `json:"id"`
	Bads int    `json:"bads"`
}

type GetBlockHeaderVerboseResult

type GetBlockHeaderVerboseResult struct {
	Hash          string    `json:"hash"`
	Confirmations int64     `json:"confirmations"`
	Version       int32     `json:"version"`
	ParentRoot    string    `json:"parentroot"`
	TxRoot        string    `json:"txRoot"`
	StateRoot     string    `json:"stateRoot"`
	Difficulty    uint32    `json:"difficulty"`
	Layer         uint32    `json:"layer"`
	Time          int64     `json:"time"`
	PowResult     PowResult `json:"pow"`
}

GetBlockHeaderVerboseResult models the data from the getblockheader command when the verbose flag is set. When the verbose flag is not set, getblockheader returns a hex-encoded string.

type GetBlockTemplateResult

type GetBlockTemplateResult struct {
	// Base fields from BIP 0022.  CoinbaseAux is optional.  One of
	// CoinbaseTxn or CoinbaseValue must be specified, but not both.
	StateRoot     string                     `json:"stateroot"`
	CurTime       int64                      `json:"curtime"`
	Height        int64                      `json:"height"`
	Blues         int64                      `json:"blues"`
	PreviousHash  string                     `json:"previousblockhash"`
	SigOpLimit    int64                      `json:"sigoplimit,omitempty"`
	SizeLimit     int64                      `json:"sizelimit,omitempty"`
	WeightLimit   int64                      `json:"weightlimit,omitempty"`
	Parents       []GetBlockTemplateResultPt `json:"parents"`
	Transactions  []GetBlockTemplateResultTx `json:"transactions"`
	Version       uint32                     `json:"version"`
	CoinbaseAux   *GetBlockTemplateResultAux `json:"coinbaseaux,omitempty"`
	CoinbaseTxn   *GetBlockTemplateResultTx  `json:"coinbasetxn,omitempty"`
	CoinbaseValue *uint64                    `json:"coinbasevalue,omitempty"`
	WorkID        string                     `json:"workid,omitempty"`
	NodeInfo      string                     `json:"nodeinfo,omitempty"`

	// Witness commitment defined in BIP 0141.
	DefaultWitnessCommitment string `json:"default_witness_commitment,omitempty"`

	// Optional long polling from BIP 0022.
	LongPollID  string `json:"longpollid,omitempty"`
	LongPollURI string `json:"longpolluri,omitempty"`
	SubmitOld   *bool  `json:"submitold,omitempty"`

	// Basic pool extension from BIP 0023.
	Expires          int64            `json:"expires,omitempty"`
	PowDiffReference PowDiffReference `json:"pow_diff_reference"`
	// Mutations from BIP 0023.
	MaxTime    int64    `json:"maxtime,omitempty"`
	MinTime    int64    `json:"mintime,omitempty"`
	Mutable    []string `json:"mutable,omitempty"`
	NonceRange string   `json:"noncerange,omitempty"`

	// Block proposal from BIP 0023.
	// temp use
	WorkData        string        `json:"workdata"`
	Capabilities    []string      `json:"capabilities,omitempty"`
	RejectReasion   string        `json:"reject-reason,omitempty"`
	BlockFeesMap    map[int]int64 `json:"block_fees_map"`
	CoinbaseVersion string        `json:"coinbase_version"`
}

GetBlockTemplateResult models the data returned from the getblocktemplate

type GetBlockTemplateResultAux

type GetBlockTemplateResultAux struct {
	Flags string `json:"flags"`
}

GetBlockTemplateResultAux models the coinbaseaux field of the getblocktemplate command.

type GetBlockTemplateResultPt

type GetBlockTemplateResultPt struct {
	Data string `json:"data"`
	Hash string `json:"hash"`
}

GetBlockTemplateResultPt models the parents field of the getblocktemplate command.

type GetBlockTemplateResultTx

type GetBlockTemplateResultTx struct {
	Data    string  `json:"data"`
	Hash    string  `json:"hash"`
	Depends []int64 `json:"depends"`
	Fee     int64   `json:"fee"`
	SigOps  int64   `json:"sigops"`
	Weight  int64   `json:"weight"`
}

GetBlockTemplateResultTx models the transactions field of the getblocktemplate command.

type GetGraphStateResult

type GetGraphStateResult struct {
	Tips       []string `json:"tips"`
	MainOrder  uint32   `json:"mainorder"`
	MainHeight uint32   `json:"mainheight"`
	Layer      uint32   `json:"layer"`
}

GetGraphStateResult data

type GetPeerInfoResult

type GetPeerInfoResult struct {
	ID         string               `json:"id"`
	QNR        string               `json:"qnr,omitempty"`
	Address    string               `json:"address"`
	State      string               `json:"state,omitempty"`
	Protocol   uint32               `json:"protocol,omitempty"`
	Genesis    string               `json:"genesis,omitempty"`
	Services   string               `json:"services,omitempty"`
	Name       string               `json:"name,omitempty"`
	Direction  string               `json:"direction,omitempty"`
	GraphState *GetGraphStateResult `json:"graphstate,omitempty"`
	GSUpdate   string               `json:"gsupdate,omitempty"`
	SyncNode   bool                 `json:"syncnode,omitempty"`
	TimeOffset int64                `json:"timeoffset"`
	LastSend   string               `json:"lastsend,omitempty"`
	LastRecv   string               `json:"lastrecv,omitempty"`
	BytesSent  uint64               `json:"bytessent,omitempty"`
	BytesRecv  uint64               `json:"bytesrecv,omitempty"`
	ConnTime   string               `json:"conntime,omitempty"`
	Version    string               `json:"version,omitempty"`
	Network    string               `json:"network,omitempty"`
	Circuit    bool                 `json:"circuit,omitempty"`
	Bads       int                  `json:"bads,omitempty"`
}

GetPeerInfoResult models the data returned from the getpeerinfo command.

type GetRawTransactionsResult

type GetRawTransactionsResult struct {
	Hex           string       `json:"hex,omitempty"`
	Txid          string       `json:"txid"`
	Hash          string       `json:"hash"`
	Size          string       `json:"size"`
	Vsize         string       `json:"vsize"`
	Version       uint32       `json:"version"`
	LockTime      uint32       `json:"locktime"`
	Vin           []VinPrevOut `json:"vin"`
	Vout          []Vout       `json:"vout"`
	BlockHash     string       `json:"blockhash,omitempty"`
	Confirmations uint64       `json:"confirmations,omitempty"`
	Time          int64        `json:"time,omitempty"`
	Blocktime     int64        `json:"blocktime,omitempty"`
}

GetRawTransactionsResult models the data from the getrawtransactions command.

type GetUtxoResult

type GetUtxoResult struct {
	BestBlock     string             `json:"bestblock"`
	Confirmations int64              `json:"confirmations"`
	CoinId        uint16             `json:"coinId"`
	Amount        float64            `json:"amount"`
	ScriptPubKey  ScriptPubKeyResult `json:"scriptPubKey"`
	Version       int32              `json:"version"`
	Coinbase      bool               `json:"coinbase"`
}

GetUtxoResult models the data from the GetUtxo command.

type InfoNodeResult

type InfoNodeResult struct {
	ID                  string                              `json:"ID"`
	Addresss            []string                            `json:"address"`
	QNR                 string                              `json:"QNR,omitempty"`
	Version             int32                               `json:"version"`
	BuildVersion        string                              `json:"buildversion"`
	ProtocolVersion     int32                               `json:"protocolversion"`
	TotalSubsidy        uint64                              `json:"totalsubsidy,omitempty"`
	GraphState          *GetGraphStateResult                `json:"graphstate,omitempty"`
	TimeOffset          int64                               `json:"timeoffset,omitempty"`
	PowDiff             *PowDiff                            `json:"pow_diff,omitempty"`
	Confirmations       int32                               `json:"confirmations,omitempty"`
	CoinbaseMaturity    int32                               `json:"coinbasematurity,omitempty"`
	Errors              string                              `json:"errors,omitempty"`
	Modules             []string                            `json:"modules,omitempty"`
	DNS                 string                              `json:"dns,omitempty"`
	ConsensusDeployment map[string]*ConsensusDeploymentDesc `json:"consensusdeployment,omitempty"`
	Network             string                              `json:"network"`
	Connections         int32                               `json:"connections"`
}

InfoNodeResult models the data returned by the node server getnodeinfo command.

type KV

type KV struct {
	Key string
	Val interface{}
}

type MeerDAGInfoResult added in v1.0.18

type MeerDAGInfoResult struct {
	Name               string `json:"name"`
	Total              uint   `json:"total"`
	BlockCacheSize     string `json:"bcachesize"`
	BlockCacheRate     string `json:"bcacherate"`
	BlockDataCacheSize string `json:"bdcachesize"`
}

type MinerInfoResult

type MinerInfoResult struct {
	Type          string `json:"type"`
	Pow           string `json:"pow"`
	Running       bool   `json:"running"`
	Coinbase      string `json:"coinbase"`
	CoinbaseFlags string `json:"coinbaseflags"`
	Height        uint64 `json:"height"`
	Difficulty    string `json:"difficulty"`
	Target        string `json:"target"`
	Timestamp     string `json:"timestamp"`
	TotalSubmit   int    `json:"totalsubmit"`
	SuccessSubmit int    `json:"successsubmit"`
}

type NetworkInfo

type NetworkInfo struct {
	Name       string `json:"name"`
	Peers      int    `json:"peers"`
	Relays     int    `json:"relays"`
	Connecteds int    `json:"connecteds"`
	AverageGS  string `json:"averagegs,omitempty"`
	MaxGS      string `json:"maxgs,omitempty"`
	MinGS      string `json:"mings,omitempty"`
}

type NetworkStat

type NetworkStat struct {
	TotalPeers     int            `json:"totalpeers"`
	MaxConnected   uint           `json:"maxconnected"`
	MaxInbound     int            `json:"maxinbound"`
	TotalConnected int            `json:"totalconnected"`
	TotalRelays    int            `json:"totalrelays"`
	Infos          []*NetworkInfo `json:"infos"`
}

type OrderedResult

type OrderedResult []KV

The OrderedResult works as the order map[string]interface{}, which useful to marshal a Json map using a specific order Note: it works almost as the 'omitEmpty' set to true, empty value should be omitted when marshaling. only for empty string/array/map/slice/interface

func (*OrderedResult) GetValue

func (ores *OrderedResult) GetValue(key string) interface{}

func (OrderedResult) MarshalJSON

func (ores OrderedResult) MarshalJSON() ([]byte, error)

type PowDiff

type PowDiff struct {
	CurrentDiff float64 `json:"current_diff"`
}

for pow diff

type PowDiffReference

type PowDiffReference struct {
	NBits  string `json:"nbits"`
	Target string `json:"target"`
}

type PowResult

type PowResult struct {
	PowName   string     `json:"pow_name"`
	PowType   uint8      `json:"pow_type"`
	Nonce     uint64     `json:"nonce"`
	ProofData *ProofData `json:"proof_data,omitempty"`
}

pow json result

type PrevOut

type PrevOut struct {
	Addresses []string `json:"addresses,omitempty"`
	CoinId    uint16   `json:"coinId"`
	Value     float64  `json:"value"`
}

type ProofData

type ProofData struct {
	EdgeBits     int    `json:"edge_bits"`
	CircleNonces string `json:"circle_nonces"`
}

type RemoteGBTResult

type RemoteGBTResult struct {
	HeaderHex     string   `json:"headerhex"`
	CoinbaseTxHex string   `json:"coinbasetxhex"`
	TxMerklePath  []string `json:"txmerklepath,omitempty"`
	TxWitnessRoot string   `json:"txwitnessroot,omitempty"`
}

type Result

type Result map[string]interface{}

The Result works as method calling response can be marshaled as json map

type ScriptPubKeyResult

type ScriptPubKeyResult struct {
	Asm       string   `json:"asm,omitempty"`
	Hex       string   `json:"hex,omitempty"`
	ReqSigs   int32    `json:"reqSigs,omitempty"`
	Type      string   `json:"type,omitempty"`
	Addresses []string `json:"addresses,omitempty"`
}

ScriptPubKeyResult models the scriptPubKey data of a tx script. It is defined separately since it is used by multiple commands.

type ScriptSig

type ScriptSig struct {
	Asm string `json:"asm"`
	Hex string `json:"hex"`
}

ScriptSig models a signature script. It is defined separately since it only applies to non-coinbase. Therefore the field in the Vin structure needs to be a pointer.

type SubmitBlockResult

type SubmitBlockResult struct {
	BlockHash      string `json:"block_hash"`
	CoinbaseTxID   string `json:"coinbase_txid"`
	Order          string `json:"order"`
	Height         int64  `json:"height"`
	CoinbaseAmount uint64 `json:"coinbase_amount"`
	MinerType      string `json:"miner_type"`
}

GetBlockTemplateResult models the data returned from the getblocktemplate

type SubsidyInfo

type SubsidyInfo struct {
	Mode               string `json:"mode"`
	TotalSubsidy       uint64 `json:"totalsubsidy"`
	TargetTotalSubsidy int64  `json:"targettotalsubsidy,omitempty"`
	LeftTotalSubsidy   int64  `json:"lefttotalsubsidy,omitempty"`
	TotalTime          string `json:"totalTime,omitempty"`
	LeftTotalTime      string `json:"lefttotalTime,omitempty"`
	BaseSubsidy        int64  `json:"basesubsidy"`
	NextSubsidy        int64  `json:"nextsubsidy"`
}

type TemplateRequest

type TemplateRequest struct {
	Mode         string   `json:"mode,omitempty"`
	PowType      byte     `json:"pow_type"`
	Capabilities []string `json:"capabilities,omitempty"`

	// Optional long polling.
	LongPollID string `json:"longpollid,omitempty"`

	// Optional template tweaking.  SigOpLimit and SizeLimit can be int64
	// or bool.
	SigOpLimit interface{} `json:"sigoplimit,omitempty"`
	SizeLimit  interface{} `json:"sizelimit,omitempty"`
	MaxVersion uint32      `json:"maxversion,omitempty"`

	// Basic pool extension from BIP 0023.
	Target string `json:"target,omitempty"`

	// Block proposal from BIP 0023.  Data is only provided when Mode is
	// "proposal".
	Data   string `json:"data,omitempty"`
	WorkID string `json:"workid,omitempty"`
}

LL(getblocktemplate RPC) 2018-10-28 TemplateRequest is a request object as defined in BIP22 (https://en.bitcoin.it/wiki/BIP_0022), it is optionally provided as an // argument to GetBlockTemplate RPC.

type TokenState

type TokenState struct {
	CoinId     uint16 `json:"coinid"`
	CoinName   string `json:"coinname"`
	Owners     string `json:"owners"`
	UpLimit    uint64 `json:"uplimit,omitempty"`
	Enable     bool   `json:"enable,omitempty"`
	Balance    int64  `json:"balance,omitempty"`
	LockedMeer int64  `json:"lockedMEER,omitempty"`
}

type TransactionInput

type TransactionInput struct {
	Txid string `json:"txid"`
	Vout uint32 `json:"vout"`
}

TransactionInput represents the inputs to a transaction. Specifically a transaction hash and output number pair.

type TransactionOutput

type TransactionOutput struct {
	Address string `json:"address"`
	Amount  int64  `json:"amount"`
}

type TxRawResult

type TxRawResult struct {
	Hex           string `json:"hex"`
	Txid          string `json:"txid"`
	TxHash        string `json:"txhash,omitempty"`
	Size          int32  `json:"size,omitempty"`
	Version       uint32 `json:"version"`
	LockTime      uint32 `json:"locktime"`
	Timestamp     string `json:"timestamp,omitempty"`
	Expire        uint32 `json:"expire"`
	Vin           []Vin  `json:"vin"`
	Vout          []Vout `json:"vout"`
	BlockHash     string `json:"blockhash,omitempty"`
	BlockOrder    uint64 `json:"blockorder,omitempty"`
	TxIndex       uint32 `json:"txindex,omitempty"`
	Confirmations int64  `json:"confirmations"`
	Time          int64  `json:"time,omitempty"`
	Blocktime     int64  `json:"blocktime,omitempty"`
	Duplicate     bool   `json:"duplicate,omitempty"`
	Txsvalid      bool   `json:"txsvalid"`
	Type          string `json:"type,omitempty"`
}

TxRawResult models the data from the getrawtransaction command.

type Vin

type Vin struct {
	Coinbase  string     `json:"coinbase"`
	Txid      string     `json:"txid"`
	Vout      uint32     `json:"vout"`
	Sequence  uint32     `json:"sequence"`
	ScriptSig *ScriptSig `json:"scriptSig"`
	TxType    string     `json:"type,omitempty"`
	From      string     `json:"from,omitempty"`
	Value     uint64     `json:"value,omitempty"`
}

Vin models parts of the tx data. It is defined separately since getrawtransaction, decoderawtransaction, and searchrawtransaction use the same structure.

func (*Vin) IsCoinBase

func (v *Vin) IsCoinBase() bool

IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.

func (*Vin) IsNonStd

func (v *Vin) IsNonStd() bool

func (*Vin) MarshalJSON

func (v *Vin) MarshalJSON() ([]byte, error)

MarshalJSON provides a custom Marshal method for Vin.

type VinPrevOut

type VinPrevOut struct {
	Coinbase  string     `json:"coinbase"`
	Txid      string     `json:"txid"`
	Vout      uint32     `json:"vout"`
	ScriptSig *ScriptSig `json:"scriptSig"`
	PrevOut   *PrevOut   `json:"prevOut"`
	Sequence  uint32     `json:"sequence"`
}

type Vout

type Vout struct {
	Coin         string             `json:"coin,omitempty"`
	CoinId       uint16             `json:"coinid"`
	Amount       uint64             `json:"amount,omitempty"`
	ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey,omitempty"`
	To           string             `json:"to,omitempty"`
}

Vout models parts of the tx data. It is defined separately since both getrawtransaction and decoderawtransaction use the same structure.

Jump to

Keyboard shortcuts

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