mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
cashierd: truncate received_balance to 8 digits
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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?;
|
||||
|
||||
Reference in New Issue
Block a user