Skip to content

Commit

Permalink
cargo clippy --all-features --fix
Browse files Browse the repository at this point in the history
And `cargo fmt`, as CI requires.
  • Loading branch information
DanGould committed Dec 3, 2024
1 parent 8083cb9 commit 8ac6abb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 31 deletions.
10 changes: 5 additions & 5 deletions src/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl Receiver {
ohttp_relay: Url,
expire_after: Option<u64>,
) -> Result<Self, PayjoinError> {
let address = payjoin::bitcoin::Address::from_str(address.as_str())?
.require_network(network.into())?;
let address =
payjoin::bitcoin::Address::from_str(address.as_str())?.require_network(network)?;
Ok(payjoin::receive::v2::Receiver::new(
address,
directory.into(),
Expand Down Expand Up @@ -191,7 +191,7 @@ impl MaybeInputsSeen {
self.0
.clone()
.check_no_inputs_seen_before(|outpoint| {
is_known(&(*outpoint).into()).map_err(|e| pdk::Error::Server(Box::new(e)))
is_known(outpoint).map_err(|e| pdk::Error::Server(Box::new(e)))
})
.map_err(Into::into)
.map(Into::into)
Expand Down Expand Up @@ -370,7 +370,7 @@ impl ProvisionalProposal {
Err(e) => Err(pdk::Error::Server(Box::new(e))),
}
},
min_feerate_sat_per_vb.and_then(|x| FeeRate::from_sat_per_vb(x)),
min_feerate_sat_per_vb.and_then(FeeRate::from_sat_per_vb),
FeeRate::from_sat_per_vb(max_fee_rate_sat_per_vb).expect("FIXME throw error"),
)
.map(Into::into)
Expand Down Expand Up @@ -400,7 +400,7 @@ impl PayjoinProposal {
<PayjoinProposal as Into<payjoin::receive::v2::PayjoinProposal>>::into(self.clone())
.utxos_to_be_locked()
{
outpoints.push(e.to_owned().into());
outpoints.push(e.to_owned());
}
outpoints
}
Expand Down
27 changes: 11 additions & 16 deletions src/receive/uni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ impl Receiver {
}

pub fn extract_req(&self) -> Result<RequestResponse, PayjoinError> {
self.0.extract_req().map(|(request, ctx)| {
RequestResponse { request, client_response: Arc::new(ctx.into()) }
})
self.0
.extract_req()
.map(|(request, ctx)| RequestResponse { request, client_response: Arc::new(ctx) })
}

///The response can either be an UncheckedProposal or an ACCEPTED message indicating no UncheckedProposal is available yet.
Expand All @@ -75,7 +75,7 @@ impl Receiver {
}

pub fn pj_uri_builder(&self) -> Arc<PjUriBuilder> {
Arc::new(self.0.pj_uri_builder().into())
Arc::new(self.0.pj_uri_builder())
}
/// The contents of the `&pj=` query parameter including the base64url-encoded public key receiver subdirectory.
/// This identifies a session at the payjoin directory server.
Expand Down Expand Up @@ -139,7 +139,6 @@ impl UncheckedProposal {
can_broadcast.callback(transaction.to_vec())
})
.map(|e| Arc::new(e.into()))
.map_err(|e| e.into())
}

/// Call this method if the only way to initiate a Payjoin with this receiver
Expand Down Expand Up @@ -208,7 +207,7 @@ impl MaybeInputsSeen {
) -> Result<Arc<OutputsUnknown>, PayjoinError> {
self.0
.clone()
.check_no_inputs_seen_before(|outpoint| is_known.callback(outpoint.clone()))
.check_no_inputs_seen_before(|outpoint| is_known.callback(*outpoint))
.map(|t| Arc::new(t.into()))
}
}
Expand Down Expand Up @@ -308,10 +307,10 @@ impl WantsInputs {
) -> Result<Arc<InputPair>, PayjoinError> {
let candidate_inputs: Vec<InputPair> = candidate_inputs
.into_iter()
.map(|pair| Arc::try_unwrap(pair).unwrap_or_else(|arc| (*arc).clone()).into())
.map(|pair| Arc::try_unwrap(pair).unwrap_or_else(|arc| (*arc).clone()))
.collect();

self.0.try_preserving_privacy(candidate_inputs).map(|t| Arc::new(t.into()))
self.0.try_preserving_privacy(candidate_inputs).map(Arc::new)
}

pub fn contribute_inputs(
Expand All @@ -320,12 +319,9 @@ impl WantsInputs {
) -> Result<Arc<WantsInputs>, PayjoinError> {
let replacement_inputs: Vec<InputPair> = replacement_inputs
.into_iter()
.map(|pair| Arc::try_unwrap(pair).unwrap_or_else(|arc| (*arc).clone()).into())
.map(|pair| Arc::try_unwrap(pair).unwrap_or_else(|arc| (*arc).clone()))
.collect();
self.0
.contribute_inputs(replacement_inputs)
.map(|t| Arc::new(t.into()))
.map_err(|e| e.into())
self.0.contribute_inputs(replacement_inputs).map(|t| Arc::new(t.into()))
}

pub fn commit_inputs(&self) -> Arc<ProvisionalProposal> {
Expand Down Expand Up @@ -358,7 +354,6 @@ impl ProvisionalProposal {
max_fee_rate_sat_per_vb,
)
.map(|e| Arc::new(e.into()))
.map_err(|e| e.into())
}
}

Expand Down Expand Up @@ -389,7 +384,7 @@ impl PayjoinProposal {
for e in <PayjoinProposal as Into<super::PayjoinProposal>>::into(self.clone())
.utxos_to_be_locked()
{
outpoints.push(e.to_owned().into());
outpoints.push(e.to_owned());
}
outpoints
}
Expand All @@ -409,7 +404,7 @@ impl PayjoinProposal {

pub fn extract_v2_req(&self) -> Result<RequestResponse, PayjoinError> {
let (req, res) = self.0.extract_v2_req()?;
Ok(RequestResponse { request: req.into(), client_response: Arc::new(res.into()) })
Ok(RequestResponse { request: req, client_response: Arc::new(res) })
}

///Processes the response for the final POST message from the receiver client in the v2 Payjoin protocol.
Expand Down
2 changes: 1 addition & 1 deletion src/send/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl V2PostContext {
/// Call this method with response from receiver to continue BIP-??? flow. A successful response can either be None if the relay has not response yet or Some(Psbt).
/// If the response is some valid PSBT you should sign and broadcast.
pub fn process_response(&self, response: &[u8]) -> Result<V2GetContext, PayjoinError> {
<&V2PostContext as Into<payjoin::send::V2PostContext>>::into(&self)
<&V2PostContext as Into<payjoin::send::V2PostContext>>::into(self)
.process_response(response)
.map(|t| t.clone().into())
.map_err(|e| e.into())
Expand Down
16 changes: 7 additions & 9 deletions src/send/uni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ impl From<Sender> for super::Sender {
#[uniffi::export]
impl Sender {
pub fn extract_v1(&self) -> Result<RequestV1Context, PayjoinError> {
self.0.extract_v1().map(|(req, ctx)| {
RequestV1Context { request: req.into(), context: Arc::new(ctx.into()) }
})
self.0
.extract_v1()
.map(|(req, ctx)| RequestV1Context { request: req, context: Arc::new(ctx.into()) })
}

/// Extract serialized Request and Context from a Payjoin Proposal.
Expand All @@ -120,11 +120,9 @@ impl Sender {
&self,
ohttp_proxy_url: Arc<Url>,
) -> Result<RequestV2PostContext, PayjoinError> {
match self.0.extract_v2((*ohttp_proxy_url).clone().into()) {
Ok((req, ctx)) => {
Ok(RequestV2PostContext { request: req.into(), context: Arc::new(ctx.into()) })
}
Err(e) => Err(e.into()),
match self.0.extract_v2((*ohttp_proxy_url).clone()) {
Ok((req, ctx)) => Ok(RequestV2PostContext { request: req, context: Arc::new(ctx) }),
Err(e) => Err(e),
}
}
}
Expand Down Expand Up @@ -200,7 +198,7 @@ impl V2GetContext {
pub fn extract_req(&self, ohttp_relay: Arc<Url>) -> Result<RequestOhttpContext, PayjoinError> {
self.0
.extract_req(Arc::try_unwrap(ohttp_relay).unwrap_or_else(|arc| (*arc).clone()))
.map(|(request, ctx)| RequestOhttpContext { request, ohttp_ctx: Arc::new(ctx.into()) })
.map(|(request, ctx)| RequestOhttpContext { request, ohttp_ctx: Arc::new(ctx) })
}

/// Decodes and validates the response.
Expand Down

0 comments on commit 8ac6abb

Please sign in to comment.