Struct lightning::sign::InMemorySigner

source ·
pub struct InMemorySigner {
    pub funding_key: SecretKey,
    pub revocation_base_key: SecretKey,
    pub payment_key: SecretKey,
    pub delayed_payment_base_key: SecretKey,
    pub htlc_base_key: SecretKey,
    pub commitment_seed: [u8; 32],
    /* private fields */
}
Expand description

A simple implementation of WriteableEcdsaChannelSigner that just keeps the private keys in memory.

This implementation performs no policy checks and is insufficient by itself as a secure external signer.

Fields§

§funding_key: SecretKey

Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the holder’s anchor output in a commitment transaction, if one is present.

§revocation_base_key: SecretKey

Holder secret key for blinded revocation pubkey.

§payment_key: SecretKey

Holder secret key used for our balance in counterparty-broadcasted commitment transactions.

§delayed_payment_base_key: SecretKey

Holder secret key used in an HTLC transaction.

§htlc_base_key: SecretKey

Holder HTLC secret key used in commitment transaction HTLC outputs.

§commitment_seed: [u8; 32]

Commitment seed.

Implementations§

source§

impl InMemorySigner

source

pub fn new<C: Signing>( secp_ctx: &Secp256k1<C>, funding_key: SecretKey, revocation_base_key: SecretKey, payment_key: SecretKey, delayed_payment_base_key: SecretKey, htlc_base_key: SecretKey, commitment_seed: [u8; 32], channel_value_satoshis: u64, channel_keys_id: [u8; 32], rand_bytes_unique_start: [u8; 32] ) -> InMemorySigner

Creates a new InMemorySigner.

source

pub fn counterparty_pubkeys(&self) -> Option<&ChannelPublicKeys>

Returns the counterparty’s pubkeys.

Will return None if ChannelSigner::provide_channel_parameters has not been called. In general, this is safe to unwrap only in ChannelSigner implementation.

source

pub fn counterparty_selected_contest_delay(&self) -> Option<u16>

Returns the contest_delay value specified by our counterparty and applied on holder-broadcastable transactions, i.e., the amount of time that we have to wait to recover our funds if we broadcast a transaction.

Will return None if ChannelSigner::provide_channel_parameters has not been called. In general, this is safe to unwrap only in ChannelSigner implementation.

source

pub fn holder_selected_contest_delay(&self) -> Option<u16>

Returns the contest_delay value specified by us and applied on transactions broadcastable by our counterparty, i.e., the amount of time that they have to wait to recover their funds if they broadcast a transaction.

Will return None if ChannelSigner::provide_channel_parameters has not been called. In general, this is safe to unwrap only in ChannelSigner implementation.

source

pub fn is_outbound(&self) -> Option<bool>

Returns whether the holder is the initiator.

Will return None if ChannelSigner::provide_channel_parameters has not been called. In general, this is safe to unwrap only in ChannelSigner implementation.

source

pub fn funding_outpoint(&self) -> Option<&OutPoint>

Funding outpoint

Will return None if ChannelSigner::provide_channel_parameters has not been called. In general, this is safe to unwrap only in ChannelSigner implementation.

source

pub fn get_channel_parameters(&self) -> Option<&ChannelTransactionParameters>

Returns a ChannelTransactionParameters for this channel, to be used when verifying or building transactions.

Will return None if ChannelSigner::provide_channel_parameters has not been called. In general, this is safe to unwrap only in ChannelSigner implementation.

source

pub fn channel_type_features(&self) -> Option<&ChannelTypeFeatures>

Returns the channel type features of the channel parameters. Should be helpful for determining a channel’s category, i. e. legacy/anchors/taproot/etc.

Will return None if ChannelSigner::provide_channel_parameters has not been called. In general, this is safe to unwrap only in ChannelSigner implementation.

source

pub fn sign_counterparty_payment_input<C: Signing>( &self, spend_tx: &Transaction, input_idx: usize, descriptor: &StaticPaymentOutputDescriptor, secp_ctx: &Secp256k1<C> ) -> Result<Witness, ()>

Sign the single input of spend_tx at index input_idx, which spends the output described by descriptor, returning the witness stack for the input.

Returns an error if the input at input_idx does not exist, has a non-empty script_sig, is not spending the outpoint described by descriptor.outpoint, or if an output descriptor script_pubkey does not match the one we can spend.

source

pub fn sign_dynamic_p2wsh_input<C: Signing>( &self, spend_tx: &Transaction, input_idx: usize, descriptor: &DelayedPaymentOutputDescriptor, secp_ctx: &Secp256k1<C> ) -> Result<Witness, ()>

Sign the single input of spend_tx at index input_idx which spends the output described by descriptor, returning the witness stack for the input.

Returns an error if the input at input_idx does not exist, has a non-empty script_sig, is not spending the outpoint described by descriptor.outpoint, does not have a sequence set to descriptor.to_self_delay, or if an output descriptor script_pubkey does not match the one we can spend.

Trait Implementations§

source§

impl ChannelSigner for InMemorySigner

source§

fn get_per_commitment_point( &self, idx: u64, secp_ctx: &Secp256k1<All> ) -> PublicKey

Gets the per-commitment point for a specific commitment number Read more
source§

fn release_commitment_secret(&self, idx: u64) -> [u8; 32]

Gets the commitment secret for a specific commitment number as part of the revocation process Read more
source§

fn validate_holder_commitment( &self, _holder_tx: &HolderCommitmentTransaction, _outbound_htlc_preimages: Vec<PaymentPreimage> ) -> Result<(), ()>

Validate the counterparty’s signatures on the holder commitment transaction and HTLCs. Read more
source§

fn validate_counterparty_revocation( &self, _idx: u64, _secret: &SecretKey ) -> Result<(), ()>

Validate the counterparty’s revocation. Read more
source§

fn pubkeys(&self) -> &ChannelPublicKeys

Returns the holder’s channel public keys and basepoints.
source§

fn channel_keys_id(&self) -> [u8; 32]

Returns an arbitrary identifier describing the set of keys which are provided back to you in some SpendableOutputDescriptor types. This should be sufficient to identify this EcdsaChannelSigner object uniquely and lookup or re-derive its keys.
source§

fn provide_channel_parameters( &mut self, channel_parameters: &ChannelTransactionParameters )

Set the counterparty static channel data, including basepoints, counterparty_selected/holder_selected_contest_delay and funding outpoint. Read more
source§

impl Clone for InMemorySigner

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for InMemorySigner

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl EcdsaChannelSigner for InMemorySigner

source§

fn sign_counterparty_commitment( &self, commitment_tx: &CommitmentTransaction, _inbound_htlc_preimages: Vec<PaymentPreimage>, _outbound_htlc_preimages: Vec<PaymentPreimage>, secp_ctx: &Secp256k1<All> ) -> Result<(Signature, Vec<Signature>), ()>

Create a signature for a counterparty’s commitment transaction and associated HTLC transactions. Read more
source§

fn sign_holder_commitment( &self, commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<All> ) -> Result<Signature, ()>

Creates a signature for a holder’s commitment transaction. Read more
source§

fn sign_justice_revoked_output( &self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<All> ) -> Result<Signature, ()>

Create a signature for the given input in a transaction spending an HTLC transaction output or a commitment transaction to_local output when our counterparty broadcasts an old state. Read more
source§

fn sign_justice_revoked_htlc( &self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<All> ) -> Result<Signature, ()>

Create a signature for the given input in a transaction spending a commitment transaction HTLC output when our counterparty broadcasts an old state. Read more
source§

fn sign_holder_htlc_transaction( &self, htlc_tx: &Transaction, input: usize, htlc_descriptor: &HTLCDescriptor, secp_ctx: &Secp256k1<All> ) -> Result<Signature, ()>

Computes the signature for a commitment transaction’s HTLC output used as an input within htlc_tx, which spends the commitment transaction at index input. The signature returned must be be computed using EcdsaSighashType::All. Read more
source§

fn sign_counterparty_htlc_transaction( &self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<All> ) -> Result<Signature, ()>

Create a signature for a claiming transaction for a HTLC output on a counterparty’s commitment transaction, either offered or received. Read more
source§

fn sign_closing_transaction( &self, closing_tx: &ClosingTransaction, secp_ctx: &Secp256k1<All> ) -> Result<Signature, ()>

Create a signature for a (proposed) closing transaction. Read more
source§

fn sign_holder_anchor_input( &self, anchor_tx: &Transaction, input: usize, secp_ctx: &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. Read more
source§

fn sign_channel_announcement_with_funding_key( &self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<All> ) -> Result<Signature, ()>

Signs a channel announcement message with our funding key proving it comes from one of the channel participants. Read more
source§

impl EntropySource for InMemorySigner

source§

fn get_secure_random_bytes(&self) -> [u8; 32]

Gets a unique, cryptographically-secure, random 32-byte value. This method must return a different value each time it is called.
source§

impl PartialEq for InMemorySigner

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<ES: Deref> ReadableArgs<ES> for InMemorySigner
where ES::Target: EntropySource,

source§

fn read<R: Read>( reader: &mut R, entropy_source: ES ) -> Result<Self, DecodeError>

Reads a Self in from the given Read.
source§

impl Writeable for InMemorySigner

source§

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>

Writes self out to the given Writer.
source§

fn encode(&self) -> Vec<u8>

Writes self out to a Vec<u8>.
source§

fn serialized_length(&self) -> usize

Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length.
source§

impl WriteableEcdsaChannelSigner for InMemorySigner

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.