json

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: ISC Imports: 5 Imported by: 3

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 AdreesAmount added in v0.10.1

type AdreesAmount map[string]Amout

type Amounts added in v0.10.1

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

type Amout added in v0.10.1

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

type BlockResult added in v0.10.1

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 added in v0.10.1

type ConsensusDeploymentDesc struct {
	Status    string `json:"status"`
	Bit       uint8  `json:"bit"`
	StartTime int64  `json:"startTime"`
	Timeout   int64  `json:"timeout"`
	Perform   int64  `json:"perform,omitempty"`
	Since     string `json:"since,omitempty"`
}

type DecodeRawTransactionResult added in v0.10.1

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 added in v0.10.1

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"`

	// 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"`
}

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"`
	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"`
}

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"`
	GraphState          GetGraphStateResult                 `json:"graphstate"`
	TimeOffset          int64                               `json:"timeoffset"`
	Connections         int32                               `json:"connections"`
	PowDiff             PowDiff                             `json:"pow_diff"`
	Network             string                              `json:"network"`
	Confirmations       int32                               `json:"confirmations"`
	CoinbaseMaturity    int32                               `json:"coinbasematurity"`
	Errors              string                              `json:"errors"`
	Modules             []string                            `json:"modules"`
	DNS                 string                              `json:"dns,omitempty"`
	ConsensusDeployment map[string]*ConsensusDeploymentDesc `json:"consensusdeployment"`
}

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

type KV

type KV struct {
	Key string
	Val interface{}
}

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 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"`
	Hex       string   `json:"hex,omitempty"`
	ReqSigs   int32    `json:"reqSigs,omitempty"`
	Type      string   `json:"type"`
	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 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 added in v0.10.1

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 added in v0.10.1

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 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"`
}

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"`
}

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 added in v0.10.1

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"`
	CoinId       uint16             `json:"coinid"`
	Amount       uint64             `json:"amount"`
	ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"`
}

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