mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-30 22:46:10 +00:00
add peg in / out labels and make 6 confs only show up for peg in / out
This commit is contained in:
parent
43e53c293c
commit
26a757f1f0
4 changed files with 35 additions and 9 deletions
|
@ -2085,6 +2085,13 @@ abstract class ElectrumWalletBase
|
|||
|
||||
final balances = await Future.wait(balanceFutures);
|
||||
|
||||
if (balances.isNotEmpty && balances.first['confirmed'] == null) {
|
||||
// if we got null balance responses from the server, set our connection status to lost and return our last known balance:
|
||||
print("got null balance responses from the server, setting connection status to lost");
|
||||
syncStatus = LostConnectionSyncStatus();
|
||||
return balance[currency] ?? ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
|
||||
}
|
||||
|
||||
for (var i = 0; i < balances.length; i++) {
|
||||
final addressRecord = addresses[i];
|
||||
final balance = balances[i];
|
||||
|
|
|
@ -1042,15 +1042,18 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
|
||||
bool hasMwebInput = false;
|
||||
bool hasMwebOutput = false;
|
||||
bool hasRegularInput = false;
|
||||
bool hasRegularOutput = false;
|
||||
|
||||
for (final output in transactionCredentials.outputs) {
|
||||
if (output.extractedAddress?.toLowerCase().contains("mweb") ?? false) {
|
||||
if (output.address.toLowerCase().contains("mweb") ||
|
||||
(output.extractedAddress?.toLowerCase().contains("mweb") ?? false)) {
|
||||
hasMwebOutput = true;
|
||||
break;
|
||||
}
|
||||
if (output.address.toLowerCase().contains("mweb")) {
|
||||
hasMwebOutput = true;
|
||||
break;
|
||||
if (!(output.address.toLowerCase().contains("mweb")) ||
|
||||
!(output.extractedAddress?.toLowerCase().contains("mweb") ?? false)) {
|
||||
hasRegularOutput = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1059,9 +1062,13 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
if (utxo.utxo.scriptType == SegwitAddresType.mweb) {
|
||||
hasMwebInput = true;
|
||||
}
|
||||
if (utxo.utxo.scriptType == SegwitAddresType.p2wpkh) {
|
||||
hasRegularInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool isPegIn = !hasMwebInput && hasMwebOutput;
|
||||
bool isPegOut = hasMwebInput && hasRegularOutput;
|
||||
bool isRegular = !hasMwebInput && !hasMwebOutput;
|
||||
tx.changeAddressOverride = (await (walletAddresses as LitecoinWalletAddresses)
|
||||
.getChangeAddress(isPegIn: isPegIn || isRegular))
|
||||
|
@ -1136,7 +1143,9 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
addressRecord.balance -= utxo.value.toInt();
|
||||
});
|
||||
transaction.inputAddresses?.addAll(addresses);
|
||||
|
||||
print("isPegIn: $isPegIn, isPegOut: $isPegOut");
|
||||
transaction.additionalInfo["isPegIn"] = isPegIn;
|
||||
transaction.additionalInfo["isPegOut"] = isPegOut;
|
||||
transactionHistory.addOne(transaction);
|
||||
await updateUnspent();
|
||||
await updateBalance();
|
||||
|
|
|
@ -25,6 +25,5 @@ abstract class TransactionInfo extends Object with Keyable {
|
|||
@override
|
||||
dynamic get keyIndex => id;
|
||||
|
||||
late Map<String, dynamic> additionalInfo;
|
||||
Map<String, dynamic> additionalInfo = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -69,9 +69,20 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
}
|
||||
break;
|
||||
case WalletType.litecoin:
|
||||
if (transaction.confirmations >= 0 && transaction.confirmations < 6) {
|
||||
return ' (${transaction.confirmations}/6)';
|
||||
bool isPegIn = (transaction.additionalInfo["isPegIn"] as bool?) ?? false;
|
||||
bool isPegOut = (transaction.additionalInfo["isPegOut"] as bool?) ?? false;
|
||||
bool isPegInOut = isPegIn || isPegOut;
|
||||
String str = '';
|
||||
if (isPegInOut && transaction.confirmations >= 0 && transaction.confirmations < 6) {
|
||||
str = " (${transaction.confirmations}/6)";
|
||||
}
|
||||
if (isPegIn) {
|
||||
str += " (Peg In)";
|
||||
}
|
||||
if (isPegOut) {
|
||||
str += " (Peg Out)";
|
||||
}
|
||||
return str;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue