- /// This method must return a different value each time it is called.
- fn get_channel_signer(&self, inbound: bool, channel_value_satoshis: u64) -> Self::Signer;
- /// Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
- /// onion packets and for temporary channel IDs. There is no requirement that these be
- /// persisted anywhere, though they must be unique across restarts.
+ /// Errors if the [`Recipient`] variant is not supported by the implementation.
+ fn get_node_id(&self, recipient: Recipient) -> Result<PublicKey, ()>;
+
+ /// Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if
+ /// one is provided. Note that this tweak can be applied to `other_key` instead of our node
+ /// secret, though this is less efficient.
+ ///
+ /// Note that if this fails while attempting to forward an HTLC, LDK will panic. The error
+ /// should be resolved to allow LDK to resume forwarding HTLCs.
+ ///
+ /// Errors if the [`Recipient`] variant is not supported by the implementation.
+ fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&Scalar>) -> Result<SharedSecret, ()>;
+
+ /// Sign an invoice.
+ ///
+ /// By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of
+ /// this trait to parse the invoice and make sure they're signing what they expect, rather than
+ /// blindly signing the hash.
+ ///
+ /// The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32.
+ ///
+ /// The secret key used to sign the invoice is dependent on the [`Recipient`].
+ ///
+ /// Errors if the [`Recipient`] variant is not supported by the implementation.
+ fn sign_invoice(&self, hrp_bytes: &[u8], invoice_data: &[u5], recipient: Recipient) -> Result<RecoverableSignature, ()>;
+
+ /// Sign a gossip message.
+ ///
+ /// Note that if this fails, LDK may panic and the message will not be broadcast to the network
+ /// or a possible channel counterparty. If LDK panics, the error should be resolved to allow the
+ /// message to be broadcast, as otherwise it may prevent one from receiving funds over the
+ /// corresponding channel.
+ fn sign_gossip_message(&self, msg: UnsignedGossipMessage) -> Result<Signature, ()>;
+}
+
+/// A trait that can return signer instances for individual channels.
+pub trait SignerProvider {
+ /// A type which implements [`Sign`] which will be returned by [`Self::derive_channel_signer`].
+ type Signer : Sign;
+
+ /// Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through
+ /// [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow
+ /// implementations of [`SignerProvider`] to maintain a mapping between itself and the generated
+ /// `channel_keys_id`.