rpc

package
v0.0.0-...-3927449 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: MIT Imports: 8 Imported by: 1

README

Build Status GitHub license GoDoc Coverage Status

rpcclient

Overview

This library is the RPC client for aknode.

Requirements

  • git
  • go 1.9+

are required to compile this.

Installation

 $ go get github.com/AidosKuneen/rpcclient

Contribution

Improvements to the codebase and pull requests are encouraged.

Dependencies and Licenses

This software includes the work that is distributed in the Apache License 2.0.

github.com/AidosKuneen/aklib          MIT License
github.com/AidosKuneen/aknode         MIT License
github.com/AidosKuneen/cuckoo         MIT License
github.com/AidosKuneen/numcpu         MIT License
github.com/AidosKuneen/sha256-simd    Apache License 2.0
github.com/AidosKuneen/xmss           MIT License
github.com/AndreasBriese/bbloom       MIT License, Public Domain
github.com/dgraph-io/badger           Apache License 2.0
github.com/dgryski/go-farm            MIT License
github.com/golang/protobuf/proto      BSD 3-clause "New" or "Revised" License
github.com/mattn/go-shellwords        MIT License
github.com/pkg/errors                 BSD 2-clause "Simplified" License
github.com/vmihailenco/msgpack/codes  BSD 2-clause "Simplified" License
golang.org/x/net                      BSD 3-clause "New" or "Revised" License
golang.org/x/sys/unix                 BSD 3-clause "New" or "Revised" License
Golang Standard Library               BSD 3-clause License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	Address string `json:"address"`
	Service byte   `json:"service"`
}

Addr is an IP address and port.

type AddressGroup

type AddressGroup struct {
	Address string
	Amount  float64
	Account *string
}

AddressGroup is a result of ListAddressGroupings.

type Bans

type Bans struct {
	Address string `json:"address"`
	Created int64  `json:"ban_created"`
	Until   int64  `json:"banned_until"`
	Reason  string `json:"ban_reason"`
}

Bans is a struct for listbanned RPC.

type Details

type Details struct {
	Account   string  `json:"account"`
	Address   string  `json:"address"`
	Category  string  `json:"category"`
	Amount    float64 `json:"amount"`
	Vout      int64   `json:"vout"`
	Fee       float64 `json:"fee"`
	Abandoned *bool   `json:"abandoned,omitempty"`
}

Details is a struct for gettransaction RPC.

type Err

type Err struct {
	Code    int64  `json:"code"`
	Message string `json:"message"`
}

Err represents error struct for response.

type GetLastHistoryResponse

type GetLastHistoryResponse struct {
	FromStart bool         `json:"from_start"`
	InoutHash []*InoutHash `json:"inout_hash"`
}

GetLastHistoryResponse is the response of get_last_history.

type Gettx

type Gettx struct {
	Amount            float64    `json:"amount"`
	Fee               float64    `json:"fee"`
	Confirmations     int        `json:"confirmations"`
	Blockhash         *string    `json:"blockhash,omitempty"`
	Blockindex        *int64     `json:"blockindex,omitempty"`
	Blocktime         *int64     `json:"blocktime,omitempty"`
	Txid              string     `json:"txid"`
	WalletConflicts   []string   `json:"walletconflicts"`
	Time              int64      `json:"time"`
	TimeReceived      int64      `json:"timereceived"`
	BIP125Replaceable string     `json:"bip125-replaceable"`
	Details           []*Details `json:"details"`
	Hex               string     `json:"hex"`
}

Gettx is a struct for gettransaction RPC.

type Info

type Info struct {
	IsValid      bool    `json:"isvalid"`
	Address      string  `json:"address"`
	ScriptPubKey string  `json:"scriptPubkey"`
	IsMine       bool    `json:"ismine"`
	IsWatchOnly  *bool   `json:"iswatchonly,omitempty"`
	IsScript     *bool   `json:"isscript,omitempty"`
	Pubkey       *string `json:"pubkey,omitempty"`
	IsCompressed *bool   `json:"iscompressed,omitempty"`
	Account      *string `json:"account,omitempty"`
}

Info is a struct for validateaddress RPC.

type InoutHash

type InoutHash struct {
	Hash  string           `json:"hash"`
	Type  tx.InOutHashType `json:"type"`
	Index byte             `json:"index"`
}

InoutHash is a struct for getlasthistory RPC.

type NodeInfo

type NodeInfo struct {
	Version         string `json:"version"`
	ProtocolVersion int    `json:"protocolversion"`
	WalletVersion   int    `json:"walletversion"`
	Connections     int    `json:"connections"`
	Proxy           string `json:"proxy"`
	IsSynced        bool   `json:"is_synced"`
	Testnet         byte   `json:"testnet"`
	Leaves          int    `json:"leaves"`
	Time            int64  `json:"time"`
	TxNo            uint64 `json:"txno"`
	Orphants        int    `json:"orphants"`
	Pendings        int    `json:"pendings"`
	Rejected        int    `json:"rejected"`
}

NodeInfo is a struct for getnodeinfo RPC.

type OTA

type OTA struct {
	Hash        string `json:"hash"`
	ExchangeKey string `json:"exchange_key"`
}

OTA is a struct for one time address.

type RPC

type RPC struct {
	Endpoint string
	User     string
	Password string
	// contains filtered or unexported fields
}

RPC is for calling RPCs.

func New

func New(endpoint, user, password string, c *http.Client) *RPC

New takes an (optional) endpoint and optional http.Client and returns an RPC struct.

func (*RPC) DumpPrivKey

func (client *RPC) DumpPrivKey() (string, error)

DumpPrivKey sends a dumpprivkey RPC.

func (*RPC) DumpWallet

func (client *RPC) DumpWallet(fname string) error

DumpWallet sends a dumpwallet RPC.

func (*RPC) GetAccount

func (client *RPC) GetAccount(account string) (string, error)

GetAccount sends a getaccount RPC.

func (*RPC) GetBalance

func (client *RPC) GetBalance(account string) (float64, error)

GetBalance sends a getbalance RPC.

func (*RPC) GetLastHistory

func (client *RPC) GetLastHistory(adr, orHash string, utxoOnly bool) (bool, []*tx.InoutHash, error)

GetLastHistory sends a getlasthistory RPC.

func (*RPC) GetLeaves

func (client *RPC) GetLeaves() ([]tx.Hash, error)

GetLeaves sends a getleaves RPC.

func (*RPC) GetMinableFeeTx

func (client *RPC) GetMinableFeeTx(fee float64) (*tx.Transaction, error)

GetMinableFeeTx sends a getminabletx RPC for fee reward.

func (*RPC) GetMinableTicketTx

func (client *RPC) GetMinableTicketTx() (*tx.Transaction, error)

GetMinableTicketTx sends a getminabletx RPC for tiecket reward.

func (*RPC) GetMultisigInfo

func (client *RPC) GetMultisigInfo(adr string) (*tx.MultisigStruct, error)

GetMultisigInfo sends a getmultisiginfo RPC.

func (*RPC) GetNewAddress

func (client *RPC) GetNewAddress(account string) (string, error)

GetNewAddress sends a getnewaddress RPC.

func (*RPC) GetNodeinfo

func (client *RPC) GetNodeinfo() (*NodeInfo, error)

GetNodeinfo sends a getnodeinfo RPC.

func (*RPC) GetOTATxs

func (client *RPC) GetOTATxs(num, skip int) ([]*OTA, error)

GetOTATxs sends a getotatxs RPC.

func (*RPC) GetRawTx

func (client *RPC) GetRawTx(txid []string) ([]*tx.Transaction, error)

GetRawTx sends a getrawtx RPC.

func (*RPC) GetTransaction

func (client *RPC) GetTransaction(txid string) (*Gettx, error)

GetTransaction sends a gettransactions RPC.

func (*RPC) GetTxsStatus

func (client *RPC) GetTxsStatus(txid ...string) ([]*TxStatus, error)

GetTxsStatus sends a gettxsstatus RPC.

func (*RPC) ImportWallet

func (client *RPC) ImportWallet(fname string) error

ImportWallet sends a importwallet RPC.

func (*RPC) ListAccounts

func (client *RPC) ListAccounts() (map[string]float64, error)

ListAccounts sends a listaccounts RPC.

func (*RPC) ListAddressGroupings

func (client *RPC) ListAddressGroupings() ([]*AddressGroup, error)

ListAddressGroupings sends a listaddressgroupings RPC.

func (*RPC) ListBanned

func (client *RPC) ListBanned() ([]*Bans, error)

ListBanned sends a listbanned RPC.

func (*RPC) ListPeer

func (client *RPC) ListPeer() ([]Addr, error)

ListPeer sends a listpeer RPC.

func (*RPC) ListTransactions

func (client *RPC) ListTransactions(account string, count, skip int) ([]*Transaction, error)

ListTransactions sends a listtransactions RPC.

func (*RPC) SendFrom

func (client *RPC) SendFrom(account, address string, amount float64) (string, error)

SendFrom sends a sendfrom RPC.

func (*RPC) SendMany

func (client *RPC) SendMany(account string, amounts map[string]float64) (string, error)

SendMany sends a sendmany RPC.

func (*RPC) SendRawTX

func (client *RPC) SendRawTX(tx *tx.Transaction, typ tx.Type) (string, error)

SendRawTX sends a sendrawtx RPC.

func (*RPC) SendToAddress

func (client *RPC) SendToAddress(address string, amount float64) (string, error)

SendToAddress sends a sendtoaddress RPC.

func (*RPC) SetTxFee

func (client *RPC) SetTxFee(amount float64) (bool, error)

SetTxFee sends a settxfee RPC.

func (*RPC) Stop

func (client *RPC) Stop() error

Stop sends a stop RPC.

func (*RPC) ValidateAddress

func (client *RPC) ValidateAddress(address string) (*Info, error)

ValidateAddress sends a validateaddress RPC.

func (*RPC) WalletLock

func (client *RPC) WalletLock() error

WalletLock sends a walletlock RPC.

func (*RPC) WalletPassphrase

func (client *RPC) WalletPassphrase(pp string, sec int) error

WalletPassphrase sends a walletpassphrase RPC.

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      interface{}     `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"`
}

Request is for parsing request from client.

type Response

type Response struct {
	Result interface{} `json:"result"`
	Error  *Err        `json:"error"`
	ID     interface{} `json:"id"`
}

Response is for respoding to clinete in jsonrpc.

type Transaction

type Transaction struct {
	Account  *string `json:"account"`
	Address  string  `json:"address"`
	Category string  `json:"category"`
	Amount   float64 `json:"amount"`
	// Label             string      `json:"label"`
	Vout          int64   `json:"vout"`
	Fee           float64 `json:"fee"`
	Confirmations int     `json:"confirmations"`
	Trusted       *bool   `json:"trusted,omitempty"`
	// Generated         bool        `json:"generated"`
	Blockhash       *string  `json:"blockhash,omitempty"`
	Blockindex      *int64   `json:"blockindex,omitempty"`
	Blocktime       *int64   `json:"blocktime,omitempty"`
	Txid            string   `json:"txid"`
	Walletconflicts []string `json:"walletconflicts"`
	Time            int64    `json:"time"`
	TimeReceived    int64    `json:"timereceived"`
	// Comment           string      `json:"string"`
	// To                string `json:"to"`
	// Otheraccount      string `json:"otheraccount"`
	BIP125Replaceable string `json:"bip125-replaceable"`
	Abandoned         *bool  `json:"abandoned,omitempty"`
}

Transaction is a struct for listtransactions RPC.

func (*Transaction) ToDetail

func (dt *Transaction) ToDetail() (*Details, error)

ToDetail converts dt to Details struct.

type TxStatus

type TxStatus struct {
	Hash        string `json:"hash"`
	Exists      bool   `json:"exists"`
	IsRejected  bool   `json:"is_rejected"`
	IsConfirmed bool   `json:"is_confirmed"`
}

TxStatus represents a confirmation status of a tx.

func (*TxStatus) IsAccepted

func (s *TxStatus) IsAccepted() bool

IsAccepted returns true if the tx is confirmed and accepted.

Jump to

Keyboard shortcuts

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