Cw-58: Show subaddress label on the transaction details page (#333)

* CW-58: Show subaddress label on the transaction details page

* add translations

* Fix interface
This commit is contained in:
clear 2022-04-12 17:38:47 +02:00 committed by GitHub
parent 04db28e276
commit 135ede6a78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 69 additions and 13 deletions

View file

@ -766,6 +766,11 @@ extern "C"
return strdup(m_wallet->getTxKey(std::string(txId)).c_str()); return strdup(m_wallet->getTxKey(std::string(txId)).c_str());
} }
char *get_subaddress_label(uint32_t accountIndex, uint32_t addressIndex)
{
return strdup(get_current_wallet()->getSubaddressLabel(accountIndex, addressIndex).c_str());
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -120,3 +120,7 @@ typedef close_current_wallet = Void Function();
typedef on_startup = Void Function(); typedef on_startup = Void Function();
typedef rescan_blockchain = Void Function(); typedef rescan_blockchain = Void Function();
typedef get_subaddress_label = Pointer<Utf8> Function(
Int32 accountIndex,
Int32 addressIndex);

View file

@ -118,3 +118,7 @@ typedef CloseCurrentWallet = void Function();
typedef OnStartup = void Function(); typedef OnStartup = void Function();
typedef RescanBlockchainAsync = void Function(); typedef RescanBlockchainAsync = void Function();
typedef GetSubaddressLabel = Pointer<Utf8> Function(
int accountIndex,
int addressIndex);

View file

@ -112,6 +112,10 @@ final rescanBlockchainAsyncNative = moneroApi
.lookup<NativeFunction<rescan_blockchain>>('rescan_blockchain') .lookup<NativeFunction<rescan_blockchain>>('rescan_blockchain')
.asFunction<RescanBlockchainAsync>(); .asFunction<RescanBlockchainAsync>();
final getSubaddressLabelNative = moneroApi
.lookup<NativeFunction<get_subaddress_label>>('get_subaddress_label')
.asFunction<GetSubaddressLabel>();
int getSyncingHeight() => getSyncingHeightNative(); int getSyncingHeight() => getSyncingHeightNative();
bool isNeededToRefresh() => isNeededToRefreshNative() != 0; bool isNeededToRefresh() => isNeededToRefreshNative() != 0;
@ -327,3 +331,7 @@ Future<bool> isConnected() => compute(_isConnected, 0);
Future<int> getNodeHeight() => compute(_getNodeHeight, 0); Future<int> getNodeHeight() => compute(_getNodeHeight, 0);
void rescanBlockchainAsync() => rescanBlockchainAsyncNative(); void rescanBlockchainAsync() => rescanBlockchainAsyncNative();
String getSubaddressLabel(int accountIndex, int addressIndex) {
return convertUTF8ToString(pointer: getSubaddressLabelNative(accountIndex, addressIndex));
}

View file

@ -314,6 +314,10 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
} }
} }
String getSubaddressLabel(int accountIndex, int addressIndex) {
return monero_wallet.getSubaddressLabel(accountIndex, addressIndex);
}
List<MoneroTransactionInfo> _getAllTransactions(dynamic _) => List<MoneroTransactionInfo> _getAllTransactions(dynamic _) =>
monero_transaction_history monero_transaction_history
.getAllTransations() .getAllTransations()

View file

@ -294,4 +294,9 @@ class CWMonero extends Monero {
final moneroWallet = wallet as MoneroWallet; final moneroWallet = wallet as MoneroWallet;
return moneroWallet.getTransactionAddress(accountIndex, addressIndex); return moneroWallet.getTransactionAddress(accountIndex, addressIndex);
} }
String getSubaddressLabel(Object wallet, int accountIndex, int addressIndex) {
final moneroWallet = wallet as MoneroWallet;
return moneroWallet.getSubaddressLabel(accountIndex, addressIndex);
}
} }

View file

@ -60,6 +60,7 @@ abstract class TransactionDetailsViewModelBase with Store {
addressIndex != null) { addressIndex != null) {
try { try {
final address = monero.getTransactionAddress(wallet, accountIndex, addressIndex); final address = monero.getTransactionAddress(wallet, accountIndex, addressIndex);
final label = monero.getSubaddressLabel(wallet, accountIndex, addressIndex);
if (address?.isNotEmpty ?? false) { if (address?.isNotEmpty ?? false) {
isRecipientAddressShown = true; isRecipientAddressShown = true;
@ -68,6 +69,14 @@ abstract class TransactionDetailsViewModelBase with Store {
title: S.current.transaction_details_recipient_address, title: S.current.transaction_details_recipient_address,
value: address)); value: address));
} }
if (label?.isNotEmpty ?? false) {
_items.add(
StandartListItem(
title: S.current.address_label,
value: label)
);
}
} catch (e) { } catch (e) {
print(e.toString()); print(e.toString());
} }

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "Bezeichnung", "new_subaddress_label_name" : "Bezeichnung",
"new_subaddress_create" : "Erstellen", "new_subaddress_create" : "Erstellen",
"address_label" : "Address label",
"subaddress_title" : "Unteradressenliste", "subaddress_title" : "Unteradressenliste",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "Label name", "new_subaddress_label_name" : "Label name",
"new_subaddress_create" : "Create", "new_subaddress_create" : "Create",
"address_label" : "Address label",
"subaddress_title" : "Subaddress list", "subaddress_title" : "Subaddress list",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "Nombre de etiqueta", "new_subaddress_label_name" : "Nombre de etiqueta",
"new_subaddress_create" : "Crear", "new_subaddress_create" : "Crear",
"address_label" : "Address label",
"subaddress_title" : "Lista de subdirecciones", "subaddress_title" : "Lista de subdirecciones",

View file

@ -266,6 +266,7 @@
"new_subaddress_label_name" : "Nom", "new_subaddress_label_name" : "Nom",
"new_subaddress_create" : "Créer", "new_subaddress_create" : "Créer",
"address_label" : "Address label",
"subaddress_title" : "Liste des sous-adresses", "subaddress_title" : "Liste des sous-adresses",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "लेबल का नाम", "new_subaddress_label_name" : "लेबल का नाम",
"new_subaddress_create" : "सर्जन करना", "new_subaddress_create" : "सर्जन करना",
"address_label" : "Address label",
"subaddress_title" : "उपखंड सूची", "subaddress_title" : "उपखंड सूची",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "Oznaka", "new_subaddress_label_name" : "Oznaka",
"new_subaddress_create" : "Izradi", "new_subaddress_create" : "Izradi",
"address_label" : "Address label",
"subaddress_title" : "Lista podadresa", "subaddress_title" : "Lista podadresa",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "Nome etichetta", "new_subaddress_label_name" : "Nome etichetta",
"new_subaddress_create" : "Crea", "new_subaddress_create" : "Crea",
"address_label" : "Address label",
"subaddress_title" : "Lista sottoindirizzi", "subaddress_title" : "Lista sottoindirizzi",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "ラベル名", "new_subaddress_label_name" : "ラベル名",
"new_subaddress_create" : "作成する", "new_subaddress_create" : "作成する",
"address_label" : "Address label",
"subaddress_title" : "サブアドレス一覧", "subaddress_title" : "サブアドレス一覧",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "라벨 이름", "new_subaddress_label_name" : "라벨 이름",
"new_subaddress_create" : "몹시 떠들어 대다", "new_subaddress_create" : "몹시 떠들어 대다",
"address_label" : "Address label",
"subaddress_title" : "하위 주소 목록", "subaddress_title" : "하위 주소 목록",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "Label naam", "new_subaddress_label_name" : "Label naam",
"new_subaddress_create" : "Creëren", "new_subaddress_create" : "Creëren",
"address_label" : "Address label",
"subaddress_title" : "Subadreslijst", "subaddress_title" : "Subadreslijst",

View file

@ -271,6 +271,7 @@
"new_subaddress_label_name" : "Nazwa etykiety", "new_subaddress_label_name" : "Nazwa etykiety",
"new_subaddress_create" : "Stwórz", "new_subaddress_create" : "Stwórz",
"address_label" : "Address label",
"subaddress_title" : "Lista podadresów", "subaddress_title" : "Lista podadresów",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "Nome", "new_subaddress_label_name" : "Nome",
"new_subaddress_create" : "Criar", "new_subaddress_create" : "Criar",
"address_label" : "Address label",
"subaddress_title" : "Sub-endereços", "subaddress_title" : "Sub-endereços",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "Имя", "new_subaddress_label_name" : "Имя",
"new_subaddress_create" : "Создать", "new_subaddress_create" : "Создать",
"address_label" : "Address label",
"subaddress_title" : "Список субадресов", "subaddress_title" : "Список субадресов",

View file

@ -267,6 +267,7 @@
"new_subaddress_label_name" : "Ім'я", "new_subaddress_label_name" : "Ім'я",
"new_subaddress_create" : "Створити", "new_subaddress_create" : "Створити",
"address_label" : "Address label",
"subaddress_title" : "Список Субадрес", "subaddress_title" : "Список Субадрес",

View file

@ -268,6 +268,7 @@
"new_subaddress_label_name" : "标签名称", "new_subaddress_label_name" : "标签名称",
"new_subaddress_create" : "创建", "new_subaddress_create" : "创建",
"address_label" : "Address label",
"subaddress_title" : "子地址列表", "subaddress_title" : "子地址列表",

View file

@ -209,6 +209,8 @@ abstract class Monero {
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex); String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
String getSubaddressLabel(Object wallet, int accountIndex, int addressIndex);
int getHeigthByDate({DateTime date}); int getHeigthByDate({DateTime date});
TransactionPriority getDefaultTransactionPriority(); TransactionPriority getDefaultTransactionPriority();
TransactionPriority deserializeMoneroTransactionPriority({int raw}); TransactionPriority deserializeMoneroTransactionPriority({int raw});