turtlecoinrpc

package module
v0.0.0-...-60d30fd Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: MIT Imports: 7 Imported by: 0

README

TurtleCoin RPC API

Go Report Card GoDoc

A Golang wrapper for the TurtleCoin RPC API

License

// Copyright (c) 2018-2019 Rashed Mohammed, The TurtleCoin Developers
// Please see the included LICENSE file for more information

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrettyPrint

func PrettyPrint(response interface{})

PrettyPrint prints the given map as a JSON object

Types

type TurtleCoind

type TurtleCoind struct {
	URL  string
	Port int
}

TurtleCoind structure contains the URL and Port info of node for RPC calls

func (*TurtleCoind) Fee

func (daemon *TurtleCoind) Fee() (map[string]interface{}, error)

Fee method returns the fee set by the node

func (*TurtleCoind) GetBlock

func (daemon *TurtleCoind) GetBlock(hash string) (map[string]interface{}, error)

GetBlock method returns the information of block corresponding to given input hash

func (*TurtleCoind) GetBlockCount

func (daemon *TurtleCoind) GetBlockCount() (map[string]interface{}, error)

GetBlockCount method returns the height of the top block

func (*TurtleCoind) GetBlockHash

func (daemon *TurtleCoind) GetBlockHash(height int) (map[string]interface{}, error)

GetBlockHash method returns the block hash by height

func (*TurtleCoind) GetBlockHeaderByHash

func (daemon *TurtleCoind) GetBlockHeaderByHash(hash string) (map[string]interface{}, error)

GetBlockHeaderByHash method returns the block header corresponding to the input block hash

func (*TurtleCoind) GetBlockHeaderByHeight

func (daemon *TurtleCoind) GetBlockHeaderByHeight(height int) (map[string]interface{}, error)

GetBlockHeaderByHeight method returns the block header corresponding to the input block height

func (*TurtleCoind) GetBlockTemplate

func (daemon *TurtleCoind) GetBlockTemplate(reserveSize int, walletAddress string) (map[string]interface{}, error)

GetBlockTemplate method returns the block template blob of the last block

func (*TurtleCoind) GetBlocks

func (daemon *TurtleCoind) GetBlocks(height int) (map[string]interface{}, error)

GetBlocks method returns information on 30 blocks from specified height (inclusive)

func (*TurtleCoind) GetCurrencyID

func (daemon *TurtleCoind) GetCurrencyID() (map[string]interface{}, error)

GetCurrencyID method returns the currency id of the network

func (*TurtleCoind) GetLastBlockHeader

func (daemon *TurtleCoind) GetLastBlockHeader() (map[string]interface{}, error)

GetLastBlockHeader method returns the block header of the last block

func (*TurtleCoind) GetTransaction

func (daemon *TurtleCoind) GetTransaction(hash string) (map[string]interface{}, error)

GetTransaction method returns information of transaction corresponding to given input hash

func (*TurtleCoind) GetTransactionPool

func (daemon *TurtleCoind) GetTransactionPool() (map[string]interface{}, error)

GetTransactionPool method returns the list of unconfirmed transactions present in mem pool

func (*TurtleCoind) Height

func (daemon *TurtleCoind) Height() (map[string]interface{}, error)

Height method returns the height of the blockchain

func (*TurtleCoind) Info

func (daemon *TurtleCoind) Info() (map[string]interface{}, error)

Info method returns information related to network and connection

func (*TurtleCoind) Peers

func (daemon *TurtleCoind) Peers() (map[string]interface{}, error)

Peers method returns array of peers connected to daemon

func (*TurtleCoind) SubmitBlock

func (daemon *TurtleCoind) SubmitBlock(blockBlob string) (map[string]interface{}, error)

SubmitBlock method submits a block to the network corresponding to the input block blob

type WalletAPI

type WalletAPI struct {
	URL         string
	Port        int
	DaemonURL   string
	DaemonPort  int
	DaemonSSL   bool
	RPCPassword string
}

WalletAPI structure contains the info of wallet URL and Port, Daemon URL and Port, and RPCPassword

func (*WalletAPI) Addresses

func (wallet *WalletAPI) Addresses() (map[string]interface{}, error)

Addresses gets a list of all addresses in the wallet container

func (*WalletAPI) Balance

func (wallet *WalletAPI) Balance(address string) (map[string]interface{}, error)

Balance returns the balance of specific address in the wallet container

func (*WalletAPI) Balances

func (wallet *WalletAPI) Balances() ([]map[string]interface{}, error)

Balances returns the balance of all addresses in the wallet container

func (*WalletAPI) CloseWallet

func (wallet *WalletAPI) CloseWallet() error

CloseWallet saves and closes the opened wallet

func (*WalletAPI) CreateAddress

func (wallet *WalletAPI) CreateAddress() (map[string]interface{}, error)

CreateAddress creates a new random address in the wallet container.

func (*WalletAPI) CreateIntegratedAddress

func (wallet *WalletAPI) CreateIntegratedAddress(
	address string,
	paymentID string) (map[string]interface{}, error)

CreateIntegratedAddress creates an integrated address from the specified address and payment id

func (*WalletAPI) CreateWallet

func (wallet *WalletAPI) CreateWallet(
	filename string,
	password string) error

CreateWallet creates a wallet with the specified filename and password.

func (*WalletAPI) DeleteAddress

func (wallet *WalletAPI) DeleteAddress(address string) error

DeleteAddress deletes the subwallet address from the container. Note that you cannot delete the primary address (first address in the container)

func (*WalletAPI) GetNodeDetails

func (wallet *WalletAPI) GetNodeDetails() (map[string]interface{}, error)

GetNodeDetails gets the node address, port fee and fee address.

func (*WalletAPI) GetTransactionDetails

func (wallet *WalletAPI) GetTransactionDetails(hash string) (map[string]interface{}, error)

GetTransactionDetails returns the details of the given transaction hash if it is present in the wallet, else error occurs

func (*WalletAPI) ImportAddress

func (wallet *WalletAPI) ImportAddress(
	scanHeight int,
	spendKey string) (map[string]interface{}, error)

ImportAddress imports a subwallet with given private spend key

func (*WalletAPI) ImportKey

func (wallet *WalletAPI) ImportKey(
	filename string,
	password string,
	scanHeight int,
	spendKey string,
	viewKey string) error

ImportKey imports a wallet with a private spend and view key

func (*WalletAPI) ImportSeed

func (wallet *WalletAPI) ImportSeed(
	filename string,
	password string,
	scanHeight int,
	mnemonicSeed string) error

ImportSeed imports a wallet using a mnemonic seed

func (*WalletAPI) ImportViewAddress

func (wallet *WalletAPI) ImportViewAddress(
	scanHeight int,
	spendKey string) (map[string]interface{}, error)

ImportViewAddress imports a view only subwallet with the given public spend key

func (*WalletAPI) ImportViewOnly

func (wallet *WalletAPI) ImportViewOnly(
	filename string,
	password string,
	scanHeight int,
	viewkey string,
	address string) error

ImportViewOnly imports a wallet using a mnemonic seed

func (*WalletAPI) Keys

func (wallet *WalletAPI) Keys(address string) (map[string]interface{}, error)

Keys returns the public and private key of the given address

func (*WalletAPI) MnemonicSeed

func (wallet *WalletAPI) MnemonicSeed(address string) (map[string]interface{}, error)

MnemonicSeed return the mnemonic seed for the given address if possible

func (*WalletAPI) OpenWallet

func (wallet *WalletAPI) OpenWallet(
	filename string,
	password string) error

OpenWallet opens an already existing wallet

func (*WalletAPI) Primary

func (wallet *WalletAPI) Primary() (map[string]interface{}, error)

Primary returns the primary address. It is the first address created and is used as change address if not specified.

func (*WalletAPI) PrivateViewKey

func (wallet *WalletAPI) PrivateViewKey() (map[string]interface{}, error)

PrivateViewKey returns the shared private view key of the wallet container

func (*WalletAPI) Reset

func (wallet *WalletAPI) Reset(scanHeight int) error

Reset method resets and saves the wallet, beginning scanning from the height given.

func (*WalletAPI) Save

func (wallet *WalletAPI) Save() error

Save saves the current wallet state

func (*WalletAPI) SendAdvancedFusion

func (wallet *WalletAPI) SendAdvancedFusion(
	mixin int,
	sourceAddress []string,
	destinationAddress string) (map[string]interface{}, error)

SendAdvancedFusion sends a single fusion transaction if it can and returns the transaction hash

func (*WalletAPI) SendAdvancedTransaction

func (wallet *WalletAPI) SendAdvancedTransaction(
	destinations []map[string]interface{},
	mixin int,
	fee int,
	sourceAddresses []string,
	paymentID string,
	changeAddress string,
	unlockTime int) (map[string]interface{}, error)

SendAdvancedTransaction sends the specified amount to the specified address with the specified paymentID.

func (*WalletAPI) SendBasicFusion

func (wallet *WalletAPI) SendBasicFusion() (map[string]interface{}, error)

SendBasicFusion sends a single fusion transaction if it can and returns the transaction hash

func (*WalletAPI) SendBasicTransaction

func (wallet *WalletAPI) SendBasicTransaction(
	destinationAddress string,
	amount int,
	paymentID string) (map[string]interface{}, error)

SendBasicTransaction sends the specified amount to the specified address with the specified paymentID.

func (*WalletAPI) SetNode

func (wallet *WalletAPI) SetNode(
	daemonHost string,
	daemonPort int,
	daemonSSL bool) error

SetNode sets the node address and port

func (*WalletAPI) Status

func (wallet *WalletAPI) Status() (map[string]interface{}, error)

Status method returns the current sync status of the wallet container

func (*WalletAPI) TotalBalance

func (wallet *WalletAPI) TotalBalance() (map[string]interface{}, error)

TotalBalance returns the total balance of the wallet container

func (*WalletAPI) TransactionPrivateKey

func (wallet *WalletAPI) TransactionPrivateKey(hash string) (map[string]interface{}, error)

TransactionPrivateKey returns the private key of the transaction for auditing purposes.

func (*WalletAPI) Transactions

func (wallet *WalletAPI) Transactions(startHeight int, endHeight int) (map[string]interface{}, error)

Transactions return a list of transactions within the range of startHeight and endHeight. If endHeight is less than startHeight then it returns all transactions from the startHeight for 1000 blocks.

func (*WalletAPI) TransactionsByAddress

func (wallet *WalletAPI) TransactionsByAddress(
	address string,
	startHeight int,
	endHeight int) (map[string]interface{}, error)

TransactionsByAddress returns list of transactions corresponding to that address. If endHeight is less than startHeight then it returns all transactions from startHeight for 1000 blocks.

func (*WalletAPI) UnconfirmedTransactions

func (wallet *WalletAPI) UnconfirmedTransactions(address string) (map[string]interface{}, error)

UnconfirmedTransactions returns the list of unconfirmed transactions for the specified address. If the address is empty then it returns all the unconfirmed transactions in the wallet container.

func (*WalletAPI) ValidateAddress

func (wallet *WalletAPI) ValidateAddress(address string) (map[string]interface{}, error)

ValidateAddress method validates an address for TRTL compatibility and returns the address break-down

type Walletd

type Walletd struct {
	URL         string
	Port        int
	RPCPassword string
}

Walletd structure contains the URL and Port info of the wallet service and RPC Password for RPC calls

func (*Walletd) CreateAddress

func (wallet *Walletd) CreateAddress(
	spendSecretKey string,
	spendPublicKey string,
	scanHeight int,
	newAddress bool) (map[string]interface{}, error)

CreateAddress method creates a new address inside the container along with old addresses

func (*Walletd) CreateDelayedTransaction

func (wallet *Walletd) CreateDelayedTransaction(
	addresses []string,
	transfers []map[string]interface{},
	fee int,
	unlockTime int,
	extra string,
	paymentID string,
	changeAddress string) (map[string]interface{}, error)

CreateDelayedTransaction method allows you to create a delayed transaction Such transactions are not sent into the network automatically and should be pushed using SendDelayedTransaction method

func (*Walletd) CreateIntegratedAddress

func (wallet *Walletd) CreateIntegratedAddress(address string, paymentID string) (map[string]interface{}, error)

CreateIntegratedAddress method creates a unique 236 char long address which corresponds to the specified address with paymentID

func (*Walletd) DeleteAddress

func (wallet *Walletd) DeleteAddress(address string) (map[string]interface{}, error)

DeleteAddress method deletes the specified address from the container

func (*Walletd) DeleteDelayedTransaction

func (wallet *Walletd) DeleteDelayedTransaction(transactionHash string) (map[string]interface{}, error)

DeleteDelayedTransaction method deletes the specified delayedTransactionHash

func (*Walletd) EstimateFusion

func (wallet *Walletd) EstimateFusion(threshold int, addresses []string) (map[string]interface{}, error)

EstimateFusion method returns the number of outputs that can be optimized This is helpful for sending fusion transactions

func (*Walletd) GetAddresses

func (wallet *Walletd) GetAddresses() (map[string]interface{}, error)

GetAddresses method returns an array of addresses present in the container

func (*Walletd) GetBalance

func (wallet *Walletd) GetBalance(address string) (map[string]interface{}, error)

GetBalance method returns the balance present in the specified address If the address is empty then returns the balance present in the container

func (*Walletd) GetBlockHashes

func (wallet *Walletd) GetBlockHashes(firstBlockIndex int, blockCount int) (map[string]interface{}, error)

GetBlockHashes method returns array of hashes starting from specified blockIndex upto blockCount

func (*Walletd) GetDelayedTransactionHashes

func (wallet *Walletd) GetDelayedTransactionHashes() (map[string]interface{}, error)

GetDelayedTransactionHashes method returns array of delayedTransactionHashes

func (*Walletd) GetFeeInfo

func (wallet *Walletd) GetFeeInfo() (map[string]interface{}, error)

GetFeeInfo method returns the fee information that the service picks up from the connected daemon

func (*Walletd) GetMnemonicSeed

func (wallet *Walletd) GetMnemonicSeed(address string) (map[string]interface{}, error)

GetMnemonicSeed method returns the 25 word random seed corresponding to the given input wallet address

func (*Walletd) GetSpendKeys

func (wallet *Walletd) GetSpendKeys(address string) (map[string]interface{}, error)

GetSpendKeys method returns the spendPublicKey and spendSecretKey corresponding the given input wallet address

func (*Walletd) GetStatus

func (wallet *Walletd) GetStatus() (map[string]interface{}, error)

GetStatus method returns the sync state of the wallet and known top block height

func (*Walletd) GetTransaction

func (wallet *Walletd) GetTransaction(transactionHash string) (map[string]interface{}, error)

GetTransaction method returns the transaction details of a particular specified transaction hash

func (*Walletd) GetTransactionHashes

func (wallet *Walletd) GetTransactionHashes(
	addresses []string,
	blockHash string,
	firstBlockIndex int,
	blockCount int,
	paymentID string) (map[string]interface{}, error)

GetTransactionHashes method returns array of objects containing block and transaction hashes of the specified address

func (*Walletd) GetTransactions

func (wallet *Walletd) GetTransactions(
	addresses []string,
	blockHash string,
	firstBlockIndex int,
	blockCount int,
	paymentID string) (map[string]interface{}, error)

GetTransactions method returns array of objects containing block and transaction details of the specified address

func (*Walletd) GetUnconfirmedTransactionHashes

func (wallet *Walletd) GetUnconfirmedTransactionHashes(addresses []string) (map[string]interface{}, error)

GetUnconfirmedTransactionHashes method returns array of hashes of unconfirmed transactions of the specified address

func (*Walletd) GetViewKey

func (wallet *Walletd) GetViewKey() (map[string]interface{}, error)

GetViewKey method returns the viewSecretKey of the wallet

func (*Walletd) Reset

func (wallet *Walletd) Reset(scanHeight int) (map[string]interface{}, error)

Reset method resyncs the wallet if no viewSecretKey is given. If viewSecretKey is given then it replaces the existing wallet with a new one corresponding to the viewSecretKey

func (*Walletd) Save

func (wallet *Walletd) Save() (map[string]interface{}, error)

Save method saves the wallet without closing it.

func (*Walletd) SendDelayedTransaction

func (wallet *Walletd) SendDelayedTransaction(transactionHash string) (map[string]interface{}, error)

SendDelayedTransaction method sends the delayedTransaction created using CreateDelayedTransaction method into the network

func (*Walletd) SendFusionTransaction

func (wallet *Walletd) SendFusionTransaction(
	threshold int,
	addresses []string,
	destinationAddress string) (map[string]interface{}, error)

SendFusionTransaction method allows you to send a fusion transaction from selected address to destination address. If there aren't any outputs that can be optimized it returns an error.

func (*Walletd) SendTransaction

func (wallet *Walletd) SendTransaction(
	addresses []string,
	transfers []map[string]interface{},
	fee int,
	unlockTime int,
	extra string,
	paymentID string,
	changeAddress string) (map[string]interface{}, error)

SendTransaction method sends specified transactions

Jump to

Keyboard shortcuts

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