hivego

package module
v0.0.0-...-648783f Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 14 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

HiveGo - A client for the Hive blockchain

At this time, there are only a few functions from the client. More will be added.

*Functions added by the DCowboy fork added below

Example usage:

create a client:

hrpc := hivego.NewHiveRpc("https://api.myHiveBlockchainNode.com")

submit a custom json tx:

txid, err := hrpc.BroadcastJson([]string{submittingAccount}, []string{}, id, string(jsonPayload), &activeWif)

vote a post:

txid, err := hrpc.VotePost(voter, author, permlink, weight, &wif)

get n blocks starting from block x as the raw response from the rpc (in bytes):

responseBytes, err := hrpc.GetBlockRangeFast(startBlock int, count int)
Added by DCowboy:

Validate account:

acct, err := hrpc.CheckAccount(account)
// will return first account name that matches (expected exact match)

Validate key:

valid, err := hrpc.CheckKey(&wifVar, "alice")
//returns false and error for any reason the check failed. Returns true if valid

WARNING: It is not recommended to stream blocks from public APIs. They are provided as a service to users and saturating them with block requests may (rightfully) result in your IP getting banned

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PublicKeyPrefix = "STM"

Functions

func DecodePublicKey

func DecodePublicKey(pubKey string) (*secp256k1.PublicKey, error)

Decodes a base58 Hive public key to secp256k1 public key

func GetPublicKeyString

func GetPublicKeyString(pubKey *secp256k1.PublicKey) *string

func GphBase58CheckDecode

func GphBase58CheckDecode(input string) ([]byte, [1]byte, error)

func SignDigest

func SignDigest(digest []byte, wif *string) ([]byte, error)

Types

type HiveRpcNode

type HiveRpcNode struct {
	MaxConn     int
	MaxBatch    int
	NoBroadcast bool
	// contains filtered or unexported fields
}

func NewHiveRpc

func NewHiveRpc(addr string) *HiveRpcNode

func NewHiveRpcWithOpts

func NewHiveRpcWithOpts(addr string, maxConn int, maxBatch int) *HiveRpcNode

func (*HiveRpcNode) BroadcastJson

func (h *HiveRpcNode) BroadcastJson(reqAuth []string, reqPostAuth []string, id string, cj string, wif *string) (string, error)

func (*HiveRpcNode) CheckAccount

func (h *HiveRpcNode) CheckAccount(account string) (string, error)

func (*HiveRpcNode) CheckKey

func (h *HiveRpcNode) CheckKey(wif *string, account string) (bool, error)

func (*HiveRpcNode) GetBlockRange

func (h *HiveRpcNode) GetBlockRange(startBlock int, count int) ([]json.RawMessage, error)

func (*HiveRpcNode) GetBlockRangeFast

func (h *HiveRpcNode) GetBlockRangeFast(startBlock int, count int) ([][]byte, error)

func (*HiveRpcNode) GetDynamicGlobalProps

func (h *HiveRpcNode) GetDynamicGlobalProps() ([]byte, error)

func (*HiveRpcNode) GetTransaction

func (h *HiveRpcNode) GetTransaction(txId string, includeReversible bool) ([]byte, error)

func (*HiveRpcNode) VotePost

func (h *HiveRpcNode) VotePost(voter string, author string, permlink string, weight int, wif *string) (string, error)

type KeyPair

type KeyPair struct {
	PrivateKey *secp256k1.PrivateKey
	PublicKey  *secp256k1.PublicKey
}

func KeyPairFromWif

func KeyPairFromWif(wif string) (*KeyPair, error)

Gets a KeyPair from a given WIF String

func (*KeyPair) GetPublicKeyString

func (kp *KeyPair) GetPublicKeyString() *string

type TransactionQueryParams

type TransactionQueryParams struct {
	TransactionId     string `json:"id"`
	IncludeReversible bool   `json:"include_reversible"`
}

Jump to

Keyboard shortcuts

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