[][src]Struct ergo_node_interface::node_interface::NodeInterface

pub struct NodeInterface {
    pub api_key: String,
    pub ip: String,
    pub port: String,
}

The NodeInterface struct which holds the relevant Ergo node data and has methods implemented to interact with the node.

Fields

api_key: Stringip: Stringport: String

Implementations

impl NodeInterface[src]

pub fn new(api_key: &str, ip: &str, port: &str) -> NodeInterface[src]

Create a new NodeInterface using details about the Node

pub fn node_url(&self) -> String[src]

Returns http://ip:port using ip and port from self

pub fn wallet_addresses(&self) -> Result<Vec<P2PKAddressString>>[src]

Get all addresses from the node wallet

pub fn select_wallet_address(&self) -> Result<P2PKAddressString>[src]

A CLI interactive interface for prompting a user to select an address

pub fn unspent_boxes(&self) -> Result<Vec<ErgoBox>>[src]

Acquires unspent boxes from the node wallet

pub fn unspent_boxes_sorted(&self) -> Result<Vec<ErgoBox>>[src]

Returns unspent boxes from the node wallet ordered from highest to lowest nanoErgs value.

pub fn unspent_boxes_with_min_total(
    &self,
    total: NanoErg
) -> Result<Vec<ErgoBox>>
[src]

Returns a sorted list of unspent boxes which cover at least the provided value total of nanoErgs. Note: This box selection strategy simply uses the largest value holding boxes from the user's wallet first.

pub fn unspent_boxes_with_min_total_by_age(
    &self,
    total: NanoErg
) -> Result<Vec<ErgoBox>>
[src]

Returns a list of unspent boxes which cover at least the provided value total of nanoErgs. Note: This box selection strategy simply uses the oldest unspent boxes from the user's full node wallet first.

pub fn highest_value_unspent_box(&self) -> Result<ErgoBox>[src]

Acquires the unspent box with the highest value of Ergs inside from the wallet

pub fn serialized_highest_value_unspent_box(&self) -> Result<String>[src]

Acquires the unspent box with the highest value of Ergs inside from the wallet and serializes it

pub fn serialized_unspent_boxes_with_min_total(
    &self,
    total: NanoErg
) -> Result<Vec<String>>
[src]

Acquires unspent boxes which cover total amount of nanoErgs from the wallet and serializes the boxes

pub fn p2s_to_tree(&self, address: &P2SAddressString) -> Result<String>[src]

Given a P2S Ergo address, extract the hex-encoded serialized ErgoTree (script)

pub fn p2s_to_bytes(&self, address: &P2SAddressString) -> Result<String>[src]

Given a P2S Ergo address, convert it to a hex-encoded Sigma byte array constant

pub fn p2pk_to_raw(&self, address: &P2PKAddressString) -> Result<String>[src]

Given an Ergo P2PK Address, convert it to a raw hex-encoded EC point

pub fn p2pk_to_raw_for_register(
    &self,
    address: &P2PKAddressString
) -> Result<String>
[src]

Given an Ergo P2PK Address, convert it to a raw hex-encoded EC point and prepend the type bytes so it is encoded and ready to be used in a register.

pub fn raw_to_p2pk(&self, raw: &String) -> Result<P2PKAddressString>[src]

Given a raw hex-encoded EC point, convert it to a P2PK address

pub fn raw_from_register_to_p2pk(
    &self,
    typed_raw: &String
) -> Result<P2PKAddressString>
[src]

Given a raw hex-encoded EC point from a register (thus with type encoded characters in front), convert it to a P2PK address

pub fn serialize_boxes(&self, b: &Vec<ErgoBox>) -> Result<Vec<String>>[src]

Given a Vec<ErgoBox> return the given boxes (which must be part of the UTXO-set) as a vec of serialized strings in Base16 encoding

pub fn serialize_box(&self, b: &ErgoBox) -> Result<String>[src]

Given an ErgoBox return the given box (which must be part of the UTXO-set) as a serialized string in Base16 encoding

pub fn serialized_box_from_id(&self, box_id: &String) -> Result<String>[src]

Given a box id return the given box (which must be part of the UTXO-set) as a serialized string in Base16 encoding

pub fn box_from_id(&self, box_id: &String) -> Result<ErgoBox>[src]

Given a box id return the given box (which must be part of the UTXO-set) as a serialized string in Base16 encoding

pub fn wallet_nano_ergs_balance(&self) -> Result<NanoErg>[src]

Get the current nanoErgs balance held in the Ergo Node wallet

pub fn current_block_height(&self) -> Result<BlockHeight>[src]

Get the current block height of the blockchain

impl NodeInterface[src]

pub fn get_node_api_header(&self) -> HeaderValue[src]

Builds a HeaderValue to use for requests with the api key specified

pub fn set_req_headers(&self, rb: RequestBuilder) -> RequestBuilder[src]

Sets required headers for a request

pub fn send_get_req(&self, endpoint: &str) -> Result<Response>[src]

Sends a GET request to the Ergo node

pub fn send_post_req(&self, endpoint: &str, body: String) -> Result<Response>[src]

Sends a POST request to the Ergo node

pub fn parse_response_to_json(
    &self,
    resp: Result<Response>
) -> Result<JsonValue>
[src]

Parses response from node into JSON

pub fn use_json_endpoint_and_check_errors(
    &self,
    endpoint: &str,
    json_body: &JsonString
) -> Result<JsonValue>
[src]

General function for submitting a Json String body to an endpoint which also returns a JsonValue response.

impl NodeInterface[src]

Scanning-related endpoints

pub fn register_scan(&self, scan_json: &JsonValue) -> Result<ScanID>[src]

Registers a scan with the node and either returns the scan_id or an error

pub fn scan_boxes(&self, scan_id: &ScanID) -> Result<Vec<ErgoBox>>[src]

Using the scan_id of a registered scan, acquires unspent boxes which have been found by said scan

pub fn add_box_to_scan(
    &self,
    scan_id: &ScanID,
    box_id: &String
) -> Result<String>
[src]

Using the scan_id of a registered scan, manually adds a box to said scan.

impl NodeInterface[src]

pub fn submit_json_transaction(
    &self,
    signed_tx_json: &JsonString
) -> Result<TxId>
[src]

Submits a Signed Transaction provided as input as JSON to the Ergo Blockchain mempool.

pub fn sign_json_transaction(
    &self,
    unsigned_tx_string: &JsonString
) -> Result<JsonValue>
[src]

Sign an Unsigned Transaction which is formatted in JSON

pub fn sign_and_submit_json_transaction(
    &self,
    unsigned_tx_string: &JsonString
) -> Result<TxId>
[src]

Sign an Unsigned Transaction which is formatted in JSON and then submit it to the mempool.

pub fn submit_transaction(&self, signed_tx: &Transaction) -> Result<TxId>[src]

Submits a Signed Transaction provided as input to the Ergo Blockchain mempool.

pub fn sign_transaction(
    &self,
    unsigned_tx: &UnsignedTransaction
) -> Result<Transaction>
[src]

Sign an UnsignedTransaction

pub fn sign_and_submit_transaction(
    &self,
    unsigned_tx: &UnsignedTransaction
) -> Result<TxId>
[src]

Sign an UnsignedTransaction and then submit it to the mempool.

pub fn generate_and_submit_transaction(
    &self,
    tx_request_json: &JsonString
) -> Result<TxId>
[src]

Generates and submits a tx using the node endpoints. Input is a json formatted request with rawInputs (and rawDataInputs) manually selected or inputs will be automatically selected by wallet. Returns the resulting TxId.

pub fn generate_json_transaction(
    &self,
    tx_request_json: &JsonString
) -> Result<JsonValue>
[src]

Generates Json of an Unsigned Transaction. Input must be a json formatted request with rawInputs (and rawDataInputs) manually selected or will be automatically selected by wallet.

Trait Implementations

impl Clone for NodeInterface[src]

impl Debug for NodeInterface[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,