fix: Handle sent to self transactions when sent to a change address

This commit is contained in:
julian 2023-05-25 09:24:07 -06:00
parent 3d5e86dc6f
commit 74d3175d87

View file

@ -148,8 +148,13 @@ mixin ElectrumXParsing {
type = TransactionType.outgoing;
amount = amountSentFromWallet - changeAmount - fee;
final possible =
outputAddresses.difference(myChangeReceivedOnAddresses).first;
// non wallet addresses found in tx outputs
final nonWalletOutAddresses = outputAddresses.difference(
myChangeReceivedOnAddresses,
);
if (nonWalletOutAddresses.isNotEmpty) {
final possible = nonWalletOutAddresses.first;
if (transactionAddress.value != possible) {
transactionAddress = Address(
@ -162,6 +167,13 @@ mixin ElectrumXParsing {
publicKey: [],
);
}
} else {
// some other type of tx where the receiving address is
// one of my change addresses
type = TransactionType.sentToSelf;
amount = changeAmount;
}
} else {
// incoming tx
type = TransactionType.incoming;