ghassmo 5 лет назад
Родитель
Сommit
57352de3c2
5 измененных файлов с 21 добавлено и 12 удалено
  1. 0 1
      src/crypto/mod.rs
  2. 4 1
      src/rpc/adapters/user_adapter.rs
  3. 11 6
      src/service/cashier.rs
  4. 3 3
      src/util.rs
  5. 3 1
      src/wallet/walletdb.rs

+ 0 - 1
src/crypto/mod.rs

@@ -26,7 +26,6 @@ pub type OwnCoins = Vec<(
     merkle::IncrementalWitness<merkle_node::MerkleNode>,
 )>;
 
-
 pub fn save_params(filename: &str, params: &groth16::Parameters<Bls12>) -> Result<()> {
     let buffer = std::fs::File::create(filename)?;
     params.write(buffer)?;

+ 4 - 1
src/rpc/adapters/user_adapter.rs

@@ -198,7 +198,10 @@ impl UserAdapter {
     pub async fn withdraw(&self, withdraw_params: WithdrawParams) -> Result<()> {
         debug!(target: "withdraw", "withdraw: START");
         // do the key exchange
-        self.withdraw_channel.0.send(withdraw_params.pub_key).await?;
+        self.withdraw_channel
+            .0
+            .send(withdraw_params.pub_key)
+            .await?;
         // send the drk
         if let Some(key) = self.withdraw_channel.1.recv().await? {
             let mut transfer_params = TransferParams::new();

+ 11 - 6
src/service/cashier.rs

@@ -1,6 +1,6 @@
-use super::GatewayClient;
-use super::reqrep::{PeerId, RepProtocol, Reply, ReqProtocol, Request};
 use super::btc::{BitcoinKeys, PubAddress};
+use super::reqrep::{PeerId, RepProtocol, Reply, ReqProtocol, Request};
+use super::GatewayClient;
 use crate::blockchain::Slab;
 use crate::crypto::load_params;
 use crate::serial::{deserialize, serialize, Encodable};
@@ -10,14 +10,14 @@ use crate::{Error, Result};
 
 use bellman::groth16;
 use bls12_381::Bls12;
-use rand::rngs::OsRng;
 use ff::Field;
+use rand::rngs::OsRng;
 //use bitcoin::blockdata::script::Script;
 use electrum_client::bitcoin::Script;
 use electrum_client::{Client, ElectrumApi};
 
-use log::*;
 use async_executor::Executor;
+use log::*;
 
 use async_std::sync::Arc;
 
@@ -204,8 +204,13 @@ impl CashierService {
                     cashier_public = deserialize(&addr.1)?;
                 } else {
                     let cashier_secret = jubjub::Fr::random(&mut OsRng);
-                    cashier_public = zcash_primitives::constants::SPENDING_KEY_GENERATOR * cashier_secret;
-                    cashier_wallet.put_withdraw_keys(btc_address, serialize(&cashier_secret), serialize(&cashier_public))?;
+                    cashier_public =
+                        zcash_primitives::constants::SPENDING_KEY_GENERATOR * cashier_secret;
+                    cashier_wallet.put_withdraw_keys(
+                        btc_address,
+                        serialize(&cashier_secret),
+                        serialize(&cashier_public),
+                    )?;
                 }
 
                 let mut reply = Reply::from(&request, CashierError::NoError as u32, vec![]);

+ 3 - 3
src/util.rs

@@ -1,9 +1,9 @@
 use crate::blockchain::Slab;
+use crate::crypto::OwnCoins;
+use crate::serial::Encodable;
 use crate::state::ProgramState;
-use crate::Result;
 use crate::tx;
-use crate::serial::Encodable;
-use crate::crypto::OwnCoins;
+use crate::Result;
 
 use bls12_381::Bls12;
 

+ 3 - 1
src/wallet/walletdb.rs

@@ -1,4 +1,6 @@
-use crate::crypto::{OwnCoins, coin::Coin, merkle::IncrementalWitness, merkle_node::MerkleNode, note::Note};
+use crate::crypto::{
+    coin::Coin, merkle::IncrementalWitness, merkle_node::MerkleNode, note::Note, OwnCoins,
+};
 use crate::serial;
 use crate::serial::{deserialize, serialize, Decodable, Encodable};
 use crate::{Error, Result};