diff --git a/src/receive/mod.rs b/src/receive/mod.rs index 986eba3..985ba6a 100644 --- a/src/receive/mod.rs +++ b/src/receive/mod.rs @@ -52,8 +52,8 @@ impl Receiver { ohttp_relay: Url, expire_after: Option, ) -> Result { - 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(), @@ -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) @@ -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) @@ -400,7 +400,7 @@ impl PayjoinProposal { >::into(self.clone()) .utxos_to_be_locked() { - outpoints.push(e.to_owned().into()); + outpoints.push(e.to_owned()); } outpoints } diff --git a/src/receive/uni.rs b/src/receive/uni.rs index 8489926..a0cd5c8 100644 --- a/src/receive/uni.rs +++ b/src/receive/uni.rs @@ -58,9 +58,9 @@ impl Receiver { } pub fn extract_req(&self) -> Result { - 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. @@ -75,7 +75,7 @@ impl Receiver { } pub fn pj_uri_builder(&self) -> Arc { - 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. @@ -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 @@ -208,7 +207,7 @@ impl MaybeInputsSeen { ) -> Result, 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())) } } @@ -308,10 +307,10 @@ impl WantsInputs { ) -> Result, PayjoinError> { let candidate_inputs: Vec = 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( @@ -320,12 +319,9 @@ impl WantsInputs { ) -> Result, PayjoinError> { let replacement_inputs: Vec = 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 { @@ -358,7 +354,6 @@ impl ProvisionalProposal { max_fee_rate_sat_per_vb, ) .map(|e| Arc::new(e.into())) - .map_err(|e| e.into()) } } @@ -389,7 +384,7 @@ impl PayjoinProposal { for e in >::into(self.clone()) .utxos_to_be_locked() { - outpoints.push(e.to_owned().into()); + outpoints.push(e.to_owned()); } outpoints } @@ -409,7 +404,7 @@ impl PayjoinProposal { pub fn extract_v2_req(&self) -> Result { 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. diff --git a/src/send/mod.rs b/src/send/mod.rs index 582b99c..cba5cec 100644 --- a/src/send/mod.rs +++ b/src/send/mod.rs @@ -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 { - <&V2PostContext as Into>::into(&self) + <&V2PostContext as Into>::into(self) .process_response(response) .map(|t| t.clone().into()) .map_err(|e| e.into()) diff --git a/src/send/uni.rs b/src/send/uni.rs index 39ba531..3d4828b 100644 --- a/src/send/uni.rs +++ b/src/send/uni.rs @@ -107,9 +107,9 @@ impl From for super::Sender { #[uniffi::export] impl Sender { pub fn extract_v1(&self) -> Result { - 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. @@ -120,11 +120,9 @@ impl Sender { &self, ohttp_proxy_url: Arc, ) -> Result { - 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), } } } @@ -200,7 +198,7 @@ impl V2GetContext { pub fn extract_req(&self, ohttp_relay: Arc) -> Result { 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.