mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-06 00:34:39 +00:00
add unlock time to monero transaction
This commit is contained in:
parent
ef0c7e3ada
commit
b180445a7b
7 changed files with 33 additions and 1 deletions
cw_bitcoin/lib
cw_core/lib
cw_haven/lib
cw_monero
lib/view_model
|
@ -235,4 +235,6 @@ class ElectrumTransactionInfo extends TransactionInfo {
|
||||||
m['fee'] = fee;
|
m['fee'] = fee;
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
@override
|
||||||
|
String? unlockTimeFormatted() => null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,12 @@ abstract class TransactionInfo extends Object with Keyable {
|
||||||
late DateTime date;
|
late DateTime date;
|
||||||
late int height;
|
late int height;
|
||||||
late int confirmations;
|
late int confirmations;
|
||||||
|
int? unlockTime;
|
||||||
String amountFormatted();
|
String amountFormatted();
|
||||||
String fiatAmount();
|
String fiatAmount();
|
||||||
String? feeFormatted();
|
String? feeFormatted();
|
||||||
void changeFiatAmount(String amount);
|
void changeFiatAmount(String amount);
|
||||||
|
String? unlockTimeFormatted();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
dynamic get keyIndex => id;
|
dynamic get keyIndex => id;
|
||||||
|
|
|
@ -66,4 +66,7 @@ class HavenTransactionInfo extends TransactionInfo {
|
||||||
@override
|
@override
|
||||||
String feeFormatted() =>
|
String feeFormatted() =>
|
||||||
'${formatAmount(moneroAmountToString(amount: fee))} $assetType';
|
'${formatAmount(moneroAmountToString(amount: fee))} $assetType';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? unlockTimeFormatted() => null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,7 @@ extern "C"
|
||||||
uint64_t blockHeight;
|
uint64_t blockHeight;
|
||||||
uint64_t confirmations;
|
uint64_t confirmations;
|
||||||
uint32_t subaddrAccount;
|
uint32_t subaddrAccount;
|
||||||
|
uint64_t unlockTime;
|
||||||
int8_t direction;
|
int8_t direction;
|
||||||
int8_t isPending;
|
int8_t isPending;
|
||||||
uint32_t subaddrIndex;
|
uint32_t subaddrIndex;
|
||||||
|
@ -152,6 +153,7 @@ extern "C"
|
||||||
std::set<uint32_t>::iterator it = transaction->subaddrIndex().begin();
|
std::set<uint32_t>::iterator it = transaction->subaddrIndex().begin();
|
||||||
subaddrIndex = *it;
|
subaddrIndex = *it;
|
||||||
confirmations = transaction->confirmations();
|
confirmations = transaction->confirmations();
|
||||||
|
unlockTime = transaction->unlockTime();
|
||||||
datetime = static_cast<int64_t>(transaction->timestamp());
|
datetime = static_cast<int64_t>(transaction->timestamp());
|
||||||
direction = transaction->direction();
|
direction = transaction->direction();
|
||||||
isPending = static_cast<int8_t>(transaction->isPending());
|
isPending = static_cast<int8_t>(transaction->isPending());
|
||||||
|
|
|
@ -14,6 +14,9 @@ class TransactionInfoRow extends Struct {
|
||||||
@Uint64()
|
@Uint64()
|
||||||
external int confirmations;
|
external int confirmations;
|
||||||
|
|
||||||
|
@Uint64()
|
||||||
|
external int unlockTime;
|
||||||
|
|
||||||
@Uint32()
|
@Uint32()
|
||||||
external int subaddrAccount;
|
external int subaddrAccount;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import 'package:cw_monero/api/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,
|
||||||
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee);
|
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee, this.unlockTime);
|
||||||
|
|
||||||
MoneroTransactionInfo.fromMap(Map<String, Object?> map)
|
MoneroTransactionInfo.fromMap(Map<String, Object?> map)
|
||||||
: id = (map['hash'] ?? '') as String,
|
: id = (map['hash'] ?? '') as String,
|
||||||
|
@ -22,6 +22,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
amount = map['amount'] as int,
|
amount = map['amount'] as int,
|
||||||
accountIndex = int.parse(map['accountIndex'] as String),
|
accountIndex = int.parse(map['accountIndex'] as String),
|
||||||
addressIndex = map['addressIndex'] as int,
|
addressIndex = map['addressIndex'] as int,
|
||||||
|
unlockTime = map['unlockTime'] as int,
|
||||||
key = getTxKey((map['hash'] ?? '') as String),
|
key = getTxKey((map['hash'] ?? '') as String),
|
||||||
fee = map['fee'] as int ?? 0 {
|
fee = map['fee'] as int ?? 0 {
|
||||||
additionalInfo = <String, dynamic>{
|
additionalInfo = <String, dynamic>{
|
||||||
|
@ -41,6 +42,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
amount = row.getAmount(),
|
amount = row.getAmount(),
|
||||||
accountIndex = row.subaddrAccount,
|
accountIndex = row.subaddrAccount,
|
||||||
addressIndex = row.subaddrIndex,
|
addressIndex = row.subaddrIndex,
|
||||||
|
unlockTime = row.unlockTime,
|
||||||
key = getTxKey(row.getHash()),
|
key = getTxKey(row.getHash()),
|
||||||
fee = row.fee {
|
fee = row.fee {
|
||||||
additionalInfo = <String, dynamic>{
|
additionalInfo = <String, dynamic>{
|
||||||
|
@ -59,6 +61,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
final int amount;
|
final int amount;
|
||||||
final int fee;
|
final int fee;
|
||||||
final int addressIndex;
|
final int addressIndex;
|
||||||
|
final int unlockTime;
|
||||||
String? recipientAddress;
|
String? recipientAddress;
|
||||||
String? key;
|
String? key;
|
||||||
String? _fiatAmount;
|
String? _fiatAmount;
|
||||||
|
@ -76,4 +79,17 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
@override
|
@override
|
||||||
String feeFormatted() =>
|
String feeFormatted() =>
|
||||||
'${formatAmount(moneroAmountToString(amount: fee))} XMR';
|
'${formatAmount(moneroAmountToString(amount: fee))} XMR';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? unlockTimeFormatted() {
|
||||||
|
final formattedTime = unlockTime * 2;
|
||||||
|
if (direction == TransactionDirection.outgoing || unlockTime == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formattedTime > 500000) {
|
||||||
|
return '>1 year';
|
||||||
|
}
|
||||||
|
return '~ $formattedTime minutes';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,12 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
final key = tx.additionalInfo['key'] as String?;
|
final key = tx.additionalInfo['key'] as String?;
|
||||||
final accountIndex = tx.additionalInfo['accountIndex'] as int;
|
final accountIndex = tx.additionalInfo['accountIndex'] as int;
|
||||||
final addressIndex = tx.additionalInfo['addressIndex'] as int;
|
final addressIndex = tx.additionalInfo['addressIndex'] as int;
|
||||||
|
final unlockTimeFormatted = tx.unlockTimeFormatted();
|
||||||
final feeFormatted = tx.feeFormatted();
|
final feeFormatted = tx.feeFormatted();
|
||||||
final _items = [
|
final _items = [
|
||||||
|
if (unlockTimeFormatted != null)
|
||||||
|
StandartListItem(
|
||||||
|
title: 'Unlock time', value: unlockTimeFormatted),
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
title: S.current.transaction_details_transaction_id, value: tx.id),
|
title: S.current.transaction_details_transaction_id, value: tx.id),
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
|
|
Loading…
Reference in a new issue