nuls

package
v0.0.0-...-fae8f5a Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MainnetMagic wire.BitcoinNet = 0xbd6b0cbf
	TestnetMagic wire.BitcoinNet = 0xffcae2ce
	RegtestMagic wire.BitcoinNet = 0xdcb7c1fc

	AddressHashLength = 24
)

magic numbers

Variables

View Source
var (
	MainNetParams chaincfg.Params
	TestNetParams chaincfg.Params
	RegtestParams chaincfg.Params
)

chain parameters

Functions

func GetChainParams

func GetChainParams(chain string) *chaincfg.Params

GetChainParams contains network parameters for the main Gincoin network, the regression test Gincoin network, the test Gincoin network and the simulation test Gincoin network, in this order

func NewNulsRPC

func NewNulsRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error)

NewNulsRPC returns new NulsRPC instance

Types

type CmdGetBestBlockHash

type CmdGetBestBlockHash struct {
	Success bool `json:"success"`
	Data    struct {
		Value string `json:"value"`
	} `json:"data"`
}

type CmdGetBestBlockHeight

type CmdGetBestBlockHeight struct {
	Success bool `json:"success"`
	Data    struct {
		Value uint32 `json:"value"`
	} `json:"data"`
}

type CmdGetBlock

type CmdGetBlock struct {
	Success bool `json:"success"`
	Data    struct {
		Hash           string  `json:"hash"`
		PreHash        string  `json:"preHash"`
		MerkleHash     string  `json:"merkleHash"`
		StateRoot      string  `json:"stateRoot"`
		Time           int64   `json:"time"`
		Height         int64   `json:"height"`
		TxCount        int     `json:"txCount"`
		PackingAddress string  `json:"packingAddress"`
		ConfirmCount   int     `json:"confirmCount"`
		ScriptSig      string  `json:"scriptSig"`
		Size           int     `json:"size"`
		Reward         float64 `json:"reward"`
		Fee            float64 `json:"fee"`

		TxList []Tx `json:"txList"`
	} `json:"data"`
}

type CmdGetBlockHeader

type CmdGetBlockHeader struct {
	Success bool `json:"success"`
	Data    struct {
		Hash           string  `json:"hash"`
		PreHash        string  `json:"preHash"`
		MerkleHash     string  `json:"merkleHash"`
		StateRoot      string  `json:"stateRoot"`
		Time           int64   `json:"time"`
		Height         int64   `json:"height"`
		TxCount        int     `json:"txCount"`
		PackingAddress string  `json:"packingAddress"`
		ConfirmCount   int     `json:"confirmCount"`
		ScriptSig      string  `json:"scriptSig"`
		Size           int     `json:"size"`
		Reward         float64 `json:"reward"`
		Fee            float64 `json:"fee"`
	} `json:"data"`
}

type CmdGetNetworkInfo

type CmdGetNetworkInfo struct {
	Success bool `json:"success"`
	Data    struct {
		LocalBestHeight int64  `json:"localBestHeight"`
		NetBestHeight   int    `json:"netBestHeight"`
		TimeOffset      string `json:"timeOffset"`
		InCount         int8   `json:"inCount"`
		OutCount        int8   `json:"outCount"`
	} `json:"data"`
}

type CmdGetTx

type CmdGetTx struct {
	Success bool `json:"success"`
	Tx      Tx   `json:"data"`
}

type CmdGetTxBytes

type CmdGetTxBytes struct {
	Success bool `json:"success"`
	Data    struct {
		Value string `json:"value"`
	} `json:"data"`
}

type CmdGetVersionInfo

type CmdGetVersionInfo struct {
	Success bool `json:"success"`
	Data    struct {
		MyVersion      string `json:"myVersion"`
		NewestVersion  string `json:"newestVersion"`
		NetworkVersion int    `json:"networkVersion"`
		Information    string `json:"information"`
	} `json:"data"`
}

type CmdTxBroadcast

type CmdTxBroadcast struct {
	Success bool `json:"success"`
	Data    struct {
		Value string `json:"value"`
	} `json:"data"`
}

type NulsParser

type NulsParser struct {
	*btc.BitcoinLikeParser
}

NulsParser handle

func NewNulsParser

func NewNulsParser(params *chaincfg.Params, c *btc.Configuration) *NulsParser

NewNulsParser returns new NulsParser instance

func (*NulsParser) DeriveAddressDescriptorsFromTo

func (p *NulsParser) DeriveAddressDescriptorsFromTo(descriptor *bchain.XpubDescriptor, change uint32, fromIndex uint32, toIndex uint32) ([]bchain.AddressDescriptor, error)

DeriveAddressDescriptorsFromTo derives address descriptors from given xpub for addresses in index range

func (*NulsParser) GetAddrDescFromAddress

func (p *NulsParser) GetAddrDescFromAddress(address string) (bchain.AddressDescriptor, error)

GetAddrDescFromAddress returns internal address representation (descriptor) of given address

func (*NulsParser) GetAddrDescFromVout

func (p *NulsParser) GetAddrDescFromVout(output *bchain.Vout) (bchain.AddressDescriptor, error)

GetAddrDescFromVout returns internal address representation (descriptor) of given transaction output

func (*NulsParser) GetAddressesFromAddrDesc

func (p *NulsParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]string, bool, error)

GetAddressesFromAddrDesc returns addresses for given address descriptor with flag if the addresses are searchable

func (*NulsParser) PackTx

func (p *NulsParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error)

PackTx packs transaction to byte array

func (*NulsParser) PackedTxidLen

func (p *NulsParser) PackedTxidLen() int

PackedTxidLen returns length in bytes of packed txid

func (*NulsParser) ParseTx

func (p *NulsParser) ParseTx(b []byte) (*bchain.Tx, error)

ParseTx parses tx from blob

func (*NulsParser) UnpackTx

func (p *NulsParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error)

UnpackTx unpacks transaction from byte array

type NulsRPC

type NulsRPC struct {
	*btc.BitcoinRPC
	// contains filtered or unexported fields
}

NulsRPC is an interface to JSON-RPC bitcoind service

func (*NulsRPC) Call

func (b *NulsRPC) Call(uri string, res interface{}) error

Call calls Backend RPC interface, using RPCMarshaler interface to marshall the request

func (*NulsRPC) EstimateFee

func (n *NulsRPC) EstimateFee(blocks int) (big.Int, error)

func (*NulsRPC) EstimateSmartFee

func (n *NulsRPC) EstimateSmartFee(blocks int, conservative bool) (big.Int, error)

func (*NulsRPC) GetBestBlockHash

func (n *NulsRPC) GetBestBlockHash() (string, error)

func (*NulsRPC) GetBestBlockHeight

func (n *NulsRPC) GetBestBlockHeight() (uint32, error)

func (*NulsRPC) GetBlock

func (n *NulsRPC) GetBlock(hash string, height uint32) (*bchain.Block, error)

func (*NulsRPC) GetBlockHash

func (n *NulsRPC) GetBlockHash(height uint32) (string, error)

func (*NulsRPC) GetBlockHeader

func (n *NulsRPC) GetBlockHeader(hash string) (*bchain.BlockHeader, error)

func (*NulsRPC) GetBlockHeaderByHeight

func (n *NulsRPC) GetBlockHeaderByHeight(height uint32) (*bchain.BlockHeader, error)

func (*NulsRPC) GetBlockInfo

func (n *NulsRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error)

func (*NulsRPC) GetChainInfo

func (n *NulsRPC) GetChainInfo() (*bchain.ChainInfo, error)

func (*NulsRPC) GetMempoolTransactions

func (n *NulsRPC) GetMempoolTransactions() ([]string, error)

func (*NulsRPC) GetTransaction

func (n *NulsRPC) GetTransaction(txid string) (*bchain.Tx, error)

func (*NulsRPC) GetTransactionForMempool

func (n *NulsRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error)

func (*NulsRPC) GetTransactionSpecific

func (n *NulsRPC) GetTransactionSpecific(tx *bchain.Tx) (json.RawMessage, error)

func (*NulsRPC) Initialize

func (n *NulsRPC) Initialize() error

Initialize initializes GincoinRPC instance.

func (*NulsRPC) Post

func (b *NulsRPC) Post(uri string, req interface{}, res interface{}) error

func (*NulsRPC) SendRawTransaction

func (n *NulsRPC) SendRawTransaction(tx string) (string, error)

type Tx

type Tx struct {
	Hash         string  `json:"hash"`
	Type         int     `json:"type"`
	Time         int64   `json:"time"`
	BlockHeight  int64   `json:"blockHeight"`
	Fee          float64 `json:"fee"`
	Value        float64 `json:"value"`
	Remark       string  `json:"remark"`
	ScriptSig    string  `json:"scriptSig"`
	Status       int     `json:"status"`
	ConfirmCount int     `json:"confirmCount"`
	Size         int     `json:"size"`
	Inputs       []struct {
		FromHash  string  `json:"fromHash"`
		FromIndex uint32  `json:"fromIndex"`
		Address   string  `json:"address"`
		Value     float64 `json:"value"`
	} `json:"inputs"`
	Outputs []struct {
		Address  string `json:"address"`
		Value    int64  `json:"value"`
		LockTime int64  `json:"lockTime"`
	} `json:"outputs"`
}

Jump to

Keyboard shortcuts

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