Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add codespell lint job into workflows & fix typos #35

Merged
merged 6 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ jobs:
with:
command: doc
args: --workspace --all-features
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: crate-ci/typos@master


2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ v0.2.0-beta.3
- Multiple BIP-32 improvements on top of rust-bitcoin functionality
- Better CI
- Android/iOS/Windows/MacOs build fixes
- AchorId strict encoding
- AnchorId strict encoding
- Fixed issue with broken `serde_with` macro (pinned older version in Cargo.toml)
- More collection types supporting `AutoConceal`

Expand Down
4 changes: 4 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[default.extend-words]
# Don't correct the name "Jon Atack".
Atack = "Atack"
optin = "optin"
4 changes: 2 additions & 2 deletions lnp2p/src/bifrost/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum CommonFeeAlgo {
/// Common fees are paid by the channel coordinator
ByCoordinator,

/// Common fees are paid in proportional amounts by all participats
/// Common fees are paid in proportional amounts by all participants
SharedFee,
}

Expand Down Expand Up @@ -209,7 +209,7 @@ pub struct UpgradeChannel {

#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Debug, Display)]
#[derive(NetworkEncode, NetworkDecode)]
#[display("donwgrade_channel({channel_id}, {protocol}, ...)")]
#[display("downgrade_channel({channel_id}, {protocol}, ...)")]
pub struct DowngradeChannel {
pub channel_id: ChannelId,
pub protocol: ProtocolName,
Expand Down
2 changes: 1 addition & 1 deletion lnp2p/src/bifrost/ctrl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct Error {
pub channel_id: Option<ChannelId>,
pub errno: u64,
pub message: Option<String>,
/// Any additiona error details
/// Any additional error details
#[network_encoding(unknown_tlvs)]
pub unknown_tlvs: tlv::Stream,
}
Expand Down
6 changes: 3 additions & 3 deletions lnp2p/src/bifrost/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct ChannelInput {
/// witness for the input. Always v0+ witness
pub descriptor: SegwitDescriptor,

/// Witness satisfying prevous transaction descriptor.
/// Witness satisfying previous transaction descriptor.
///
/// Must be present only when the transaction is signed
pub witness: Option<Witness>,
Expand Down Expand Up @@ -152,7 +152,7 @@ pub enum ChannelFunding {
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
#[derive(NetworkEncode, NetworkDecode)]
pub struct ChannelLink {
/// Amount allocated to the transaction outut and consumed by the child
/// Amount allocated to the transaction output and consumed by the child
/// channel transaction
pub amount: Amount,

Expand All @@ -163,7 +163,7 @@ pub struct ChannelLink {
///
/// We provide full descriptor to enable nodes to use custom keys. Still,
/// the descriptor mod key values MUST match template defined for the
/// gived [`TxRole`] from [`ChannelTx::children`] containing this link.
/// given [`TxRole`] from [`ChannelTx::children`] containing this link.
pub descriptor: TaprootDescriptor,

/// Sequence number to use in the child transaction input
Expand Down
2 changes: 1 addition & 1 deletion lnp2p/src/bolt/bolt2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ pub struct UpdateAddHtlc {
#[derive(Clone, PartialEq, Eq, Debug, Display)]
#[derive(LightningEncode, LightningDecode)]
#[cfg_attr(feature = "strict_encoding", derive(NetworkEncode, NetworkDecode))]
#[display("update_fullfill_htlc({channel_id}, {htlc_id}, ...preimages)")]
#[display("update_fulfill_htlc({channel_id}, {htlc_id}, ...preimages)")]
pub struct UpdateFulfillHtlc {
/// The channel ID
pub channel_id: ChannelId,
Expand Down
2 changes: 1 addition & 1 deletion lnp2p/src/bolt/bolt7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub struct ReplyShortChannelIdsEnd {
#[derive(LightningEncode, LightningDecode)]
#[cfg_attr(feature = "strict_encoding", derive(NetworkEncode, NetworkDecode))]
#[display(
"querry_channel_range({chain_hash}, {first_blocknum}, {number_of_blocks}, \
"query_channel_range({chain_hash}, {first_blocknum}, {number_of_blocks}, \
...tlvs)"
)]
pub struct QueryChannelRange {
Expand Down
4 changes: 2 additions & 2 deletions lnp2p/src/bolt/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ pub enum ShortChannelIdParseError {
WrongOutputIndex,
/// too many short channel id components; expected three (block height,
/// tx index and output index)
ExessiveComponents,
ExcessiveComponents,
}

impl FromStr for ShortChannelId {
Expand All @@ -382,7 +382,7 @@ impl FromStr for ShortChannelId {
})?,
})
}
_ => Err(ShortChannelIdParseError::ExessiveComponents),
_ => Err(ShortChannelIdParseError::ExcessiveComponents),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/channel/bolt/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ pub enum Error {
},

/// the channel does not have permanent channel_id assigned
NoChanelId,
NoChannelId,

/// the channel must have a temporary channel id and not be active for the
/// operaiton
/// operation
NoTemporaryId,
}

Expand Down Expand Up @@ -187,7 +187,7 @@ impl Channel<BoltExt> {
self.constructor_mut().set_policy(policy)
}

/// Sets common parameters for the chanel.
/// Sets common parameters for the channel.
///
/// Can be used for changing prospective channel parameters on the fly to
/// enable accepting new `open_channel` - or follow-up `accept_channel`
Expand Down Expand Up @@ -223,7 +223,7 @@ impl Channel<BoltExt> {
/// otherwise.
#[inline]
pub fn try_channel_id(&self) -> Result<ChannelId, Error> {
self.channel_id().ok_or(Error::NoChanelId)
self.channel_id().ok_or(Error::NoChannelId)
}

/// Before the channel is assigned a final [`ChannelId`] returns
Expand Down Expand Up @@ -498,7 +498,7 @@ impl BoltChannel {
/// otherwise.
#[inline]
pub fn try_channel_id(&self) -> Result<ChannelId, Error> {
self.channel_id().ok_or(Error::NoChanelId)
self.channel_id().ok_or(Error::NoChannelId)
}

/// Assigns channel a temporary id
Expand Down Expand Up @@ -531,7 +531,7 @@ impl BoltChannel {
self.policy = policy
}

/// Sets common parameters for the chanel
/// Sets common parameters for the channel
#[inline]
pub fn set_common_params(&mut self, params: CommonParams) {
self.common_params = params
Expand Down
34 changes: 17 additions & 17 deletions src/channel/bolt/extensions/htlc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct Htlc {
/// will be pushed through an anchor transaction.
anchors_zero_fee_htlc_tx: bool,

// Sets of HTLC informations
// Sets of HTLC information
offered_htlcs: BTreeMap<u64, HtlcSecret>,
received_htlcs: BTreeMap<u64, HtlcSecret>,
resolved_htlcs: BTreeMap<u64, HtlcKnown>,
Expand All @@ -85,7 +85,7 @@ pub struct Htlc {
max_htlc_value_in_flight_msat: u64,
max_accepted_htlcs: u16,

next_recieved_htlc_id: u64,
next_received_htlc_id: u64,
next_offered_htlc_id: u64,
}

Expand All @@ -106,7 +106,7 @@ impl Default for Htlc {
htlc_minimum_msat: 0,
max_htlc_value_in_flight_msat: 0,
max_accepted_htlcs: 0,
next_recieved_htlc_id: 0,
next_received_htlc_id: 0,
next_offered_htlc_id: 0,
}
}
Expand Down Expand Up @@ -229,7 +229,7 @@ impl Extension<BoltExt> for Htlc {
"Leading zeros not satisfied for Bitcoin network"
.to_string(),
));
} else if message.htlc_id < self.next_recieved_htlc_id {
} else if message.htlc_id < self.next_received_htlc_id {
return Err(Error::Htlc(
"HTLC id violation occurred".to_string(),
)); // TODO handle reconnection
Expand All @@ -242,11 +242,11 @@ impl Extension<BoltExt> for Htlc {
};
self.received_htlcs.insert(htlc.id, htlc);

self.next_recieved_htlc_id += 1;
self.next_received_htlc_id += 1;
}
} else {
return Err(Error::Htlc(
"Missmatched channel_id, bad remote node".to_string(),
"Mismatched channel_id, bad remote node".to_string(),
));
}
}
Expand Down Expand Up @@ -274,7 +274,7 @@ impl Extension<BoltExt> for Htlc {
}
} else {
return Err(Error::Htlc(
"Missmatched channel_id, bad remote node".to_string(),
"Mismatched channel_id, bad remote node".to_string(),
));
}
}
Expand Down Expand Up @@ -321,15 +321,15 @@ impl Extension<BoltExt> for Htlc {
state.remote_params.max_htlc_value_in_flight_msat;
self.max_accepted_htlcs = state.remote_params.max_accepted_htlcs;

self.next_recieved_htlc_id = state.last_recieved_htlc_id;
self.next_received_htlc_id = state.last_received_htlc_id;
self.next_offered_htlc_id = state.last_offered_htlc_id;
}

fn store_state(&self, state: &mut ChannelState) {
state.offered_htlcs = self.offered_htlcs.clone();
state.received_htlcs = self.received_htlcs.clone();
state.resolved_htlcs = self.resolved_htlcs.clone();
state.last_recieved_htlc_id = self.next_recieved_htlc_id;
state.last_received_htlc_id = self.next_received_htlc_id;
state.last_offered_htlc_id = self.next_offered_htlc_id;
}
}
Expand Down Expand Up @@ -392,14 +392,14 @@ impl ChannelExtension<BoltExt> for Htlc {
}

// Process received HTLCs
for (index, recieved) in self.received_htlcs.iter() {
for (index, received) in self.received_htlcs.iter() {
let htlc_output: Output = ScriptGenerators::ln_received_htlc(
recieved.amount / 1000,
received.amount / 1000,
self.remote_revocation_basepoint,
self.local_basepoint,
self.remote_basepoint,
recieved.cltv_expiry,
recieved.hashlock,
received.cltv_expiry,
received.hashlock,
);

// Sum amounts to same OutPoints
Expand All @@ -409,17 +409,17 @@ impl ChannelExtension<BoltExt> for Htlc {
}) {
Some(index) => {
let mut htlc_output = tx_graph.cmt_outs.remove(index);
htlc_output.amount += recieved.amount;
htlc_output.amount += received.amount;
tx_graph.cmt_outs.insert(index, htlc_output);
}
_ => tx_graph.cmt_outs.push(htlc_output),
};

let htlc_tx = Psbt::ln_htlc(
recieved.amount,
received.amount,
// TODO: do a two-staged graph generation process
OutPoint::default(),
recieved.cltv_expiry,
received.cltv_expiry,
self.remote_revocation_basepoint,
self.local_delayed_basepoint,
self.to_self_delay,
Expand All @@ -432,7 +432,7 @@ impl ChannelExtension<BoltExt> for Htlc {
htlc_tx,
);

accumulate += recieved.amount / 1000;
accumulate += received.amount / 1000;
}

// Subtracts from the total amount of the commitment transaction
Expand Down
4 changes: 2 additions & 2 deletions src/channel/bolt/keyset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl LocalKeyset {
channel_xpriv: ExtendedPrivKey,
shutdown_scriptpubkey: Option<PubkeyScript>,
) -> Self {
let fingerpint = channel_source.0;
let fingerprint = channel_source.0;

let secrets = (0u16..=6)
.into_iter()
Expand Down Expand Up @@ -232,7 +232,7 @@ impl LocalKeyset {
.private_key;
LocalPubkey {
key: PublicKey::from_secret_key(secp, &seckey),
source: (fingerpint, derivation_path),
source: (fingerprint, derivation_path),
}
})
.collect::<Vec<_>>();
Expand Down
4 changes: 2 additions & 2 deletions src/channel/bolt/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ impl Policy {
}

/// Structure containing part of the channel configuration (and state, as it
/// contains adjustible fee) which must follow specific policies and be accepted
/// contains adjustable fee) which must follow specific policies and be accepted
/// or validated basing on those policies and additional protocol-level
/// requirements.
///
Expand Down Expand Up @@ -930,7 +930,7 @@ mod test {
}

#[test]
fn test_local_dust_limit_exeeds_remote_reserve() {
fn test_local_dust_limit_exceeds_remote_reserve() {
let policy = Policy::default();
let open_channel = get_open_channel();
let mut accept_channel = get_accept_channel();
Expand Down
4 changes: 2 additions & 2 deletions src/channel/bolt/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub struct ChannelState {
pub offered_htlcs: BTreeMap<u64, HtlcSecret>,
pub received_htlcs: BTreeMap<u64, HtlcSecret>,
pub resolved_htlcs: BTreeMap<u64, HtlcKnown>,
pub last_recieved_htlc_id: u64,
pub last_received_htlc_id: u64,
pub last_offered_htlc_id: u64,
}

Expand Down Expand Up @@ -139,7 +139,7 @@ impl DumbDefault for ChannelState {
offered_htlcs: none!(),
received_htlcs: none!(),
resolved_htlcs: none!(),
last_recieved_htlc_id: 0,
last_received_htlc_id: 0,
last_offered_htlc_id: 0,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/channel/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ where

/// Adds new extension to the channel.
///
/// Will be effective onl upon next channel state update.
/// Will be effective only upon next channel state update.
#[inline]
pub fn add_extender(&mut self, extension: Box<dyn ChannelExtension<N>>) {
self.extenders.insert(extension.identity(), extension);
}

/// Adds new modifier to the channel.
///
/// Will be effective onl upon next channel state update.
/// Will be effective only upon next channel state update.
#[inline]
pub fn add_modifier(&mut self, modifier: Box<dyn ChannelExtension<N>>) {
self.modifiers.insert(modifier.identity(), modifier);
Expand Down
Loading