Skip to content

Commit 6cecb7b

Browse files
committed
AddToWalletIfInvolvingMe should test pIndex, not posInBlock
Adaptation of btc@714e4ad13d805d45210d390fae83790360f47d9a
1 parent 73499ff commit 6cecb7b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/wallet/wallet.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,9 +1037,9 @@ void CWallet::AddExternalNotesDataToTx(CWalletTx& wtx) const
10371037
/**
10381038
* Add a transaction to the wallet, or update it. pIndex and posInBlock should
10391039
* be set when the transaction was known to be included in a block. When
1040-
* posInBlock = SYNC_TRANSACTION_NOT_IN_BLOCK (-1) , then wallet state is not
1041-
* updated in AddToWallet, but notifications happen and cached balances are
1042-
* marked dirty.
1040+
* pIndex == NULL, then wallet state is not updated in AddToWallet, but
1041+
* notifications happen and cached balances are marked dirty.
1042+
*
10431043
* If fUpdate is true, existing transactions will be updated.
10441044
* TODO: One exception to this is that the abandoned state is cleared under the
10451045
* assumption that any further notification of a transaction that was considered
@@ -1053,7 +1053,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const uint256
10531053
{
10541054
AssertLockHeld(cs_wallet);
10551055

1056-
if (posInBlock != -1 && !tx.HasZerocoinSpendInputs() && !tx.IsCoinBase()) {
1056+
if (!blockHash.IsNull() && !tx.HasZerocoinSpendInputs() && !tx.IsCoinBase()) {
10571057
for (const CTxIn& txin : tx.vin) {
10581058
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range(txin.prevout);
10591059
while (range.first != range.second) {
@@ -1102,8 +1102,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const uint256
11021102
}
11031103

11041104
// Get merkle branch if transaction was found in a block
1105-
if (posInBlock != -1)
1105+
if (!blockHash.IsNull()) {
11061106
wtx.SetMerkleBranch(blockHash, posInBlock);
1107+
}
11071108

11081109
return AddToWallet(wtx, false);
11091110
}

0 commit comments

Comments
 (0)