btc

package
v0.0.0-...-e66b27f Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlaceHolder           = 0xEE
	BaseDifficulty uint64 = 4294967296
	MaxHash        string = "00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
)
View Source
const (
	VersionV1 = "1.0"
	VersionV2 = "2.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockTemplate

type BlockTemplate struct {
	Capabilities             []string                    `json:"capabilities"`
	Version                  int32                       `json:"version"`
	Rules                    []string                    `json:"rules"`
	VBAvailable              interface{}                 `json:"vbavailable"`
	VBRequired               int32                       `json:"vbrequired"`
	PreviousBlockHash        string                      `json:"previousblockhash"`
	Transactions             []*BlockTemplateTransaction `json:"transactions"`
	CoinBaseAux              interface{}                 `json:"coinbaseaux"`
	CoinBaseValue            int64                       `json:"coinbasevalue"`
	LongPollId               string                      `json:"langpollid"`
	Target                   string                      `json:"target"`
	MinTime                  int32                       `json:"mintime"`
	Mutable                  []string                    `json:"mutable"`
	NonceRange               string                      `json:"noncerange"`
	SigOpLimit               int32                       `json:"sigoplimit"`
	SizeLimit                int32                       `json:"sizelimit"`
	WeightLimit              int32                       `json:"weightlimit"`
	CurTime                  int32                       `json:"curtime"`
	Bits                     string                      `json:"bits"`
	Height                   int32                       `json:"height"`
	DefaultWitnessCommitment string                      `json:"default_witness_commitment"`
}

type BlockTemplateTransaction

type BlockTemplateTransaction struct {
	Data    string  `json:"data"`
	TxId    string  `json:"txid"`
	Hash    string  `json:"hash"`
	Depends []int32 `json:"depends"`
	Fee     int32   `json:"int32"`
	SigOps  int32   `json:"sigops"`
	Weight  int32   `json:"weight"`
}

type Coin

type Coin struct {
	// contains filtered or unexported fields
}

func NewBTCoinWithArgs

func NewBTCoinWithArgs(client *RpcClient) *Coin

func NewCoin

func NewCoin() *Coin

func (*Coin) CalculateShareComputePower

func (c *Coin) CalculateShareComputePower(targetDifficulty *big.Int) (*big.Int, error)

func (*Coin) GetLatestStratumJob

func (c *Coin) GetLatestStratumJob(ctx *service.Register) (*service.StratumJobPart, []*service.Transaction, error)

func (*Coin) GetNewBlockHeight

func (c *Coin) GetNewBlockHeight() (int, error)

func (*Coin) GetTargetDifficulty

func (c *Coin) GetTargetDifficulty(bitsHex string) (*big.Int, error)

func (*Coin) IsSolveHash

func (c *Coin) IsSolveHash(hash string, targetDifficulty *big.Int) (bool, error)

func (*Coin) IsValidAddress

func (c *Coin) IsValidAddress(address string, isUsedTestNet bool) bool

func (*Coin) MakeBlock

func (c *Coin) MakeBlock(ctx *service.Register, header *service.BlockHeaderPart, base *service.BlockCoinBasePart, transactions []*service.Transaction) (*service.Block, error)

func (*Coin) SetRPCClient

func (c *Coin) SetRPCClient(client *RpcClient) *Coin

func (*Coin) SubmitBlock

func (c *Coin) SubmitBlock(data string) (bool, error)

type MiningInfo

type MiningInfo struct {
	Blocks             int     `json:"blocks"`
	CurrentBlockWeight int     `json:"currentblockweight"`
	CurrentBlockTx     int     `json:"currentblocktx"`
	Difficulty         float64 `json:"difficulty"`
	NetworkHashPs      float64 `json:"networkhashps"`
	PooledTx           int     `json:"pooledtx"`
	Chain              string  `json:"chain"`
	Warnings           string  `json:"warnings"`
}

type RpcClient

type RpcClient struct {
	// contains filtered or unexported fields
}

A rpcClient represents a JSON RPC client (over HTTP(s)).

func NewClient

func NewClient(host string, port int, user, passwd string, useSSL bool) (c *RpcClient)

func (*RpcClient) GetBlockTemplate

func (c *RpcClient) GetBlockTemplate(params interface{}) (*BlockTemplate, error)

func (*RpcClient) GetMiningInfo

func (c *RpcClient) GetMiningInfo() (*MiningInfo, error)

func (*RpcClient) SubmitBlock

func (c *RpcClient) SubmitBlock(params interface{}) (bool, error)

type RpcResponse

type RpcResponse struct {
	Id     int64           `json:"id"`
	Result json.RawMessage `json:"result"`
	Err    interface{}     `json:"error"`
}

Jump to

Keyboard shortcuts

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