mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-07 03:19:31 +00:00
cast unlock_time type
This commit is contained in:
parent
832ff62044
commit
ec94c02148
4 changed files with 31 additions and 25 deletions
|
@ -44,4 +44,5 @@ class TransactionInfoRow extends Struct {
|
|||
String getHash() => hash.toDartString();
|
||||
String getPaymentId() => paymentId.toDartString();
|
||||
String getAssetType() => assetType.toDartString();
|
||||
int getUnlockTime() => unlockTime >> 32;
|
||||
}
|
||||
|
|
|
@ -8,11 +8,10 @@ import 'package:cw_haven/api/transaction_history.dart';
|
|||
import 'package:intl/intl.dart';
|
||||
|
||||
class HavenTransactionInfo extends TransactionInfo {
|
||||
HavenTransactionInfo(this.id, this.height, this.direction, this.date,
|
||||
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee, this.unlockTime,
|
||||
this.confirmations);
|
||||
HavenTransactionInfo(this.id, this.height, this.direction, this.date, this.isPending, this.amount,
|
||||
this.accountIndex, this.addressIndex, this.fee, this.unlockTime, this.confirmations);
|
||||
|
||||
HavenTransactionInfo.fromRow(TransactionInfoRow row)
|
||||
HavenTransactionInfo.fromRow(TransactionInfoRow row)
|
||||
: id = row.getHash(),
|
||||
height = row.blockHeight,
|
||||
direction = TransactionDirection.parseFromInt(row.direction),
|
||||
|
@ -21,9 +20,10 @@ class HavenTransactionInfo extends TransactionInfo {
|
|||
amount = row.getAmount(),
|
||||
accountIndex = row.subaddrAccount,
|
||||
addressIndex = row.subaddrIndex,
|
||||
unlockTime = row.unlockTime,
|
||||
unlockTime = row.getUnlockTime(),
|
||||
confirmations = row.confirmations,
|
||||
key = null, //getTxKey(row.getHash()),
|
||||
key = null,
|
||||
//getTxKey(row.getHash()),
|
||||
fee = row.fee,
|
||||
assetType = row.getAssetType();
|
||||
|
||||
|
@ -44,8 +44,7 @@ class HavenTransactionInfo extends TransactionInfo {
|
|||
String? key;
|
||||
|
||||
@override
|
||||
String amountFormatted() =>
|
||||
'${formatAmount(moneroAmountToString(amount: amount))} $assetType';
|
||||
String amountFormatted() => '${formatAmount(moneroAmountToString(amount: amount))} $assetType';
|
||||
|
||||
@override
|
||||
String fiatAmount() => _fiatAmount ?? '';
|
||||
|
@ -54,8 +53,7 @@ class HavenTransactionInfo extends TransactionInfo {
|
|||
void changeFiatAmount(String amount) => _fiatAmount = formatAmount(amount);
|
||||
|
||||
@override
|
||||
String feeFormatted() =>
|
||||
'${formatAmount(moneroAmountToString(amount: fee))} $assetType';
|
||||
String feeFormatted() => '${formatAmount(moneroAmountToString(amount: fee))} $assetType';
|
||||
|
||||
@override
|
||||
String? unlockTimeFormatted() {
|
||||
|
@ -68,12 +66,15 @@ class HavenTransactionInfo extends TransactionInfo {
|
|||
? '>1 year'
|
||||
: '~${(unlockTime - height) * 2} minutes';
|
||||
}
|
||||
|
||||
var locked = DateTime.fromMicrosecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
||||
final DateFormat formatter = DateFormat('yyyy-MM-dd HH:mm:ss');
|
||||
final String formattedUnlockTime =
|
||||
formatter.format(DateTime.fromMicrosecondsSinceEpoch(unlockTime));
|
||||
|
||||
return locked >= 0 ? '$formattedUnlockTime' : null;
|
||||
try {
|
||||
var locked = DateTime.fromMicrosecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
||||
final DateFormat formatter = DateFormat('yyyy-MM-dd HH:mm:ss');
|
||||
final String formattedUnlockTime =
|
||||
formatter.format(DateTime.fromMicrosecondsSinceEpoch(unlockTime));
|
||||
return locked >= 0 ? '$formattedUnlockTime' : null;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,5 @@ class TransactionInfoRow extends Struct {
|
|||
bool getIsPending() => isPending != 0;
|
||||
String getHash() => hash.toDartString();
|
||||
String getPaymentId() => paymentId.toDartString();
|
||||
int getUnlockTime() => unlockTime >> 32;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
|||
amount = row.getAmount(),
|
||||
accountIndex = row.subaddrAccount,
|
||||
addressIndex = row.subaddrIndex,
|
||||
unlockTime = row.unlockTime,
|
||||
unlockTime = row.getUnlockTime(),
|
||||
confirmations = row.confirmations,
|
||||
key = getTxKey(row.getHash()),
|
||||
fee = row.fee {
|
||||
|
@ -72,12 +72,15 @@ class MoneroTransactionInfo extends TransactionInfo {
|
|||
? '>1 year'
|
||||
: '~${(unlockTime - height) * 2} minutes';
|
||||
}
|
||||
|
||||
var locked = DateTime.fromMicrosecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
||||
final DateFormat formatter = DateFormat('yyyy-MM-dd HH:mm:ss');
|
||||
final String formattedUnlockTime =
|
||||
formatter.format(DateTime.fromMicrosecondsSinceEpoch(unlockTime));
|
||||
|
||||
return locked >= 0 ? '$formattedUnlockTime' : null;
|
||||
try {
|
||||
var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
||||
final DateFormat formatter = DateFormat('yyyy-MM-dd HH:mm:ss');
|
||||
final String formattedUnlockTime =
|
||||
formatter.format(DateTime.fromMillisecondsSinceEpoch(unlockTime));
|
||||
return locked >= 0 ? '$formattedUnlockTime' : null;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue