cashierd: truncate received_balance to 8 digits

This commit is contained in:
ghassmo
2021-10-12 12:14:09 +03:00
parent 5cae0cf6e0
commit 3ba34fe2ae
2 changed files with 12 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ use serde_json::{json, Value};
use std::collections::HashMap;
use std::path::PathBuf;
use std::str::FromStr;
use std::iter::FromIterator;
use drk::{
blockchain::Rocks,
@@ -566,10 +567,16 @@ impl Cashierd {
let token_notification = token_notification?;
// truncate received_balance to 8 digits
let received_balance = token_notification.received_balance;
let mut rv: Vec<char> = received_balance.to_string().chars().collect();
rv.truncate(8);
let received_balance = u64::from_str(&String::from_iter(rv))?;
client
.send(
token_notification.drk_pub_key,
token_notification.received_balance,
received_balance,
token_notification.token_id,
true,
)

View File

@@ -124,10 +124,6 @@ impl Client {
) -> ClientResult<()> {
debug!(target: "CLIENT", "Start transfer {}", amount);
if amount == 0 {
return Err(ClientFailed::InvalidAmount(amount as u64));
}
let token_id_exists = self.state.lock().await.wallet.token_id_exists(&token_id)?;
if token_id_exists {
@@ -150,6 +146,10 @@ impl Client {
) -> ClientResult<()> {
debug!(target: "CLIENT", "Start send {}", amount);
if amount == 0 {
return Err(ClientFailed::InvalidAmount(amount as u64));
}
let slab = self
.build_slab_from_tx(pub_key, amount, token_id, clear_input)
.await?;