mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-24 19:25:52 +00:00
fix: incorrect number of confirms for monero (and wownero) outputs and transactions
This commit is contained in:
parent
ad667025ac
commit
0d1bf5895d
3 changed files with 19 additions and 5 deletions
|
@ -77,7 +77,9 @@ class UTXO {
|
|||
int getConfirmations(int currentChainHeight) {
|
||||
if (blockTime == null || blockHash == null) return 0;
|
||||
if (blockHeight == null || blockHeight! <= 0) return 0;
|
||||
return max(0, currentChainHeight - (blockHeight! - 1));
|
||||
return _isMonero()
|
||||
? max(0, currentChainHeight - (blockHeight!))
|
||||
: max(0, currentChainHeight - (blockHeight! - 1));
|
||||
}
|
||||
|
||||
bool isConfirmed(
|
||||
|
@ -90,6 +92,11 @@ class UTXO {
|
|||
(isCoinbase ? minimumCoinbaseConfirms : minimumConfirms);
|
||||
}
|
||||
|
||||
// fuzzy
|
||||
bool _isMonero() {
|
||||
return keyImage != null;
|
||||
}
|
||||
|
||||
@ignore
|
||||
String? get keyImage {
|
||||
if (otherData == null) {
|
||||
|
@ -98,7 +105,7 @@ class UTXO {
|
|||
|
||||
try {
|
||||
final map = jsonDecode(otherData!) as Map;
|
||||
return map["keyImage"] as String;
|
||||
return map[UTXOOtherDataKeys.keyImage] as String;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
|
@ -169,3 +176,8 @@ class UTXO {
|
|||
@ignore
|
||||
int get hashCode => Object.hashAll([walletId, txid, vout]);
|
||||
}
|
||||
|
||||
abstract final class UTXOOtherDataKeys {
|
||||
static const keyImage = "keyImage";
|
||||
static const spent = "spent";
|
||||
}
|
||||
|
|
|
@ -109,7 +109,9 @@ class TransactionV2 {
|
|||
|
||||
int getConfirmations(int currentChainHeight) {
|
||||
if (height == null || height! <= 0) return 0;
|
||||
return max(0, currentChainHeight - (height! - 1));
|
||||
return _isMonero()
|
||||
? max(0, currentChainHeight - (height!))
|
||||
: max(0, currentChainHeight - (height! - 1));
|
||||
}
|
||||
|
||||
bool isConfirmed(
|
||||
|
|
|
@ -1017,8 +1017,8 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
|
|||
.findFirst();
|
||||
|
||||
final otherDataMap = {
|
||||
"keyImage": rawUTXO.keyImage,
|
||||
"spent": rawUTXO.spent,
|
||||
UTXOOtherDataKeys.keyImage: rawUTXO.keyImage,
|
||||
UTXOOtherDataKeys.spent: rawUTXO.spent,
|
||||
};
|
||||
|
||||
final utxo = UTXO(
|
||||
|
|
Loading…
Reference in a new issue