libzec

package module
v0.0.0-...-5ec660f Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: GPL-3.0 Imports: 29 Imported by: 0

README

LibZEC · GitHub license CircleCI Status

Documentation

Index

Constants

View Source
const (
	Nil = TxExecutionSpeed(iota)
	Slow
	Standard
	Fast
)

TxExecutionSpeed values.

View Source
const MaxZCashFee = int64(10000)
View Source
const ZCashDust = 600
View Source
const ZCashExpiryHeight = 6000000

Variables

View Source
var ErrMismatchedPubKeys = fmt.Errorf("failed to fund the transaction mismatched script public keys")
View Source
var ErrNoSpendingTransactions = fmt.Errorf("No spending transactions")
View Source
var ErrPostConditionCheckFailed = errors.New("post-condition check failed")

ErrPostConditionCheckFailed indicates that the post-condition for executing a transaction failed.

View Source
var ErrPreConditionCheckFailed = errors.New("pre-condition check failed")

ErrPreConditionCheckFailed indicates that the pre-condition for executing a transaction failed.

View Source
var ErrTimedOut = errors.New("timed out")

Functions

func AddressFromHash160

func AddressFromHash160(hash [20]byte, params *chaincfg.Params, isScript bool) (btcutil.Address, error)

func CalcSignatureHash

func CalcSignatureHash(
	subScript []byte,
	hashType txscript.SigHashType,
	tx *zecutil.MsgTx,
	idx int,
	amt int64,
) ([]byte, error)

func DecodeAddress

func DecodeAddress(address string, params *chaincfg.Params) (btcutil.Address, error)

func NewErrInsufficientBalance

func NewErrInsufficientBalance(address string, required, current int64) error

func NewErrUnsupportedNetwork

func NewErrUnsupportedNetwork(network string) error

func NewErrZCashSubmitTx

func NewErrZCashSubmitTx(msg string) error

func PayToAddrScript

func PayToAddrScript(address btcutil.Address) ([]byte, error)

func SuggestedTxRate

func SuggestedTxRate(txSpeed TxExecutionSpeed) (int64, error)

SuggestedTxRate returns the gas price that zcashfees.earn.com recommends for transactions to be mined on ZCash blockchain based on the speed provided.

Types

type Account

type Account interface {
	Client
	BTCClient() Client
	Address() (btcutil.Address, error)
	SerializedPublicKey() ([]byte, error)
	Transfer(ctx context.Context, to string, value int64, speed TxExecutionSpeed, sendAll bool) (string, int64, error)
	SendTransaction(
		ctx context.Context,
		script []byte,
		speed TxExecutionSpeed,
		updateTxIn func(*wire.TxIn),
		preCond func(*wire.MsgTx) bool,
		f func(*txscript.ScriptBuilder),
		postCond func(*wire.MsgTx) bool,
		sendAll bool,
	) (string, int64, error)
}

Account is an ZCash external account that can sign and submit transactions to the ZCash blockchain. An Account is an abstraction over the ZCash blockchain.

func NewAccount

func NewAccount(client Client, privateKey *ecdsa.PrivateKey, logger logrus.FieldLogger) Account

NewAccount returns a user account for the provided private key which is connected to a ZCash client.

type Client

type Client interface {
	clients.ClientCore

	// Balance of the given address on ZCash blockchain.
	Balance(address string, confirmations int64) (int64, error)

	// FormatTransactionView formats the message and txhash into a user friendly
	// message.
	FormatTransactionView(msg, txhash string) string

	// SerializePublicKey serializes the given public key.
	SerializePublicKey(pubKey *btcec.PublicKey) ([]byte, error)

	// PublicKeyToAddress converts the public key to a zcash address.
	PublicKeyToAddress(pubKeyBytes []byte) (btcutil.Address, error)

	// SlaveAddress creates an a deterministic unique address that can be spent
	// by the private key correspndong to the given master public key hash
	SlaveAddress(mpkh, nonce []byte) (btcutil.Address, error)

	// SlaveScript creates a deterministic unique script that can be spent by
	// the private key correspndong to the given master public key hash
	SlaveScript(mpkh, nonce []byte) ([]byte, error)

	// UTXOCount returns the number of utxos that can be spent.
	UTXOCount(address string, confirmations int64) (int, error)

	// Validate returns whether an address is valid or not
	Validate(address string) error
}

func NewChainSoClient

func NewChainSoClient(network string) (Client, error)

func NewMercuryClient

func NewMercuryClient(network string) (Client, error)

type Tx

type Tx interface {
	Hashes() [][]byte
	InjectSigs(sigs []*btcec.Signature) error
	Submit() ([]byte, error)
}

type TxBuilder

type TxBuilder interface {
	Build(pubKey ecdsa.PublicKey, to string, contract []byte, value int64, mwUTXOs, scriptUTXOs []clients.UTXO) (Tx, error)
}

The TxBuilder can build txs, that allow the user to extract the hashes to be signed.

func NewTxBuilder

func NewTxBuilder(client Client) TxBuilder

NewTxBuilder creates a new tx builder.

type TxExecutionSpeed

type TxExecutionSpeed uint8

The TxExecutionSpeed indicates the tier of speed that the transaction falls under while writing to the blockchain.

type Wallet

type Wallet interface {
	NewAccount(derivationPath []uint32, password string) (Account, error)
}

func NewWallet

func NewWallet(mnemonic string, client Client, logger logrus.FieldLogger) Wallet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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