using a base-58 encoded string for transfer coins and show user's address

This commit is contained in:
ghassmo
2021-08-05 05:04:55 +03:00
parent 40d71df4dd
commit 1e87fb2bb4
2 changed files with 10 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
use drk::blockchain::{rocks::columns, Rocks, RocksColumn, Slab};
use drk::cli::TransferParams;
use drk::cli::{Config, DarkfidCli, DarkfidConfig};
use drk::crypto::{
coin::Coin,
@@ -11,14 +12,12 @@ use drk::crypto::{
};
use drk::rpc::adapter::RpcAdapter;
use drk::rpc::jsonserver;
use drk::serial::Decodable;
use drk::serial::Encodable;
use drk::serial::{deserialize, Decodable, Encodable};
use drk::service::{GatewayClient, GatewaySlabsSubscriber};
use drk::state::{state_transition, ProgramState, StateUpdate};
use drk::util::join_config_path;
use drk::wallet::{WalletDb, WalletPtr};
use drk::{tx, Result};
use drk::cli::TransferParams;
use async_executor::Executor;
use bellman::groth16;
@@ -235,11 +234,8 @@ async fn start(executor: Arc<Executor<'_>>, config: Arc<&DarkfidConfig>) -> Resu
merkle_path
};
// TODO: Should use the address value from transfer_params
// The receiving wallet has a secret key
let secret2 = jubjub::Fr::random(&mut OsRng);
// This is their public key to receive payment
let public2 = zcash_primitives::constants::SPENDING_KEY_GENERATOR * secret2;
let address = bs58::decode(transfer_params.pub_key).into_vec().unwrap();
let address: jubjub::SubgroupPoint = deserialize(&address).unwrap();
// Make a spend tx
@@ -256,7 +252,7 @@ async fn start(executor: Arc<Executor<'_>>, config: Arc<&DarkfidConfig>) -> Resu
outputs: vec![tx::TransactionBuilderOutputInfo {
value: transfer_params.amount,
asset_id: 1,
public: public2,
public: address,
}],
};
// Build the tx

View File

@@ -3,6 +3,7 @@ use crate::service::cashier::CashierClient;
use crate::wallet::WalletDb;
use crate::{Error, Result};
use crate::cli::TransferParams;
use crate::serial::serialize;
use log::*;
@@ -65,15 +66,16 @@ impl RpcAdapter {
pub fn get_key(&self) -> Result<()> {
debug!(target: "adapter", "get_key() [START]");
let key_public = self.wallet.get_public()?;
println!("{:?}", key_public);
let key_public = self.wallet.get_public()?;
let bs58_address = bs58::encode(serialize(&key_public)).into_string();
info!("Address: {}", bs58_address);
Ok(())
}
pub fn get_cash_key(&self) -> Result<()> {
debug!(target: "adapter", "get_cash_key() [START]");
let cashier_public = self.wallet.get_cashier_public()?;
println!("{:?}", cashier_public);
info!("{:?}", cashier_public);
Ok(())
}