Trait lightning::chain::keysinterface::KeysInterface
source · [−]pub trait KeysInterface {
type Signer: Sign;
fn get_node_secret(&self, recipient: Recipient) -> Result<SecretKey, ()>;
fn get_destination_script(&self) -> Script;
fn get_shutdown_scriptpubkey(&self) -> ShutdownScript;
fn get_channel_signer(
&self,
inbound: bool,
channel_value_satoshis: u64
) -> Self::Signer;
fn get_secure_random_bytes(&self) -> [u8; 32];
fn read_chan_signer(
&self,
reader: &[u8]
) -> Result<Self::Signer, DecodeError>;
fn sign_invoice(
&self,
hrp_bytes: &[u8],
invoice_data: &[u5],
receipient: Recipient
) -> Result<RecoverableSignature, ()>;
fn get_inbound_payment_key_material(&self) -> KeyMaterial;
}
Expand description
A trait to describe an object which can get user secrets and key material.
Associated Types
Required methods
Get node secret key (aka node_id or network_key) based on the provided Recipient
.
This method must return the same value each time it is called with a given Recipient
parameter.
fn get_destination_script(&self) -> Script
fn get_destination_script(&self) -> Script
Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
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) -> ShutdownScript
fn get_shutdown_scriptpubkey(&self) -> ShutdownScript
Get a script pubkey which we will send funds to when closing a channel.
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_channel_signer(
&self,
inbound: bool,
channel_value_satoshis: u64
) -> Self::Signer
fn get_channel_signer(
&self,
inbound: bool,
channel_value_satoshis: u64
) -> Self::Signer
Get a new set of Sign for per-channel secrets. These MUST be unique even if you restarted with some stale data!
This method must return a different value each time it is called.
fn get_secure_random_bytes(&self) -> [u8; 32]
fn get_secure_random_bytes(&self) -> [u8; 32]
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.
This method must return a different value each time it is called.
fn read_chan_signer(&self, reader: &[u8]) -> Result<Self::Signer, DecodeError>
fn read_chan_signer(&self, reader: &[u8]) -> Result<Self::Signer, DecodeError>
Reads a Signer
for this KeysInterface
from the given input stream.
This is only called during deserialization of other objects which contain
Sign
-implementing objects (ie ChannelMonitor
s and ChannelManager
s).
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.
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 is ascii bytes, while the invoice data is base32.
The secret key used to sign the invoice is dependent on the Recipient
.
fn get_inbound_payment_key_material(&self) -> KeyMaterial
fn get_inbound_payment_key_material(&self) -> KeyMaterial
Get secret key material as bytes for use in encrypting and decrypting inbound payment data.
If the implementor of this trait supports phantom node payments, then every node that is intended to be included in the phantom invoice route hints must return the same value from this method.
This method must return the same value each time it is called.