Allow(unused_imports) on prelude imports
[rust-lightning] / lightning / src / sign / ecdsa.rs
index 2e98213c1825f2c0af8802bcc0838c2dc4d7af55..45152cf6937d668496b66166c42d96614f084e54 100644 (file)
@@ -11,7 +11,9 @@ use crate::ln::PaymentPreimage;
 use crate::ln::chan_utils::{HTLCOutputInCommitment, HolderCommitmentTransaction, CommitmentTransaction, ClosingTransaction};
 use crate::ln::msgs::UnsignedChannelAnnouncement;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
+
 use crate::sign::{ChannelSigner, HTLCDescriptor};
 
 /// A trait to sign Lightning channel transactions as described in
@@ -51,6 +53,13 @@ pub trait EcdsaChannelSigner: ChannelSigner {
        /// This may be called multiple times for the same transaction.
        ///
        /// An external signer implementation should check that the commitment has not been revoked.
+       ///
+       /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
+       /// signature and should be retried later. Once the signer is ready to provide a signature after
+       /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
+       /// monitor.
+       ///
+       /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
        //
        // TODO: Document the things someone using this interface should enforce before signing.
        fn sign_holder_commitment(&self, commitment_tx: &HolderCommitmentTransaction,
@@ -76,6 +85,13 @@ pub trait EcdsaChannelSigner: ChannelSigner {
        /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
        /// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
        /// so).
+       ///
+       /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
+       /// signature and should be retried later. Once the signer is ready to provide a signature after
+       /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
+       /// monitor.
+       ///
+       /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
        fn sign_justice_revoked_output(&self, justice_tx: &Transaction, input: usize, amount: u64,
                per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>
        ) -> Result<Signature, ()>;
@@ -97,6 +113,13 @@ pub trait EcdsaChannelSigner: ChannelSigner {
        ///
        /// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
        /// (which is committed to in the BIP 143 signatures).
+       ///
+       /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
+       /// signature and should be retried later. Once the signer is ready to provide a signature after
+       /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
+       /// monitor.
+       ///
+       /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
        fn sign_justice_revoked_htlc(&self, justice_tx: &Transaction, input: usize, amount: u64,
                per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
                secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()>;
@@ -108,8 +131,14 @@ pub trait EcdsaChannelSigner: ChannelSigner {
        /// [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas)
        /// broadcasts it before receiving the update for the latest commitment transaction.
        ///
+       /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
+       /// signature and should be retried later. Once the signer is ready to provide a signature after
+       /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
+       /// monitor.
+       ///
        /// [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All
        /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
+       /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
        fn sign_holder_htlc_transaction(&self, htlc_tx: &Transaction, input: usize,
                htlc_descriptor: &HTLCDescriptor, secp_ctx: &Secp256k1<secp256k1::All>
        ) -> Result<Signature, ()>;
@@ -130,6 +159,13 @@ pub trait EcdsaChannelSigner: ChannelSigner {
        /// detected onchain. It has been generated by our counterparty and is used to derive
        /// channel state keys, which are then included in the witness script and committed to in the
        /// BIP 143 signature.
+       ///
+       /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
+       /// signature and should be retried later. Once the signer is ready to provide a signature after
+       /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
+       /// monitor.
+       ///
+       /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
        fn sign_counterparty_htlc_transaction(&self, htlc_tx: &Transaction, input: usize, amount: u64,
                per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment,
                secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()>;
@@ -141,6 +177,13 @@ pub trait EcdsaChannelSigner: ChannelSigner {
                secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()>;
        /// Computes the signature for a commitment transaction's anchor output used as an
        /// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
+       ///
+       /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
+       /// signature and should be retried later. Once the signer is ready to provide a signature after
+       /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
+       /// monitor.
+       ///
+       /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
        fn sign_holder_anchor_input(
                &self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
        ) -> Result<Signature, ()>;