Signer

Trait Signer 

Source
pub trait Signer {
    // Required methods
    fn sign_raw_transaction_with_wallet(
        &self,
        tx: &Transaction,
        prev_outputs: Option<Vec<PreviousTransactionOutput>>,
    ) -> impl Future<Output = ClientResult<SignRawTransactionWithWallet>> + Send;
    fn get_xpriv(
        &self,
    ) -> impl Future<Output = ClientResult<Option<Xpriv>>> + Send;
    fn import_descriptors(
        &self,
        descriptors: Vec<ImportDescriptor>,
        wallet_name: String,
    ) -> impl Future<Output = ClientResult<Vec<ImportDescriptorResult>>> + Send;
    fn wallet_process_psbt(
        &self,
        psbt: &str,
        sign: Option<bool>,
        sighashtype: Option<SighashType>,
        bip32_derivs: Option<bool>,
    ) -> impl Future<Output = ClientResult<WalletProcessPsbtResult>> + Send;
    fn psbt_bump_fee(
        &self,
        txid: &Txid,
        options: Option<PsbtBumpFeeOptions>,
    ) -> impl Future<Output = ClientResult<PsbtBumpFee>> + Send;
}
Expand description

Signing functionality that any Bitcoin client with private keys that interacts with the Bitcoin network should provide.

§Note

This is a fully async trait. The user should be responsible for handling the async nature of the trait methods. And if implementing this trait for a specific type that is not async, the user should consider wrapping with tokio’s spawn_blocking or any other method.

Required Methods§

Source

fn sign_raw_transaction_with_wallet( &self, tx: &Transaction, prev_outputs: Option<Vec<PreviousTransactionOutput>>, ) -> impl Future<Output = ClientResult<SignRawTransactionWithWallet>> + Send

Signs a transaction using the keys available in the underlying Bitcoin client’s wallet and returns a signed transaction.

§Note

The returned signed transaction might not be consensus-valid if it requires additional signatures, such as in a multisignature context.

Source

fn get_xpriv(&self) -> impl Future<Output = ClientResult<Option<Xpriv>>> + Send

Gets the underlying Xpriv from the wallet.

Source

fn import_descriptors( &self, descriptors: Vec<ImportDescriptor>, wallet_name: String, ) -> impl Future<Output = ClientResult<Vec<ImportDescriptorResult>>> + Send

Imports the descriptors into the wallet.

Source

fn wallet_process_psbt( &self, psbt: &str, sign: Option<bool>, sighashtype: Option<SighashType>, bip32_derivs: Option<bool>, ) -> impl Future<Output = ClientResult<WalletProcessPsbtResult>> + Send

Updates a PSBT with input information from the wallet and optionally signs it.

§Parameters
  • psbt: The PSBT to process as a base64 string.
  • sign: Whether to sign the transaction (default: true).
  • sighashtype: Optional signature hash type to use.
  • bip32_derivs: Whether to include BIP32 derivation paths.
§Returns

Returns a WalletProcessPsbtResult with the processed PSBT and completion status.

Source

fn psbt_bump_fee( &self, txid: &Txid, options: Option<PsbtBumpFeeOptions>, ) -> impl Future<Output = ClientResult<PsbtBumpFee>> + Send

Bumps the fee of an opt-in-RBF transaction, replacing it with a new transaction.

§Parameters
  • txid: The transaction ID to be bumped.
  • options: Optional fee bumping options including:
    • conf_target: Confirmation target in blocks
    • fee_rate: Fee rate in sat/vB (overrides conf_target)
    • replaceable: Whether the new transaction should be BIP-125 replaceable
    • estimate_mode: Fee estimate mode (“unset”, “economical”, “conservative”)
    • outputs: New transaction outputs to replace existing ones
    • original_change_index: Index of change output to recycle from original transaction
§Returns

Returns a PsbtBumpFee containing the new PSBT and fee information.

§Note

The transaction must be BIP-125 opt-in replaceable and the new fee rate must be higher than the original.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§