zcashrpc

package module
v0.0.0-...-94b9190 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 10 Imported by: 0

README

zcashrpc

A small go library for interfacing with a zcash full node. Currently supports:

  • gettransaction
  • z_validateaddress
  • z_sendmany
  • z_listreceivedbyaddress

Documentation

Index

Constants

View Source
const (
	GetBlock       Method = "getblock"
	GetTransaction Method = "gettransaction"

	ZGetTotalBalance       = "z_gettotalbalance"
	ZListAddresses         = "z_listaddresses"
	ZListReceivedByAddress = "z_listreceivedbyaddress"
	ZSendMany              = "z_sendmany"
	ZValidateAddress       = "z_validateaddress"
)

Constant block of Method assignments

Variables

This section is empty.

Functions

func NewGetBlock

func NewGetBlock(is int) []byte

NewGetBlock constructs a properly formatted getblock request

func NewGetTransaction

func NewGetTransaction(id string) []byte

NewGetTransaction constructs a properly formatted gettransaction request

func NewZGetTotalBalance

func NewZGetTotalBalance(minConfirmations int) []byte

NewZGetTotalBalance constructs a properly formatted z_gettotalbalance request

func NewZListAddresses

func NewZListAddresses() []byte

NewZListAddresses constructs a properly formatted z_listaddresses request

func NewZListReceivedByAddress

func NewZListReceivedByAddress(fromAddress string) []byte

NewZListReceivedByAddress constructs a properly formatted z_listreceivedbyaddress request

func NewZSendMany

func NewZSendMany(fromAddress string, amounts []ZcashAmount) []byte

NewZSendMany constructs a properly formatted z_sendmany request

func NewZValidateAddress

func NewZValidateAddress(address string) []byte

NewZValidateAddress constructs a properly formatted z_validateaddress request

Types

type Block

type Block struct {
	Transactions []string `json:"tx"`
}

Block

type Hex

type Hex string

Hex encapsulates behaviour related to zcash hex encoding of certain fields like memo and keys

func MakeHex

func MakeHex(input string) Hex

MakeHex converts a string into a zcash-compatible hex string

func (Hex) Decode

func (h Hex) Decode() ([]byte, error)

Decode returns the raw byte representation of a hex-string

type Method

type Method string

Method restricts method definitions to constants

type Transaction

type Transaction struct {
	Time int `json:"time"`
}

Transaction encapsulates the result of GetTransaction TODO: currently this only supports time so we can obtain an ordered list of transactions

type ZGetTotalBalanceResponse

type ZGetTotalBalanceResponse struct {
	Transparent string `json:"transparent"`
	Private     string `json:"private"`
	Total       string `json:"total"`
}

ZGetTotalBalanceResponse encapsulates the result returned from a z_gettotalbalance request

type ZValidateAddressResponse

type ZValidateAddressResponse struct {
	IsValid                    bool   `json:"isvalid"`
	Address                    string `json:"address"`
	Type                       string `json:"type"`
	IsMine                     bool   `json:"ismine"`
	Diversifier                Hex    `json:"diversifier"`
	DiversifiedTransmissionKey Hex    `json:"diversifiedtransmissionkey"`
}

ZValidateAddressResponse encapsulates the result returned from a z_validateaddress request

type ZcashAmount

type ZcashAmount struct {
	Address string  `json:"address"`
	Amount  float64 `json:"amount"`
	Memo    Hex     `json:"memo"`
}

ZcashAmount an object representing an amount to send in z_sendmany

func NewZcashAmount

func NewZcashAmount(toAddress string, memo string, amount float64) ZcashAmount

NewZcashAmount generates a new ZcashAmount object with a properly hex encoded memo field

type ZcashClient

type ZcashClient interface {
	GetTotalBalance(minConfirmations int) (float64, error)
	GetTransaction(string) (Transaction, error)
	ListAddresses() ([]string, error)
	ListReceivedTransactionsByAddress(string) ([]ZcashTransaction, error)
	GetBlock(int) (Block, error)
	SendOne(string, string, string, float64) ([]byte, error)
	ValidateAddress(address string) (ZValidateAddressResponse, error)
}

ZcashClient defines an interface for any zcash client to present.

func NewLocalClient

func NewLocalClient(username, password string) ZcashClient

NewLocalClient creates a new Zcash rpc client over a local address

func NewOnionClient

func NewOnionClient(onion string, username, password string, acn connectivity.ACN) ZcashClient

NewOnionClient creates a new Zcash rpc client over an onion address

type ZcashResult

type ZcashResult struct {
	Result interface{} `json:"result"`
}

ZcashResult represents the result of a zcash operation. Result can be any one of a number of defined types.

type ZcashTransaction

type ZcashTransaction struct {
	TransactionID string  `json:"txid"`
	Amount        float64 `json:"amount"`
	Memo          Hex     `json:"memo"`
	Change        bool    `json:"change"`
	OutIndex      int     `json:"outindex"`

	// The following parameters are not provided by the zcash node
	Address string `json:"address"`
}

ZcashTransaction defines a transaction received to a zaddress

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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