Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Repeated Addresses Bug #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions BRWallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static int _BRWalletContainsTx(BRWallet *wallet, const BRTransaction *tx)

static void _BRWalletUpdateBalance(BRWallet *wallet)
{
int isInvalid, isPending;
int isInvalid, isPending = 0;
uint64_t balance = 0, prevBalance = 0;
time_t now = time(NULL);
size_t i, j;
Expand Down Expand Up @@ -225,7 +225,6 @@ static void _BRWalletUpdateBalance(BRWallet *wallet)
if (isPending) {
BRSetAdd(wallet->pendingTx, tx);
array_add(wallet->balanceHist, balance);
continue;
}
}

Expand All @@ -239,12 +238,17 @@ static void _BRWalletUpdateBalance(BRWallet *wallet)

if (pkh && BRSetContains(wallet->allPKH, pkh)) {
BRSetAdd(wallet->usedPKH, (void *)pkh);
array_add(wallet->utxos, ((const BRUTXO) { tx->txHash, (uint32_t)j }));
balance += tx->outputs[j].amount;

if (!isPending) {
array_add(wallet->utxos, ((const BRUTXO) { tx->txHash, (uint32_t)j }));
balance += tx->outputs[j].amount;
}
}
}
}

if (isPending) continue;

// transaction ordering is not guaranteed, so check the entire UTXO set against the entire spent output set
for (j = array_count(wallet->utxos); j > 0; j--) {
if (! BRSetContains(wallet->spentOutputs, &wallet->utxos[j - 1])) continue;
Expand Down