mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-23 23:58:48 +00:00
Added displaying of transaction key.
This commit is contained in:
parent
e4b5bcf07e
commit
9eb74f7155
6 changed files with 42 additions and 4 deletions
|
@ -5,8 +5,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "thread"
|
#include "thread"
|
||||||
#include "../External/android/monero/include/wallet2_api.h"
|
|
||||||
#include "CwWalletListener.h"
|
#include "CwWalletListener.h"
|
||||||
|
#include "../External/android/monero/include/wallet2_api.h"
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
@ -684,6 +684,11 @@ extern "C"
|
||||||
m_wallet->rescanBlockchainAsync();
|
m_wallet->rescanBlockchainAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * get_tx_key(char * txId)
|
||||||
|
{
|
||||||
|
return strdup(m_wallet->getTxKey(std::string(txId)).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -76,7 +76,9 @@ typedef account_add_new = Void Function(Pointer<Utf8> label);
|
||||||
typedef account_set_label = Void Function(
|
typedef account_set_label = Void Function(
|
||||||
Int32 accountIndex, Pointer<Utf8> label);
|
Int32 accountIndex, Pointer<Utf8> label);
|
||||||
|
|
||||||
typedef transactions_refresh = Void Function();
|
typedef transactions_refresh = Void Function();
|
||||||
|
|
||||||
|
typedef get_tx_key = Pointer<Utf8> Function(Pointer<Utf8> txId);
|
||||||
|
|
||||||
typedef transactions_count = Int64 Function();
|
typedef transactions_count = Int64 Function();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
|
import 'package:cw_monero/convert_utf8_to_string.dart';
|
||||||
import 'package:cw_monero/structs/ut8_box.dart';
|
import 'package:cw_monero/structs/ut8_box.dart';
|
||||||
import 'package:ffi/ffi.dart';
|
import 'package:ffi/ffi.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
@ -29,6 +30,23 @@ final transactionCommitNative = moneroApi
|
||||||
.lookup<NativeFunction<transaction_commit>>('transaction_commit')
|
.lookup<NativeFunction<transaction_commit>>('transaction_commit')
|
||||||
.asFunction<TransactionCommit>();
|
.asFunction<TransactionCommit>();
|
||||||
|
|
||||||
|
final getTxKeyNative = moneroApi
|
||||||
|
.lookup<NativeFunction<get_tx_key>>('get_tx_key')
|
||||||
|
.asFunction<GetTxKey>();
|
||||||
|
|
||||||
|
String getTxKey(String txId) {
|
||||||
|
final txIdPointer = Utf8.toUtf8(txId);
|
||||||
|
final keyPointer = getTxKeyNative(txIdPointer);
|
||||||
|
|
||||||
|
free(txIdPointer);
|
||||||
|
|
||||||
|
if (keyPointer != null) {
|
||||||
|
return convertUTF8ToString(pointer: keyPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
void refreshTransactions() => transactionsRefreshNative();
|
void refreshTransactions() => transactionsRefreshNative();
|
||||||
|
|
||||||
int countOfTransactions() => transactionsCountNative();
|
int countOfTransactions() => transactionsCountNative();
|
||||||
|
|
|
@ -76,6 +76,8 @@ typedef AccountSetLabel = void Function(int accountIndex, Pointer<Utf8> label);
|
||||||
|
|
||||||
typedef TransactionsRefresh = void Function();
|
typedef TransactionsRefresh = void Function();
|
||||||
|
|
||||||
|
typedef GetTxKey = Pointer<Utf8> Function(Pointer<Utf8> txId);
|
||||||
|
|
||||||
typedef TransactionsCount = int Function();
|
typedef TransactionsCount = int Function();
|
||||||
|
|
||||||
typedef TransactionsGetAll = Pointer<Int64> Function();
|
typedef TransactionsGetAll = Pointer<Int64> Function();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:cw_monero/structs/transaction_info_row.dart';
|
||||||
import 'package:cake_wallet/entities/parseBoolFromString.dart';
|
import 'package:cake_wallet/entities/parseBoolFromString.dart';
|
||||||
import 'package:cake_wallet/entities/transaction_direction.dart';
|
import 'package:cake_wallet/entities/transaction_direction.dart';
|
||||||
import 'package:cake_wallet/entities/format_amount.dart';
|
import 'package:cake_wallet/entities/format_amount.dart';
|
||||||
|
import 'package:cw_monero/transaction_history.dart';
|
||||||
|
|
||||||
class MoneroTransactionInfo extends TransactionInfo {
|
class MoneroTransactionInfo extends TransactionInfo {
|
||||||
MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
|
MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
|
||||||
|
@ -19,7 +20,8 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
(int.parse(map['timestamp'] as String) ?? 0) * 1000),
|
(int.parse(map['timestamp'] as String) ?? 0) * 1000),
|
||||||
isPending = parseBoolFromString(map['isPending'] as String),
|
isPending = parseBoolFromString(map['isPending'] as String),
|
||||||
amount = map['amount'] as int,
|
amount = map['amount'] as int,
|
||||||
accountIndex = int.parse(map['accountIndex'] as String);
|
accountIndex = int.parse(map['accountIndex'] as String),
|
||||||
|
key = getTxKey((map['hash'] ?? '') as String);
|
||||||
|
|
||||||
MoneroTransactionInfo.fromRow(TransactionInfoRow row)
|
MoneroTransactionInfo.fromRow(TransactionInfoRow row)
|
||||||
: id = row.getHash(),
|
: id = row.getHash(),
|
||||||
|
@ -29,7 +31,8 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000),
|
date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000),
|
||||||
isPending = row.isPending != 0,
|
isPending = row.isPending != 0,
|
||||||
amount = row.getAmount(),
|
amount = row.getAmount(),
|
||||||
accountIndex = row.subaddrAccount;
|
accountIndex = row.subaddrAccount,
|
||||||
|
key = getTxKey(row.getHash());
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
final int height;
|
final int height;
|
||||||
|
@ -39,11 +42,14 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
final bool isPending;
|
final bool isPending;
|
||||||
final int amount;
|
final int amount;
|
||||||
String recipientAddress;
|
String recipientAddress;
|
||||||
|
String key;
|
||||||
|
|
||||||
String _fiatAmount;
|
String _fiatAmount;
|
||||||
|
|
||||||
|
@override
|
||||||
String amountFormatted() => '${formatAmount(moneroAmountToString(amount: amount))} XMR';
|
String amountFormatted() => '${formatAmount(moneroAmountToString(amount: amount))} XMR';
|
||||||
|
|
||||||
|
@override
|
||||||
String fiatAmount() => _fiatAmount ?? '';
|
String fiatAmount() => _fiatAmount ?? '';
|
||||||
|
|
||||||
void changeFiatAmount(String amount) => _fiatAmount = formatAmount(amount);
|
void changeFiatAmount(String amount) => _fiatAmount = formatAmount(amount);
|
||||||
|
|
|
@ -35,6 +35,11 @@ class TransactionDetailsPage extends BasePage {
|
||||||
// value: tx.recipientAddress));
|
// value: tx.recipientAddress));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if (tx.key?.isNotEmpty) {
|
||||||
|
// FIXME: add translation
|
||||||
|
items.add(StandartListItem(title: 'Transaction Key', value: tx.key));
|
||||||
|
}
|
||||||
|
|
||||||
_items.addAll(items);
|
_items.addAll(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue