Fix missing receiving address for incoming transactions

This commit is contained in:
likho 2023-10-06 11:55:24 +02:00
parent c08bdd3c08
commit e18c06fbcd
2 changed files with 7 additions and 4 deletions

View file

@ -1485,7 +1485,7 @@ class EpicCashWallet extends CoinServiceAPI
DateTime dt = DateTime.parse(tx.creationTs); DateTime dt = DateTime.parse(tx.creationTs);
String? slateId = tx.txSlateId; String? slateId = tx.txSlateId == "null" ? null : tx.txSlateId;
String address = slatesToCommits[slateId] String address = slatesToCommits[slateId]
?[tx.txType == EpicTransactionType.TxReceived ? "from" : "to"] as String? ?? ?[tx.txType == EpicTransactionType.TxReceived ? "from" : "to"] as String? ??
""; "";
@ -1537,11 +1537,13 @@ class EpicCashWallet extends CoinServiceAPI
.valueEqualTo(address) .valueEqualTo(address)
.findFirst(); .findFirst();
if (transactionAddress == null) { if (transactionAddress!.value.isEmpty) {
if (isIncoming) { if (isIncoming) {
//Use current receiving address as address
String receivingAddress = await currentReceivingAddress;
transactionAddress = isar_models.Address( transactionAddress = isar_models.Address(
walletId: walletId, walletId: walletId,
value: address, value: receivingAddress,
publicKey: [], publicKey: [],
derivationIndex: 0, derivationIndex: 0,
derivationPath: null, derivationPath: null,

View file

@ -277,14 +277,15 @@ abstract class LibEpiccash {
if (result.toUpperCase().contains("ERROR")) { if (result.toUpperCase().contains("ERROR")) {
throw Exception("Error getting epic transactions ${result.toString()}"); throw Exception("Error getting epic transactions ${result.toString()}");
} }
//Parse the returned data as an EpicTransaction //Parse the returned data as an EpicTransaction
List<EpicTransaction> finalResult = []; List<EpicTransaction> finalResult = [];
var jsonResult = json.decode(result) as List; var jsonResult = json.decode(result) as List;
for (var tx in jsonResult) { for (var tx in jsonResult) {
EpicTransaction itemTx = EpicTransaction.fromJson(tx); EpicTransaction itemTx = EpicTransaction.fromJson(tx);
finalResult.add(itemTx); finalResult.add(itemTx);
} }
return finalResult; return finalResult;
} catch (e) { } catch (e) {
throw ("Error getting epic transactions : ${e.toString()}"); throw ("Error getting epic transactions : ${e.toString()}");