From 642f1d8318cff7163265c7d2f17ffe3a09864151 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 19 May 2021 13:54:55 +1000 Subject: [PATCH] Update Rust toolchain to get cargo fmt back --- monero-rpc/src/monerod.rs | 7 +++--- monero-wallet/src/lib.rs | 38 ++++++++++++++--------------- monero-wallet/src/v2.rs | 19 +++++++++++---- rust-toolchain | 2 +- swap/src/protocol/alice/state.rs | 41 +++++++++++++++----------------- swap/tests/harness/mod.rs | 17 ++++++------- 6 files changed, 63 insertions(+), 61 deletions(-) diff --git a/monero-rpc/src/monerod.rs b/monero-rpc/src/monerod.rs index fa0008a7..26376aa3 100644 --- a/monero-rpc/src/monerod.rs +++ b/monero-rpc/src/monerod.rs @@ -71,10 +71,9 @@ impl Client { } pub async fn get_o_indexes(&self, txid: Hash) -> Result { - self.binary_request( - self.get_o_indexes_bin_url.clone(), - GetOIndexesPayload { txid }, - ) + self.binary_request(self.get_o_indexes_bin_url.clone(), GetOIndexesPayload { + txid, + }) .await } diff --git a/monero-wallet/src/lib.rs b/monero-wallet/src/lib.rs index 83056f6b..d1e23a13 100644 --- a/monero-wallet/src/lib.rs +++ b/monero-wallet/src/lib.rs @@ -63,7 +63,8 @@ impl ConfidentialTransactionBuilder { input_commitment: input_to_spend.commitment().unwrap(), // TODO: Error handling spend_amount: input_to_spend.amount().unwrap(), // TODO: Error handling, global_output_index, - real_commitment_blinder: input_to_spend.blinding_factor().unwrap(), // TODO: Error handling + real_commitment_blinder: input_to_spend.blinding_factor().unwrap(), /* TODO: Error + * handling */ } } @@ -312,7 +313,8 @@ impl CalculateKeyOffsetBoundaries for monerod::Client { .into_iter() .max() .context("Expected at least one output index")?; - // let oldest_index = last_index - (last_index / 100) * 40; // oldest index must be within last 40% TODO: CONFIRM THIS + // let oldest_index = last_index - (last_index / 100) * 40; // oldest index must + // be within last 40% TODO: CONFIRM THIS Ok((VarInt(0), VarInt(last_index))) } @@ -340,7 +342,8 @@ impl FetchDecoyInputs for monerod::Client { .map(|(out_key, index)| { DecoyInput { global_output_index: *index, - key: out_key.key.point.decompress().unwrap(), // TODO: should decompress on deserialization + key: out_key.key.point.decompress().unwrap(), /* TODO: should decompress on + * deserialization */ commitment: CompressedEdwardsY(out_key.mask.key).decompress().unwrap(), } }) @@ -378,22 +381,19 @@ mod tests { let relative_offsets = to_relative_offsets(&key_offsets); - assert_eq!( - &relative_offsets, - &[ - VarInt(78), - VarInt(3), - VarInt(10), - VarInt(0), - VarInt(5), - VarInt(2), - VarInt(3), - VarInt(11), - VarInt(1), - VarInt(1), - VarInt(3), - ] - ) + assert_eq!(&relative_offsets, &[ + VarInt(78), + VarInt(3), + VarInt(10), + VarInt(0), + VarInt(5), + VarInt(2), + VarInt(3), + VarInt(11), + VarInt(1), + VarInt(1), + VarInt(3), + ]) } #[tokio::test] diff --git a/monero-wallet/src/v2.rs b/monero-wallet/src/v2.rs index e1452263..72c2ae21 100644 --- a/monero-wallet/src/v2.rs +++ b/monero-wallet/src/v2.rs @@ -9,7 +9,10 @@ pub struct EmptyTransaction {} impl EmptyTransaction { // TODO: Need to validate that given index matches with tx pubkey and commitment - pub fn spend_from(input: OwnedTxOut<'_>, global_output_index: u64) -> Result { + pub fn spend_from( + input: OwnedTxOut<'_>, + global_output_index: u64, + ) -> Result { todo!() } } @@ -19,7 +22,10 @@ pub struct MissingOpening; // The opening was missing from the TX pub struct InputAdded {} impl InputAdded { - pub fn with_decoys(self, decoys: [DecoyInput; 10]) -> Result { + pub fn with_decoys( + self, + decoys: [DecoyInput; 10], + ) -> Result { todo!() } @@ -83,7 +89,9 @@ impl OutputsBlinded { /// Signs the transaction. /// - /// This function calls the CLSAG sign algorithm with a set of parameters that will work. This however, assumes the caller does not want to have control over these parameters. + /// This function calls the CLSAG sign algorithm with a set of parameters + /// that will work. This however, assumes the caller does not want to have + /// control over these parameters. pub fn sign(self, keys: KeyPair, rng: &mut (impl RngCore + CryptoRng)) -> Transaction { // TODO: Do we want a sign_recommended API in monero::clsag? @@ -92,8 +100,9 @@ impl OutputsBlinded { /// Use the given signature for the internal transaction. /// - /// This function is useful if the caller wants to have full control over certain parameters such as responses, L, R or I. - /// The provided signature will be validated to make sure it is correct. + /// This function is useful if the caller wants to have full control over + /// certain parameters such as responses, L, R or I. The provided + /// signature will be validated to make sure it is correct. pub fn with_signature(self, sig: Clsag) -> Result { todo!() } diff --git a/rust-toolchain b/rust-toolchain index 8fc862b0..8af09d16 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2021-05-04" +channel = "nightly-2021-05-18" components = ["clippy"] targets = ["armv7-unknown-linux-gnueabihf"] diff --git a/swap/src/protocol/alice/state.rs b/swap/src/protocol/alice/state.rs index 82acd2d8..339be1a4 100644 --- a/swap/src/protocol/alice/state.rs +++ b/swap/src/protocol/alice/state.rs @@ -165,28 +165,25 @@ impl State0 { let v = self.v_a + msg.v_b; - Ok(( - msg.swap_id, - State1 { - a: self.a, - B: msg.B, - s_a: self.s_a, - S_a_monero: self.S_a_monero, - S_a_bitcoin: self.S_a_bitcoin, - S_b_monero: msg.S_b_monero, - S_b_bitcoin: msg.S_b_bitcoin, - v, - v_a: self.v_a, - dleq_proof_s_a: self.dleq_proof_s_a, - btc: self.btc, - xmr: self.xmr, - cancel_timelock: self.cancel_timelock, - punish_timelock: self.punish_timelock, - refund_address: msg.refund_address, - redeem_address: self.redeem_address, - punish_address: self.punish_address, - }, - )) + Ok((msg.swap_id, State1 { + a: self.a, + B: msg.B, + s_a: self.s_a, + S_a_monero: self.S_a_monero, + S_a_bitcoin: self.S_a_bitcoin, + S_b_monero: msg.S_b_monero, + S_b_bitcoin: msg.S_b_bitcoin, + v, + v_a: self.v_a, + dleq_proof_s_a: self.dleq_proof_s_a, + btc: self.btc, + xmr: self.xmr, + cancel_timelock: self.cancel_timelock, + punish_timelock: self.punish_timelock, + refund_address: msg.refund_address, + redeem_address: self.redeem_address, + punish_address: self.punish_address, + })) } } diff --git a/swap/tests/harness/mod.rs b/swap/tests/harness/mod.rs index c1cbfeae..fcdc77bb 100644 --- a/swap/tests/harness/mod.rs +++ b/swap/tests/harness/mod.rs @@ -155,16 +155,13 @@ async fn init_containers(cli: &Cli) -> (Monero, Containers<'_>) { .await .unwrap(); - ( - monero, - Containers { - bitcoind_url, - bitcoind, - monerod_container, - monero_wallet_rpc_containers, - electrs, - }, - ) + (monero, Containers { + bitcoind_url, + bitcoind, + monerod_container, + monero_wallet_rpc_containers, + electrs, + }) } async fn init_bitcoind_container(