//! ScriptType::External,
//! Fingerprint::from_str("e30f11b8").unwrap().into(),
//! SignerOrdering(200),
-//! Arc::new(Box::new(custom_signer))
+//! Arc::new(custom_signer)
//! );
//!
//! # Ok::<_, bdk::Error>(())
/// Container for multiple signers
#[derive(Debug, Default, Clone)]
-pub struct SignersContainer(BTreeMap<SignersContainerKey, Arc<Box<dyn Signer>>>);
+pub struct SignersContainer(BTreeMap<SignersContainerKey, Arc<dyn Signer>>);
impl SignersContainer {
pub fn as_key_map(&self) -> KeyMap {
.to_pubkeyhash(),
),
SignerOrdering::default(),
- Arc::new(Box::new(private_key.key)),
+ Arc::new(private_key.key),
),
DescriptorSecretKey::XPrv(xprv) => container.add_external(
SignerId::from(xprv.root_fingerprint()),
SignerOrdering::default(),
- Arc::new(Box::new(xprv)),
+ Arc::new(xprv),
),
};
}
&mut self,
id: SignerId,
ordering: SignerOrdering,
- signer: Arc<Box<dyn Signer>>,
- ) -> Option<Arc<Box<dyn Signer>>> {
+ signer: Arc<dyn Signer>,
+ ) -> Option<Arc<dyn Signer>> {
self.0.insert((id, ordering).into(), signer)
}
/// Removes a signer from the container and returns it
- pub fn remove(
- &mut self,
- id: SignerId,
- ordering: SignerOrdering,
- ) -> Option<Arc<Box<dyn Signer>>> {
+ pub fn remove(&mut self, id: SignerId, ordering: SignerOrdering) -> Option<Arc<dyn Signer>> {
self.0.remove(&(id, ordering).into())
}
}
/// Returns the list of signers in the container, sorted by lowest to highest `ordering`
- pub fn signers(&self) -> Vec<&Arc<Box<dyn Signer>>> {
+ pub fn signers(&self) -> Vec<&Arc<dyn Signer>> {
self.0.values().collect()
}
/// Finds the signer with lowest ordering for a given id in the container.
- pub fn find(&self, id: SignerId) -> Option<&Arc<Box<dyn Signer>>> {
+ pub fn find(&self, id: SignerId) -> Option<&Arc<dyn Signer>> {
self.0
.range((
Included(&(id.clone(), SignerOrdering(0)).into()),