pub struct TestChannelSigner {
    pub inner: InMemorySigner,
    pub state: Arc<Mutex<EnforcementState>>,
    pub disable_revocation_policy_check: bool,
}
Expand description

An implementation of Sign that enforces some policy checks. The current checks are an incomplete set. They include:

  • When signing, the holder transaction has not been revoked
  • When revoking, the holder transaction has not been signed
  • The holder commitment number is monotonic and without gaps
  • The revoked holder commitment number is monotonic and without gaps
  • There is at least one unrevoked holder transaction at all times
  • The counterparty commitment number is monotonic and without gaps
  • The pre-derived keys and pre-built transaction in CommitmentTransaction were correctly built

Eventually we will probably want to expose a variant of this which would essentially be what you’d want to run on a hardware wallet.

Note that counterparty signatures on the holder transaction are not checked, but it should be in a complete implementation.

Note that before we do so we should ensure its serialization format has backwards- and forwards-compatibility prefix/suffixes!

Fields§

§inner: InMemorySigner§state: Arc<Mutex<EnforcementState>>

Channel state used for policy enforcement

§disable_revocation_policy_check: bool

Implementations§

§

impl TestChannelSigner

pub fn new(inner: InMemorySigner) -> TestChannelSigner

Construct an TestChannelSigner

pub fn new_with_revoked( inner: InMemorySigner, state: Arc<Mutex<EnforcementState>>, disable_revocation_policy_check: bool, ) -> TestChannelSigner

Construct an TestChannelSigner with externally managed storage

Since there are multiple copies of this struct for each channel, some coordination is needed so that all copies are aware of enforcement state. A pointer to this state is provided here, usually by an implementation of KeysInterface.

pub fn channel_type_features(&self) -> &Features<ChannelTypeContext>

Trait Implementations§

§

impl ChannelSigner for TestChannelSigner

§

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
§

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
§

fn validate_holder_commitment( &self, holder_tx: &HolderCommitmentTransaction, _preimages: Vec<PaymentPreimage>, ) -> Result<(), ()>

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

fn pubkeys(&self) -> &ChannelPublicKeys

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

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.
§

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
§

impl Clone for TestChannelSigner

§

fn clone(&self) -> TestChannelSigner

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
§

impl EcdsaChannelSigner for TestChannelSigner

§

fn sign_counterparty_commitment( &self, commitment_tx: &CommitmentTransaction, 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
§

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

Validate the counterparty’s revocation. Read more
§

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
§

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

Same as [sign_holder_commitment], but exists only for tests to get access to holder commitment transactions which will be broadcasted later, after the channel has moved on to a newer state. Thus, needs its own method as [sign_holder_commitment] may enforce that we only ever get called once.
§

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
§

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
§

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
§

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
§

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

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

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.
§

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
§

impl PartialEq for TestChannelSigner

§

fn eq(&self, o: &TestChannelSigner) -> 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.
§

impl<'a> Watch<TestChannelSigner> for TestChainMonitor<'a>

§

fn watch_channel( &self, funding_txo: OutPoint, monitor: ChannelMonitor<TestChannelSigner>, ) -> Result<ChannelMonitorUpdateStatus, ()>

Watches a channel identified by funding_txo using monitor. Read more
§

fn update_channel( &self, funding_txo: OutPoint, update: &ChannelMonitorUpdate, ) -> ChannelMonitorUpdateStatus

Updates a channel identified by funding_txo by applying update to its monitor. Read more
§

fn release_pending_monitor_events( &self, ) -> Vec<(OutPoint, Vec<MonitorEvent>, Option<PublicKey>)>

Returns any monitor events since the last call. Subsequent calls must only return new events. Read more
§

impl Writeable for TestChannelSigner

§

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

Writes self out to the given Writer.
§

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

Writes self out to a Vec<u8>.
§

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.
§

impl WriteableEcdsaChannelSigner for TestChannelSigner

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
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

§

fn type_name(&self) -> &'static str

Gets the type name of self
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> Downcast for T
where T: AsAny + ?Sized,

§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> DartSafe for T