Skip to content

Commit a7e122e

Browse files
authored
Fix uninline format rust 1.88.0 clippy violations (payjoin#667)
2 parents 518d8d2 + b42eee4 commit a7e122e

File tree

32 files changed

+163
-180
lines changed

32 files changed

+163
-180
lines changed

payjoin-cli/src/app/config.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Config {
7171
"Multiple version flags specified. Please use only one of: {}",
7272
Self::VERSION_FLAGS
7373
.iter()
74-
.map(|(flag, _)| format!("--{}", flag))
74+
.map(|(flag, _)| format!("--{flag}"))
7575
.collect::<Vec<_>>()
7676
.join(", ")
7777
)));
@@ -146,8 +146,7 @@ impl Config {
146146
Ok(v1) => config.version = Some(VersionConfig::V1(v1)),
147147
Err(e) =>
148148
return Err(ConfigError::Message(format!(
149-
"Valid V1 configuration is required for BIP78 mode: {}",
150-
e
149+
"Valid V1 configuration is required for BIP78 mode: {e}"
151150
))),
152151
}
153152
}
@@ -163,8 +162,7 @@ impl Config {
163162
Ok(v2) => config.version = Some(VersionConfig::V2(v2)),
164163
Err(e) =>
165164
return Err(ConfigError::Message(format!(
166-
"Valid V2 configuration is required for BIP77 mode: {}",
167-
e
165+
"Valid V2 configuration is required for BIP77 mode: {e}"
168166
))),
169167
}
170168
}
@@ -182,7 +180,7 @@ impl Config {
182180
));
183181
}
184182

185-
log::debug!("App config: {:?}", config);
183+
log::debug!("App config: {config:?}");
186184
Ok(config)
187185
}
188186

@@ -315,10 +313,10 @@ where
315313
match path_str {
316314
None => Ok(None),
317315
Some(path) => std::fs::read(path)
318-
.map_err(|e| serde::de::Error::custom(format!("Failed to read ohttp_keys file: {}", e)))
316+
.map_err(|e| serde::de::Error::custom(format!("Failed to read ohttp_keys file: {e}")))
319317
.and_then(|bytes| {
320318
payjoin::OhttpKeys::decode(&bytes).map_err(|e| {
321-
serde::de::Error::custom(format!("Failed to decode ohttp keys: {}", e))
319+
serde::de::Error::custom(format!("Failed to decode ohttp keys: {e}"))
322320
})
323321
})
324322
.map(Some),

payjoin-cli/src/app/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ pub trait App: Send + Sync {
4343
}
4444

4545
fn process_pj_response(&self, psbt: Psbt) -> Result<bitcoin::Txid> {
46-
log::debug!("Proposed psbt: {:#?}", psbt);
46+
log::debug!("Proposed psbt: {psbt:#?}");
4747

4848
let signed = self.wallet().process_psbt(&psbt)?;
4949
let tx = self.wallet().finalize_psbt(&signed)?;
5050

5151
let txid = self.wallet().broadcast_tx(&tx)?;
5252

53-
println!("Payjoin sent. TXID: {}", txid);
53+
println!("Payjoin sent. TXID: {txid}");
5454
Ok(txid)
5555
}
5656
}
@@ -83,7 +83,7 @@ fn read_local_cert() -> Result<Vec<u8>> {
8383

8484
async fn handle_interrupt(tx: watch::Sender<()>) {
8585
if let Err(e) = signal::ctrl_c().await {
86-
eprintln!("Error setting up Ctrl-C handler: {}", e);
86+
eprintln!("Error setting up Ctrl-C handler: {e}");
8787
}
8888
let _ = tx.send(());
8989
}

payjoin-cli/src/app/v1.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ impl AppTrait for App {
9191
);
9292
let psbt = ctx.process_response(&mut response.bytes().await?.to_vec().as_slice()).map_err(
9393
|e| {
94-
log::debug!("Error processing response: {:?}", e);
95-
anyhow!("Failed to process response {}", e)
94+
log::debug!("Error processing response: {e:?}");
95+
anyhow!("Failed to process response {e}")
9696
},
9797
)?;
9898

@@ -165,7 +165,7 @@ impl App {
165165
let stream = match tls_acceptor.accept(stream).await {
166166
Ok(tls_stream) => tls_stream,
167167
Err(e) => {
168-
log::error!("TLS accept error: {}", e);
168+
log::error!("TLS accept error: {e}");
169169
return;
170170
}
171171
};
@@ -211,19 +211,19 @@ impl App {
211211
self,
212212
req: Request<Incoming>,
213213
) -> Result<Response<BoxBody<Bytes, hyper::Error>>> {
214-
log::debug!("Received request: {:?}", req);
214+
log::debug!("Received request: {req:?}");
215215
let mut response = match (req.method(), req.uri().path()) {
216216
(&Method::GET, "/bip21") => {
217217
let query_string = req.uri().query().unwrap_or("");
218-
log::debug!("{:?}, {:?}", req.method(), query_string);
218+
log::debug!("{:?}, {query_string:?}", req.method());
219219
let query_params: HashMap<_, _> =
220220
url::form_urlencoded::parse(query_string.as_bytes()).into_owned().collect();
221221
let amount = query_params.get("amount").map(|amt| {
222222
Amount::from_btc(amt.parse().expect("Failed to parse amount")).unwrap()
223223
});
224224
self.handle_get_bip21(amount)
225225
.map_err(|e| {
226-
log::error!("Error handling request: {}", e);
226+
log::error!("Error handling request: {e}");
227227
Response::builder().status(500).body(full(e.to_string())).unwrap()
228228
})
229229
.unwrap_or_else(|err_resp| err_resp)
@@ -233,11 +233,11 @@ impl App {
233233
.await
234234
.map_err(|e| match e {
235235
V1(e) => {
236-
log::error!("Error handling request: {}", e);
236+
log::error!("Error handling request: {e}");
237237
Response::builder().status(400).body(full(e.to_string())).unwrap()
238238
}
239239
e => {
240-
log::error!("Error handling request: {}", e);
240+
log::error!("Error handling request: {e}");
241241
Response::builder().status(500).body(full(e.to_string())).unwrap()
242242
}
243243
})

payjoin-cli/src/app/v2.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl App {
152152
let mut pj_uri = session.pj_uri();
153153
pj_uri.amount = amount;
154154
println!("Request Payjoin by sharing this Payjoin Uri:");
155-
println!("{}", pj_uri);
155+
println!("{pj_uri}");
156156

157157
let mut interrupt = self.interrupt.clone();
158158
let receiver = tokio::select! {
@@ -208,8 +208,8 @@ impl App {
208208
println!("No response yet.");
209209
}
210210
Err(re) => {
211-
println!("{}", re);
212-
log::debug!("{:?}", re);
211+
println!("{re}");
212+
log::debug!("{re:?}");
213213
return Err(anyhow!("Response error").context(re));
214214
}
215215
}
@@ -223,8 +223,8 @@ impl App {
223223
match v1_ctx.process_response(&mut response.bytes().await?.to_vec().as_slice()) {
224224
Ok(psbt) => Ok(psbt),
225225
Err(re) => {
226-
println!("{}", re);
227-
log::debug!("{:?}", re);
226+
println!("{re}");
227+
log::debug!("{re:?}");
228228
Err(anyhow!("Response error").context(re))
229229
}
230230
}
@@ -286,7 +286,7 @@ impl App {
286286
self.config.max_fee_rate,
287287
)?;
288288
let payjoin_proposal_psbt = payjoin_proposal.psbt();
289-
log::debug!("Receiver's Payjoin proposal PSBT Rsponse: {:#?}", payjoin_proposal_psbt);
289+
log::debug!("Receiver's Payjoin proposal PSBT Rsponse: {payjoin_proposal_psbt:#?}");
290290
Ok(payjoin_proposal)
291291
}
292292
}

payjoin-cli/src/db/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ pub(crate) enum Error {
2020
impl fmt::Display for Error {
2121
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2222
match self {
23-
Error::Sled(e) => write!(f, "Database operation failed: {}", e),
23+
Error::Sled(e) => write!(f, "Database operation failed: {e}"),
2424
#[cfg(feature = "v2")]
25-
Error::Serialize(e) => write!(f, "Serialization failed: {}", e),
25+
Error::Serialize(e) => write!(f, "Serialization failed: {e}"),
2626
#[cfg(feature = "v2")]
27-
Error::Deserialize(e) => write!(f, "Deserialization failed: {}", e),
27+
Error::Deserialize(e) => write!(f, "Deserialization failed: {e}"),
2828
#[cfg(feature = "v2")]
29-
Error::NotFound(key) => write!(f, "Key not found: {}", key),
29+
Error::NotFound(key) => write!(f, "Key not found: {key}"),
3030
}
3131
}
3232
}

payjoin-cli/tests/e2e.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mod e2e {
4848
let receiver_rpchost = format!("http://{}/wallet/receiver", bitcoind.params.rpc_socket);
4949
let sender_rpchost = format!("http://{}/wallet/sender", bitcoind.params.rpc_socket);
5050
let cookie_file = &bitcoind.params.cookie_file;
51-
let pj_endpoint = format!("https://localhost:{}", port);
51+
let pj_endpoint = format!("https://localhost:{port}");
5252
let payjoin_cli = env!("CARGO_BIN_EXE_payjoin-cli");
5353

5454
let mut cli_receiver = Command::new(payjoin_cli)
@@ -82,7 +82,7 @@ mod e2e {
8282
{
8383
// Write to stdout regardless
8484
stdout
85-
.write_all(format!("{}\n", line).as_bytes())
85+
.write_all(format!("{line}\n").as_bytes())
8686
.await
8787
.expect("Failed to write to stdout");
8888

@@ -121,7 +121,7 @@ mod e2e {
121121
lines.next_line().await.expect("Failed to read line from stdout")
122122
{
123123
stdout
124-
.write_all(format!("{}\n", line).as_bytes())
124+
.write_all(format!("{line}\n").as_bytes())
125125
.await
126126
.expect("Failed to write to stdout");
127127
if line.contains("Payjoin sent") {
@@ -173,8 +173,8 @@ mod e2e {
173173
CleanupGuard { paths: vec![receiver_db_path.clone(), sender_db_path.clone()] };
174174

175175
let result = tokio::select! {
176-
res = services.take_ohttp_relay_handle() => Err(format!("Ohttp relay is long running: {:?}", res).into()),
177-
res = services.take_directory_handle() => Err(format!("Directory server is long running: {:?}", res).into()),
176+
res = services.take_ohttp_relay_handle() => Err(format!("Ohttp relay is long running: {res:?}").into()),
177+
res = services.take_directory_handle() => Err(format!("Directory server is long running: {res:?}").into()),
178178
res = send_receive_cli_async(&services, receiver_db_path.clone(), sender_db_path.clone()) => res,
179179
};
180180

@@ -357,7 +357,7 @@ mod e2e {
357357
{
358358
// Write all output to tests stdout
359359
stdout
360-
.write_all(format!("{}\n", line).as_bytes())
360+
.write_all(format!("{line}\n").as_bytes())
361361
.await
362362
.expect("Failed to write to stdout");
363363

@@ -375,7 +375,7 @@ mod e2e {
375375

376376
fn cleanup_temp_file(path: &std::path::Path) {
377377
if let Err(e) = std::fs::remove_dir_all(path) {
378-
eprintln!("Failed to remove {:?}: {}", path, e);
378+
eprintln!("Failed to remove {path:?}: {e}");
379379
}
380380
}
381381
}

payjoin-directory/src/db.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl std::fmt::Display for Error {
2626
use Error::*;
2727

2828
match &self {
29-
Redis(error) => write!(f, "Redis error: {}", error),
30-
Timeout(timeout) => write!(f, "Timeout: {}", timeout),
29+
Redis(error) => write!(f, "Redis error: {error}"),
30+
Timeout(timeout) => write!(f, "Timeout: {timeout}"),
3131
}
3232
}
3333
}
@@ -49,7 +49,7 @@ pub(crate) type Result<T> = core::result::Result<T, Error>;
4949

5050
impl DbPool {
5151
pub async fn new(timeout: Duration, db_host: String) -> Result<Self> {
52-
let client = Client::open(format!("redis://{}", db_host))?;
52+
let client = Client::open(format!("redis://{db_host}"))?;
5353
Ok(Self { client, timeout })
5454
}
5555

payjoin-directory/src/key_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn read_server_config(dir: &Path) -> Result<ServerKeyConfig> {
7474
/// Get the path to the key configuration file
7575
/// For now, default to [KEY_ID].ikm.
7676
/// In the future this might be able to save multiple keys named by KeyId.
77-
fn key_path(dir: &Path) -> PathBuf { dir.join(format!("{}.ikm", KEY_ID)) }
77+
fn key_path(dir: &Path) -> PathBuf { dir.join(format!("{KEY_ID}.ikm")) }
7878

7979
#[cfg(test)]
8080
mod tests {

payjoin-directory/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub async fn listen_tcp_with_tls(
142142
cert_key: (Vec<u8>, Vec<u8>),
143143
ohttp: ohttp::Server,
144144
) -> Result<tokio::task::JoinHandle<Result<(), BoxError>>, BoxError> {
145-
let addr = format!("0.0.0.0:{}", port);
145+
let addr = format!("0.0.0.0:{port}");
146146
let listener = tokio::net::TcpListener::bind(&addr).await?;
147147
listen_tcp_with_tls_on_listener(listener, db_host, timeout, cert_key, ohttp).await
148148
}
@@ -352,7 +352,7 @@ async fn post_fallback_v1(
352352
Err(_) => return Ok(bad_request_body_res),
353353
};
354354

355-
let v2_compat_body = format!("{}\n{}", body_str, query);
355+
let v2_compat_body = format!("{body_str}\n{query}");
356356
let id = ShortId::from_str(id)?;
357357
pool.push_default(&id, v2_compat_body.into())
358358
.await

payjoin-test-utils/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub async fn init_directory(
129129
(u16, tokio::task::JoinHandle<std::result::Result<(), BoxSendSyncError>>),
130130
BoxSendSyncError,
131131
> {
132-
println!("Database running on {}", db_host);
132+
println!("Database running on {db_host}");
133133
let timeout = Duration::from_secs(2);
134134
let ohttp_server = payjoin_directory::gen_ohttp_server_config()?;
135135
payjoin_directory::listen_tcp_with_tls_on_free_port(
@@ -221,7 +221,7 @@ pub fn init_bitcoind_multi_sender_single_reciever(
221221
) -> Result<(bitcoind::BitcoinD, Vec<bitcoincore_rpc::Client>, bitcoincore_rpc::Client), BoxError> {
222222
let bitcoind = init_bitcoind()?;
223223
let wallets_to_create =
224-
(0..number_of_senders + 1).map(|i| (format!("sender_{}", i), None)).collect::<Vec<_>>();
224+
(0..number_of_senders + 1).map(|i| (format!("sender_{i}"), None)).collect::<Vec<_>>();
225225
let mut wallets = create_and_fund_wallets(&bitcoind, wallets_to_create)?;
226226
let receiver = wallets.pop().expect("receiver to exist");
227227
let senders = wallets;

0 commit comments

Comments
 (0)