Skip to content

Commit 4f8a213

Browse files
committed
Merge #11: Fix clippy
1fabfe0 chore: Make clippy happy (志宇) a1ddd5b clippy: address `clippy::large_enum_variant` by using `Box` (valued mammal) Pull request description: Top commit has no ACKs. Tree-SHA512: 9b4519c2b1b76a04ca749d396ea0779e2a2dd36a8be4f438be939ef0569e9f67dc5377038de07b46c529d014aeb6fa9d7afbea702abecad4219e4d754d5aafe0
2 parents 19d9578 + 1fabfe0 commit 4f8a213

File tree

6 files changed

+28
-26
lines changed

6 files changed

+28
-26
lines changed

examples/synopsis.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() -> anyhow::Result<()> {
3131
let txid = env.send(&addr, Amount::ONE_BTC)?;
3232
env.mine_blocks(1, None)?;
3333
wallet.sync(&env)?;
34-
println!("Received {}", txid);
34+
println!("Received {txid}");
3535
println!("Balance (confirmed): {}", wallet.balance());
3636

3737
let txid = env.send(&addr, Amount::ONE_BTC)?;
@@ -88,14 +88,14 @@ fn main() -> anyhow::Result<()> {
8888

8989
// We will try bump this tx fee.
9090
let txid = env.rpc_client().send_raw_transaction(&tx)?;
91-
println!("tx broadcasted: {}", txid);
91+
println!("tx broadcasted: {txid}");
9292
wallet.sync(&env)?;
9393
println!("Balance (send tx): {}", wallet.balance());
9494

9595
// Try cancel a tx.
9696
// We follow all the rules as specified by
9797
// https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md#current-replace-by-fee-policy
98-
println!("OKAY LET's TRY CANCEL {}", txid);
98+
println!("OKAY LET's TRY CANCEL {txid}");
9999
{
100100
let original_tx = wallet
101101
.graph
@@ -172,7 +172,7 @@ fn main() -> anyhow::Result<()> {
172172
((fee.to_sat() as f32) / (tx.weight().to_vbytes_ceil() as f32)),
173173
);
174174
let txid = env.rpc_client().send_raw_transaction(&tx)?;
175-
println!("tx broadcasted: {}", txid);
175+
println!("tx broadcasted: {txid}");
176176
wallet.sync(&env)?;
177177
println!("Balance (RBF): {}", wallet.balance());
178178
}

src/canonical_unspents.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ pub enum GetForeignUnspentError {
242242
impl fmt::Display for GetForeignUnspentError {
243243
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
244244
match self {
245-
Self::Coinbase(err) => write!(f, "{}", err),
246-
Self::FromPsbtInput(err) => write!(f, "{}", err),
245+
Self::Coinbase(err) => write!(f, "{err}"),
246+
Self::FromPsbtInput(err) => write!(f, "{err}"),
247247
Self::OutputIsAlreadySpent(op) => {
248-
write!(f, "outpoint is already spent: {}", op)
248+
write!(f, "outpoint is already spent: {op}")
249249
}
250-
Self::UtxoMismatch(op) => write!(f, "UTXO mismatch: {}", op),
250+
Self::UtxoMismatch(op) => write!(f, "UTXO mismatch: {op}"),
251251
}
252252
}
253253
}
@@ -269,9 +269,9 @@ pub enum ExtractReplacementsError {
269269
impl fmt::Display for ExtractReplacementsError {
270270
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
271271
match self {
272-
Self::TransactionNotFound(txid) => write!(f, "transaction not found: {}", txid),
272+
Self::TransactionNotFound(txid) => write!(f, "transaction not found: {txid}"),
273273
Self::CannotReplaceCoinbase => write!(f, "cannot replace a coinbase transaction"),
274-
Self::PreviousOutputNotFound(op) => write!(f, "previous output not found: {}", op),
274+
Self::PreviousOutputNotFound(op) => write!(f, "previous output not found: {op}"),
275275
}
276276
}
277277
}

src/input.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use alloc::boxed::Box;
12
use alloc::sync::Arc;
23
use alloc::vec::Vec;
34
use core::fmt;
@@ -34,9 +35,9 @@ impl TxStatus {
3435

3536
#[derive(Debug, Clone)]
3637
enum PlanOrPsbtInput {
37-
Plan(Plan),
38+
Plan(Box<Plan>),
3839
PsbtInput {
39-
psbt_input: psbt::Input,
40+
psbt_input: Box<psbt::Input>,
4041
sequence: Sequence,
4142
absolute_timelock: absolute::LockTime,
4243
satisfaction_weight: usize,
@@ -57,7 +58,7 @@ impl PlanOrPsbtInput {
5758
return Err(FromPsbtInputError::UtxoCheck);
5859
}
5960
Ok(Self::PsbtInput {
60-
psbt_input,
61+
psbt_input: Box::new(psbt_input),
6162
sequence,
6263
absolute_timelock: absolute::LockTime::ZERO,
6364
satisfaction_weight,
@@ -166,9 +167,9 @@ pub enum FromPsbtInputError {
166167
impl fmt::Display for FromPsbtInputError {
167168
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
168169
match self {
169-
Self::Coinbase(err) => write!(f, "{}", err),
170+
Self::Coinbase(err) => write!(f, "{err}"),
170171
Self::InvalidOutPoint(op) => {
171-
write!(f, "invalid outpoint: {}", op)
172+
write!(f, "invalid outpoint: {op}")
172173
}
173174
Self::UtxoCheck => {
174175
write!(
@@ -216,7 +217,7 @@ impl Input {
216217
prev_outpoint: OutPoint::new(tx.compute_txid(), output_index as _),
217218
prev_txout: tx.tx_out(output_index).cloned()?,
218219
prev_tx: Some(tx),
219-
plan: PlanOrPsbtInput::Plan(plan),
220+
plan: PlanOrPsbtInput::Plan(Box::new(plan)),
220221
status,
221222
is_coinbase,
222223
})
@@ -234,7 +235,7 @@ impl Input {
234235
prev_outpoint,
235236
prev_txout,
236237
prev_tx: None,
237-
plan: PlanOrPsbtInput::Plan(plan),
238+
plan: PlanOrPsbtInput::Plan(Box::new(plan)),
238239
status,
239240
is_coinbase,
240241
}

src/input_candidates.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ impl<E: fmt::Display> fmt::Display for IntoSelectionError<E> {
228228
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
229229
match self {
230230
IntoSelectionError::Selector(error) => {
231-
write!(f, "{}", error)
231+
write!(f, "{error}")
232232
}
233233
IntoSelectionError::SelectionAlgorithm(error) => {
234-
write!(f, "selection algorithm failed: {}", error)
234+
write!(f, "selection algorithm failed: {error}")
235235
}
236-
IntoSelectionError::CannotMeetTarget(error) => write!(f, "{}", error),
236+
IntoSelectionError::CannotMeetTarget(error) => write!(f, "{error}"),
237237
}
238238
}
239239
}
@@ -275,9 +275,9 @@ pub enum PolicyFailure<PF> {
275275
impl<PF: fmt::Display> fmt::Display for PolicyFailure<PF> {
276276
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
277277
match self {
278-
PolicyFailure::MissingOutputs(err) => write!(f, "{}", err),
278+
PolicyFailure::MissingOutputs(err) => write!(f, "{err}"),
279279
PolicyFailure::PolicyFailure(err) => {
280-
write!(f, "policy failure: {}", err)
280+
write!(f, "policy failure: {err}")
281281
}
282282
}
283283
}

src/output.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use alloc::boxed::Box;
12
use bitcoin::{Amount, ScriptBuf, TxOut};
23
use miniscript::bitcoin;
34

@@ -9,7 +10,7 @@ pub enum ScriptSource {
910
/// bitcoin script
1011
Script(ScriptBuf),
1112
/// definite descriptor
12-
Descriptor(DefiniteDescriptor),
13+
Descriptor(Box<DefiniteDescriptor>),
1314
}
1415

1516
impl From<ScriptBuf> for ScriptSource {
@@ -32,7 +33,7 @@ impl ScriptSource {
3233

3334
/// From descriptor
3435
pub fn from_descriptor(descriptor: DefiniteDescriptor) -> Self {
35-
Self::Descriptor(descriptor)
36+
Self::Descriptor(Box::new(descriptor))
3637
}
3738

3839
/// To ScriptBuf

src/selector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ pub enum SelectorError {
243243
impl fmt::Display for SelectorError {
244244
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
245245
match self {
246-
Self::Miniscript(err) => write!(f, "{}", err),
247-
Self::CannotMeetTarget(err) => write!(f, "{}", err),
246+
Self::Miniscript(err) => write!(f, "{err}"),
247+
Self::CannotMeetTarget(err) => write!(f, "{err}"),
248248
}
249249
}
250250
}

0 commit comments

Comments
 (0)