mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 03:49:43 +00:00
fix current height
This commit is contained in:
parent
7205725b5c
commit
a2a24b1b72
2 changed files with 10 additions and 6 deletions
|
@ -6,6 +6,7 @@ import 'package:cw_core/transaction_direction.dart';
|
||||||
import 'package:cw_core/format_amount.dart';
|
import 'package:cw_core/format_amount.dart';
|
||||||
import 'package:cw_haven/api/transaction_history.dart';
|
import 'package:cw_haven/api/transaction_history.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:cw_haven/api/wallet.dart' as haven_wallet;
|
||||||
|
|
||||||
class HavenTransactionInfo extends TransactionInfo {
|
class HavenTransactionInfo extends TransactionInfo {
|
||||||
HavenTransactionInfo(this.id, this.height, this.direction, this.date, this.isPending, this.amount,
|
HavenTransactionInfo(this.id, this.height, this.direction, this.date, this.isPending, this.amount,
|
||||||
|
@ -57,14 +58,15 @@ class HavenTransactionInfo extends TransactionInfo {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? unlockTimeFormatted() {
|
String? unlockTimeFormatted() {
|
||||||
if (direction == TransactionDirection.outgoing || unlockTime < (height + 10)) {
|
final currentHeight = haven_wallet.getCurrentHeight();
|
||||||
|
if (direction == TransactionDirection.outgoing || unlockTime < (currentHeight + 10)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlockTime < 500000000) {
|
if (unlockTime < 500000000) {
|
||||||
return (unlockTime - height) * 2 > 500000
|
return (unlockTime - currentHeight) * 2 > 500000
|
||||||
? '>1 year'
|
? '>1 year'
|
||||||
: '~${(unlockTime - height) * 2} minutes';
|
: '~${(unlockTime - currentHeight) * 2} minutes';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:cw_core/transaction_direction.dart';
|
||||||
import 'package:cw_core/format_amount.dart';
|
import 'package:cw_core/format_amount.dart';
|
||||||
import 'package:cw_monero/api/transaction_history.dart';
|
import 'package:cw_monero/api/transaction_history.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:cw_monero/api/wallet.dart' as monero_wallet;
|
||||||
|
|
||||||
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,
|
||||||
|
@ -63,14 +64,15 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? unlockTimeFormatted() {
|
String? unlockTimeFormatted() {
|
||||||
if (direction == TransactionDirection.outgoing || unlockTime < (height + 10)) {
|
final currentHeight = monero_wallet.getCurrentHeight();
|
||||||
|
if (direction == TransactionDirection.outgoing || unlockTime < (currentHeight + 10)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlockTime < 500000000) {
|
if (unlockTime < 500000000) {
|
||||||
return (unlockTime - height) * 2 > 500000
|
return (unlockTime - currentHeight) * 2 > 500000
|
||||||
? '>1 year'
|
? '>1 year'
|
||||||
: '~${(unlockTime - height) * 2} minutes';
|
: '~${(unlockTime - currentHeight) * 2} minutes';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
var locked = DateTime.fromMillisecondsSinceEpoch(unlockTime).compareTo(DateTime.now());
|
||||||
|
|
Loading…
Reference in a new issue