Skip to content

Commit

Permalink
chore: merge development
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Dec 10, 2021
1 parent c4a090a commit 5ec2975
Show file tree
Hide file tree
Showing 143 changed files with 3,519 additions and 1,500 deletions.
2,828 changes: 2,648 additions & 180 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion applications/tari_app_grpc/src/conversions/aggregate_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

use std::convert::TryFrom;

use tari_core::{tari_utilities::convert::try_convert_all, transactions::aggregated_body::AggregateBody};
use tari_core::transactions::aggregated_body::AggregateBody;
use tari_utilities::convert::try_convert_all;

use crate::tari_rpc as grpc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use std::convert::TryFrom;

use tari_common_types::types::{ComSignature, Commitment, PrivateKey};
use tari_core::crypto::tari_utilities::ByteArray;
use tari_utilities::ByteArray;

use crate::tari_rpc as grpc;

Expand Down
2 changes: 1 addition & 1 deletion applications/tari_app_grpc/src/conversions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod transaction_output;
mod unblinded_output;

use prost_types::Timestamp;
use tari_core::crypto::tari_utilities::epoch_time::EpochTime;
use tari_utilities::epoch_time::EpochTime;

pub use self::{
aggregate_body::*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use tari_core::{
blocks::{NewBlockHeaderTemplate, NewBlockTemplate},
proof_of_work::ProofOfWork,
};
use tari_utilities::ByteArray;

use crate::tari_rpc as grpc;

Expand Down
3 changes: 0 additions & 3 deletions applications/tari_app_grpc/src/conversions/output_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use std::convert::{TryFrom, TryInto};

use tari_common_types::types::{Commitment, PublicKey};

use tari_core::transactions::transaction::{
AssetOutputFeatures,
MintNonFungibleFeatures,
Expand All @@ -36,8 +35,6 @@ use tari_crypto::tari_utilities::ByteArray;

use crate::tari_rpc as grpc;

use crate::tari_rpc as grpc;

impl TryFrom<grpc::OutputFeatures> for OutputFeatures {
type Error = String;

Expand Down
2 changes: 0 additions & 2 deletions applications/tari_app_grpc/src/conversions/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ use tari_utilities::ByteArray;

use crate::{conversions::datetime_to_timestamp, tari_rpc as grpc};

use crate::{conversions::datetime_to_timestamp, tari_rpc as grpc};

impl From<Peer> for grpc::Peer {
fn from(peer: Peer) -> Self {
let public_key = peer.public_key.to_vec();
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_app_grpc/src/conversions/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use std::convert::TryFrom;

use tari_common_types::types::{PrivateKey, PublicKey, Signature};
use tari_core::crypto::tari_utilities::ByteArray;
use tari_utilities::ByteArray;

use crate::tari_rpc as grpc;

Expand Down
2 changes: 0 additions & 2 deletions applications/tari_app_grpc/src/conversions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ use tari_utilities::ByteArray;

use crate::tari_rpc as grpc;

use crate::tari_rpc as grpc;

impl From<Transaction> for grpc::Transaction {
fn from(source: Transaction) -> Self {
Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ use tari_utilities::{ByteArray, Hashable};

use crate::tari_rpc as grpc;

use crate::tari_rpc as grpc;

impl TryFrom<grpc::TransactionOutput> for TransactionOutput {
type Error = String;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ use tari_utilities::ByteArray;

use crate::tari_rpc as grpc;

use crate::tari_rpc as grpc;

impl From<UnblindedOutput> for grpc::UnblindedOutput {
fn from(output: UnblindedOutput) -> Self {
grpc::UnblindedOutput {
Expand Down
16 changes: 0 additions & 16 deletions applications/tari_app_utilities/src/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ use tari_common::{
DatabaseType,
GlobalConfig,
};
use tari_comms::multiaddr::Multiaddr;

use crate::consts;

use crate::consts;

Expand Down Expand Up @@ -64,19 +61,6 @@ pub fn init_configuration(
}
}

if let Some(str) = bootstrap.wallet_grpc_address.clone() {
log::info!(
target: LOG_TARGET,
"{}",
format!("GRPC address specified in command parameters: {}", str)
);

let grpc_address = str
.parse::<Multiaddr>()
.map_err(|_| ExitCodes::InputError("GRPC address is not valid".to_string()))?;
global_config.grpc_console_wallet_address = grpc_address;
}

check_file_paths(&mut global_config, &bootstrap);

Ok((bootstrap, global_config, cfg))
Expand Down
1 change: 1 addition & 0 deletions applications/tari_app_utilities/src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use tari_comms::{
utils::multiaddr::multiaddr_to_socketaddr,
};
use tari_p2p::transport::{TorConfig, TransportType};
use tari_utilities::hex::Hex;
use tokio::{runtime, runtime::Runtime};

use crate::identity_management::load_from_json;
Expand Down
7 changes: 3 additions & 4 deletions applications/tari_base_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,13 @@ async fn run_node(node_config: Arc<GlobalConfig>, bootstrap: ConfigBootstrap) ->
})?;

if let Some(ref base_node_config) = node_config.base_node_config {
if let Some(address) = base_node_config.grpc_address {
if let Some(ref address) = base_node_config.grpc_address {
// Go, GRPC, go go
let grpc = crate::grpc::base_node_grpc_server::BaseNodeGrpcServer::from_base_node_context(&ctx);
let socket_addr = multiaddr_to_socketaddr(&node_config.grpc_base_node_address)
.map_err(|e| ExitCodes::ConfigError(e.to_string()))?;
let socket_addr = multiaddr_to_socketaddr(address).map_err(|e| ExitCodes::ConfigError(e.to_string()))?;
task::spawn(run_grpc(grpc, socket_addr, shutdown.to_signal()));
}
}
}

// Run, node, run!
let command_handler = Arc::new(Mutex::new(CommandHandler::new(runtime::Handle::current(), &ctx)));
Expand Down
5 changes: 5 additions & 0 deletions applications/tari_base_node/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ use tari_app_utilities::utilities::{
use tari_common_types::types::{Commitment, PrivateKey, PublicKey, Signature};
use tari_core::proof_of_work::PowAlgorithm;
use tari_shutdown::Shutdown;
use tari_utilities::{
hex,
hex::{from_hex, Hex},
ByteArray,
};
use tokio::sync::Mutex;

use super::LOG_TARGET;
Expand Down
19 changes: 8 additions & 11 deletions applications/tari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ use tari_comms::{
types::CommsPublicKey,
};
use tari_comms_dht::{envelope::NodeDestination, DhtDiscoveryRequester};
use tari_core::{
tari_utilities::hex::Hex,
transactions::{
tari_amount::{uT, MicroTari, Tari},
transaction::{TransactionOutput, UnblindedOutput},
},
use tari_core::transactions::{
tari_amount::{uT, MicroTari, Tari},
transaction::{TransactionOutput, UnblindedOutput},
};
use tari_crypto::{
keys::PublicKey as PublicKeyTrait,
ristretto::pedersen::PedersenCommitmentFactory,
tari_utilities::{ByteArray, Hashable},
};
use tari_crypto::{keys::PublicKey as PublicKeyTrait, ristretto::pedersen::PedersenCommitmentFactory};
use tari_utilities::hex::Hex;
use tari_wallet::{
output_manager_service::handle::OutputManagerHandle,
Expand Down Expand Up @@ -204,11 +201,11 @@ pub async fn finalise_sha_atomic_swap(
PublicKey(key) => Ok(key),
_ => Err(CommandError::Argument),
}?;
let (tx_id, fee, amount, tx) = output_service
let (tx_id, _fee, amount, tx) = output_service
.create_claim_sha_atomic_swap_transaction(output, pre_image, MicroTari(25))
.await?;
transaction_service
.submit_transaction(tx_id, tx, fee, amount, "Claimed HTLC atomic swap".into())
.submit_transaction(tx_id, tx, amount, "Claimed HTLC atomic swap".into())
.await?;
Ok(tx_id)
}
Expand All @@ -225,11 +222,11 @@ pub async fn claim_htlc_refund(
_ => Err(CommandError::Argument),
}?;

let (tx_id, fee, amount, tx) = output_service
let (tx_id, _fee, amount, tx) = output_service
.create_htlc_refund_transaction(output, MicroTari(25))
.await?;
transaction_service
.submit_transaction(tx_id, tx, fee, amount, "Claimed HTLC refund".into())
.submit_transaction(tx_id, tx, amount, "Claimed HTLC refund".into())
.await?;
Ok(tx_id)
}
Expand Down
10 changes: 4 additions & 6 deletions applications/tari_console_wallet/src/automation/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ use std::num::{ParseFloatError, ParseIntError};

use log::*;
use tari_common::exit_codes::ExitCodes;
use tari_core::{
tari_utilities::hex::HexError,
transactions::{
tari_amount::{MicroTariError, TariConversionError},
transaction::TransactionError,
},
use tari_core::transactions::{
tari_amount::{MicroTariError, TariConversionError},
transaction::TransactionError,
};
use tari_utilities::hex::HexError;
use tari_wallet::{
error::{WalletError, WalletStorageError},
output_manager_service::error::OutputManagerError,
Expand Down
20 changes: 10 additions & 10 deletions applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::convert::TryFrom;
use std::convert::{TryFrom, TryInto};

use futures::{channel::mpsc, future, SinkExt};
use log::*;
Expand Down Expand Up @@ -47,13 +47,14 @@ use tari_app_grpc::{
TransferResult,
},
};
use tari_common_types::types::{BlockHash, Signature};
use tari_common_types::types::{BlockHash, PublicKey, Signature};
use tari_comms::{types::CommsPublicKey, CommsNode};
use tari_core::transactions::{
tari_amount::MicroTari,
transaction::{OutputFeatures, UnblindedOutput},
};
use tari_crypto::tari_utilities::Hashable;
use tari_crypto::{ristretto::RistrettoPublicKey, tari_utilities::Hashable};
use tari_utilities::{hex::Hex, ByteArray};
use tari_wallet::{
output_manager_service::handle::OutputManagerHandle,
transaction_service::{handle::TransactionServiceHandle, storage::models},
Expand Down Expand Up @@ -201,7 +202,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
output.hash().to_hex()
);
SendShaAtomicSwapResponse {
transaction_id: tx_id,
transaction_id: tx_id.as_u64(),
pre_image: pre_image.to_hex(),
output_hash: output.hash().to_hex(),
is_success: true,
Expand Down Expand Up @@ -242,20 +243,19 @@ impl wallet_server::Wallet for WalletGrpcServer {
.create_claim_sha_atomic_swap_transaction(output, pre_image, message.fee_per_gram.into())
.await
{
Ok((tx_id, fee, amount, tx)) => {
Ok((tx_id, _fee, amount, tx)) => {
match transaction_service
.submit_transaction(
tx_id,
tx,
fee,
amount,
"Claiming HTLC transaction with pre-image".to_string(),
)
.await
{
Ok(()) => TransferResult {
address: Default::default(),
transaction_id: tx_id,
transaction_id: tx_id.as_u64(),
is_success: true,
failure_message: Default::default(),
},
Expand Down Expand Up @@ -298,14 +298,14 @@ impl wallet_server::Wallet for WalletGrpcServer {
.create_htlc_refund_transaction(output, message.fee_per_gram.into())
.await
{
Ok((tx_id, fee, amount, tx)) => {
Ok((tx_id, _fee, amount, tx)) => {
match transaction_service
.submit_transaction(tx_id, tx, fee, amount, "Creating HTLC refund transaction".to_string())
.submit_transaction(tx_id, tx, amount, "Creating HTLC refund transaction".to_string())
.await
{
Ok(()) => TransferResult {
address: Default::default(),
transaction_id: tx_id,
transaction_id: tx_id.as_u64(),
is_success: true,
failure_message: Default::default(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use unicode_width::UnicodeWidthStr;

use crate::{
ui::{
components::{balance::Balance, Component, KeyHandled},
components::{balance::Balance, styles, Component, KeyHandled},
state::{AppState, UiTransactionSendStatus},
widgets::{centered_rect_absolute, draw_dialog, MultiColumnList, WindowedListState},
MAX_WIDTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tui::{
};

use crate::ui::{
components::{balance::Balance, Component},
components::{balance::Balance, styles, Component},
state::{AppState, CompletedTransactionInfo},
widgets::{draw_dialog, MultiColumnList, WindowedListState},
MAX_WIDTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ use tari_wallet::{
};
use tokio::sync::{broadcast, RwLock};

use crate::{notifier::Notifier, ui::state::AppStateInner};
use crate::{
notifier::Notifier,
ui::state::{AppStateInner, EventListItem},
};

const LOG_TARGET: &str = "wallet::console_wallet::wallet_event_monitor";

Expand Down
2 changes: 1 addition & 1 deletion applications/tari_console_wallet/src/wallet_modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn tui_mode(config: WalletModeConfig, mut wallet: WalletSqlite) -> Result<()
.and_then(|c| c.grpc_address.as_ref())
{
let grpc = WalletGrpcServer::new(wallet.clone());
handle.spawn(run_grpc(grpc, *grpc_address));
handle.spawn(run_grpc(grpc, grpc_address.clone()));
}

let notifier = Notifier::new(notify_script, handle.clone(), wallet.clone());
Expand Down
21 changes: 13 additions & 8 deletions applications/tari_merge_mining_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,25 @@ pub struct MergeMiningProxyConfig {
}

impl TryFrom<GlobalConfig> for MergeMiningProxyConfig {
type Error = std::io::Error;
type Error = String;

fn try_from(config: GlobalConfig) -> Result<Self, Self::Error> {
let grpc_base_node_address = multiaddr_to_socketaddr(&config.grpc_base_node_address)?;
let grpc_console_wallet_address = multiaddr_to_socketaddr(&config.grpc_console_wallet_address)?;
let merge_mining_config = config
.merge_mining_config
.ok_or_else(|| "Merge mining config settings are missing".to_string())?;
let grpc_base_node_address = multiaddr_to_socketaddr(&merge_mining_config.base_node_grpc_address)
.map_err(|e| format!("Invalid base_node_grpc_address: {}", e))?;
let grpc_console_wallet_address = multiaddr_to_socketaddr(&merge_mining_config.wallet_grpc_address)
.map_err(|e| format!("Invalid wallet_grpc_address: {}", e))?;
Ok(Self {
network: config.network,
monerod_url: config.monerod_url,
monerod_username: config.monerod_username,
monerod_password: config.monerod_password,
monerod_use_auth: config.monerod_use_auth,
monerod_url: merge_mining_config.monerod_url.clone(),
monerod_username: merge_mining_config.monerod_username,
monerod_password: merge_mining_config.monerod_password,
monerod_use_auth: merge_mining_config.monerod_use_auth,
grpc_base_node_address,
grpc_console_wallet_address,
proxy_host_address: config.proxy_host_address,
proxy_host_address: merge_mining_config.proxy_host_address,
proxy_submit_to_origin: config.proxy_submit_to_origin,
wait_for_initial_sync_at_startup: config.wait_for_initial_sync_at_startup,
})
Expand Down
Loading

0 comments on commit 5ec2975

Please sign in to comment.