Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | |||||
* Legacy class used for deserializing vtxPrev for backwards compatibility. | * Legacy class used for deserializing vtxPrev for backwards compatibility. | ||||
* vtxPrev was removed in commit 93a18a3650292afbb441a47d1fa1b94aeb0164e3, | * vtxPrev was removed in commit 93a18a3650292afbb441a47d1fa1b94aeb0164e3, | ||||
* but old wallet.dat files may still contain vtxPrev vectors of CMerkleTxs. | * but old wallet.dat files may still contain vtxPrev vectors of CMerkleTxs. | ||||
* These need to get deserialized for field alignment when deserializing | * These need to get deserialized for field alignment when deserializing | ||||
* a CWalletTx, but the deserialized values are discarded. | * a CWalletTx, but the deserialized values are discarded. | ||||
*/ | */ | ||||
class CMerkleTx { | class CMerkleTx { | ||||
public: | public: | ||||
ADD_SERIALIZE_METHODS; | template <typename Stream> void Unserialize(Stream &s) { | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
CTransactionRef tx; | CTransactionRef tx; | ||||
BlockHash hashBlock; | BlockHash hashBlock; | ||||
int nIndex = 0; | |||||
// For compatibility with older versions. | |||||
std::vector<uint256> vMerkleBranch; | std::vector<uint256> vMerkleBranch; | ||||
READWRITE(tx); | int nIndex = 0; | ||||
READWRITE(hashBlock); | |||||
READWRITE(vMerkleBranch); | s >> tx >> hashBlock >> vMerkleBranch >> nIndex; | ||||
READWRITE(nIndex); | |||||
} | } | ||||
}; | }; | ||||
// Get the marginal bytes of spending the specified output | // Get the marginal bytes of spending the specified output | ||||
int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, | int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, | ||||
bool use_max_sig = false); | bool use_max_sig = false); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | public: | ||||
* An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest | * An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest | ||||
* block in the chain we know this or any in-wallet dependency conflicts | * block in the chain we know this or any in-wallet dependency conflicts | ||||
* with. Older clients interpret nIndex == -1 as unconfirmed for backward | * with. Older clients interpret nIndex == -1 as unconfirmed for backward | ||||
* compatibility. | * compatibility. | ||||
*/ | */ | ||||
int nIndex; | int nIndex; | ||||
template <typename Stream> void Serialize(Stream &s) const { | template <typename Stream> void Serialize(Stream &s) const { | ||||
char fSpent = false; | |||||
mapValue_t mapValueCopy = mapValue; | mapValue_t mapValueCopy = mapValue; | ||||
mapValueCopy["fromaccount"] = ""; | mapValueCopy["fromaccount"] = ""; | ||||
WriteOrderPos(nOrderPos, mapValueCopy); | WriteOrderPos(nOrderPos, mapValueCopy); | ||||
if (nTimeSmart) { | if (nTimeSmart) { | ||||
mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart); | mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart); | ||||
} | } | ||||
//! Used to be vMerkleBranch | //! Used to be vMerkleBranch | ||||
std::vector<uint256> dummy_vector; | std::vector<char> dummy_vector1; | ||||
s << tx << hashBlock << dummy_vector << nIndex; | |||||
//! Used to be vtxPrev | //! Used to be vtxPrev | ||||
std::vector<CMerkleTx> vUnused; | std::vector<char> dummy_vector2; | ||||
s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime | //! Used to be fSpent | ||||
<< nTimeReceived << fFromMe << fSpent; | char dummy_char = false; | ||||
s << tx << hashBlock << dummy_vector1 << nIndex << dummy_vector2 | |||||
<< mapValueCopy << vOrderForm << fTimeReceivedIsTxTime | |||||
<< nTimeReceived << fFromMe << dummy_char; | |||||
} | } | ||||
template <typename Stream> void Unserialize(Stream &s) { | template <typename Stream> void Unserialize(Stream &s) { | ||||
Init(nullptr); | Init(nullptr); | ||||
char fSpent; | |||||
//! Used to be vMerkleBranch | //! Used to be vMerkleBranch | ||||
std::vector<uint256> dummy_vector; | std::vector<uint256> dummy_vector1; | ||||
s >> tx >> hashBlock >> dummy_vector >> nIndex; | |||||
//! Used to be vtxPrev | //! Used to be vtxPrev | ||||
std::vector<CMerkleTx> vUnused; | std::vector<CMerkleTx> dummy_vector2; | ||||
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> | //! Used to be fSpent | ||||
nTimeReceived >> fFromMe >> fSpent; | char dummy_char; | ||||
s >> tx >> hashBlock >> dummy_vector1 >> nIndex >> dummy_vector2 >> | |||||
mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> | |||||
fFromMe >> dummy_char; | |||||
ReadOrderPos(nOrderPos, mapValue); | ReadOrderPos(nOrderPos, mapValue); | ||||
nTimeSmart = mapValue.count("timesmart") | nTimeSmart = mapValue.count("timesmart") | ||||
? (unsigned int)atoi64(mapValue["timesmart"]) | ? (unsigned int)atoi64(mapValue["timesmart"]) | ||||
: 0; | : 0; | ||||
mapValue.erase("fromaccount"); | mapValue.erase("fromaccount"); | ||||
mapValue.erase("spent"); | mapValue.erase("spent"); | ||||
▲ Show 20 Lines • Show All 1,141 Lines • Show Last 20 Lines |