General cleanup for the docs

This commit is contained in:
Alekos Filini
2020-08-31 10:49:44 +02:00
parent d61e974dbe
commit c0867a6adc
23 changed files with 305 additions and 201 deletions

View File

@@ -84,6 +84,14 @@ pub enum SignerError {
MissingHDKeypath,
}
impl fmt::Display for SignerError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl std::error::Error for SignerError {}
/// Trait for signers
pub trait Signer: fmt::Debug {
fn sign(
@@ -92,9 +100,7 @@ pub trait Signer: fmt::Debug {
input_index: Option<usize>,
) -> Result<(), SignerError>;
fn sign_whole_tx(&self) -> bool {
false
}
fn sign_whole_tx(&self) -> bool;
fn descriptor_secret_key(&self) -> Option<DescriptorSecretKey> {
None
@@ -128,6 +134,10 @@ impl Signer for DescriptorXKey<ExtendedPrivKey> {
derived_key.private_key.sign(psbt, Some(input_index))
}
fn sign_whole_tx(&self) -> bool {
false
}
fn descriptor_secret_key(&self) -> Option<DescriptorSecretKey> {
Some(DescriptorSecretKey::XPrv(self.clone()))
}
@@ -176,6 +186,10 @@ impl Signer for PrivateKey {
Ok(())
}
fn sign_whole_tx(&self) -> bool {
false
}
fn descriptor_secret_key(&self) -> Option<DescriptorSecretKey> {
Some(DescriptorSecretKey::PrivKey(self.clone()))
}
@@ -299,7 +313,7 @@ impl<Pk: MiniscriptKey> SignersContainer<Pk> {
}
}
pub trait ComputeSighash {
pub(crate) trait ComputeSighash {
fn sighash(
psbt: &psbt::PartiallySignedTransaction,
input_index: usize,