Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Client implements a JSON-RPC client for the Bitcoin Core daemon or compatible APIs.

Implementations§

Source§

impl Client

Source

pub fn new(url: &str) -> Self

Creates a client to a bitcoind JSON-RPC server without authentication.

Source

pub fn new_with_auth(url: &str, auth: Auth) -> Result<Self>

Creates a client to a bitcoind JSON-RPC server with authentication.

Source

pub fn call<T: for<'a> Deserialize<'a>>( &self, method: &str, args: &[Value], ) -> Result<T>

Call an RPC method with given args list.

Source§

impl Client

Source

pub fn check_expected_server_version(&self) -> Result<()>

Checks that the JSON-RPC endpoint is for a bitcoind instance with the expected version.

Source§

impl Client

Source

pub fn dump_tx_out_set( &self, path: &str, snapshot_type: &str, ) -> Result<DumpTxOutSet>

Source§

impl Client

Source

pub fn best_block_hash(&self) -> Result<BlockHash>

Gets the blockhash of the current chain tip.

Source

pub fn get_best_block_hash(&self) -> Result<GetBestBlockHash>

Source§

impl Client

Source

pub fn get_block(&self, hash: BlockHash) -> Result<Block>

Gets a block by blockhash.

Source

pub fn get_block_verbose_zero( &self, hash: BlockHash, ) -> Result<GetBlockVerboseZero>

Gets a block by blockhash with verbose set to 0.

Source

pub fn get_block_verbose_one( &self, hash: BlockHash, ) -> Result<GetBlockVerboseOne>

Gets a block by blockhash with verbose set to 1.

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn get_block_from_peer( &self, blockhash: BlockHash, peer_id: u32, ) -> Result<()>

Source§

impl Client

Source

pub fn get_block_hash(&self, height: u64) -> Result<GetBlockHash>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn get_tx_out(&self, txid: Txid, vout: u64) -> Result<GetTxOut>

Source§

impl Client

Source

pub fn get_tx_out_proof(&self, txids: &[Txid]) -> Result<String>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn import_mempool(&self, filepath: &str) -> Result<()>

Source§

impl Client

Source

pub fn precious_block(&self, hash: BlockHash) -> Result<()>

Source§

impl Client

Source

pub fn prune_blockchain(&self, target: u64) -> Result<PruneBlockchain>

Instructs the node to prune the blockchain up to a specified height or timestamp.

Source§

impl Client

Source§

impl Client

Source

pub fn scan_blocks_abort(&self) -> Result<ScanBlocksAbort>

Aborts an ongoing scanblocks scan.

Source

pub fn scan_blocks_start( &self, scan_objects: &[&str], ) -> Result<ScanBlocksStart>

Starts a scan of blocks for specified descriptors.

Source

pub fn scan_blocks_status(&self) -> Result<Option<ScanBlocksStatus>>

Checks the status of an ongoing scanblocks scan.

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn help(&self) -> Result<String>

Source§

impl Client

Source

pub fn logging(&self) -> Result<Logging>

Source§

impl Client

Source

pub fn stop(&self) -> Result<String>

Source§

impl Client

Source

pub fn uptime(&self) -> Result<u32>

Source§

impl Client

Source

pub fn generate_block( &self, output: &str, transactions: &[String], submit: bool, ) -> Result<GenerateBlock>

Source§

impl Client

Source

pub fn generate_to_address( &self, nblocks: usize, address: &Address, ) -> Result<GenerateToAddress>

Source§

impl Client

Source

pub fn generate_to_descriptor( &self, nblocks: usize, descriptor: &str, ) -> Result<GenerateToDescriptor>

Source§

impl Client

Source

pub fn invalidate_block(&self, hash: BlockHash) -> Result<()>

Source§

impl Client

Source

pub fn add_peer_address( &self, address: &str, port: u16, ) -> Result<AddPeerAddress>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn prioritise_transaction( &self, txid: &Txid, fee_delta: SignedAmount, ) -> Result<bool>

Source§

impl Client

Source

pub fn submit_block(&self, block: &Block) -> Result<()>

Source§

impl Client

Source

pub fn submit_header(&self, header: &Header) -> Result<()>

Source§

impl Client

Source

pub fn add_node(&self, node: &str, command: AddNodeCommand) -> Result<()>

Source§

impl Client

Source

pub fn clear_banned(&self) -> Result<()>

Source§

impl Client

Source

pub fn disconnect_node(&self, address: &str) -> Result<()>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn server_version(&self) -> Result<usize>

Returns the server version field of GetNetworkInfo.

Source

pub fn get_network_info(&self) -> Result<GetNetworkInfo>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn ping(&self) -> Result<()>

Source§

impl Client

Source

pub fn set_ban(&self, subnet: &str, command: SetBanCommand) -> Result<()>

Source§

impl Client

Source§

impl Client

Source

pub fn analyze_psbt(&self, psbt: &Psbt) -> Result<AnalyzePsbt>

Source§

impl Client

Source

pub fn combine_psbt(&self, txs: &[Psbt]) -> Result<CombinePsbt>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn create_psbt( &self, inputs: &[Input], outputs: &[Output], ) -> Result<CreatePsbt>

Source§

impl Client

Source

pub fn create_raw_transaction( &self, inputs: &[Input], outputs: &[Output], ) -> Result<CreateRawTransaction>

Source§

impl Client

Source

pub fn decode_psbt(&self, psbt: &str) -> Result<DecodePsbt>

Source§

impl Client

Source§

impl Client

Source

pub fn decode_script(&self, script: &str) -> Result<DecodeScript>

Source§

impl Client

Source

pub fn finalize_psbt(&self, psbt: &Psbt) -> Result<FinalizePsbt>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn join_psbts(&self, psbts: &[Psbt]) -> Result<JoinPsbts>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn submit_package( &self, package: &[Transaction], max_fee_rate: Option<FeeRate>, max_burn_amount: Option<Amount>, ) -> Result<SubmitPackage>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn create_multisig( &self, nrequired: u32, keys: Vec<PublicKey>, ) -> Result<CreateMultisig>

Source§

impl Client

Source

pub fn derive_addresses(&self, descriptor: &str) -> Result<DeriveAddresses>

Source

pub fn derive_addresses_multipath( &self, descriptor: &str, range: (u32, u32), ) -> Result<DeriveAddressesMultipath>

Source§

impl Client

Source§

impl Client

Source

pub fn get_descriptor_info(&self, descriptor: &str) -> Result<GetDescriptorInfo>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn verify_message( &self, address: &Address<NetworkChecked>, signature: &MessageSignature, message: &str, ) -> Result<VerifyMessage>

Source§

impl Client

Source

pub fn abandon_transaction(&self, txid: Txid) -> Result<()>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn backup_wallet(&self, destination: &Path) -> Result<()>

Source§

impl Client

Source

pub fn bump_fee(&self, txid: Txid) -> Result<BumpFee>

Source§

impl Client

Source

pub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet>

Calls createwallet with wallet as the only argument.

In v23 and later this creates a descriptor wallet. Use create_legacy_wallet to create a legacy wallet.

Source

pub fn create_legacy_wallet(&self, wallet: &str) -> Result<CreateWallet>

Creates a legacy wallet (i.e not a native descriptor wallet).

createwallet “wallet_name” ( disable_private_keys blank “passphrase” avoid_reuse descriptors load_on_startup external_signer )

Creates and loads a new wallet.

Arguments:

  1. wallet_name (string, required) The name for the new wallet. If this is a path, the wallet will be created at the path location.
  2. disable_private_keys (boolean, optional, default=false) Disable the possibility of private keys (only watchonlys are possible in this mode).
  3. blank (boolean, optional, default=false) Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed.
  4. passphrase (string, optional) Encrypt the wallet with this passphrase.
  5. avoid_reuse (boolean, optional, default=false) Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind.
  6. descriptors (boolean, optional, default=true) Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation
  7. load_on_startup (boolean, optional) Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged.
  8. external_signer (boolean, optional, default=false) Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true.
Source§

impl Client

Source

pub fn create_wallet_descriptor( &self, address_type: &str, hdkey: &str, ) -> Result<CreateWalletDescriptor>

Source§

impl Client

Source

pub fn dump_priv_key(&self, address: &Address) -> Result<DumpPrivKey>

Source§

impl Client

Source

pub fn dump_wallet(&self, filename: &Path) -> Result<DumpWallet>

Source§

impl Client

Source

pub fn encrypt_wallet(&self, passphrase: &str) -> Result<EncryptWallet>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn new_address(&self) -> Result<Address>

Gets a new address from bitcoind and parses it assuming its correct.

Source

pub fn new_address_with_type(&self, ty: AddressType) -> Result<Address>

Gets a new address from bitcoind and parses it assuming its correct.

Source

pub fn new_address_with_label( &self, label: &str, ) -> Result<Address<NetworkUnchecked>>

Gets a new address with label from bitcoind and parses it assuming its correct.

Source

pub fn get_new_address( &self, label: Option<&str>, ty: Option<AddressType>, ) -> Result<GetNewAddress>

Gets a new address - low level RPC call.

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn import_address(&self, address: &Address) -> Result<()>

Source§

impl Client

Source§

impl Client

Source

pub fn import_multi( &self, requests: &[ImportMultiRequest], ) -> Result<ImportMulti>

Source§

impl Client

Source

pub fn import_privkey(&self, privkey: &PrivateKey) -> Result<()>

Source§

impl Client

Source

pub fn import_pruned_funds( &self, raw_transaction: &str, tx_out_proof: &str, ) -> Result<()>

Source§

impl Client

Source

pub fn import_pubkey(&self, pubkey: &PublicKey) -> Result<()>

Source§

impl Client

Source

pub fn import_wallet(&self, filename: &Path) -> Result<()>

Source§

impl Client

Source

pub fn key_pool_refill(&self) -> Result<()>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn load_wallet(&self, wallet: &str) -> Result<LoadWallet>

Source§

impl Client

Source

pub fn lock_unspent(&self, outputs: &[(Txid, u32)]) -> Result<LockUnspent>

Lock the given list of transaction outputs. Returns true on success.

This wraps Core RPC: lockunspent false [{"txid":"..","vout":n},...].

Source

pub fn unlock_unspent(&self, outputs: &[(Txid, u32)]) -> Result<LockUnspent>

Unlock the given list of transaction outputs. Returns true on success.

This wraps Core RPC: lockunspent true [{"txid":"..","vout":n},...].

Source§

impl Client

Source

pub fn migrate_wallet(&self, wallet_name: &str) -> Result<MigrateWallet>

Source§

impl Client

Source

pub fn new_keypool(&self) -> Result<()>

Calls newkeypool for the loaded wallet.

newkeypool

Entirely clears and refills the keypool. Requires wallet passphrase to be set if wallet is encrypted.

Source§

impl Client

Source

pub fn psbt_bump_fee(&self, txid: &Txid) -> Result<PsbtBumpFee>

Source§

impl Client

Source

pub fn remove_pruned_funds(&self, txid: Txid) -> Result<()>

Source§

impl Client

Source§

impl Client

Source

pub fn restore_wallet( &self, wallet_name: &str, backup_file: &Path, ) -> Result<RestoreWallet>

Calls restorewallet with required and optional arguments.

restorewallet “wallet_name” “backup_file” ( load_on_startup )

Source§

impl Client

Source

pub fn send(&self, outputs: &BTreeMap<String, f64>) -> Result<Send>

Source§

impl Client

Source

pub fn send_all(&self, recipients: &[Address]) -> Result<SendAll>

Source§

impl Client

Source

pub fn send_many(&self, amounts: BTreeMap<Address, Amount>) -> Result<SendMany>

Source§

impl Client

Source§

impl Client

Source

pub fn send_to_address( &self, address: &Address<NetworkChecked>, amount: Amount, ) -> Result<SendToAddress>

Source

pub fn send_to_address_rbf( &self, address: &Address<NetworkChecked>, amount: Amount, ) -> Result<SendToAddress>

Source§

impl Client

Source

pub fn set_hd_seed(&self) -> Result<()>

Source§

impl Client

Source

pub fn set_tx_fee(&self, fee_rate: FeeRate) -> Result<SetTxFee>

Source§

impl Client

Source

pub fn set_wallet_flag(&self, flag: &str) -> Result<SetWalletFlag>

Source§

impl Client

Source

pub fn sign_message( &self, address: &Address, message: &str, ) -> Result<SignMessage>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn unload_wallet(&self, wallet: &str) -> Result<UnloadWallet>

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn wallet_lock(&self) -> Result<()>

Source§

impl Client

Source

pub fn wallet_passphrase(&self, passphrase: &str, timeout: u64) -> Result<()>

Source§

impl Client

Source

pub fn wallet_passphrase_change( &self, old_passphrase: &str, new_passphrase: &str, ) -> Result<()>

Source§

impl Client

Source§

impl Client

Trait Implementations§

Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.