Skip to content

Commit 6d2d526

Browse files
committed
Rename Sign to WriteableEcdsaChannelSigner, hopefully to be removed a year hence.
1 parent 6e5990f commit 6d2d526

11 files changed

+56
-56
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::chain::{ChannelMonitorUpdateStatus, Filter, WatchedOutput};
3131
use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
3232
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, Balance, MonitorEvent, TransactionOutputs, LATENCY_GRACE_PERIOD_BLOCKS};
3333
use crate::chain::transaction::{OutPoint, TransactionData};
34-
use crate::chain::keysinterface::Sign;
34+
use crate::chain::keysinterface::WriteableEcdsaChannelSigner;
3535
use crate::util::atomic_counter::AtomicCounter;
3636
use crate::util::logger::Logger;
3737
use crate::util::errors::APIError;
@@ -68,7 +68,7 @@ impl MonitorUpdateId {
6868
pub(crate) fn from_monitor_update(update: &ChannelMonitorUpdate) -> Self {
6969
Self { contents: UpdateOrigin::OffChain(update.update_id) }
7070
}
71-
pub(crate) fn from_new_monitor<ChannelSigner: Sign>(monitor: &ChannelMonitor<ChannelSigner>) -> Self {
71+
pub(crate) fn from_new_monitor<ChannelSigner: WriteableEcdsaChannelSigner>(monitor: &ChannelMonitor<ChannelSigner>) -> Self {
7272
Self { contents: UpdateOrigin::OffChain(monitor.get_latest_update_id()) }
7373
}
7474
}
@@ -93,7 +93,7 @@ impl MonitorUpdateId {
9393
/// [`ChannelMonitorUpdateStatus::PermanentFailure`], in which case the channel will likely be
9494
/// closed without broadcasting the latest state. See
9595
/// [`ChannelMonitorUpdateStatus::PermanentFailure`] for more details.
96-
pub trait Persist<ChannelSigner: Sign> {
96+
pub trait Persist<ChannelSigner: WriteableEcdsaChannelSigner> {
9797
/// Persist a new channel's data in response to a [`chain::Watch::watch_channel`] call. This is
9898
/// called by [`ChannelManager`] for new channels, or may be called directly, e.g. on startup.
9999
///
@@ -147,7 +147,7 @@ pub trait Persist<ChannelSigner: Sign> {
147147
fn update_persisted_channel(&self, channel_id: OutPoint, update: Option<&ChannelMonitorUpdate>, data: &ChannelMonitor<ChannelSigner>, update_id: MonitorUpdateId) -> ChannelMonitorUpdateStatus;
148148
}
149149

150-
struct MonitorHolder<ChannelSigner: Sign> {
150+
struct MonitorHolder<ChannelSigner: WriteableEcdsaChannelSigner> {
151151
monitor: ChannelMonitor<ChannelSigner>,
152152
/// The full set of pending monitor updates for this Channel.
153153
///
@@ -182,7 +182,7 @@ struct MonitorHolder<ChannelSigner: Sign> {
182182
last_chain_persist_height: AtomicUsize,
183183
}
184184

185-
impl<ChannelSigner: Sign> MonitorHolder<ChannelSigner> {
185+
impl<ChannelSigner: WriteableEcdsaChannelSigner> MonitorHolder<ChannelSigner> {
186186
fn has_pending_offchain_updates(&self, pending_monitor_updates_lock: &MutexGuard<Vec<MonitorUpdateId>>) -> bool {
187187
pending_monitor_updates_lock.iter().any(|update_id|
188188
if let UpdateOrigin::OffChain(_) = update_id.contents { true } else { false })
@@ -197,12 +197,12 @@ impl<ChannelSigner: Sign> MonitorHolder<ChannelSigner> {
197197
///
198198
/// Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is
199199
/// released.
200-
pub struct LockedChannelMonitor<'a, ChannelSigner: Sign> {
200+
pub struct LockedChannelMonitor<'a, ChannelSigner: WriteableEcdsaChannelSigner> {
201201
lock: RwLockReadGuard<'a, HashMap<OutPoint, MonitorHolder<ChannelSigner>>>,
202202
funding_txo: OutPoint,
203203
}
204204

205-
impl<ChannelSigner: Sign> Deref for LockedChannelMonitor<'_, ChannelSigner> {
205+
impl<ChannelSigner: WriteableEcdsaChannelSigner> Deref for LockedChannelMonitor<'_, ChannelSigner> {
206206
type Target = ChannelMonitor<ChannelSigner>;
207207
fn deref(&self) -> &ChannelMonitor<ChannelSigner> {
208208
&self.lock.get(&self.funding_txo).expect("Checked at construction").monitor
@@ -218,7 +218,7 @@ impl<ChannelSigner: Sign> Deref for LockedChannelMonitor<'_, ChannelSigner> {
218218
///
219219
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
220220
/// [module-level documentation]: crate::chain::chainmonitor
221-
pub struct ChainMonitor<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref>
221+
pub struct ChainMonitor<ChannelSigner: WriteableEcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref>
222222
where C::Target: chain::Filter,
223223
T::Target: BroadcasterInterface,
224224
F::Target: FeeEstimator,
@@ -242,7 +242,7 @@ pub struct ChainMonitor<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: De
242242
highest_chain_height: AtomicUsize,
243243
}
244244

245-
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> ChainMonitor<ChannelSigner, C, T, F, L, P>
245+
impl<ChannelSigner: WriteableEcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> ChainMonitor<ChannelSigner, C, T, F, L, P>
246246
where C::Target: chain::Filter,
247247
T::Target: BroadcasterInterface,
248248
F::Target: FeeEstimator,
@@ -516,7 +516,7 @@ where C::Target: chain::Filter,
516516
}
517517
}
518518

519-
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref>
519+
impl<ChannelSigner: WriteableEcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref>
520520
chain::Listen for ChainMonitor<ChannelSigner, C, T, F, L, P>
521521
where
522522
C::Target: chain::Filter,
@@ -543,7 +543,7 @@ where
543543
}
544544
}
545545

546-
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref>
546+
impl<ChannelSigner: WriteableEcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref>
547547
chain::Confirm for ChainMonitor<ChannelSigner, C, T, F, L, P>
548548
where
549549
C::Target: chain::Filter,
@@ -592,7 +592,7 @@ where
592592
}
593593
}
594594

595-
impl<ChannelSigner: Sign, C: Deref , T: Deref , F: Deref , L: Deref , P: Deref >
595+
impl<ChannelSigner: WriteableEcdsaChannelSigner, C: Deref , T: Deref , F: Deref , L: Deref , P: Deref >
596596
chain::Watch<ChannelSigner> for ChainMonitor<ChannelSigner, C, T, F, L, P>
597597
where C::Target: chain::Filter,
598598
T::Target: BroadcasterInterface,
@@ -735,7 +735,7 @@ where C::Target: chain::Filter,
735735
}
736736
}
737737

738-
impl<ChannelSigner: Sign, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> events::EventsProvider for ChainMonitor<ChannelSigner, C, T, F, L, P>
738+
impl<ChannelSigner: WriteableEcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref, P: Deref> events::EventsProvider for ChainMonitor<ChannelSigner, C, T, F, L, P>
739739
where C::Target: chain::Filter,
740740
T::Target: BroadcasterInterface,
741741
F::Target: FeeEstimator,

lightning/src/chain/channelmonitor.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use crate::chain;
4242
use crate::chain::{BestBlock, WatchedOutput};
4343
use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator, LowerBoundedFeeEstimator};
4444
use crate::chain::transaction::{OutPoint, TransactionData};
45-
use crate::chain::keysinterface::{SpendableOutputDescriptor, StaticPaymentOutputDescriptor, DelayedPaymentOutputDescriptor, Sign, SignerProvider, EntropySource};
45+
use crate::chain::keysinterface::{SpendableOutputDescriptor, StaticPaymentOutputDescriptor, DelayedPaymentOutputDescriptor, WriteableEcdsaChannelSigner, SignerProvider, EntropySource};
4646
#[cfg(anchors)]
4747
use crate::chain::onchaintx::ClaimEvent;
4848
use crate::chain::onchaintx::OnchainTxHandler;
@@ -706,14 +706,14 @@ impl Readable for IrrevocablyResolvedHTLC {
706706
/// the "reorg path" (ie disconnecting blocks until you find a common ancestor from both the
707707
/// returned block hash and the the current chain and then reconnecting blocks to get to the
708708
/// best chain) upon deserializing the object!
709-
pub struct ChannelMonitor<Signer: Sign> {
709+
pub struct ChannelMonitor<Signer: WriteableEcdsaChannelSigner> {
710710
#[cfg(test)]
711711
pub(crate) inner: Mutex<ChannelMonitorImpl<Signer>>,
712712
#[cfg(not(test))]
713713
inner: Mutex<ChannelMonitorImpl<Signer>>,
714714
}
715715

716-
pub(crate) struct ChannelMonitorImpl<Signer: Sign> {
716+
pub(crate) struct ChannelMonitorImpl<Signer: WriteableEcdsaChannelSigner> {
717717
latest_update_id: u64,
718718
commitment_transaction_number_obscure_factor: u64,
719719

@@ -857,7 +857,7 @@ pub type TransactionOutputs = (Txid, Vec<(u32, TxOut)>);
857857
#[cfg(any(test, fuzzing, feature = "_test_utils"))]
858858
/// Used only in testing and fuzzing to check serialization roundtrips don't change the underlying
859859
/// object
860-
impl<Signer: Sign> PartialEq for ChannelMonitor<Signer> {
860+
impl<Signer: WriteableEcdsaChannelSigner> PartialEq for ChannelMonitor<Signer> {
861861
fn eq(&self, other: &Self) -> bool {
862862
let inner = self.inner.lock().unwrap();
863863
let other = other.inner.lock().unwrap();
@@ -868,7 +868,7 @@ impl<Signer: Sign> PartialEq for ChannelMonitor<Signer> {
868868
#[cfg(any(test, fuzzing, feature = "_test_utils"))]
869869
/// Used only in testing and fuzzing to check serialization roundtrips don't change the underlying
870870
/// object
871-
impl<Signer: Sign> PartialEq for ChannelMonitorImpl<Signer> {
871+
impl<Signer: WriteableEcdsaChannelSigner> PartialEq for ChannelMonitorImpl<Signer> {
872872
fn eq(&self, other: &Self) -> bool {
873873
if self.latest_update_id != other.latest_update_id ||
874874
self.commitment_transaction_number_obscure_factor != other.commitment_transaction_number_obscure_factor ||
@@ -912,7 +912,7 @@ impl<Signer: Sign> PartialEq for ChannelMonitorImpl<Signer> {
912912
}
913913
}
914914

915-
impl<Signer: Sign> Writeable for ChannelMonitor<Signer> {
915+
impl<Signer: WriteableEcdsaChannelSigner> Writeable for ChannelMonitor<Signer> {
916916
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
917917
self.inner.lock().unwrap().write(writer)
918918
}
@@ -922,7 +922,7 @@ impl<Signer: Sign> Writeable for ChannelMonitor<Signer> {
922922
const SERIALIZATION_VERSION: u8 = 1;
923923
const MIN_SERIALIZATION_VERSION: u8 = 1;
924924

925-
impl<Signer: Sign> Writeable for ChannelMonitorImpl<Signer> {
925+
impl<Signer: WriteableEcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
926926
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
927927
write_ver_prefix!(writer, SERIALIZATION_VERSION, MIN_SERIALIZATION_VERSION);
928928

@@ -1090,7 +1090,7 @@ impl<Signer: Sign> Writeable for ChannelMonitorImpl<Signer> {
10901090
}
10911091
}
10921092

1093-
impl<Signer: Sign> ChannelMonitor<Signer> {
1093+
impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
10941094
/// For lockorder enforcement purposes, we need to have a single site which constructs the
10951095
/// `inner` mutex, otherwise cases where we lock two monitors at the same time (eg in our
10961096
/// PartialEq implementation) we may decide a lockorder violation has occurred.
@@ -1521,7 +1521,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
15211521
}
15221522
}
15231523

1524-
impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1524+
impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
15251525
/// Helper for get_claimable_balances which does the work for an individual HTLC, generating up
15261526
/// to one `Balance` for the HTLC.
15271527
fn get_htlc_balance(&self, htlc: &HTLCOutputInCommitment, holder_commitment: bool,
@@ -1684,7 +1684,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16841684
}
16851685
}
16861686

1687-
impl<Signer: Sign> ChannelMonitor<Signer> {
1687+
impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
16881688
/// Gets the balances in this channel which are either claimable by us if we were to
16891689
/// force-close the channel now or which are claimable on-chain (possibly awaiting
16901690
/// confirmation).
@@ -2082,7 +2082,7 @@ pub fn deliberately_bogus_accepted_htlc_witness() -> Vec<Vec<u8>> {
20822082
vec![Vec::new(), Vec::new(), Vec::new(), Vec::new(), deliberately_bogus_accepted_htlc_witness_program().into()].into()
20832083
}
20842084

2085-
impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2085+
impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
20862086
/// Inserts a revocation secret into this channel monitor. Prunes old preimages if neither
20872087
/// needed by holder commitment transactions HTCLs nor by counterparty ones. Unless we haven't already seen
20882088
/// counterparty commitment transaction's secret, they are de facto pruned (we can use revocation key).
@@ -3664,7 +3664,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
36643664
}
36653665
}
36663666

3667-
impl<Signer: Sign, T: Deref, F: Deref, L: Deref> chain::Listen for (ChannelMonitor<Signer>, T, F, L)
3667+
impl<Signer: WriteableEcdsaChannelSigner, T: Deref, F: Deref, L: Deref> chain::Listen for (ChannelMonitor<Signer>, T, F, L)
36683668
where
36693669
T::Target: BroadcasterInterface,
36703670
F::Target: FeeEstimator,
@@ -3679,7 +3679,7 @@ where
36793679
}
36803680
}
36813681

3682-
impl<Signer: Sign, T: Deref, F: Deref, L: Deref> chain::Confirm for (ChannelMonitor<Signer>, T, F, L)
3682+
impl<Signer: WriteableEcdsaChannelSigner, T: Deref, F: Deref, L: Deref> chain::Confirm for (ChannelMonitor<Signer>, T, F, L)
36833683
where
36843684
T::Target: BroadcasterInterface,
36853685
F::Target: FeeEstimator,

lightning/src/chain/keysinterface.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub trait EcdsaChannelSigner: ChannelSigner {
424424
///
425425
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
426426
/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
427-
pub trait Sign: EcdsaChannelSigner + Writeable {}
427+
pub trait WriteableEcdsaChannelSigner: EcdsaChannelSigner + Writeable {}
428428

429429
/// Specifies the recipient of an invoice.
430430
///
@@ -505,8 +505,8 @@ pub trait NodeSigner {
505505

506506
/// A trait that can return signer instances for individual channels.
507507
pub trait SignerProvider {
508-
/// A type which implements [`Sign`] which will be returned by [`Self::derive_channel_signer`].
509-
type Signer : Sign;
508+
/// A type which implements [`WriteableEcdsaChannelSigner`] which will be returned by [`Self::derive_channel_signer`].
509+
type Signer : WriteableEcdsaChannelSigner;
510510

511511
/// Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through
512512
/// [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow
@@ -526,7 +526,7 @@ pub trait SignerProvider {
526526

527527
/// Reads a [`Signer`] for this [`SignerProvider`] from the given input stream.
528528
/// This is only called during deserialization of other objects which contain
529-
/// [`Sign`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s).
529+
/// [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s).
530530
/// The bytes are exactly those which `<Self::Signer as Writeable>::write()` writes, and
531531
/// contain no versioning scheme. You may wish to include your own version prefix and ensure
532532
/// you've read all of the provided bytes to ensure no corruption occurred.
@@ -553,7 +553,7 @@ pub trait SignerProvider {
553553
}
554554

555555
#[derive(Clone)]
556-
/// A simple implementation of [`Sign`] that just keeps the private keys in memory.
556+
/// A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory.
557557
///
558558
/// This implementation performs no policy checks and is insufficient by itself as
559559
/// a secure external signer.
@@ -899,7 +899,7 @@ const SERIALIZATION_VERSION: u8 = 1;
899899

900900
const MIN_SERIALIZATION_VERSION: u8 = 1;
901901

902-
impl Sign for InMemorySigner {}
902+
impl WriteableEcdsaChannelSigner for InMemorySigner {}
903903

904904
impl Writeable for InMemorySigner {
905905
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
@@ -1064,7 +1064,7 @@ impl KeysManager {
10641064
Err(_) => panic!("Your rng is busted"),
10651065
}
10661066
}
1067-
/// Derive an old [`Sign`] containing per-channel secrets based on a key derivation parameters.
1067+
/// Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters.
10681068
pub fn derive_channel_keys(&self, channel_value_satoshis: u64, params: &[u8; 32]) -> InMemorySigner {
10691069
let chan_id = u64::from_be_bytes(params[0..8].try_into().unwrap());
10701070
let mut unique_start = Sha256::engine();

lightning/src/chain/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use bitcoin::network::constants::Network;
1818
use bitcoin::secp256k1::PublicKey;
1919

2020
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, MonitorEvent};
21-
use crate::chain::keysinterface::Sign;
21+
use crate::chain::keysinterface::WriteableEcdsaChannelSigner;
2222
use crate::chain::transaction::{OutPoint, TransactionData};
2323

2424
use crate::prelude::*;
@@ -291,7 +291,7 @@ pub enum ChannelMonitorUpdateStatus {
291291
/// multiple instances.
292292
///
293293
/// [`PermanentFailure`]: ChannelMonitorUpdateStatus::PermanentFailure
294-
pub trait Watch<ChannelSigner: Sign> {
294+
pub trait Watch<ChannelSigner: WriteableEcdsaChannelSigner> {
295295
/// Watches a channel identified by `funding_txo` using `monitor`.
296296
///
297297
/// Implementations are responsible for watching the chain for the funding transaction along

lightning/src/chain/onchaintx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::ln::chan_utils::{ChannelTransactionParameters, HolderCommitmentTransa
3131
use crate::chain::chaininterface::ConfirmationTarget;
3232
use crate::chain::chaininterface::{FeeEstimator, BroadcasterInterface, LowerBoundedFeeEstimator};
3333
use crate::chain::channelmonitor::{ANTI_REORG_DELAY, CLTV_SHARED_CLAIM_BUFFER};
34-
use crate::chain::keysinterface::Sign;
34+
use crate::chain::keysinterface::WriteableEcdsaChannelSigner;
3535
#[cfg(anchors)]
3636
use crate::chain::package::PackageSolvingData;
3737
use crate::chain::package::PackageTemplate;
@@ -219,7 +219,7 @@ type PackageID = [u8; 32];
219219

220220
/// OnchainTxHandler receives claiming requests, aggregates them if it's sound, broadcast and
221221
/// do RBF bumping if possible.
222-
pub struct OnchainTxHandler<ChannelSigner: Sign> {
222+
pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
223223
destination_script: Script,
224224
holder_commitment: HolderCommitmentTransaction,
225225
// holder_htlc_sigs and prev_holder_htlc_sigs are in the order as they appear in the commitment
@@ -271,7 +271,7 @@ pub struct OnchainTxHandler<ChannelSigner: Sign> {
271271
const SERIALIZATION_VERSION: u8 = 1;
272272
const MIN_SERIALIZATION_VERSION: u8 = 1;
273273

274-
impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
274+
impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
275275
pub(crate) fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
276276
write_ver_prefix!(writer, SERIALIZATION_VERSION, MIN_SERIALIZATION_VERSION);
277277

@@ -415,7 +415,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
415415
}
416416
}
417417

418-
impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
418+
impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
419419
pub(crate) fn new(destination_script: Script, signer: ChannelSigner, channel_parameters: ChannelTransactionParameters, holder_commitment: HolderCommitmentTransaction, secp_ctx: Secp256k1<secp256k1::All>) -> Self {
420420
OnchainTxHandler {
421421
destination_script,

0 commit comments

Comments
 (0)