blockchain

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Mainnet = "mainnet"
	Testnet = "testnet"
	Regtest = "regtest"
	Simnet  = "simnet"
)

bitcoin blockchain network type

View Source
const (
	CoinTypeBitcoin        uint32 = 0
	CoinTypeBitcoinTestnet uint32 = 1
)

BIP44 CoinType

View Source
const (
	ChangeTypeExternal uint32 = 0
	ChangeTypeInternal uint32 = 1
)

BIP44 change type

View Source
const (
	AddressP2KH   string = "p2kh"
	AddressP2SH   string = "p2sh"
	AddressBech32 string = "bech32"
)
View Source
const (
	Hash      = "hash"
	HashBlock = "hashblock"
	HashTx    = "hashtx"
	RawBlock  = "rawblock"
	RawTx     = "rawtx"
)

ZMQ topics

View Source
const HardenedKey = 0x80000000

HardenedKey BIP44 hardened key

View Source
const Purpose = 44

Purpose is BIP44 purpose

Variables

View Source
var MaxTries int64 = 10

MaxTries is RPC max tries count

Functions

func GenerateMnemonic

func GenerateMnemonic(bitSize int) (string, error)

GenerateMnemonic return mnemonic (bitSize must be [128, 256] and a multiple of 32)

func GenerateSeed

func GenerateSeed(mnemonic, password string) ([]byte, error)

GenerateSeed return seed from mnemonic and password

func GetCoinType

func GetCoinType(network string) uint32

GetCoinType return BIP44 cointype by network

func GetParamsFromNetwork

func GetParamsFromNetwork(network string) (*chaincfg.Params, error)

GetParamsFromNetwork return chain params from BlockChain Network type

Types

type Account

type Account struct {
	ExtendedKey *hdkeychain.ExtendedKey
	ChainParams *chaincfg.Params
}

Account is HDWallet account

func (*Account) DeriveAddress

func (a *Account) DeriveAddress(change, addressIndex uint32, addressType string) (*ChildWallet, error)

DeriveAddress return ChildWallet by change type and addressIndex

type ChildWallet

type ChildWallet struct {
	Address   btcutil.Address
	WIF       *btcutil.WIF
	PublicKey btcec.PublicKey
}

ChildWallet is created from HDWallet by index

type HDWallet

type HDWallet struct {
	Mnemonic    string
	ExtendedKey *hdkeychain.ExtendedKey
	ChainParams *chaincfg.Params
}

HDWallet is BIP44 HD Wallet format. Apostrophe is a hardend key to enhance security m / purpose' / coin_type' / account' / change / address_index

func NewHDWallet

func NewHDWallet(bitSize int, mnemonic string, network string, password string) (*HDWallet, error)

NewHDWallet return mnemonic and HDWallet ExtendedKey and network Params

func (*HDWallet) NewAccount

func (hd *HDWallet) NewAccount(purpose, coinType, account uint32) (*Account, error)

NewAccount create Account by BIP44 settings

type Message

type Message struct {
	Msg zmq.Msg
}

Message is ZMQ message

type RPC

type RPC struct {
	Client *rpcclient.Client
}

RPC client & settings

func NewRPC

func NewRPC(hostName, port, user, password string, disabletls bool) (*RPC, error)

NewRPC return new RPC client

type ZMQ

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

ZMQ zero mq settings https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md

func NewZmqClient

func NewZmqClient(zmqAddress string, verbose bool) (*ZMQ, error)

NewZmqClient zero mq client

func (*ZMQ) Close

func (zmq *ZMQ) Close()

Close socket connection close

func (*ZMQ) Receive

func (zmq *ZMQ) Receive(message chan Message) error

Receive zmq message

Jump to

Keyboard shortcuts

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