pub trait FlorestaRPC {
Show 17 methods // Required methods fn get_block_filter(&self, heigth: u32) -> Result<String, Error>; fn get_blockchain_info(&self) -> Result<GetBlockchainInfoRes, Error>; fn get_block_hash(&self, height: u32) -> Result<BlockHash, Error>; fn get_block_header(&self, hash: BlockHash) -> Result<BlockHeader, Error>; fn get_transaction( &self, tx_id: Txid, verbosity: Option<bool> ) -> Result<Value, Error>; fn get_tx_proof(&self, tx_id: Txid) -> Result<Vec<String>, Error>; fn load_descriptor(&self, descriptor: String) -> Result<bool, Error>; fn rescan(&self, rescan: u32) -> Result<bool, Error>; fn get_height(&self) -> Result<u32, Error>; fn send_raw_transaction(&self, tx: String) -> Result<Txid, Error>; fn get_roots(&self) -> Result<Vec<String>, Error>; fn get_peer_info(&self) -> Result<Vec<PeerInfo>, Error>; fn get_block(&self, hash: BlockHash) -> Result<GetBlockRes, Error>; fn get_tx_out(&self, tx_id: Txid, outpoint: u32) -> Result<Value, Error>; fn stop(&self) -> Result<bool, Error>; fn add_node(&self, node: String) -> Result<bool, Error>; fn find_tx_out( &self, tx_id: Txid, outpoint: u32, script: String, height_hint: u32 ) -> Result<Value, Error>;
}
Expand description

A trait specifying all possible methods for floresta’s json-rpc

Required Methods§

source

fn get_block_filter(&self, heigth: u32) -> Result<String, Error>

Get the BIP158 filter for a given block height

BIP158 filters are a compact representation of the set of transactions in a block, designed for efficient light client synchronization. This method returns the filter for a given block height, encoded as a hexadecimal string. You need to have enabled block filters by setting the blockfilters=1 option

source

fn get_blockchain_info(&self) -> Result<GetBlockchainInfoRes, Error>

Returns general information about the chain we are on

This method returns a bunch of information about the chain we are on, including the current height, the best block hash, the difficulty, and whether we are currently in IBD (Initial Block Download) mode.

source

fn get_block_hash(&self, height: u32) -> Result<BlockHash, Error>

Returns the hash of the block at the given height

This method returns the hash of the block at the given height. If the height is invalid, an error is returned.

source

fn get_block_header(&self, hash: BlockHash) -> Result<BlockHeader, Error>

Returns the block header for the given block hash

This method returns the block header for the given block hash, as defined in the Bitcoin protocol specification. A header contains the block’s version, the previous block hash, the merkle root, the timestamp, the difficulty target, and the nonce.

source

fn get_transaction( &self, tx_id: Txid, verbosity: Option<bool> ) -> Result<Value, Error>

Gets a transaction from the blockchain

This method returns a transaction that’s cached in our wallet. If the verbosity flag is set to false, the transaction is returned as a hexadecimal string. If the verbosity flag is set to true, the transaction is returned as a json object.

source

fn get_tx_proof(&self, tx_id: Txid) -> Result<Vec<String>, Error>

Returns the proof that one or more transactions were included in a block

This method returns the Merkle proof, showing that a transaction was included in a block. The pooof is returned as a vector hexadecimal string.

source

fn load_descriptor(&self, descriptor: String) -> Result<bool, Error>

Loads up a descriptor into the wallet

This method loads up a descriptor into the wallet. If the rescan option is not None, the wallet will be rescanned for transactions matching the descriptor. If you have compact block filters enabled, this process will be much faster and use less bandwidth. The rescan parameter is the height at which to start the rescan, and should be at least as old as the oldest transaction this descriptor could have been used in.

source

fn rescan(&self, rescan: u32) -> Result<bool, Error>

Trigger a rescan of the wallet

This method triggers a rescan of the wallet. If you have compact block filters enabled, this process will be much faster and use less bandwidth. If you don’t have compact block filters, we’ll need to download the entire blockchain again, which will take a while. The rescan parameter is the height at which to start the rescan, and should be at least as old as the oldest transaction this descriptor could have been used in.

source

fn get_height(&self) -> Result<u32, Error>

Returns the current height of the blockchain

source

fn send_raw_transaction(&self, tx: String) -> Result<Txid, Error>

Sends a hex-encoded transaction to the network

This method sends a transaction to the network. The transaction should be encoded as a hexadecimal string. If the transaction is valid, it will be broadcast to the network, and return the transaction id. If the transaction is invalid, an error will be returned.

source

fn get_roots(&self) -> Result<Vec<String>, Error>

Gets the current accumulator for the chain we’re on

This method returns the current accumulator for the chain we’re on. The accumulator is a set of roots, that let’s us prove that a UTXO exists in the chain. This method returns a vector of hexadecimal strings, each of which is a root in the accumulator.

source

fn get_peer_info(&self) -> Result<Vec<PeerInfo>, Error>

Gets information about the peers we’re connected with

This method returns information about the peers we’re connected with. This includes the peer’s IP address, the peer’s version, the peer’s user agent, and the peer’s current height.

source

fn get_block(&self, hash: BlockHash) -> Result<GetBlockRes, Error>

Returns a block, given a block hash

This method returns a block, given a block hash. If the verbosity flag is 0, the block is returned as a hexadecimal string. If the verbosity flag is 1, the block is returned as a json object.

source

fn get_tx_out(&self, tx_id: Txid, outpoint: u32) -> Result<Value, Error>

Return a cached transaction output

This method returns a cached transaction output. If the output is not in the cache, or is spent, an empty object is returned. If you want to find a utxo that’s not in the cache, you can use the findtxout method.

source

fn stop(&self) -> Result<bool, Error>

Stops the florestad process

This can be used to gracefully stop the florestad process.

source

fn add_node(&self, node: String) -> Result<bool, Error>

Tells florestad to connect with a peer

You can use this to connect with a given node, providing it’s IP address and port.

source

fn find_tx_out( &self, tx_id: Txid, outpoint: u32, script: String, height_hint: u32 ) -> Result<Value, Error>

Finds an specific utxo in the chain

You can use this to look for a utxo. If it exists, it will return the amount and scriptPubKey of this utxo. It returns an empty object if the utxo doesn’t exist. You must have enabled block filters by setting the blockfilters=1 option.

Implementors§