Skip to content

Commit

Permalink
Merge branch 'development' into dan-layer-state-store
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Aug 3, 2022
2 parents 1159ef1 + 214a986 commit f00742c
Show file tree
Hide file tree
Showing 98 changed files with 5,669 additions and 1,261 deletions.
749 changes: 329 additions & 420 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions applications/tari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ edition = "2018"
tari_common_types = { version = "^0.34", path = "../../base_layer/common_types"}
tari_comms = { path = "../../comms/core"}
tari_core = { path = "../../base_layer/core"}
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_script = { path = "../../infrastructure/tari_script" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

chrono = { version = "0.4.19", default-features = false }
prost = "0.9"
Expand Down
2 changes: 2 additions & 0 deletions applications/tari_app_grpc/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ message TransactionKernel {
bytes hash = 8;
// Version
uint32 version = 9;
// Optional burned commitment
bytes burn_commitment = 10;
}

// A transaction input.
Expand Down
14 changes: 14 additions & 0 deletions applications/tari_app_grpc/proto/wallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ service Wallet {
rpc RevalidateAllTransactions (RevalidateRequest) returns (RevalidateResponse);
// This will send a XTR SHA Atomic swap transaction
rpc SendShaAtomicSwapTransaction(SendShaAtomicSwapRequest) returns (SendShaAtomicSwapResponse);
// This will create a burn transaction
rpc CreateBurnTransaction(CreateBurnTransactionRequest) returns (CreateBurnTransactionResponse);
// This will claim a XTR SHA Atomic swap transaction
rpc ClaimShaAtomicSwapTransaction(ClaimShaAtomicSwapRequest) returns (ClaimShaAtomicSwapResponse);
// This will claim a HTLC refund transaction
Expand Down Expand Up @@ -106,6 +108,12 @@ message SendShaAtomicSwapRequest {
PaymentRecipient recipient = 1;
}

message CreateBurnTransactionRequest{
uint64 amount = 1;
uint64 fee_per_gram = 2;
string message = 3;
}

message PaymentRecipient {
string address = 1;
uint64 amount = 2;
Expand All @@ -131,6 +139,12 @@ message SendShaAtomicSwapResponse {
string failure_message = 5;
}

message CreateBurnTransactionResponse{
uint64 transaction_id = 1;
bool is_success = 2;
string failure_message = 3;
}

message TransferResult {
string address = 1;
uint64 transaction_id = 2;
Expand Down
14 changes: 14 additions & 0 deletions applications/tari_app_grpc/src/conversions/transaction_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ impl TryFrom<grpc::TransactionKernel> for TransactionKernel {
.map_err(|_| "excess_sig could not be converted".to_string())?;

let kernel_features = u8::try_from(kernel.features).map_err(|_| "kernel features must be a single byte")?;
let commitment = if kernel.burn_commitment.is_empty() {
None
} else {
Some(
Commitment::from_bytes(&kernel.burn_commitment)
.map_err(|err| format!("Burn commitment could not be converted:{}", err))?,
)
};

Ok(Self::new(
TransactionKernelVersion::try_from(
Expand All @@ -56,13 +64,18 @@ impl TryFrom<grpc::TransactionKernel> for TransactionKernel {
kernel.lock_height,
excess,
excess_sig,
commitment,
))
}
}

impl From<TransactionKernel> for grpc::TransactionKernel {
fn from(kernel: TransactionKernel) -> Self {
let hash = kernel.hash();
let commitment = match kernel.burn_commitment {
Some(c) => c.as_bytes().to_vec(),
None => vec![],
};

grpc::TransactionKernel {
features: u32::from(kernel.features.bits()),
Expand All @@ -75,6 +88,7 @@ impl From<TransactionKernel> for grpc::TransactionKernel {
}),
hash,
version: kernel.version as u32,
burn_commitment: commitment,
}
}
}
4 changes: 2 additions & 2 deletions applications/tari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ license = "BSD-3-Clause"

[dependencies]
tari_comms = { path = "../../comms/core" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_common = { path = "../../common" }
tari_common_types = { path = "../../base_layer/common_types" }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

clap = { version = "3.2.0", features = ["derive", "env"] }
config = { version = "0.13.0" }
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_base_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ tari_comms = { path = "../../comms/core", features = ["rpc"] }
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms_dht = { path = "../../comms/dht" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_libtor = { path = "../../infrastructure/libtor" }
tari_mmr = { path = "../../base_layer/mmr", features = ["native_bitmap"] }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_storage = {path="../../infrastructure/storage"}
tari_service_framework = { path = "../../base_layer/service_framework" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

anyhow = "1.0.53"
async-trait = "0.1.52"
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_collectibles/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ tari_app_grpc = { path = "../../tari_app_grpc" }
tari_app_utilities = { path = "../../tari_app_utilities" }
tari_common = { path = "../../../common" }
tari_common_types = { path = "../../../base_layer/common_types" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_key_manager = { path = "../../../base_layer/key_manager" }
tari_mmr = { path = "../../../base_layer/mmr" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }
tari_dan_common_types = { path = "../../../dan_layer/common_types" }

blake2 = "^0.9.0"
Expand Down
65 changes: 53 additions & 12 deletions applications/tari_collectibles/web-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions applications/tari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "BSD-3-Clause"

[dependencies]
tari_wallet = { path = "../../base_layer/wallet", features = ["bundled_sqlite"] }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_common = { path = "../../common" }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_comms = { path = "../../comms/core" }
Expand All @@ -18,7 +18,7 @@ tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_app_grpc = { path = "../tari_app_grpc" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_key_manager = { path = "../../base_layer/key_manager" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

# Uncomment for tokio tracing via tokio-console (needs "tracing" featurs)
#console-subscriber = "0.1.3"
Expand Down
71 changes: 49 additions & 22 deletions applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use std::{
convert::{TryFrom, TryInto},
fs,
path::PathBuf,
};

use clap::Parser;
Expand All @@ -45,6 +46,8 @@ use tari_app_grpc::{
ClaimShaAtomicSwapResponse,
CoinSplitRequest,
CoinSplitResponse,
CreateBurnTransactionRequest,
CreateBurnTransactionResponse,
CreateConstitutionDefinitionRequest,
CreateConstitutionDefinitionResponse,
CreateFollowOnAssetCheckpointRequest,
Expand Down Expand Up @@ -560,6 +563,39 @@ impl wallet_server::Wallet for WalletGrpcServer {
Ok(Response::new(TransferResponse { results }))
}

async fn create_burn_transaction(
&self,
request: Request<CreateBurnTransactionRequest>,
) -> Result<Response<CreateBurnTransactionResponse>, Status> {
let message = request.into_inner();

let mut transaction_service = self.get_transaction_service();
debug!(target: LOG_TARGET, "Trying to burn {} Tari", message.amount);
let response = match transaction_service
.burn_tari(message.amount.into(), message.fee_per_gram.into(), message.message)
.await
{
Ok(tx_id) => {
debug!(target: LOG_TARGET, "Transaction broadcast: {}", tx_id,);
CreateBurnTransactionResponse {
transaction_id: tx_id.as_u64(),
is_success: true,
failure_message: Default::default(),
}
},
Err(e) => {
warn!(target: LOG_TARGET, "Failed to burn Tarid: {}", e);
CreateBurnTransactionResponse {
transaction_id: Default::default(),
is_success: false,
failure_message: e.to_string(),
}
},
};

Ok(Response::new(response))
}

async fn get_transaction_info(
&self,
request: Request<GetTransactionInfoRequest>,
Expand Down Expand Up @@ -1205,47 +1241,38 @@ impl wallet_server::Wallet for WalletGrpcServer {
}
}

/// Returns the contents of a seed words file, provided via CLI
async fn seed_words(&self, _: Request<tari_rpc::Empty>) -> Result<Response<SeedWordsResponse>, Status> {
let cli = Cli::parse();
let file_path = cli.seed_words_file_name.unwrap();

if !file_path.is_file() {
return Err(Status::not_found("file not found"));
}

let file_name = file_path.clone().into_os_string().into_string().unwrap();

if file_name.is_empty() {
return Err(Status::not_found("seed_words_file_name is empty"));
}
let filepath: PathBuf = match cli.seed_words_file_name {
Some(filepath) => filepath,
None => return Err(Status::not_found("file path is empty")),
};

let contents = fs::read_to_string(file_path)?;
let words = contents
let words = fs::read_to_string(filepath)?
.split(' ')
.collect::<Vec<&str>>()
.iter()
.map(|&x| x.into())
.collect::<Vec<String>>();

Ok(Response::new(SeedWordsResponse { words }))
}

/// Deletes the seed words file, provided via CLI
async fn delete_seed_words_file(
&self,
_: Request<tari_rpc::Empty>,
) -> Result<Response<FileDeletedResponse>, Status> {
let cli = Cli::parse();
let file_path = cli.seed_words_file_name.unwrap();

if !file_path.is_file() {
return Err(Status::not_found("file not found"));
}

let file_name = file_path.clone().into_os_string().into_string().unwrap();
// WARNING: the filepath used is supplied as an argument
fs::remove_file(match cli.seed_words_file_name {
Some(filepath) => filepath,
None => return Err(Status::not_found("file path is empty")),
})?;

if file_name.is_empty() {
return Err(Status::not_found("seed_words_file_name is empty"));
}
fs::remove_file(file_path)?;
Ok(Response::new(FileDeletedResponse {}))
}
}
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_merge_mining_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ tari_common = { path = "../../common" }
tari_comms = { path = "../../comms/core" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

anyhow = "1.0.53"
crossterm = { version = "0.17" }
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ tari_common = { path = "../../common" }
tari_comms = { path = "../../comms/core" }
tari_app_utilities = { path = "../tari_app_utilities"}
tari_app_grpc = { path = "../tari_app_grpc" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

crossterm = { version = "0.17" }
clap = { version = "3.1.1", features = ["derive"] }
Expand Down
Loading

0 comments on commit f00742c

Please sign in to comment.