Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit b62a4f0

Browse files
committed
a more sanitized check for received transaction: check commitment whenever receive a tranaction
1 parent 993f400 commit b62a4f0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/wallet.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7040,10 +7040,20 @@ bool CWallet::RevealTxOutAmount(const CTransaction& tx, const CTxOut& out, CAmou
70407040
uint256 mask = out.maskValue.mask;
70417041
CKey decodedMask;
70427042
ECDHInfo::Decode(mask.begin(), val.begin(), sharedSec, decodedMask, amount);
7043-
amountMap[out.scriptPubKey] = amount;
7044-
blindMap[out.scriptPubKey] = decodedMask;
7045-
blind.Set(blindMap[out.scriptPubKey].begin(), blindMap[out.scriptPubKey].end(), true);
7046-
return true;
7043+
std::vector<unsigned char> commitment;
7044+
if (CreateCommitment(decodedMask.begin(), amount, commitment)) {
7045+
//make sure the amount and commitment are matched
7046+
if (commitment == out.commitment) {
7047+
amountMap[out.scriptPubKey] = amount;
7048+
blindMap[out.scriptPubKey] = decodedMask;
7049+
blind.Set(blindMap[out.scriptPubKey].begin(), blindMap[out.scriptPubKey].end(), true);
7050+
return true;
7051+
} else {
7052+
amount = 0;
7053+
amountMap[out.scriptPubKey] = amount;
7054+
return false;
7055+
}
7056+
}
70477057
}
70487058
}
70497059
}

0 commit comments

Comments
 (0)