Show full transaction details for Monero and XRP
This commit is contained in:
@@ -209,15 +209,41 @@ static void connectDaemon(monero_wallet_full *w) {
|
||||
const auto &tx = transfer->m_tx;
|
||||
const auto isIn = transfer->is_incoming();
|
||||
boost::optional<uint64_t> txHeight = tx ? tx->get_height() : boost::none;
|
||||
[entries addObject:@{
|
||||
@"hash" : [NSString stringWithUTF8String:((tx && tx->m_hash) ? *tx->m_hash : "").c_str()],
|
||||
@"amount" : @((transfer->m_amount ? *transfer->m_amount : 0)).stringValue,
|
||||
@"timestamp" : @((tx && tx->m_received_timestamp) ? *tx->m_received_timestamp : 0),
|
||||
@"direction" : (isIn && *isIn) ? @"in" : @"out",
|
||||
@"confirmed" : @((tx && tx->m_is_confirmed) ? *tx->m_is_confirmed : false),
|
||||
@"height" : @(txHeight ? *txHeight : 0),
|
||||
@"fee" : @((tx && tx->m_fee) ? *tx->m_fee : 0).stringValue,
|
||||
}];
|
||||
|
||||
NSMutableDictionary *entry = [NSMutableDictionary dictionary];
|
||||
entry[@"hash"] = [NSString stringWithUTF8String:((tx && tx->m_hash) ? *tx->m_hash : "").c_str()];
|
||||
entry[@"amount"] = @((transfer->m_amount ? *transfer->m_amount : 0)).stringValue;
|
||||
entry[@"timestamp"] = @((tx && tx->m_received_timestamp) ? *tx->m_received_timestamp : 0);
|
||||
entry[@"direction"] = (isIn && *isIn) ? @"in" : @"out";
|
||||
entry[@"confirmed"] = @((tx && tx->m_is_confirmed) ? *tx->m_is_confirmed : false);
|
||||
entry[@"height"] = @(txHeight ? *txHeight : 0);
|
||||
entry[@"fee"] = @((tx && tx->m_fee) ? *tx->m_fee : 0).stringValue;
|
||||
|
||||
// Extra detail for the transaction view.
|
||||
if (tx) {
|
||||
if (tx->m_payment_id) entry[@"paymentId"] = [NSString stringWithUTF8String:tx->m_payment_id->c_str()];
|
||||
if (tx->m_num_confirmations) entry[@"confirmations"] = @(*tx->m_num_confirmations);
|
||||
if (tx->m_weight) entry[@"weight"] = @(*tx->m_weight);
|
||||
if (tx->m_note) entry[@"note"] = [NSString stringWithUTF8String:tx->m_note->c_str()];
|
||||
if (tx->m_unlock_time) entry[@"unlockTime"] = @(*tx->m_unlock_time);
|
||||
}
|
||||
if (transfer->m_account_index) entry[@"accountIndex"] = @(*transfer->m_account_index);
|
||||
|
||||
if (isIn && *isIn) {
|
||||
auto incoming = std::dynamic_pointer_cast<monero_incoming_transfer>(transfer);
|
||||
if (incoming) {
|
||||
if (incoming->m_subaddress_index) entry[@"subaddressIndex"] = @(*incoming->m_subaddress_index);
|
||||
if (incoming->m_address) entry[@"counterparty"] = [NSString stringWithUTF8String:incoming->m_address->c_str()];
|
||||
}
|
||||
} else {
|
||||
auto outgoing = std::dynamic_pointer_cast<monero_outgoing_transfer>(transfer);
|
||||
if (outgoing) {
|
||||
if (!outgoing->m_addresses.empty()) entry[@"counterparty"] = [NSString stringWithUTF8String:outgoing->m_addresses.front().c_str()];
|
||||
if (!outgoing->m_subaddress_indices.empty()) entry[@"subaddressIndex"] = @(outgoing->m_subaddress_indices.front());
|
||||
}
|
||||
}
|
||||
|
||||
[entries addObject:entry];
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
os_log_error(OS_LOG_DEFAULT, "[koins] getTransactions: %{public}s", e.what());
|
||||
|
||||
Reference in New Issue
Block a user