Module bdk::wallet::signer [−][src]
Expand description
Generalized signers
This module provides the ability to add customized signers to a Wallet
through the Wallet::add_signer
function.
#[derive(Debug)]
struct CustomSigner {
device: CustomHSM,
}
impl CustomSigner {
fn connect() -> Self {
CustomSigner { device: CustomHSM::connect() }
}
}
impl Signer for CustomSigner {
fn sign(
&self,
psbt: &mut psbt::PartiallySignedTransaction,
input_index: Option<usize>,
_secp: &Secp256k1<All>,
) -> Result<(), SignerError> {
let input_index = input_index.ok_or(SignerError::InputIndexOutOfRange)?;
self.device.sign_input(psbt, input_index)?;
Ok(())
}
fn id(&self, _secp: &Secp256k1<All>) -> SignerId {
self.device.get_id()
}
fn sign_whole_tx(&self) -> bool {
false
}
}
let custom_signer = CustomSigner::connect();
let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
let mut wallet = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
wallet.add_signer(
KeychainKind::External,
SignerOrdering(200),
Arc::new(custom_signer)
);
Structs
Options for a software signer
Defines the order in which signers are called
Container for multiple signers
Enums
Signing error
Identifier of a signer in the SignersContainers
. Used as a key to find the right signer among
multiple of them
Traits
Trait for signers