Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.cpp
Show First 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | try { | ||||
ssKey >> strAddress; | ssKey >> strAddress; | ||||
ssValue >> pwallet | ssValue >> pwallet | ||||
->m_address_book[DecodeDestination( | ->m_address_book[DecodeDestination( | ||||
strAddress, pwallet->GetChainParams())] | strAddress, pwallet->GetChainParams())] | ||||
.purpose; | .purpose; | ||||
} else if (strType == DBKeys::TX) { | } else if (strType == DBKeys::TX) { | ||||
TxId txid; | TxId txid; | ||||
ssKey >> txid; | ssKey >> txid; | ||||
CWalletTx wtx(nullptr /* pwallet */, MakeTransactionRef()); | // LoadToWallet call below creates a new CWalletTx that fill_wtx | ||||
// callback fills with transaction metadata. | |||||
auto fill_wtx = [&](CWalletTx &wtx, bool new_tx) { | |||||
assert(new_tx); | |||||
ssValue >> wtx; | ssValue >> wtx; | ||||
if (wtx.GetId() != txid) { | if (wtx.GetId() != txid) { | ||||
return false; | return false; | ||||
} | } | ||||
// Undo serialize changes in 31600 | // Undo serialize changes in 31600 | ||||
if (31404 <= wtx.fTimeReceivedIsTxTime && | if (31404 <= wtx.fTimeReceivedIsTxTime && | ||||
wtx.fTimeReceivedIsTxTime <= 31703) { | wtx.fTimeReceivedIsTxTime <= 31703) { | ||||
if (!ssValue.empty()) { | if (!ssValue.empty()) { | ||||
char fTmp; | char fTmp; | ||||
char fUnused; | char fUnused; | ||||
std::string unused_string; | std::string unused_string; | ||||
ssValue >> fTmp >> fUnused >> unused_string; | ssValue >> fTmp >> fUnused >> unused_string; | ||||
strErr = strprintf("LoadWallet() upgrading tx ver=%d %d %s", | strErr = strprintf( | ||||
wtx.fTimeReceivedIsTxTime, fTmp, | "LoadWallet() upgrading tx ver=%d %d %s", | ||||
txid.ToString()); | wtx.fTimeReceivedIsTxTime, fTmp, txid.ToString()); | ||||
wtx.fTimeReceivedIsTxTime = fTmp; | wtx.fTimeReceivedIsTxTime = fTmp; | ||||
} else { | } else { | ||||
strErr = | strErr = strprintf( | ||||
strprintf("LoadWallet() repairing tx ver=%d %s", | "LoadWallet() repairing tx ver=%d %s", | ||||
wtx.fTimeReceivedIsTxTime, txid.ToString()); | wtx.fTimeReceivedIsTxTime, txid.ToString()); | ||||
wtx.fTimeReceivedIsTxTime = 0; | wtx.fTimeReceivedIsTxTime = 0; | ||||
} | } | ||||
wss.vWalletUpgrade.push_back(txid); | wss.vWalletUpgrade.push_back(txid); | ||||
} | } | ||||
if (wtx.nOrderPos == -1) { | if (wtx.nOrderPos == -1) { | ||||
wss.fAnyUnordered = true; | wss.fAnyUnordered = true; | ||||
} | } | ||||
pwallet->LoadToWallet(wtx); | return true; | ||||
}; | |||||
if (!pwallet->LoadToWallet(txid, fill_wtx)) { | |||||
return false; | |||||
} | |||||
} else if (strType == DBKeys::WATCHS) { | } else if (strType == DBKeys::WATCHS) { | ||||
wss.nWatchKeys++; | wss.nWatchKeys++; | ||||
CScript script; | CScript script; | ||||
ssKey >> script; | ssKey >> script; | ||||
char fYes; | char fYes; | ||||
ssValue >> fYes; | ssValue >> fYes; | ||||
if (fYes == '1') { | if (fYes == '1') { | ||||
pwallet->GetOrCreateLegacyScriptPubKeyMan()->LoadWatchOnly( | pwallet->GetOrCreateLegacyScriptPubKeyMan()->LoadWatchOnly( | ||||
▲ Show 20 Lines • Show All 654 Lines • Show Last 20 Lines |