mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-18 16:55:58 +00:00
minor code cleanup and minor peg-out fix
This commit is contained in:
parent
d9df5be3af
commit
579b9de496
2 changed files with 1 additions and 11 deletions
|
@ -1956,10 +1956,9 @@ abstract class ElectrumWalletBase
|
||||||
// that matches this received transaction, mark it as being from a peg out:
|
// that matches this received transaction, mark it as being from a peg out:
|
||||||
for (final tx2 in transactionHistory.transactions.values) {
|
for (final tx2 in transactionHistory.transactions.values) {
|
||||||
final heightDiff = ((tx2.height ?? 0) - (tx.height ?? 0)).abs();
|
final heightDiff = ((tx2.height ?? 0) - (tx.height ?? 0)).abs();
|
||||||
// this isn't a perfect matching algorithm since we don't have the right input/output information from these transaction models (the addresses are in different formats), but this should be more than good enough for now as it's extremely unlikely a user receives the EXACT same amount from 2 different sources and one of them is a peg out and the other isn't AND the fees are also exactly the same within 5 blocks of each other
|
// this isn't a perfect matching algorithm since we don't have the right input/output information from these transaction models (the addresses are in different formats), but this should be more than good enough for now as it's extremely unlikely a user receives the EXACT same amount from 2 different sources and one of them is a peg out and the other isn't WITHIN 5 blocks of each other
|
||||||
if (tx2.additionalInfo["isPegOut"] == true &&
|
if (tx2.additionalInfo["isPegOut"] == true &&
|
||||||
tx2.amount == tx.amount &&
|
tx2.amount == tx.amount &&
|
||||||
tx2.fee == tx.fee &&
|
|
||||||
heightDiff <= 5) {
|
heightDiff <= 5) {
|
||||||
tx.additionalInfo["fromPegOut"] = true;
|
tx.additionalInfo["fromPegOut"] = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1039,7 +1039,6 @@ 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;
|
bool hasRegularOutput = false;
|
||||||
|
|
||||||
for (final output in transactionCredentials.outputs) {
|
for (final output in transactionCredentials.outputs) {
|
||||||
|
@ -1067,9 +1066,6 @@ 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;
|
||||||
|
@ -1127,18 +1123,13 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||||
|
|
||||||
return tx
|
return tx
|
||||||
..addListener((transaction) async {
|
..addListener((transaction) async {
|
||||||
print(
|
|
||||||
"@@@@@@@@@@@@@@@@@@@@@@@@@############################# transaction: ${transaction.outputAddresses}");
|
|
||||||
final addresses = <String>{};
|
final addresses = <String>{};
|
||||||
transaction.inputAddresses?.forEach((id) async {
|
transaction.inputAddresses?.forEach((id) async {
|
||||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@ input address: $id");
|
|
||||||
final utxo = mwebUtxosBox.get(id);
|
final utxo = mwebUtxosBox.get(id);
|
||||||
// await mwebUtxosBox.delete(id); // gets deleted in checkMwebUtxosSpent
|
// await mwebUtxosBox.delete(id); // gets deleted in checkMwebUtxosSpent
|
||||||
if (utxo == null) return;
|
if (utxo == null) return;
|
||||||
// mark utxo as spent so we add it to the unconfirmed balance (as negative):
|
// mark utxo as spent so we add it to the unconfirmed balance (as negative):
|
||||||
utxo.spent = true;
|
utxo.spent = true;
|
||||||
print(
|
|
||||||
"@@@@@@@@@@@@@@@@@@@@@@@@@ spent utxo: ${utxo.outputId} ${utxo.height} ${utxo.value}");
|
|
||||||
await mwebUtxosBox.put(id, utxo);
|
await mwebUtxosBox.put(id, utxo);
|
||||||
final addressRecord = walletAddresses.allAddresses
|
final addressRecord = walletAddresses.allAddresses
|
||||||
.firstWhere((addressRecord) => addressRecord.address == utxo.address);
|
.firstWhere((addressRecord) => addressRecord.address == utxo.address);
|
||||||
|
|
Loading…
Reference in a new issue