Struct InMemorySigner
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§
§impl InMemorySigner
impl InMemorySigner
pub fn new<C>(
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],
) -> InMemorySignerwhere
C: Signing,
pub fn new<C>(
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],
) -> InMemorySignerwhere
C: Signing,
Creates a new InMemorySigner
.
pub fn counterparty_pubkeys(&self) -> Option<&ChannelPublicKeys>
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.
pub fn counterparty_selected_contest_delay(&self) -> Option<u16>
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.
pub fn holder_selected_contest_delay(&self) -> Option<u16>
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.
pub fn is_outbound(&self) -> Option<bool>
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.
pub fn funding_outpoint(&self) -> Option<&OutPoint>
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.
pub fn get_channel_parameters(&self) -> Option<&ChannelTransactionParameters>
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.
pub fn channel_type_features(&self) -> Option<&Features<ChannelTypeContext>>
pub fn channel_type_features(&self) -> Option<&Features<ChannelTypeContext>>
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.
pub fn sign_counterparty_payment_input<C>(
&self,
spend_tx: &Transaction,
input_idx: usize,
descriptor: &StaticPaymentOutputDescriptor,
secp_ctx: &Secp256k1<C>,
) -> Result<Vec<Vec<u8>>, ()>where
C: Signing,
pub fn sign_counterparty_payment_input<C>(
&self,
spend_tx: &Transaction,
input_idx: usize,
descriptor: &StaticPaymentOutputDescriptor,
secp_ctx: &Secp256k1<C>,
) -> Result<Vec<Vec<u8>>, ()>where
C: Signing,
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.
pub fn sign_dynamic_p2wsh_input<C>(
&self,
spend_tx: &Transaction,
input_idx: usize,
descriptor: &DelayedPaymentOutputDescriptor,
secp_ctx: &Secp256k1<C>,
) -> Result<Vec<Vec<u8>>, ()>where
C: Signing,
pub fn sign_dynamic_p2wsh_input<C>(
&self,
spend_tx: &Transaction,
input_idx: usize,
descriptor: &DelayedPaymentOutputDescriptor,
secp_ctx: &Secp256k1<C>,
) -> Result<Vec<Vec<u8>>, ()>where
C: Signing,
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§
§impl ChannelSigner for InMemorySigner
impl ChannelSigner for InMemorySigner
§fn get_per_commitment_point(
&self,
idx: u64,
secp_ctx: &Secp256k1<All>,
) -> PublicKey
fn get_per_commitment_point( &self, idx: u64, secp_ctx: &Secp256k1<All>, ) -> PublicKey
§fn release_commitment_secret(&self, idx: u64) -> [u8; 32]
fn release_commitment_secret(&self, idx: u64) -> [u8; 32]
§fn validate_holder_commitment(
&self,
_holder_tx: &HolderCommitmentTransaction,
_preimages: Vec<PaymentPreimage>,
) -> Result<(), ()>
fn validate_holder_commitment( &self, _holder_tx: &HolderCommitmentTransaction, _preimages: Vec<PaymentPreimage>, ) -> Result<(), ()>
§fn pubkeys(&self) -> &ChannelPublicKeys
fn pubkeys(&self) -> &ChannelPublicKeys
§fn channel_keys_id(&self) -> [u8; 32]
fn channel_keys_id(&self) -> [u8; 32]
SpendableOutputDescriptor
types. This should be sufficient to identify this
EcdsaChannelSigner
object uniquely and lookup or re-derive its keys.§fn provide_channel_parameters(
&mut self,
channel_parameters: &ChannelTransactionParameters,
)
fn provide_channel_parameters( &mut self, channel_parameters: &ChannelTransactionParameters, )
counterparty_selected
/holder_selected_contest_delay
and funding outpoint. Read more§impl Clone for InMemorySigner
impl Clone for InMemorySigner
§fn clone(&self) -> InMemorySigner
fn clone(&self) -> InMemorySigner
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for InMemorySigner
impl Debug for InMemorySigner
§impl EcdsaChannelSigner for InMemorySigner
impl EcdsaChannelSigner for InMemorySigner
§fn sign_counterparty_commitment(
&self,
commitment_tx: &CommitmentTransaction,
_preimages: Vec<PaymentPreimage>,
secp_ctx: &Secp256k1<All>,
) -> Result<(Signature, Vec<Signature>), ()>
fn sign_counterparty_commitment( &self, commitment_tx: &CommitmentTransaction, _preimages: Vec<PaymentPreimage>, secp_ctx: &Secp256k1<All>, ) -> Result<(Signature, Vec<Signature>), ()>
§fn validate_counterparty_revocation(
&self,
_idx: u64,
_secret: &SecretKey,
) -> Result<(), ()>
fn validate_counterparty_revocation( &self, _idx: u64, _secret: &SecretKey, ) -> Result<(), ()>
§fn sign_holder_commitment(
&self,
commitment_tx: &HolderCommitmentTransaction,
secp_ctx: &Secp256k1<All>,
) -> Result<Signature, ()>
fn sign_holder_commitment( &self, commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<All>, ) -> Result<Signature, ()>
§fn sign_justice_revoked_output(
&self,
justice_tx: &Transaction,
input: usize,
amount: u64,
per_commitment_key: &SecretKey,
secp_ctx: &Secp256k1<All>,
) -> Result<Signature, ()>
fn sign_justice_revoked_output( &self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<All>, ) -> Result<Signature, ()>
to_local
output when our counterparty broadcasts an old state. Read more§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, ()>
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, ()>
§fn sign_holder_htlc_transaction(
&self,
htlc_tx: &Transaction,
input: usize,
htlc_descriptor: &HTLCDescriptor,
secp_ctx: &Secp256k1<All>,
) -> Result<Signature, ()>
fn sign_holder_htlc_transaction( &self, htlc_tx: &Transaction, input: usize, htlc_descriptor: &HTLCDescriptor, secp_ctx: &Secp256k1<All>, ) -> Result<Signature, ()>
htlc_tx
, which spends the commitment transaction at index input
. The signature returned
must be be computed using EcdsaSighashType::All
. Read more§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, ()>
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, ()>
§fn sign_closing_transaction(
&self,
closing_tx: &ClosingTransaction,
secp_ctx: &Secp256k1<All>,
) -> Result<Signature, ()>
fn sign_closing_transaction( &self, closing_tx: &ClosingTransaction, secp_ctx: &Secp256k1<All>, ) -> Result<Signature, ()>
§fn sign_holder_anchor_input(
&self,
anchor_tx: &Transaction,
input: usize,
secp_ctx: &Secp256k1<All>,
) -> Result<Signature, ()>
fn sign_holder_anchor_input( &self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<All>, ) -> Result<Signature, ()>
anchor_tx
, which spends the commitment transaction, at index input
.§fn sign_channel_announcement_with_funding_key(
&self,
msg: &UnsignedChannelAnnouncement,
secp_ctx: &Secp256k1<All>,
) -> Result<Signature, ()>
fn sign_channel_announcement_with_funding_key( &self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<All>, ) -> Result<Signature, ()>
§impl EntropySource for InMemorySigner
impl EntropySource for InMemorySigner
§fn get_secure_random_bytes(&self) -> [u8; 32]
fn get_secure_random_bytes(&self) -> [u8; 32]
§impl PartialEq for InMemorySigner
impl PartialEq for InMemorySigner
§impl<ES> ReadableArgs<ES> for InMemorySigner
impl<ES> ReadableArgs<ES> for InMemorySigner
§fn read<R>(
reader: &mut R,
entropy_source: ES,
) -> Result<InMemorySigner, DecodeError>where
R: Read,
fn read<R>(
reader: &mut R,
entropy_source: ES,
) -> Result<InMemorySigner, DecodeError>where
R: Read,
Self
in from the given Read
.§impl Writeable for InMemorySigner
impl Writeable for InMemorySigner
impl WriteableEcdsaChannelSigner for InMemorySigner
Auto Trait Implementations§
impl !Freeze for InMemorySigner
impl RefUnwindSafe for InMemorySigner
impl Send for InMemorySigner
impl Sync for InMemorySigner
impl Unpin for InMemorySigner
impl UnwindSafe for InMemorySigner
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request