Trait breez_sdk_core::lightning::sign::SignerProvider

pub trait SignerProvider {
    type Signer: WriteableEcdsaChannelSigner;

    // Required methods
    fn generate_channel_keys_id(
        &self,
        inbound: bool,
        channel_value_satoshis: u64,
        user_channel_id: u128,
    ) -> [u8; 32];
    fn derive_channel_signer(
        &self,
        channel_value_satoshis: u64,
        channel_keys_id: [u8; 32],
    ) -> Self::Signer;
    fn read_chan_signer(
        &self,
        reader: &[u8],
    ) -> Result<Self::Signer, DecodeError>;
    fn get_destination_script(&self) -> Result<Script, ()>;
    fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()>;
}
Expand description

A trait that can return signer instances for individual channels.

Required Associated Types§

type Signer: WriteableEcdsaChannelSigner

A type which implements WriteableEcdsaChannelSigner which will be returned by Self::derive_channel_signer.

Required Methods§

fn generate_channel_keys_id( &self, inbound: bool, channel_value_satoshis: u64, user_channel_id: u128, ) -> [u8; 32]

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.

This method must return a different value each time it is called.

fn derive_channel_signer( &self, channel_value_satoshis: u64, channel_keys_id: [u8; 32], ) -> Self::Signer

Derives the private key material backing a Signer.

To derive a new Signer, a fresh channel_keys_id should be obtained through SignerProvider::generate_channel_keys_id. Otherwise, an existing Signer can be re-derived from its channel_keys_id, which can be obtained through its trait method ChannelSigner::channel_keys_id.

fn read_chan_signer(&self, reader: &[u8]) -> Result<Self::Signer, DecodeError>

Reads a Signer for this SignerProvider from the given input stream. This is only called during deserialization of other objects which contain WriteableEcdsaChannelSigner-implementing objects (i.e., ChannelMonitors and ChannelManagers). The bytes are exactly those which <Self::Signer as Writeable>::write() writes, and contain no versioning scheme. You may wish to include your own version prefix and ensure you’ve read all of the provided bytes to ensure no corruption occurred.

This method is slowly being phased out – it will only be called when reading objects written by LDK versions prior to 0.0.113.

fn get_destination_script(&self) -> Result<Script, ()>

Get a script pubkey which we send funds to when claiming on-chain contestable outputs.

If this function returns an error, this will result in a channel failing to open.

This method should return a different value each time it is called, to avoid linking on-chain funds across channels as controlled to the same user.

fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()>

Get a script pubkey which we will send funds to when closing a channel.

If this function returns an error, this will result in a channel failing to open or close. In the event of a failure when the counterparty is initiating a close, this can result in a channel force close.

This method should return a different value each time it is called, to avoid linking on-chain funds across channels as controlled to the same user.

Implementations on Foreign Types§

§

impl SignerProvider for LoopbackSignerKeysInterface

§

type Signer = LoopbackChannelSigner

§

fn get_destination_script(&self) -> Result<Script, ()>

§

fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()>

§

fn generate_channel_keys_id( &self, _inbound: bool, _channel_value_satoshis: u64, _user_channel_id: u128, ) -> [u8; 32]

§

fn derive_channel_signer( &self, channel_value_satoshis: u64, channel_keys_id: [u8; 32], ) -> <LoopbackSignerKeysInterface as SignerProvider>::Signer

§

fn read_chan_signer( &self, reader: &[u8], ) -> Result<<LoopbackSignerKeysInterface as SignerProvider>::Signer, DecodeError>

§

impl SignerProvider for MyKeysManager

§

type Signer = InMemorySigner

§

fn get_destination_script(&self) -> Result<Script, ()>

§

fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()>

§

fn generate_channel_keys_id( &self, _inbound: bool, _channel_value_satoshis: u64, _user_channel_id: u128, ) -> [u8; 32]

§

fn derive_channel_signer( &self, _channel_value_satoshis: u64, _channel_keys_id: [u8; 32], ) -> <MyKeysManager as SignerProvider>::Signer

§

fn read_chan_signer( &self, _reader: &[u8], ) -> Result<<MyKeysManager as SignerProvider>::Signer, DecodeError>

Implementors§