Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add one-sided coinbase payments #5967

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Cargo.lock

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

26 changes: 6 additions & 20 deletions applications/minotari_app_grpc/proto/wallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ service Wallet {
rpc Identify (GetIdentityRequest) returns (GetIdentityResponse);
// This returns the tari address
rpc GetAddress (Empty) returns (GetAddressResponse);
// This returns a coinbase transaction
rpc GetCoinbase (GetCoinbaseRequest) returns (GetCoinbaseResponse);
// Send Minotari to a number of recipients
rpc Transfer (TransferRequest) returns (TransferResponse);
// Returns the transaction details for the given transaction IDs
Expand Down Expand Up @@ -213,16 +211,16 @@ enum TransactionStatus {
TRANSACTION_STATUS_COINBASE = 5;
// This transaction is mined and confirmed at the current base node's height
TRANSACTION_STATUS_MINED_CONFIRMED = 6;
// The transaction was not found by the wallet its in transaction database
TRANSACTION_STATUS_NOT_FOUND = 7;
// The transaction was rejected by the mempool
TRANSACTION_STATUS_REJECTED = 8;
TRANSACTION_STATUS_REJECTED = 7;
// This is faux transaction mainly for one-sided transaction outputs or wallet recovery outputs have been found
TRANSACTION_STATUS_FAUX_UNCONFIRMED = 9;
TRANSACTION_STATUS_FAUX_UNCONFIRMED = 8;
// All Imported and FauxUnconfirmed transactions will end up with this status when the outputs have been confirmed
TRANSACTION_STATUS_FAUX_CONFIRMED = 10;
TRANSACTION_STATUS_FAUX_CONFIRMED = 9;
// This transaction is still being queued for sending
TRANSACTION_STATUS_QUEUED = 11;
TRANSACTION_STATUS_QUEUED = 10;
// The transaction was not found by the wallet its in transaction database
TRANSACTION_STATUS_NOT_FOUND = 11;
}

message GetCompletedTransactionsRequest { }
Expand All @@ -244,17 +242,6 @@ message GetUnspentAmountsResponse {
repeated uint64 amount = 1;
}

message GetCoinbaseRequest {
uint64 reward = 1;
uint64 fee = 2;
uint64 height = 3;
bytes extra = 4;
}

message GetCoinbaseResponse {
Transaction transaction = 1;
}

message CoinSplitRequest {
uint64 amount_per_split = 1;
uint64 split_count = 2;
Expand Down Expand Up @@ -329,7 +316,6 @@ message TransactionEvent {
string direction = 6;
uint64 amount = 7;
string message = 8;
bool is_coinbase = 9;
}

message TransactionEventResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ impl From<TransactionStatus> for grpc::TransactionStatus {
Completed => grpc::TransactionStatus::Completed,
Broadcast => grpc::TransactionStatus::Broadcast,
MinedUnconfirmed => grpc::TransactionStatus::MinedUnconfirmed,
MinedConfirmed => grpc::TransactionStatus::MinedConfirmed,
Imported => grpc::TransactionStatus::Imported,
Pending => grpc::TransactionStatus::Pending,
Coinbase => grpc::TransactionStatus::Coinbase,
MinedConfirmed => grpc::TransactionStatus::MinedConfirmed,
Rejected => grpc::TransactionStatus::Rejected,
FauxUnconfirmed => grpc::TransactionStatus::FauxUnconfirmed,
FauxConfirmed => grpc::TransactionStatus::FauxConfirmed,
Expand Down
1 change: 0 additions & 1 deletion applications/minotari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ console-subscriber = "0.1.8"
# Uncomment for normal use (non tokio-console tracing)
tokio = { version = "1.23", features = ["signal"] }

bitflags = { version = "2.4", features = ["serde"] }
chrono = { version = "0.4.19", default-features = false }
clap = { version = "3.2", features = ["derive", "env"] }
config = "0.13.0"
Expand Down
12 changes: 6 additions & 6 deletions applications/minotari_console_wallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ Total value of UTXOs: 36105.165440 T
example output - `--csv-file` (contents of `utxos.csv`)

```
"#","Value (uT)","Spending Key","Commitment","Flags","Maturity"
hansieodendaal marked this conversation as resolved.
Show resolved Hide resolved
"1","121999250","0b0ce2add569845ec8bb84256b731e644e2224580b568e75666399e868ea5701","22514e279bd7e7e0a6e45905e07323b16f6114e300bcc02f36b2baf44a17b43d","(empty)","0"
"2","124000000","8829254b5267de26fe926f30518604abeec156740abe64b435ac6081269f2f0d","88f4e7216353032b90bee1c8b4243c3f25b357902a5cb145fda1c98316525214","(empty)","0"
"3","125000000","295853fad02d56313920130c3a5fa3aa8be54297ee5375aa2d788f4e49f08309","72a42d2db4f8eebbc4d0074fcb04338b8caa22312ce6a68e8798c2452b52e465","(empty)","0"
"#","Value (uT)","Spending Key","Commitment","Maturity"
"1","121999250","0b0ce2add569845ec8bb84256b731e644e2224580b568e75666399e868ea5701","22514e279bd7e7e0a6e45905e07323b16f6114e300bcc02f36b2baf44a17b43d","0"
"2","124000000","8829254b5267de26fe926f30518604abeec156740abe64b435ac6081269f2f0d","88f4e7216353032b90bee1c8b4243c3f25b357902a5cb145fda1c98316525214","0"
"3","125000000","295853fad02d56313920130c3a5fa3aa8be54297ee5375aa2d788f4e49f08309","72a42d2db4f8eebbc4d0074fcb04338b8caa22312ce6a68e8798c2452b52e465","0"
...
"10","5513131148","a6323f62ef21c45f03c73b424d9823b1a0f44a4408be688e5f6fde6419a11407","dcec835619474a62b5cef8227481cebd5831aec515e85286f3932c8093e9d06b","COINBASE_OUTPUT","10655"
"11","5513145680","5af45bff0f533999c94ec799aa4789260a1b989207363c33ec6ec388899ec906","7ec353f1f005637192d50104b3c5b4621d1ebdafb5c5cc078cf3f86754669352","COINBASE_OUTPUT","10649"
"10","5513131148","a6323f62ef21c45f03c73b424d9823b1a0f44a4408be688e5f6fde6419a11407","dcec835619474a62b5cef8227481cebd5831aec515e85286f3932c8093e9d06b","10655"
"11","5513145680","5af45bff0f533999c94ec799aa4789260a1b989207363c33ec6ec388899ec906","7ec353f1f005637192d50104b3c5b4621d1ebdafb5c5cc078cf3f86754669352","10649"
```

- **count-utxos**
Expand Down
6 changes: 0 additions & 6 deletions applications/minotari_console_wallet/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub fn convert_to_transaction_event(event: String, source: TransactionWrapper) -
direction: completed.direction.to_string(),
amount: completed.amount.as_u64(),
message: completed.message.to_string(),
is_coinbase: completed.is_coinbase(),
},
TransactionWrapper::Outbound(outbound) => TransactionEvent {
event,
Expand All @@ -40,7 +39,6 @@ pub fn convert_to_transaction_event(event: String, source: TransactionWrapper) -
direction: "outbound".to_string(),
amount: outbound.amount.as_u64(),
message: outbound.message,
is_coinbase: false,
},
TransactionWrapper::Inbound(inbound) => TransactionEvent {
event,
Expand All @@ -51,10 +49,6 @@ pub fn convert_to_transaction_event(event: String, source: TransactionWrapper) -
direction: "inbound".to_string(),
amount: inbound.amount.as_u64(),
message: inbound.message.clone(),
// The coinbase are technically Inbound.
// To determine whether a transaction is coinbase
// we will check whether the message contains `Coinbase`.
is_coinbase: inbound.message.to_lowercase().contains("coinbase"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not have coinbase transactions anymore; we just import one-sided coinbase UTXOs and make faux transactions

},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ use minotari_app_grpc::tari_rpc::{
GetAddressResponse,
GetBalanceRequest,
GetBalanceResponse,
GetCoinbaseRequest,
GetCoinbaseResponse,
GetCompletedTransactionsRequest,
GetCompletedTransactionsResponse,
GetConnectivityRequest,
Expand Down Expand Up @@ -309,24 +307,6 @@ impl wallet_server::Wallet for WalletGrpcServer {
Ok(Response::new(RevalidateResponse {}))
}

async fn get_coinbase(
&self,
request: Request<GetCoinbaseRequest>,
) -> Result<Response<GetCoinbaseResponse>, Status> {
let request = request.into_inner();
let mut tx_service = self.get_transaction_service();

let coinbase = tx_service
.generate_coinbase_transaction(request.reward.into(), request.fee.into(), request.height, request.extra)
.await
.map_err(|err| Status::unknown(err.to_string()))?;

let coinbase = coinbase.try_into().map_err(Status::internal)?;
Ok(Response::new(GetCoinbaseResponse {
transaction: Some(coinbase),
}))
}

async fn send_sha_atomic_swap_transaction(
&self,
request: Request<SendShaAtomicSwapRequest>,
Expand Down Expand Up @@ -1090,7 +1070,6 @@ fn simple_event(event: &str) -> TransactionEvent {
direction: event.to_string(),
amount: 0,
message: String::default(),
is_coinbase: false,
}
}

Expand Down
1 change: 0 additions & 1 deletion applications/minotari_console_wallet/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ fn display_password_feedback(passphrase: &SafePassword) -> bool {
"The password you chose is weak; a determined attacker with access to your device may be able to guess it."
);
println!("You may want to consider changing it to a stronger one.");
println!("Here are some suggestions:");
hansieodendaal marked this conversation as resolved.
Show resolved Hide resolved
for suggestion in feedback {
println!("- {}", suggestion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ impl TransactionsTab {
Style::default().fg(text_color),
)));

let status = if matches!(t.cancelled, Some(TxCancellationReason::AbandonedCoinbase)) {
"Abandoned".to_string()
} else if matches!(t.cancelled, Some(TxCancellationReason::UserCancelled)) {
let status = if matches!(t.cancelled, Some(TxCancellationReason::UserCancelled)) {
"Cancelled".to_string()
} else if t.cancelled.is_some() {
"Rejected".to_string()
Expand Down Expand Up @@ -364,9 +362,7 @@ impl TransactionsTab {
let amount = tx.amount.to_string();
let content = &amount;
let amount = Span::styled(content, Style::default().fg(Color::White));
let fee_details = if tx.is_coinbase {
Span::raw("")
} else {
let fee_details = {
Span::styled(
format!(
" (weight: {}g, #inputs: {}, #outputs: {})",
Expand Down Expand Up @@ -602,7 +598,6 @@ impl<B: Backend> Component<B> for TransactionsTab {
error!(target: LOG_TARGET, "Error rebroadcasting transactions: {}", e);
}
},
'a' => app_state.toggle_abandoned_coinbase_filter(),
'\n' => match self.selected_tx_list {
SelectedTransactionList::None => {},
SelectedTransactionList::PendingTxs => {
Expand Down
32 changes: 1 addition & 31 deletions applications/minotari_console_wallet/src/ui/state/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use std::{
time::{Duration, Instant},
};

use bitflags::bitflags;
use chrono::{DateTime, Local, NaiveDateTime};
use log::*;
use minotari_wallet::{
Expand Down Expand Up @@ -97,7 +96,6 @@ pub struct AppState {
inner: Arc<RwLock<AppStateInner>>,
cached_data: AppStateData,
cache_update_cooldown: Option<Instant>,
completed_tx_filter: TransactionFilter,
config: AppStateConfig,
wallet_config: WalletConfig,
wallet_connectivity: WalletConnectivityHandle,
Expand All @@ -122,7 +120,6 @@ impl AppState {
inner: inner.clone(),
cached_data,
cache_update_cooldown: None,
completed_tx_filter: TransactionFilter::ABANDONED_COINBASES,
config: AppStateConfig::default(),
wallet_connectivity,
balance_enquiry_debouncer: BalanceEnquiryDebouncer::new(
Expand Down Expand Up @@ -559,19 +556,7 @@ impl AppState {
}

pub fn get_completed_txs(&self) -> Vec<&CompletedTransactionInfo> {
if self
.completed_tx_filter
.contains(TransactionFilter::ABANDONED_COINBASES)
{
self.cached_data
.completed_txs
.iter()
.filter(|tx| !matches!(tx.cancelled, Some(TxCancellationReason::AbandonedCoinbase)))
.filter(|tx| !matches!(tx.status, TransactionStatus::Coinbase))
.collect()
} else {
self.cached_data.completed_txs.iter().collect()
}
self.cached_data.completed_txs.iter().collect()
}

pub fn get_confirmations(&self, tx_id: TxId) -> Option<&u64> {
Expand Down Expand Up @@ -657,10 +642,6 @@ impl AppState {
self.wallet_config.num_required_confirmations
}

pub fn toggle_abandoned_coinbase_filter(&mut self) {
self.completed_tx_filter.toggle(TransactionFilter::ABANDONED_COINBASES);
}

pub fn get_notifications(&self) -> &[(DateTime<Local>, String)] {
&self.cached_data.notifications
}
Expand Down Expand Up @@ -1166,7 +1147,6 @@ pub struct CompletedTransactionInfo {
pub cancelled: Option<TxCancellationReason>,
pub direction: TransactionDirection,
pub mined_height: Option<u64>,
pub is_coinbase: bool,
pub weight: u64,
pub inputs_count: usize,
pub outputs_count: usize,
Expand All @@ -1182,7 +1162,6 @@ impl CompletedTransactionInfo {
.first_kernel_excess_sig()
.map(|s| s.get_signature().to_hex())
.unwrap_or_default();
let is_coinbase = tx.is_coinbase();
let weight = tx.transaction.calculate_weight(transaction_weighting)?;
let inputs_count = tx.transaction.body.inputs().len();
let outputs_count = tx.transaction.body.outputs().len();
Expand All @@ -1208,7 +1187,6 @@ impl CompletedTransactionInfo {
cancelled: tx.cancelled,
direction: tx.direction,
mined_height: tx.mined_height,
is_coinbase,
weight,
inputs_count,
outputs_count,
Expand Down Expand Up @@ -1344,14 +1322,6 @@ pub enum UiTransactionBurnStatus {
Error(String),
}

bitflags! {
#[derive(Clone)]
pub struct TransactionFilter: u8 {
const NONE = 0b0000_0000;
const ABANDONED_COINBASES = 0b0000_0001;
}
}

#[derive(Clone)]
struct AppStateConfig {
pub cache_update_cooldown: Duration,
Expand Down
4 changes: 4 additions & 0 deletions applications/minotari_merge_mining_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ default = []

[dependencies]
tari_common = { path = "../../common" }
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
minotari_app_utilities = { path = "../minotari_app_utilities" }
tari_utilities = { version = "0.6" }
minotari_node_grpc_client = { path = "../../clients/rust/base_node_grpc_client" }
minotari_wallet_grpc_client = { path = "../../clients/rust/wallet_grpc_client" }
minotari_app_grpc = { path = "../minotari_app_grpc" }
tari_key_manager = { path = "../../base_layer/key_manager", features = ["key_manager_service"] }
tari_crypto = { version = "0.19", features = ["borsh"] }

anyhow = "1.0.53"
crossterm = { version = "0.25.0" }
Expand All @@ -41,6 +44,7 @@ tokio = { version = "1.23", features = ["macros"] }
tonic = "0.6.2"
tracing = "0.1"
url = "2.1.1"
rand = "0.8"

[build-dependencies]
tari_features = { path = "../../common/tari_features"}
Loading
Loading