diff options
| author | Wladimir J. van der Laan <[email protected]> | 2015-07-02 19:58:11 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2015-07-02 19:59:50 +0200 |
| commit | 3203a0832adf72f4303c7ab1a7a6046a6dd14778 (patch) | |
| tree | 9222e3cb6e0a9e602fedec702d7497e397d06c00 /src | |
| parent | Merge pull request #6133 (diff) | |
| parent | Add txn_clone.py test (diff) | |
| download | discoin-3203a0832adf72f4303c7ab1a7a6046a6dd14778.tar.xz discoin-3203a0832adf72f4303c7ab1a7a6046a6dd14778.zip | |
Merge pull request #5881
5d34e16 Add txn_clone.py test (Tom Harding)
defd2d5 Better txn_doublespend.py test (Tom Harding)
b2b3619 Implement CTransaction::IsEquivalentTo(...) (Tom Harding)
Diffstat (limited to 'src')
| -rw-r--r-- | src/primitives/transaction.cpp | 9 | ||||
| -rw-r--r-- | src/primitives/transaction.h | 3 | ||||
| -rw-r--r-- | src/wallet/wallet.cpp | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 606dbea79..d864a9b6d 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -87,6 +87,15 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) { return *this; } +bool CTransaction::IsEquivalentTo(const CTransaction& tx) const +{ + CMutableTransaction tx1 = *this; + CMutableTransaction tx2 = tx; + for (unsigned int i = 0; i < tx1.vin.size(); i++) tx1.vin[i].scriptSig = CScript(); + for (unsigned int i = 0; i < tx2.vin.size(); i++) tx2.vin[i].scriptSig = CScript(); + return CTransaction(tx1) == CTransaction(tx2); +} + CAmount CTransaction::GetValueOut() const { CAmount nValueOut = 0; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 6cfd93a9a..0c9ebb7b8 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -222,6 +222,9 @@ public: return hash; } + // True if only scriptSigs are different + bool IsEquivalentTo(const CTransaction& tx) const; + // Return sum of txouts. CAmount GetValueOut() const; // GetValueIn() is a method on CCoinsViewCache, because diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 238f62a57..44e28de0c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -419,6 +419,7 @@ void CWallet::SyncMetaData(pair<TxSpends::iterator, TxSpends::iterator> range) const uint256& hash = it->second; CWalletTx* copyTo = &mapWallet[hash]; if (copyFrom == copyTo) continue; + if (!copyFrom->IsEquivalentTo(*copyTo)) continue; copyTo->mapValue = copyFrom->mapValue; copyTo->vOrderForm = copyFrom->vOrderForm; // fTimeReceivedIsTxTime not copied on purpose |