client

package
v5.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncryptedData

type EncryptedData struct {
	Nonce   string `json:"nonce"`
	BodyEnc string `json:"body_enc"`
}

EncryptedData are the params or result to send/receive for the encrypted owner API

type Envelope

type Envelope struct {
	ID      JSONRPCID        `json:"id"`
	Version JSONRPCV2Version `json:"jsonrpc"`
	Method  string           `json:"method"`
	Params  json.RawMessage  `json:"params,omitempty"`
	Result  json.RawMessage  `json:"result,omitempty"`
	Error   *rpcError        `json:"error,omitempty"`
}

Envelope is the JSON-RPC envelope

type JSONRPCID

type JSONRPCID string

JSONRPCID represents the JSON-RPC V2 id will automatically be serialized

func (JSONRPCID) MarshalJSON

func (e JSONRPCID) MarshalJSON() ([]byte, error)

MarshalJSON implement the Marshaler interface on JSONRPCID

type JSONRPCV2Version

type JSONRPCV2Version string

JSONRPCV2Version represents the JSON-RPC V2 version string will always be serialized to "2.0"

func (JSONRPCV2Version) MarshalJSON

func (e JSONRPCV2Version) MarshalJSON() ([]byte, error)

MarshalJSON implement the Marshaler interface on JSONRPCVersion

type NodeForeignAPI added in v5.1.0

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

NodeForeignAPI represents the node foreign API (v2)

func NewNodeForeignAPI added in v5.1.0

func NewNodeForeignAPI(url string) *NodeForeignAPI

NewNodeForeignAPI creates a new node foreign API

func (*NodeForeignAPI) GetBlock added in v5.1.0

func (foreign *NodeForeignAPI) GetBlock(height *uint64, hash, commit *string) (*api.BlockPrintable, error)

GetBlock gets block details given either a height, a hash or an unspent output commitment. Only one parameters is needed. If multiple parameters are provided only the first one in the list is used.

func (*NodeForeignAPI) GetHeader added in v5.1.0

func (foreign *NodeForeignAPI) GetHeader(height *uint64, hash, commit *string) (*api.BlockHeaderPrintable, error)

GetHeader gets block header given either a height, a hash or an unspent output commitment. Only one parameters is needed. If multiple parameters are provided only the first one in the list is used.

func (*NodeForeignAPI) GetKernel added in v5.1.0

func (foreign *NodeForeignAPI) GetKernel(excess string, minHeight, maxHeight *uint64) (*api.LocatedTxKernel, error)

GetKernel returns a LocatedTxKernel based on the kernel excess. The min_height and max_height parameters are both optional. If not supplied, min_height will be set to 0 and max_height will be set to the head of the chain. The method will start at the block height max_height and traverse the kernel MMR backwards, until either the kernel is found or min_height is reached.

func (*NodeForeignAPI) GetOutputs added in v5.1.0

func (foreign *NodeForeignAPI) GetOutputs(commit *[]string, startHeight, endHeight *uint64, includeProof, includeMerkleProof *bool) (*[]api.OutputPrintable, error)

GetOutputs retrieves details about specifics outputs. Supports retrieval of multiple outputs in a single request. Support retrieval by both commitment string and block height.

func (*NodeForeignAPI) GetPMMRIndices added in v5.1.0

func (foreign *NodeForeignAPI) GetPMMRIndices(startBlockHeight uint64, endHBlockHeight *uint64) (*api.OutputListing, error)

GetPMMRIndices retrieves the PMMR indices based on the provided block height(s).

func (*NodeForeignAPI) GetPoolSize added in v5.1.0

func (foreign *NodeForeignAPI) GetPoolSize() (*uint, error)

GetPoolSize returns the number of transaction in the transaction pool.

func (*NodeForeignAPI) GetStempoolSize added in v5.1.0

func (foreign *NodeForeignAPI) GetStempoolSize() (*uint, error)

GetStempoolSize returns the number of transaction in the stem transaction pool.

func (*NodeForeignAPI) GetTip added in v5.1.0

func (foreign *NodeForeignAPI) GetTip() (*api.Tip, error)

GetTip returns details about the state of the current fork tip.

func (*NodeForeignAPI) GetUnconfirmedTransactions added in v5.1.0

func (foreign *NodeForeignAPI) GetUnconfirmedTransactions() (*[]pool.PoolEntry, error)

GetUnconfirmedTransactions returns the unconfirmed transactions in the transaction pool. Will not return transactions in the stempool.

func (*NodeForeignAPI) GetUnspentOutputs added in v5.1.0

func (foreign *NodeForeignAPI) GetUnspentOutputs(startIndex uint64, endIndex *uint64, max uint64, includeProof *bool) (*api.OutputListing, error)

GetUnspentOutputs is an UTXO traversal. Retrieves last utxos since a start_index until a max.

func (*NodeForeignAPI) GetVersion added in v5.1.0

func (foreign *NodeForeignAPI) GetVersion() (*api.Version, error)

GetVersion returns details about the state of the current fork tip.

func (*NodeForeignAPI) PushTransaction added in v5.1.0

func (foreign *NodeForeignAPI) PushTransaction(tx core.Transaction, fluff *bool) error

PushTransaction pushes a new transaction to our local transaction pool.

type NodeOwnerAPI added in v5.1.0

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

NodeOwnerAPI represents the node owner API (v2)

func NewNodeOwnerAPI added in v5.1.0

func NewNodeOwnerAPI(url string) *NodeOwnerAPI

NewNodeOwnerAPI creates a new node owner API

func (*NodeOwnerAPI) BanPeer added in v5.1.0

func (owner *NodeOwnerAPI) BanPeer(peerAddr string) error

BanPeer bans a specific peer.

func (*NodeOwnerAPI) CompactChain added in v5.1.0

func (owner *NodeOwnerAPI) CompactChain() error

CompactChain triggers a compaction of the chain state to regain storage space.

func (*NodeOwnerAPI) GetConnectedPeers added in v5.1.0

func (owner *NodeOwnerAPI) GetConnectedPeers() (*[]p2p.PeerInfoDisplay, error)

GetConnectedPeers retrieve information about stored peers. If None is provided, will list all stored peers.

func (*NodeOwnerAPI) GetPeers added in v5.1.0

func (owner *NodeOwnerAPI) GetPeers(peerAddr *string) (*[]p2p.PeerData, error)

GetPeers retrieves information about stored peers. If None is provided, will list all stored peers.

func (*NodeOwnerAPI) GetStatus added in v5.1.0

func (owner *NodeOwnerAPI) GetStatus() (*api.Status, error)

GetStatus returns various information about the node, the network and the current sync status.

func (*NodeOwnerAPI) UnbanPeer added in v5.1.0

func (owner *NodeOwnerAPI) UnbanPeer(peerAddr string) error

UnbanPeer unbans a specific peer.

func (*NodeOwnerAPI) ValidateChain added in v5.1.0

func (owner *NodeOwnerAPI) ValidateChain() error

ValidateChain triggers a validation of the chain state.

type RPCHTTPClient

type RPCHTTPClient struct {
	URL string
}

RPCHTTPClient is a JSON-RPC over HTTP Client

func (*RPCHTTPClient) EncryptedRequest

func (c *RPCHTTPClient) EncryptedRequest(method string, params json.RawMessage, sharedSecret []byte) (*Envelope, error)

EncryptedRequest do an encrypted RPC POST request with the server

func (*RPCHTTPClient) Request

func (c *RPCHTTPClient) Request(method string, params json.RawMessage) (*Envelope, error)

Request do a RPC POST request with the server

type Result

type Result struct {
	Ok  json.RawMessage
	Err json.RawMessage
}

Result is golang equivalent of Rust result

type WalletForeignAPI added in v5.1.0

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

WalletForeignAPI represents the wallet foreign API (v2)

func NewWalletForeignAPI added in v5.1.0

func NewWalletForeignAPI(url string) *WalletForeignAPI

NewWalletForeignAPI creates a new wallet foreign API

func (*WalletForeignAPI) BuildCoinbase added in v5.1.0

func (foreign *WalletForeignAPI) BuildCoinbase(blockFees libwallet.BlockFees) (*libwallet.CbData, error)

BuildCoinbase builds a new unconfirmed coinbase output in the wallet, generally for inclusion in a potential new block's coinbase output during mining.

All potential coinbase outputs are created as 'Unconfirmed' with the coinbase flag set. If a potential coinbase output is found on the chain after a wallet update, it status is set to Unsent and a Transaction Log Entry will be created. Note the output will be unspendable until the coinbase maturity period has expired.

func (*WalletForeignAPI) CheckVersion added in v5.1.0

func (foreign *WalletForeignAPI) CheckVersion() (*libwallet.VersionInfo, error)

CheckVersion returns the version capabilities of the running ForeignApi Node

func (*WalletForeignAPI) FinalizeTx added in v5.1.0

func (foreign *WalletForeignAPI) FinalizeTx(slate *slateversions.SlateV4) (*slateversions.SlateV4, error)

FinalizeTx finalizes a (standard or invoice) transaction initiated by this wallet's Owner api. This step assumes the paying party has completed round 1 and 2 of slate creation, and added their partial signatures. This wallet will verify and add their partial sig, then create the finalized transaction, ready to post to a node.

This function also stores the final transaction in the user's wallet files for retrieval via the get_stored_tx function.

func (*WalletForeignAPI) ReceiveTx added in v5.1.0

func (foreign *WalletForeignAPI) ReceiveTx(slate slateversions.SlateV4, destAcctName *string, dest *string) (*slateversions.SlateV4, error)

ReceiveTx receives a transaction created by another party, returning the modified Slate object, modified with the recipient's output for the transaction amount, and public signature data. This slate can then be sent back to the sender to finalize the transaction via the Owner API's finalize_tx method.

This function creates a single output for the full amount, set to a status of 'Awaiting finalization'. It will remain in this state until the wallet finds the corresponding output on the chain, at which point it will become 'Unspent'. The slate will be updated with the results of Signing round 1 and 2, adding the recipient's public nonce, public excess value, and partial signature to the slate.

Also creates a corresponding Transaction Log Entry in the wallet's transaction log.

type WalletOwnerAPI added in v5.1.0

type WalletOwnerAPI struct {
	PublicKey       btcec.PublicKey
	ServerPublicKey *btcec.PublicKey
	// contains filtered or unexported fields
}

WalletOwnerAPI represents the wallet owner API (v3)

func NewWalletOwnerAPI added in v5.1.0

func NewWalletOwnerAPI(url string) *WalletOwnerAPI

NewWalletOwnerAPI creates a new wallet owner API

func (*WalletOwnerAPI) Accounts added in v5.1.0

func (owner *WalletOwnerAPI) Accounts() (*[]libwallet.AccountPathMapping, error)

Accounts Returns a list of accounts stored in the wallet (i.e. mappings between user-specified labels and BIP32 derivation paths

func (*WalletOwnerAPI) CancelTx added in v5.1.0

func (owner *WalletOwnerAPI) CancelTx(txID *uint32, txSlateID *uuid.UUID) error

CancelTx cancels a transaction.

func (*WalletOwnerAPI) Close added in v5.1.0

func (owner *WalletOwnerAPI) Close(name *string) error

Close is an helper function to close the wallet and free the token from memory

func (*WalletOwnerAPI) CloseWallet added in v5.1.0

func (owner *WalletOwnerAPI) CloseWallet(name *string) error

CloseWallet close a wallet, removing the master seed from memory.

func (*WalletOwnerAPI) CreateSlatepackMessage added in v5.1.0

func (owner *WalletOwnerAPI) CreateSlatepackMessage(derivationIndex uint32, slate slateversions.SlateV4, senderIndex *uint32, recipients []string) (*string, error)

CreateSlatepackMessage create a slatepack message from the given slate

func (*WalletOwnerAPI) DecodeSlatepackMessage added in v5.1.0

func (owner *WalletOwnerAPI) DecodeSlatepackMessage(message string, secretIndices []uint32) (*slatepack.Slatepack, error)

DecodeSlatepackMessage decodes a slatepack message

func (*WalletOwnerAPI) FinalizeTx added in v5.1.0

func (owner *WalletOwnerAPI) FinalizeTx(slateIn slateversions.SlateV4) (*slateversions.SlateV4, error)

FinalizeTx finalizes a transaction, after all parties have filled in both rounds of Slate generation.

func (*WalletOwnerAPI) GetSlatepackAddress added in v5.1.0

func (owner *WalletOwnerAPI) GetSlatepackAddress(derivationIndex uint32) (*string, error)

GetSlatepackAddress retrieve the slatepack address for the current parent key at the given index

func (*WalletOwnerAPI) GetSlatepackSecretKey added in v5.1.0

func (owner *WalletOwnerAPI) GetSlatepackSecretKey(derivationIndex uint32) (*string, error)

GetSlatepackSecretKey retrieve the decryption key for the current parent key the given index

func (*WalletOwnerAPI) GetStoredTx added in v5.1.0

func (owner *WalletOwnerAPI) GetStoredTx(id *uint32, slateID *uuid.UUID) (*slateversions.SlateV4, error)

GetStoredTx retrieves the stored transaction associated with a TxLogEntry. Can be used even after the transaction has completed. Either the Transaction Log ID or the Slate UUID must be supplied. If both are supplied, the Transaction Log ID is preferred.

func (*WalletOwnerAPI) Init added in v5.1.0

func (owner *WalletOwnerAPI) Init() error

Init initalize the secure owner API

func (*WalletOwnerAPI) InitSecureAPI added in v5.1.0

func (owner *WalletOwnerAPI) InitSecureAPI(pubKey []byte) (string, error)

InitSecureAPI Initializes the secure JSON-RPC API. This function must be called and a shared key established before any other WalletOwnerAPI JSON-RPC function can be called.

func (*WalletOwnerAPI) InitSendTx added in v5.1.0

func (owner *WalletOwnerAPI) InitSendTx(initTxArgs libwallet.InitTxArgs) (*slateversions.SlateV4, error)

InitSendTx initiates a new transaction as the sender, creating a new Slate object containing the sender's inputs, change outputs, and public signature data.

func (*WalletOwnerAPI) NodeHeight added in v5.1.0

func (owner *WalletOwnerAPI) NodeHeight() (*libwallet.NodeHeightResult, error)

NodeHeight retrieves the last known height known by the node.

func (*WalletOwnerAPI) Open added in v5.1.0

func (owner *WalletOwnerAPI) Open(name *string, password string) error

Open is an helper function to open the wallet and set the token

func (*WalletOwnerAPI) OpenWallet added in v5.1.0

func (owner *WalletOwnerAPI) OpenWallet(name *string, password string) (string, error)

OpenWallet `opens` a wallet, populating the internal keychain with the encrypted seed, and optionally returning a `keychain_mask` token to the caller to provide in all future calls. If using a mask, the seed will be stored in-memory XORed against the `keychain_mask`, and will not be useable if the mask is not provided.

func (*WalletOwnerAPI) PostTx added in v5.1.0

func (owner *WalletOwnerAPI) PostTx(slate slateversions.SlateV4, fluff bool) error

PostTx posts a completed transaction to the listening node for validation and inclusion in a block for mining.

func (*WalletOwnerAPI) RetrieveOutputs added in v5.1.0

func (owner *WalletOwnerAPI) RetrieveOutputs(includeSpent, refreshFromNode bool, txID *uint32) (bool, *[]libwallet.OutputCommitMapping, error)

RetrieveOutputs returns a list of outputs from the active account in the

func (*WalletOwnerAPI) RetrieveSummaryInfo added in v5.1.0

func (owner *WalletOwnerAPI) RetrieveSummaryInfo(refreshFromNode bool, minimumConfirmations uint64) (bool, *libwallet.WalletInfo, error)

RetrieveSummaryInfo returns summary information from the active account in the

func (*WalletOwnerAPI) RetrieveTxs added in v5.1.0

func (owner *WalletOwnerAPI) RetrieveTxs(refreshFromNode bool, txID *uint32, txSlateID *uuid.UUID) (bool, *[]libwallet.TxLogEntry, error)

RetrieveTxs returns a list of Transaction Log Entries from the active account in the

func (*WalletOwnerAPI) SetTorConfig added in v5.1.0

func (owner *WalletOwnerAPI) SetTorConfig(torConfig libwallet.TorConfig) error

SetTorConfig set the TOR configuration for this instance of the WalletOwnerAPI, used during InitSendTx when send args are present and a TOR address is specified

func (*WalletOwnerAPI) SlateFromSlatepackMessage added in v5.1.0

func (owner *WalletOwnerAPI) SlateFromSlatepackMessage(message string, secretIndices []uint32) (*slateversions.SlateV4, error)

SlateFromSlatepackMessage create a slate from a slatepack message

func (*WalletOwnerAPI) TxLockOutputs added in v5.1.0

func (owner *WalletOwnerAPI) TxLockOutputs(slate slateversions.SlateV4) error

TxLockOutputs locks the outputs associated with the inputs to the transaction in the given Slate, making them unavailable for use in further transactions.

Jump to

Keyboard shortcuts

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