zcashd

package module
v0.0.0-...-2b76590 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: MIT Imports: 38 Imported by: 0

README

zcashd-wallet

OpenBazaar plugin for a zcashd based wallet

Documentation

Index

Constants

View Source
const (
	Account = "OpenBazaar"
)

Variables

View Source
var (
	// ErrChecksumMismatch describes an error where decoding failed due
	// to a bad checksum.
	ErrChecksumMismatch = errors.New("checksum mismatch")

	// ErrUnknownAddressType describes an error where an address can not
	// decoded as a specific address type due to the string encoding
	// begining with an identifier byte unknown to any standard or
	// registered (via chaincfg.Register) network.
	ErrUnknownAddressType = errors.New("unknown address type")

	// ErrAddressCollision describes an error where an address can not
	// be uniquely determined as either a pay-to-pubkey-hash or
	// pay-to-script-hash address since the leading identifier is used for
	// describing both address kinds, but for different networks.  Rather
	// than assuming or defaulting to one or the other, this error is
	// returned and the caller must decide how to decode the address.
	ErrAddressCollision = errors.New("address collision")

	// ErrInvalidFormat describes an error where decoding failed due to invalid version
	ErrInvalidFormat = errors.New("invalid format: version and/or checksum bytes missing")

	NetIDs map[string]NetID
)

Functions

func CheckDecode

func CheckDecode(input string) (result []byte, version []byte, err error)

CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.

func CheckEncode

func CheckEncode(input []byte, version []byte) string

CheckEncode prepends a version byte and appends a four byte checksum.

func DecodeAddress

func DecodeAddress(addr string, defaultNet *chaincfg.Params) (btcutil.Address, error)

DecodeAddress decodes the string encoding of an address and returns the Address if addr is a valid encoding for a known address type.

The zcash network the address is associated with is extracted if possible.

func ExtractPkScriptAddrs

func ExtractPkScriptAddrs(pkScript []byte, chainParams *chaincfg.Params) (btcutil.Address, error)

ExtractPkScriptAddrs returns the type of script, addresses and required signatures associated with the passed PkScript. Note that it only works for 'standard' transaction script types. Any data such as public keys which are invalid are omitted from the results.

func GetCredentials

func GetCredentials(repoPath string) (username, password string, err error)

func PayToAddrScript

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

PayToAddrScript creates a new script to pay a transaction output to a the specified address.

func StartNotificationListener

func StartNotificationListener(client *btcrpcclient.Client, params *chaincfg.Params, listeners []func(wallet.TransactionCallback))

Types

type AddressPubKeyHash

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

AddressPubKeyHash is an Address for a pay-to-pubkey-hash (P2PKH) transaction.

func NewAddressPubKeyHash

func NewAddressPubKeyHash(pkHash []byte, net *chaincfg.Params) (*AddressPubKeyHash, error)

NewAddressPubKeyHash returns a new AddressPubKeyHash. pkHash mustbe 20 bytes.

func (*AddressPubKeyHash) EncodeAddress

func (a *AddressPubKeyHash) EncodeAddress() string

EncodeAddress returns the string encoding of a pay-to-pubkey-hash address. Part of the Address interface.

func (*AddressPubKeyHash) Hash160

func (a *AddressPubKeyHash) Hash160() *[ripemd160.Size]byte

Hash160 returns the underlying array of the pubkey hash. This can be useful when an array is more appropiate than a slice (for example, when used as map keys).

func (*AddressPubKeyHash) IsForNet

func (a *AddressPubKeyHash) IsForNet(net *chaincfg.Params) bool

IsForNet returns whether or not the pay-to-pubkey-hash address is associated with the passed zcash network.

func (*AddressPubKeyHash) ScriptAddress

func (a *AddressPubKeyHash) ScriptAddress() []byte

ScriptAddress returns the bytes to be included in a txout script to pay to a pubkey hash. Part of the Address interface.

func (*AddressPubKeyHash) String

func (a *AddressPubKeyHash) String() string

String returns a human-readable string for the pay-to-pubkey-hash address. This is equivalent to calling EncodeAddress, but is provided so the type can be used as a fmt.Stringer.

type AddressScriptHash

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

AddressScriptHash is an Address for a pay-to-script-hash (P2SH) transaction.

func NewAddressScriptHash

func NewAddressScriptHash(serializedScript []byte, net *chaincfg.Params) (*AddressScriptHash, error)

NewAddressScriptHash returns a new AddressScriptHash.

func NewAddressScriptHashFromHash

func NewAddressScriptHashFromHash(scriptHash []byte, net *chaincfg.Params) (*AddressScriptHash, error)

NewAddressScriptHashFromHash returns a new AddressScriptHash. scriptHash must be 20 bytes.

func (*AddressScriptHash) EncodeAddress

func (a *AddressScriptHash) EncodeAddress() string

EncodeAddress returns the string encoding of a pay-to-script-hash address. Part of the Address interface.

func (*AddressScriptHash) Hash160

func (a *AddressScriptHash) Hash160() *[ripemd160.Size]byte

Hash160 returns the underlying array of the script hash. This can be useful when an array is more appropiate than a slice (for example, when used as map keys).

func (*AddressScriptHash) IsForNet

func (a *AddressScriptHash) IsForNet(net *chaincfg.Params) bool

IsForNet returns whether or not the pay-to-script-hash address is associated with the passed zcash network.

func (*AddressScriptHash) ScriptAddress

func (a *AddressScriptHash) ScriptAddress() []byte

ScriptAddress returns the bytes to be included in a txout script to pay to a script hash. Part of the Address interface.

func (*AddressScriptHash) String

func (a *AddressScriptHash) String() string

String returns a human-readable string for the pay-to-script-hash address. This is equivalent to calling EncodeAddress, but is provided so the type can be used as a fmt.Stringer.

type NetID

type NetID struct {
	AddressPubKeyHash []byte
	AddressScriptHash []byte
	ZAddress          []byte
}

type NotificationListener

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

type ZcashdWallet

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

func NewZcashdWallet

func NewZcashdWallet(mnemonic string, params *chaincfg.Params, repoPath string, trustedPeer string, binary string, useTor bool, torControlPort int, proxy proxy.Dialer, disableExchangeRates bool) (*ZcashdWallet, error)

func (*ZcashdWallet) AddTransactionListener

func (w *ZcashdWallet) AddTransactionListener(callback func(wallet.TransactionCallback))

func (*ZcashdWallet) AddWatchedAddress

func (w *ZcashdWallet) AddWatchedAddress(addr btc.Address) error

func (*ZcashdWallet) AddressToScript

func (w *ZcashdWallet) AddressToScript(addr btc.Address) ([]byte, error)

func (*ZcashdWallet) Balance

func (w *ZcashdWallet) Balance() (confirmed, unconfirmed int64)

func (*ZcashdWallet) BuildArguments

func (w *ZcashdWallet) BuildArguments(rescan bool) []string

func (*ZcashdWallet) BumpFee

func (w *ZcashdWallet) BumpFee(txid chainhash.Hash) (*chainhash.Hash, error)

func (*ZcashdWallet) ChainTip

func (w *ZcashdWallet) ChainTip() (uint32, chainhash.Hash)

func (*ZcashdWallet) ChildKey

func (w *ZcashdWallet) ChildKey(keyBytes []byte, chaincode []byte, isPrivateKey bool) (*hd.ExtendedKey, error)

func (*ZcashdWallet) Close

func (w *ZcashdWallet) Close()

func (*ZcashdWallet) CreateMultisigSignature

func (w *ZcashdWallet) CreateMultisigSignature(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, key *hd.ExtendedKey, redeemScript []byte, feePerByte uint64) ([]wallet.Signature, error)

func (*ZcashdWallet) CurrencyCode

func (w *ZcashdWallet) CurrencyCode() string

func (*ZcashdWallet) CurrentAddress

func (w *ZcashdWallet) CurrentAddress(purpose wallet.KeyPurpose) btc.Address

func (*ZcashdWallet) DecodeAddress

func (w *ZcashdWallet) DecodeAddress(addr string) (btc.Address, error)

func (*ZcashdWallet) EstimateFee

func (w *ZcashdWallet) EstimateFee(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, feePerByte uint64) uint64

func (*ZcashdWallet) EstimateSpendFee

func (w *ZcashdWallet) EstimateSpendFee(amount int64, feeLevel wallet.FeeLevel) (uint64, error)

func (*ZcashdWallet) ExchangeRates

func (w *ZcashdWallet) ExchangeRates() wallet.ExchangeRates

func (*ZcashdWallet) FindHeightBeforeTime

func (w *ZcashdWallet) FindHeightBeforeTime(ts time.Time) (int32, error)

func (*ZcashdWallet) GenerateMultisigScript

func (w *ZcashdWallet) GenerateMultisigScript(keys []hd.ExtendedKey, threshold int, timeout time.Duration, timeoutKey *hd.ExtendedKey) (addr btc.Address, redeemScript []byte, err error)

func (*ZcashdWallet) GetBlockHeight

func (w *ZcashdWallet) GetBlockHeight(hash *chainhash.Hash) (int32, error)

func (*ZcashdWallet) GetConfirmations

func (w *ZcashdWallet) GetConfirmations(txid chainhash.Hash) (uint32, uint32, error)

func (*ZcashdWallet) GetFeePerByte

func (w *ZcashdWallet) GetFeePerByte(feeLevel wallet.FeeLevel) uint64

func (*ZcashdWallet) GetTransaction

func (w *ZcashdWallet) GetTransaction(txid chainhash.Hash) (wallet.Txn, error)

func (*ZcashdWallet) HasKey

func (w *ZcashdWallet) HasKey(addr btc.Address) bool

func (*ZcashdWallet) InitChan

func (w *ZcashdWallet) InitChan() chan struct{}

func (*ZcashdWallet) IsDust

func (w *ZcashdWallet) IsDust(amount int64) bool

func (*ZcashdWallet) MainNetworkEnabled

func (w *ZcashdWallet) MainNetworkEnabled() bool

MainNetworkEnabled indicates if the current network being used is the live Network

func (*ZcashdWallet) MasterPrivateKey

func (w *ZcashdWallet) MasterPrivateKey() *hd.ExtendedKey

func (*ZcashdWallet) MasterPublicKey

func (w *ZcashdWallet) MasterPublicKey() *hd.ExtendedKey

func (*ZcashdWallet) Multisign

func (w *ZcashdWallet) Multisign(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, sigs1 []wallet.Signature, sigs2 []wallet.Signature, redeemScript []byte, feePerByte uint64, broadcast bool) ([]byte, error)

func (*ZcashdWallet) NewAddress

func (w *ZcashdWallet) NewAddress(purpose wallet.KeyPurpose) btc.Address

func (*ZcashdWallet) Params

func (w *ZcashdWallet) Params() *chaincfg.Params

func (*ZcashdWallet) ReSyncBlockchain

func (w *ZcashdWallet) ReSyncBlockchain(fromDate time.Time)

func (*ZcashdWallet) RegressionNetworkEnabled

func (w *ZcashdWallet) RegressionNetworkEnabled() bool

RegressionNetworkEnabled indicates if the current network being used is Regression Network

func (*ZcashdWallet) ScriptToAddress

func (w *ZcashdWallet) ScriptToAddress(script []byte) (btc.Address, error)

func (*ZcashdWallet) Spend

func (w *ZcashdWallet) Spend(amount int64, addr btc.Address, feeLevel wallet.FeeLevel) (*chainhash.Hash, error)

func (*ZcashdWallet) Start

func (w *ZcashdWallet) Start()

func (*ZcashdWallet) SweepAddress

func (w *ZcashdWallet) SweepAddress(ins []wallet.TransactionInput, address *btc.Address, key *hd.ExtendedKey, redeemScript *[]byte, feeLevel wallet.FeeLevel) (*chainhash.Hash, error)

func (*ZcashdWallet) TestNetworkEnabled

func (w *ZcashdWallet) TestNetworkEnabled() bool

TestNetworkEnabled indicates if the current network being used is Test Network

func (*ZcashdWallet) Transactions

func (w *ZcashdWallet) Transactions() ([]wallet.Txn, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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