mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-25 20:40:40 +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
cw_bitcoin/lib
cw_core/lib
lib/view_model/dashboard
|
@ -2085,6 +2085,13 @@ abstract class ElectrumWalletBase
|
||||||
|
|
||||||
final balances = await Future.wait(balanceFutures);
|
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++) {
|
for (var i = 0; i < balances.length; i++) {
|
||||||
final addressRecord = addresses[i];
|
final addressRecord = addresses[i];
|
||||||
final balance = balances[i];
|
final balance = balances[i];
|
||||||
|
|
|
@ -1042,15 +1042,18 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
|
|
||||||
bool hasMwebInput = false;
|
bool hasMwebInput = false;
|
||||||
bool hasMwebOutput = false;
|
bool hasMwebOutput = false;
|
||||||
|
bool hasRegularInput = false;
|
||||||
|
bool hasRegularOutput = false;
|
||||||
|
|
||||||
for (final output in transactionCredentials.outputs) {
|
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;
|
hasMwebOutput = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (output.address.toLowerCase().contains("mweb")) {
|
if (!(output.address.toLowerCase().contains("mweb")) ||
|
||||||
hasMwebOutput = true;
|
!(output.extractedAddress?.toLowerCase().contains("mweb") ?? false)) {
|
||||||
break;
|
hasRegularOutput = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,9 +1062,13 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
if (utxo.utxo.scriptType == SegwitAddresType.mweb) {
|
if (utxo.utxo.scriptType == SegwitAddresType.mweb) {
|
||||||
hasMwebInput = true;
|
hasMwebInput = true;
|
||||||
}
|
}
|
||||||
|
if (utxo.utxo.scriptType == SegwitAddresType.p2wpkh) {
|
||||||
|
hasRegularInput = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isPegIn = !hasMwebInput && hasMwebOutput;
|
bool isPegIn = !hasMwebInput && hasMwebOutput;
|
||||||
|
bool isPegOut = hasMwebInput && hasRegularOutput;
|
||||||
bool isRegular = !hasMwebInput && !hasMwebOutput;
|
bool isRegular = !hasMwebInput && !hasMwebOutput;
|
||||||
tx.changeAddressOverride = (await (walletAddresses as LitecoinWalletAddresses)
|
tx.changeAddressOverride = (await (walletAddresses as LitecoinWalletAddresses)
|
||||||
.getChangeAddress(isPegIn: isPegIn || isRegular))
|
.getChangeAddress(isPegIn: isPegIn || isRegular))
|
||||||
|
@ -1136,7 +1143,9 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
addressRecord.balance -= utxo.value.toInt();
|
addressRecord.balance -= utxo.value.toInt();
|
||||||
});
|
});
|
||||||
transaction.inputAddresses?.addAll(addresses);
|
transaction.inputAddresses?.addAll(addresses);
|
||||||
|
print("isPegIn: $isPegIn, isPegOut: $isPegOut");
|
||||||
|
transaction.additionalInfo["isPegIn"] = isPegIn;
|
||||||
|
transaction.additionalInfo["isPegOut"] = isPegOut;
|
||||||
transactionHistory.addOne(transaction);
|
transactionHistory.addOne(transaction);
|
||||||
await updateUnspent();
|
await updateUnspent();
|
||||||
await updateBalance();
|
await updateBalance();
|
||||||
|
|
|
@ -25,6 +25,5 @@ abstract class TransactionInfo extends Object with Keyable {
|
||||||
@override
|
@override
|
||||||
dynamic get keyIndex => id;
|
dynamic get keyIndex => id;
|
||||||
|
|
||||||
late Map<String, dynamic> additionalInfo;
|
Map<String, dynamic> additionalInfo = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,9 +69,20 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WalletType.litecoin:
|
case WalletType.litecoin:
|
||||||
if (transaction.confirmations >= 0 && transaction.confirmations < 6) {
|
bool isPegIn = (transaction.additionalInfo["isPegIn"] as bool?) ?? false;
|
||||||
return ' (${transaction.confirmations}/6)';
|
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:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue