Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
98 changes: 54 additions & 44 deletions applications/minotari_app_grpc/proto/wallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ service Wallet {
// ```
rpc GetAddress (Empty) returns (GetAddressResponse);

// This RPC returns addresses generated for a specific payment ID. It provides both the interactive
// and one-sided addresses for the given payment ID, along with their respective representations in
// This RPC returns addresses generated for a specific payment ID. It provides both the interactive
// and one-sided addresses for the given payment ID, along with their respective representations in
// base58 and emoji formats.
//
// Example usage (JavaScript):
Expand Down Expand Up @@ -200,7 +200,7 @@ service Wallet {
// - Raw binary
// - Base58-encoded (human-readable)
// - Emoji-encoded (for fun and friendliness)
//
//
// Example usage (JavaScript with gRPC):
//
// ```js
Expand Down Expand Up @@ -262,18 +262,18 @@ service Wallet {
// }
// ```
rpc Transfer (TransferRequest) returns (TransferResponse);

// Returns the transaction details for the given transaction IDs.
//
// The GetTransactionInfo RPC retrieves detailed information about specific transactions based on their IDs.
// The response includes details such as transaction status, direction, amount, fee, and more.
//
// ### Request Parameters:
//
// - `transaction_ids` (required):
// - **Type**: `repeated uint64`
// - **Description**: A list of transaction IDs to query.
// - **Restrictions**:
// - `transaction_ids` (required):
// - **Type**: `repeated uint64`
// - **Description**: A list of transaction IDs to query.
// - **Restrictions**:
// - Must contain at least one ID.
// - All IDs must be valid unsigned 64-bit integers.
// - Duplicates will be ignored; only the first occurrence is processed.
Expand Down Expand Up @@ -440,7 +440,7 @@ service Wallet {
//
// ### Request Parameters:
//
// - *(none)*
// - *(none)*
// - This method uses an empty request body (`google.protobuf.Empty`).
// - No filters or arguments are required.
//
Expand Down Expand Up @@ -470,29 +470,29 @@ service Wallet {
//
// ### Request Parameters:
//
// - `amount_per_split` (required):
// - **Type**: `uint64`
// - **Description**: The value of each individual output in the split.
// - `amount_per_split` (required):
// - **Type**: `uint64`
// - **Description**: The value of each individual output in the split.
// - **Restrictions**: Must be greater than zero.
//
// - `split_count` (required):
// - **Type**: `uint64`
// - **Description**: The number of outputs to create.
// - `split_count` (required):
// - **Type**: `uint64`
// - **Description**: The number of outputs to create.
// - **Restrictions**: Must be greater than zero and within practical system limits.
//
// - `fee_per_gram` (required):
// - **Type**: `uint64`
// - **Description**: The transaction fee rate (per gram of weight).
// - `fee_per_gram` (required):
// - **Type**: `uint64`
// - **Description**: The transaction fee rate (per gram of weight).
// - **Restrictions**: Should be set high enough to ensure confirmation.
//
// - `lock_height` (optional):
// - **Type**: `uint64`
// - **Description**: The earliest block height at which the transaction becomes valid.
// - `lock_height` (optional):
// - **Type**: `uint64`
// - **Description**: The earliest block height at which the transaction becomes valid.
// - **Restrictions**: Defaults to 0 if not specified.
//
// - `payment_id` (optional):
// - **Type**: `bytes`
// - **Description**: A user-defined identifier for tracking or referencing the transaction.
// - `payment_id` (optional):
// - **Type**: `bytes`
// - **Description**: A user-defined identifier for tracking or referencing the transaction.
// - **Restrictions**: Optional; can be left empty.
//
// ### Example JavaScript gRPC client usage:
Expand Down Expand Up @@ -528,17 +528,17 @@ service Wallet {
//
// ### Request Parameters:
//
// - `outputs` (required):
// - **Type**: `repeated UnblindedOutput`
// - **Description**: A list of unblinded outputs to import into the wallet.
// - **Restrictions**:
// - `outputs` (required):
// - **Type**: `repeated UnblindedOutput`
// - **Description**: A list of unblinded outputs to import into the wallet.
// - **Restrictions**:
// - Each output must be valid and convertible to an internal UTXO format.
// - The list must contain at least one item.
//
// - `payment_id` (optional):
// - **Type**: `bytes`
// - **Description**: An optional user-defined identifier to associate with the imported outputs.
// - **Restrictions**:
// - `payment_id` (optional):
// - **Type**: `bytes`
// - **Description**: An optional user-defined identifier to associate with the imported outputs.
// - **Restrictions**:
// - Can be left empty if not needed.
// - Must be a valid byte string if provided.
//
Expand Down Expand Up @@ -572,7 +572,7 @@ service Wallet {
//
// ### Request Parameters:
//
// - *(none)*
// - *(none)*
// - This method uses an empty request body (`google.protobuf.Empty`).
// - No filters or arguments are required.
//
Expand All @@ -599,16 +599,16 @@ service Wallet {
//
// The `status` field indicates the current network connectivity of the wallet. Possible values are:
//
// - `ONLINE`:
// - The wallet is fully connected to the network and functioning normally.
// - `ONLINE`:
// - The wallet is fully connected to the network and functioning normally.
// - The node has enough active peer connections to operate efficiently.
//
// - `DEGRADED`:
// - The wallet is connected to some peers but not enough to maintain full functionality.
// - `DEGRADED`:
// - The wallet is connected to some peers but not enough to maintain full functionality.
// - This could indicate issues with network connectivity, such as intermittent disconnections or insufficient peers, leading to reduced performance or reliability.
//
// - `OFFLINE`:
// - The wallet is not connected to any peers.
// - `OFFLINE`:
// - The wallet is not connected to any peers.
// - This status means the wallet is unable to communicate with the network and cannot perform any network-related operations.
//
rpc GetNetworkStatus(Empty) returns (NetworkStatusResponse);
Expand All @@ -621,7 +621,7 @@ service Wallet {
//
// ### Request Parameters:
//
// - *(none)*
// - *(none)*
// - This method uses an empty request body (`google.protobuf.Empty`).
// - No filters or arguments are required.
//
Expand Down Expand Up @@ -681,7 +681,7 @@ service Wallet {
// Cancels a specific transaction by its ID.
//
// The `CancelTransaction` call allows a transaction to be cancelled by its unique transaction ID (TxId).
// If the cancellation is successful, the response will indicate success. Otherwise, the response will
// If the cancellation is successful, the response will indicate success. Otherwise, the response will
// contain a failure message with the reason for the failure.
//
// ### Request Parameters:
Expand Down Expand Up @@ -723,13 +723,13 @@ service Wallet {

// Sends a XTR SHA Atomic Swap transaction.
//
// The `SendShaAtomicSwapTransaction` call is used to initiate an Atomic Swap
// transaction using SHA. It allows the sender to send a payment to the recipient
// The `SendShaAtomicSwapTransaction` call is used to initiate an Atomic Swap
// transaction using SHA. It allows the sender to send a payment to the recipient
// in exchange for an atomic swap, with SHA used as the secret for the swap.
// The method accepts the recipient's information and initiates the transaction.
//
// ### Request Parameters:
// - **recipient** (required): A PaymentRecipient object containing the recipient's address,
// - **recipient** (required): A PaymentRecipient object containing the recipient's address,
// the amount to be swapped, the fee per gram, and the payment ID to identify the transaction.
//
// ### Response Fields:
Expand Down Expand Up @@ -997,6 +997,8 @@ service Wallet {
rpc StreamTransactionEvents(TransactionEventRequest) returns (stream TransactionEventResponse);

rpc RegisterValidatorNode(RegisterValidatorNodeRequest) returns (RegisterValidatorNodeResponse);

rpc ImportTransactions(ImportTransactionsRequest) returns (ImportTransactionsResponse);
}


Expand Down Expand Up @@ -1355,3 +1357,11 @@ message RegisterValidatorNodeResponse {
bool is_success = 2;
string failure_message = 3;
}

message ImportTransactionsRequest {
string txs = 1;
}

message ImportTransactionsResponse {
repeated uint64 tx_ids = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,7 @@ pub async fn command_runner(
target: LOG_TARGET,
"send-one-sided-to-stealth-address concluded with tx_id {}", tx_id
);
println!("Transaction ID: {}", tx_id);
tx_ids.push(tx_id);
},
Err(e) => eprintln!("SendOneSidedToStealthAddress error! {}", e),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ use minotari_app_grpc::tari_rpc::{
GetUnspentAmountsResponse,
GetVersionRequest,
GetVersionResponse,
ImportTransactionsRequest,
ImportTransactionsResponse,
ImportUtxosRequest,
ImportUtxosResponse,
RegisterValidatorNodeRequest,
Expand Down Expand Up @@ -1251,6 +1253,28 @@ impl wallet_server::Wallet for WalletGrpcServer {
};
Ok(Response::new(response))
}

async fn import_transactions(
&self,
request: Request<ImportTransactionsRequest>,
) -> Result<Response<ImportTransactionsResponse>, Status> {
let request = request.into_inner();
let txs: Vec<WalletTransaction> = serde_json::from_str(&request.txs)
.map_err(|_| Status::invalid_argument("Could not parse transactions. Use valid JSON format."))?;
info!(target: LOG_TARGET, "Importing {:?} transactions", txs.len());

let mut transaction_service = self.get_transaction_service();
let mut tx_ids = Vec::new();
for tx in txs {
match transaction_service.import_transaction(tx).await {
Ok(id) => {
tx_ids.push(id.into());
},
Err(e) => eprintln!("Could not import tx {}", e),
};
}
Ok(Response::new(ImportTransactionsResponse { tx_ids }))
}
}

async fn handle_completed_tx(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ impl WalletEventMonitor {
self.trigger_full_tx_state_refresh().await;
self.trigger_balance_refresh();
},
TransactionEvent::TransactionImported(tx_id) => {
self.trigger_tx_state_refresh(tx_id).await;
self.trigger_balance_refresh();
self.add_notification(
format!("Transaction Imported - TxId: {}", tx_id)
).await;
},
// Only the above variants trigger state refresh
_ => (),
}
Expand Down
4 changes: 4 additions & 0 deletions base_layer/wallet/src/transaction_service/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ pub enum TransactionEvent {
num_confirmations: u64,
is_valid: bool,
},
TransactionImported(TxId),
TransactionValidationStateChanged(OperationId),
TransactionValidationCompleted(OperationId),
TransactionValidationFailed(OperationId, u64),
Expand Down Expand Up @@ -551,6 +552,9 @@ impl fmt::Display for TransactionEvent {
{is_valid}",
)
},
TransactionEvent::TransactionImported(tx) => {
write!(f, "TransactionImported for {tx}")
},
TransactionEvent::Error(error) => {
write!(f, "Error:{error}")
},
Expand Down
3 changes: 3 additions & 0 deletions base_layer/wallet/src/transaction_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,9 @@ where
tx_id
},
};
let _size = self
.event_publisher
.send(Arc::new(TransactionEvent::TransactionImported(tx_id)));
Ok(TransactionServiceResponse::TransactionImported(tx_id))
},
TransactionServiceRequest::ImportUtxoWithStatus {
Expand Down
Loading