mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 23:36:32 +01:00
scripted-diff: Use DataStream in most places
The remaining places are handled easier outside a scripted-diff. -BEGIN VERIFY SCRIPT- sed --regexp-extended -i 's/CDataStream ([0-9a-zA-Z_]+)\(SER_[A-Z]+, [A-Z_]+_VERSION\);/DataStream \1{};/g' $( git grep -l CDataStream) sed -i 's/, CDataStream/, DataStream/g' src/wallet/walletdb.cpp -END VERIFY SCRIPT-
This commit is contained in:
parent
fac39b56b7
commit
fae76a1f2a
12 changed files with 53 additions and 53 deletions
|
@ -74,7 +74,7 @@ UniValue ExternalSigner::GetDescriptors(const int account)
|
|||
bool ExternalSigner::SignTransaction(PartiallySignedTransaction& psbtx, std::string& error)
|
||||
{
|
||||
// Serialize the PSBT
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
// parse ExternalSigner master fingerprint
|
||||
std::vector<unsigned char> parsed_m_fingerprint = ParseHex(m_fingerprint);
|
||||
|
|
|
@ -128,14 +128,14 @@ void PSBTOperationsDialog::broadcastTransaction()
|
|||
}
|
||||
|
||||
void PSBTOperationsDialog::copyToClipboard() {
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << m_transaction_data;
|
||||
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
|
||||
showStatus(tr("PSBT copied to clipboard."), StatusLevel::INFO);
|
||||
}
|
||||
|
||||
void PSBTOperationsDialog::saveTransaction() {
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << m_transaction_data;
|
||||
|
||||
QString selected_filter;
|
||||
|
|
|
@ -397,7 +397,7 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
|
|||
void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
|
||||
{
|
||||
// Serialize the PSBT
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
|
||||
QMessageBox msgBox(this);
|
||||
|
|
|
@ -543,7 +543,7 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
|
|||
return false;
|
||||
}
|
||||
// Serialize the PSBT
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
|
||||
Q_EMIT message(tr("PSBT copied"), tr("Copied to clipboard", "Fee-bump PSBT saved"), CClientUIInterface::MSG_INFORMATION);
|
||||
|
|
|
@ -1493,7 +1493,7 @@ static RPCHelpMan combinepsbt()
|
|||
throw JSONRPCTransactionError(error);
|
||||
}
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << merged_psbt;
|
||||
return EncodeBase64(ssTx);
|
||||
},
|
||||
|
@ -1538,7 +1538,7 @@ static RPCHelpMan finalizepsbt()
|
|||
bool complete = FinalizeAndExtractPSBT(psbtx, mtx);
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
std::string result_str;
|
||||
|
||||
if (complete && extract) {
|
||||
|
@ -1589,7 +1589,7 @@ static RPCHelpMan createpsbt()
|
|||
}
|
||||
|
||||
// Serialize the PSBT
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
|
||||
return EncodeBase64(ssTx);
|
||||
|
@ -1656,7 +1656,7 @@ static RPCHelpMan converttopsbt()
|
|||
}
|
||||
|
||||
// Serialize the PSBT
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
|
||||
return EncodeBase64(ssTx);
|
||||
|
@ -1703,7 +1703,7 @@ static RPCHelpMan utxoupdatepsbt()
|
|||
/*sighash_type=*/SIGHASH_ALL,
|
||||
/*finalize=*/false);
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
return EncodeBase64(ssTx);
|
||||
},
|
||||
|
@ -1804,7 +1804,7 @@ static RPCHelpMan joinpsbts()
|
|||
}
|
||||
shuffled_psbt.unknown.insert(merged_psbt.unknown.begin(), merged_psbt.unknown.end());
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << shuffled_psbt;
|
||||
return EncodeBase64(ssTx);
|
||||
},
|
||||
|
@ -1984,7 +1984,7 @@ RPCHelpMan descriptorprocesspsbt()
|
|||
complete &= PSBTInputSigned(input);
|
||||
}
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
|
|
|
@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
|
|||
{
|
||||
CBlockHeaderAndShortTxIDs shortIDs{block};
|
||||
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream stream{};
|
||||
stream << shortIDs;
|
||||
|
||||
CBlockHeaderAndShortTxIDs shortIDs2;
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
std::vector<PrefilledTransaction> prefilledtxn;
|
||||
|
||||
explicit TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs& orig) {
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream stream{};
|
||||
stream << orig;
|
||||
stream >> *this;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public:
|
|||
TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs{block}) {}
|
||||
|
||||
uint64_t GetShortID(const uint256& txhash) const {
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream stream{};
|
||||
stream << *this;
|
||||
CBlockHeaderAndShortTxIDs base;
|
||||
stream >> base;
|
||||
|
@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
|
|||
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetHash());
|
||||
shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetHash());
|
||||
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream stream{};
|
||||
stream << shortIDs;
|
||||
|
||||
CBlockHeaderAndShortTxIDs shortIDs2;
|
||||
|
@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
|
|||
shortIDs.shorttxids.resize(1);
|
||||
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash());
|
||||
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream stream{};
|
||||
stream << shortIDs;
|
||||
|
||||
CBlockHeaderAndShortTxIDs shortIDs2;
|
||||
|
@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest)
|
|||
{
|
||||
CBlockHeaderAndShortTxIDs shortIDs{block};
|
||||
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream stream{};
|
||||
stream << shortIDs;
|
||||
|
||||
CBlockHeaderAndShortTxIDs shortIDs2;
|
||||
|
|
|
@ -1126,7 +1126,7 @@ public:
|
|||
void SendV1Version(const MessageStartChars& magic)
|
||||
{
|
||||
CMessageHeader hdr(magic, "version", 126 + InsecureRandRange(11));
|
||||
CDataStream ser(SER_NETWORK, CLIENT_VERSION);
|
||||
DataStream ser{};
|
||||
ser << hdr;
|
||||
m_to_send.insert(m_to_send.end(), UCharCast(ser.data()), UCharCast(ser.data() + ser.size()));
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
ssKey.reserve(1000);
|
||||
ssKey << key;
|
||||
|
||||
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||
DataStream ssValue{};
|
||||
if (!ReadKey(std::move(ssKey), ssValue)) return false;
|
||||
try {
|
||||
ssValue >> value;
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
ssKey.reserve(1000);
|
||||
ssKey << key;
|
||||
|
||||
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||
DataStream ssValue{};
|
||||
ssValue.reserve(10000);
|
||||
ssValue << value;
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ static UniValue FinishTransaction(const std::shared_ptr<CWallet> pwallet, const
|
|||
bool add_to_wallet{options.exists("add_to_wallet") ? options["add_to_wallet"].get_bool() : true};
|
||||
if (psbt_opt_in || !complete || !add_to_wallet) {
|
||||
// Serialize the PSBT
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
result.pushKV("psbt", EncodeBase64(ssTx.str()));
|
||||
}
|
||||
|
@ -1165,7 +1165,7 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
|
|||
const TransactionError err = pwallet->FillPSBT(psbtx, complete, SIGHASH_DEFAULT, /*sign=*/false, /*bip32derivs=*/true);
|
||||
CHECK_NONFATAL(err == TransactionError::OK);
|
||||
CHECK_NONFATAL(!complete);
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
result.pushKV("psbt", EncodeBase64(ssTx.str()));
|
||||
}
|
||||
|
@ -1610,7 +1610,7 @@ RPCHelpMan walletprocesspsbt()
|
|||
}
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
result.pushKV("psbt", EncodeBase64(ssTx.str()));
|
||||
result.pushKV("complete", complete);
|
||||
|
@ -1737,7 +1737,7 @@ RPCHelpMan walletcreatefundedpsbt()
|
|||
}
|
||||
|
||||
// Serialize the PSBT
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
|
|
|
@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(psbt_updater_test)
|
|||
BOOST_REQUIRE_EQUAL(TransactionError::OK, m_wallet.FillPSBT(psbtx, complete, SIGHASH_ALL, false, true));
|
||||
|
||||
// Get the final tx
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
DataStream ssTx{};
|
||||
ssTx << psbtx;
|
||||
std::string final_hex = HexStr(ssTx);
|
||||
BOOST_CHECK_EQUAL(final_hex, "70736274ff01009a020000000258e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd750000000000ffffffff838d0427d0ec650a68aa46bb0b098aea4422c071b2ca78352a077959d07cea1d0100000000ffffffff0270aaf00800000000160014d85c2b71d0060b09c9886aeb815e50991dda124d00e1f5050000000016001400aea9a2e5f0f876a588df5546e8742d1d87008f00000000000100bb0200000001aad73931018bd25f84ae400b68848be09db706eac2ac18298babee71ab656f8b0000000048473044022058f6fc7c6a33e1b31548d481c826c015bd30135aad42cd67790dab66d2ad243b02204a1ced2604c6735b6393e5b41691dd78b00f0c5942fb9f751856faa938157dba01feffffff0280f0fa020000000017a9140fb9463421696b82c833af241c78c17ddbde493487d0f20a270100000017a91429ca74f8a08f81999428185c97b5d852e4063f6187650000000104475221029583bf39ae0a609747ad199addd634fa6108559d6c5cd39b4c2183f1ab96e07f2102dab61ff49a14db6a7d02b0cd1fbb78fc4b18312b5b4e54dae4dba2fbfef536d752ae2206029583bf39ae0a609747ad199addd634fa6108559d6c5cd39b4c2183f1ab96e07f10d90c6a4f000000800000008000000080220602dab61ff49a14db6a7d02b0cd1fbb78fc4b18312b5b4e54dae4dba2fbfef536d710d90c6a4f0000008000000080010000800001008a020000000158e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd7501000000171600145f275f436b09a8cc9a2eb2a2f528485c68a56323feffffff02d8231f1b0100000017a914aed962d6654f9a2b36608eb9d64d2b260db4f1118700c2eb0b0000000017a914b7f5faf40e3d40a5a459b1db3535f2b72fa921e8876500000001012000c2eb0b0000000017a914b7f5faf40e3d40a5a459b1db3535f2b72fa921e88701042200208c2353173743b595dfb4a07b72ba8e42e3797da74e87fe7d9d7497e3b2028903010547522103089dc10c7ac6db54f91329af617333db388cead0c231f723379d1b99030b02dc21023add904f3d6dcf59ddb906b0dee23529b7ffb9ed50e5e86151926860221f0e7352ae2206023add904f3d6dcf59ddb906b0dee23529b7ffb9ed50e5e86151926860221f0e7310d90c6a4f000000800000008003000080220603089dc10c7ac6db54f91329af617333db388cead0c231f723379d1b99030b02dc10d90c6a4f00000080000000800200008000220203a9a4c37f5996d3aa25dbac6b570af0650394492942460b354753ed9eeca5877110d90c6a4f000000800000008004000080002202027f6399757d2eff55a136ad02c684b1838b6556e5f1b6b34282a94b6b5005109610d90c6a4f00000080000000800500008000");
|
||||
|
|
|
@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(walletdb_readkeyvalue)
|
|||
* silently fail. The test here makes sure the type of exception thrown from CDataStream::read()
|
||||
* matches the type we expect, otherwise we need to update the "key"/"wkey" exception type caught.
|
||||
*/
|
||||
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||
DataStream ssValue{};
|
||||
uint256 dummy;
|
||||
BOOST_CHECK_THROW(ssValue >> dummy, std::ios_base::failure);
|
||||
}
|
||||
|
|
|
@ -478,12 +478,12 @@ struct LoadResult
|
|||
int m_records{0};
|
||||
};
|
||||
|
||||
using LoadFunc = std::function<DBErrors(CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err)>;
|
||||
using LoadFunc = std::function<DBErrors(CWallet* pwallet, DataStream& key, DataStream& value, std::string& err)>;
|
||||
static LoadResult LoadRecords(CWallet* pwallet, DatabaseBatch& batch, const std::string& key, DataStream& prefix, LoadFunc load_func)
|
||||
{
|
||||
LoadResult result;
|
||||
DataStream ssKey;
|
||||
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
|
||||
DataStream ssValue{};
|
||||
|
||||
Assume(!prefix.empty());
|
||||
std::unique_ptr<DatabaseCursor> cursor = batch.GetNewPrefixCursor(prefix);
|
||||
|
@ -532,7 +532,7 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
if (pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||
for (const auto& type : DBKeys::LEGACY_TYPES) {
|
||||
DataStream key;
|
||||
CDataStream value(SER_DISK, CLIENT_VERSION);
|
||||
DataStream value{};
|
||||
|
||||
DataStream prefix;
|
||||
prefix << type;
|
||||
|
@ -555,28 +555,28 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
// Load HD Chain
|
||||
// Note: There should only be one HDCHAIN record with no data following the type
|
||||
LoadResult hd_chain_res = LoadRecords(pwallet, batch, DBKeys::HDCHAIN,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
return LoadHDChain(pwallet, value, err) ? DBErrors:: LOAD_OK : DBErrors::CORRUPT;
|
||||
});
|
||||
result = std::max(result, hd_chain_res.m_result);
|
||||
|
||||
// Load unencrypted keys
|
||||
LoadResult key_res = LoadRecords(pwallet, batch, DBKeys::KEY,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
return LoadKey(pwallet, key, value, err) ? DBErrors::LOAD_OK : DBErrors::CORRUPT;
|
||||
});
|
||||
result = std::max(result, key_res.m_result);
|
||||
|
||||
// Load encrypted keys
|
||||
LoadResult ckey_res = LoadRecords(pwallet, batch, DBKeys::CRYPTED_KEY,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
return LoadCryptedKey(pwallet, key, value, err) ? DBErrors::LOAD_OK : DBErrors::CORRUPT;
|
||||
});
|
||||
result = std::max(result, ckey_res.m_result);
|
||||
|
||||
// Load scripts
|
||||
LoadResult script_res = LoadRecords(pwallet, batch, DBKeys::CSCRIPT,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& strErr) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& strErr) {
|
||||
uint160 hash;
|
||||
key >> hash;
|
||||
CScript script;
|
||||
|
@ -599,7 +599,7 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
// Load keymeta
|
||||
std::map<uint160, CHDChain> hd_chains;
|
||||
LoadResult keymeta_res = LoadRecords(pwallet, batch, DBKeys::KEYMETA,
|
||||
[&hd_chains] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& strErr) {
|
||||
[&hd_chains] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& strErr) {
|
||||
CPubKey vchPubKey;
|
||||
key >> vchPubKey;
|
||||
CKeyMetadata keyMeta;
|
||||
|
@ -686,7 +686,7 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
|
||||
// Load watchonly scripts
|
||||
LoadResult watch_script_res = LoadRecords(pwallet, batch, DBKeys::WATCHS,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
CScript script;
|
||||
key >> script;
|
||||
uint8_t fYes;
|
||||
|
@ -700,7 +700,7 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
|
||||
// Load watchonly meta
|
||||
LoadResult watch_meta_res = LoadRecords(pwallet, batch, DBKeys::WATCHMETA,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
CScript script;
|
||||
key >> script;
|
||||
CKeyMetadata keyMeta;
|
||||
|
@ -712,7 +712,7 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
|
||||
// Load keypool
|
||||
LoadResult pool_res = LoadRecords(pwallet, batch, DBKeys::POOL,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
int64_t nIndex;
|
||||
key >> nIndex;
|
||||
CKeyPool keypool;
|
||||
|
@ -729,7 +729,7 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
// we want to make sure that it is valid so that we can detect corruption
|
||||
// Note: There should only be one DEFAULTKEY with nothing trailing the type
|
||||
LoadResult default_key_res = LoadRecords(pwallet, batch, DBKeys::DEFAULTKEY,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
CPubKey default_pubkey;
|
||||
try {
|
||||
value >> default_pubkey;
|
||||
|
@ -747,7 +747,7 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
|
|||
|
||||
// "wkey" records are unsupported, if we see any, throw an error
|
||||
LoadResult wkey_res = LoadRecords(pwallet, batch, DBKeys::OLD_KEY,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
err = "Found unsupported 'wkey' record, try loading with version 0.18";
|
||||
return DBErrors::LOAD_FAIL;
|
||||
});
|
||||
|
@ -787,7 +787,7 @@ static DBErrors LoadDescriptorWalletRecords(CWallet* pwallet, DatabaseBatch& bat
|
|||
int num_keys = 0;
|
||||
int num_ckeys= 0;
|
||||
LoadResult desc_res = LoadRecords(pwallet, batch, DBKeys::WALLETDESCRIPTOR,
|
||||
[&batch, &num_keys, &num_ckeys, &last_client] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& strErr) {
|
||||
[&batch, &num_keys, &num_ckeys, &last_client] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& strErr) {
|
||||
DBErrors result = DBErrors::LOAD_OK;
|
||||
|
||||
uint256 id;
|
||||
|
@ -817,7 +817,7 @@ static DBErrors LoadDescriptorWalletRecords(CWallet* pwallet, DatabaseBatch& bat
|
|||
// Get key cache for this descriptor
|
||||
DataStream prefix = PrefixStream(DBKeys::WALLETDESCRIPTORCACHE, id);
|
||||
LoadResult key_cache_res = LoadRecords(pwallet, batch, DBKeys::WALLETDESCRIPTORCACHE, prefix,
|
||||
[&id, &cache] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[&id, &cache] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
bool parent = true;
|
||||
uint256 desc_id;
|
||||
uint32_t key_exp_index;
|
||||
|
@ -850,7 +850,7 @@ static DBErrors LoadDescriptorWalletRecords(CWallet* pwallet, DatabaseBatch& bat
|
|||
// Get last hardened cache for this descriptor
|
||||
prefix = PrefixStream(DBKeys::WALLETDESCRIPTORLHCACHE, id);
|
||||
LoadResult lh_cache_res = LoadRecords(pwallet, batch, DBKeys::WALLETDESCRIPTORLHCACHE, prefix,
|
||||
[&id, &cache] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[&id, &cache] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
uint256 desc_id;
|
||||
uint32_t key_exp_index;
|
||||
key >> desc_id;
|
||||
|
@ -874,7 +874,7 @@ static DBErrors LoadDescriptorWalletRecords(CWallet* pwallet, DatabaseBatch& bat
|
|||
// Get unencrypted keys
|
||||
prefix = PrefixStream(DBKeys::WALLETDESCRIPTORKEY, id);
|
||||
LoadResult key_res = LoadRecords(pwallet, batch, DBKeys::WALLETDESCRIPTORKEY, prefix,
|
||||
[&id, &spk_man] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& strErr) {
|
||||
[&id, &spk_man] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& strErr) {
|
||||
uint256 desc_id;
|
||||
CPubKey pubkey;
|
||||
key >> desc_id;
|
||||
|
@ -918,7 +918,7 @@ static DBErrors LoadDescriptorWalletRecords(CWallet* pwallet, DatabaseBatch& bat
|
|||
// Get encrypted keys
|
||||
prefix = PrefixStream(DBKeys::WALLETDESCRIPTORCKEY, id);
|
||||
LoadResult ckey_res = LoadRecords(pwallet, batch, DBKeys::WALLETDESCRIPTORCKEY, prefix,
|
||||
[&id, &spk_man] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[&id, &spk_man] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
uint256 desc_id;
|
||||
CPubKey pubkey;
|
||||
key >> desc_id;
|
||||
|
@ -957,7 +957,7 @@ static DBErrors LoadAddressBookRecords(CWallet* pwallet, DatabaseBatch& batch) E
|
|||
|
||||
// Load name record
|
||||
LoadResult name_res = LoadRecords(pwallet, batch, DBKeys::NAME,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
std::string strAddress;
|
||||
key >> strAddress;
|
||||
std::string label;
|
||||
|
@ -969,7 +969,7 @@ static DBErrors LoadAddressBookRecords(CWallet* pwallet, DatabaseBatch& batch) E
|
|||
|
||||
// Load purpose record
|
||||
LoadResult purpose_res = LoadRecords(pwallet, batch, DBKeys::PURPOSE,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
std::string strAddress;
|
||||
key >> strAddress;
|
||||
std::string purpose_str;
|
||||
|
@ -985,7 +985,7 @@ static DBErrors LoadAddressBookRecords(CWallet* pwallet, DatabaseBatch& batch) E
|
|||
|
||||
// Load destination data record
|
||||
LoadResult dest_res = LoadRecords(pwallet, batch, DBKeys::DESTDATA,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
std::string strAddress, strKey, strValue;
|
||||
key >> strAddress;
|
||||
key >> strKey;
|
||||
|
@ -1019,7 +1019,7 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto
|
|||
// Load tx record
|
||||
any_unordered = false;
|
||||
LoadResult tx_res = LoadRecords(pwallet, batch, DBKeys::TX,
|
||||
[&any_unordered, &upgraded_txs] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
[&any_unordered, &upgraded_txs] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
DBErrors result = DBErrors::LOAD_OK;
|
||||
uint256 hash;
|
||||
key >> hash;
|
||||
|
@ -1072,7 +1072,7 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto
|
|||
|
||||
// Load locked utxo record
|
||||
LoadResult locked_utxo_res = LoadRecords(pwallet, batch, DBKeys::LOCKED_UTXO,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
Txid hash;
|
||||
uint32_t n;
|
||||
key >> hash;
|
||||
|
@ -1085,7 +1085,7 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto
|
|||
// Load orderposnext record
|
||||
// Note: There should only be one ORDERPOSNEXT record with nothing trailing the type
|
||||
LoadResult order_pos_res = LoadRecords(pwallet, batch, DBKeys::ORDERPOSNEXT,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
|
||||
try {
|
||||
value >> pwallet->nOrderPosNext;
|
||||
} catch (const std::exception& e) {
|
||||
|
@ -1108,7 +1108,7 @@ static DBErrors LoadActiveSPKMs(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIV
|
|||
std::set<std::pair<OutputType, bool>> seen_spks;
|
||||
for (const auto& spk_key : {DBKeys::ACTIVEEXTERNALSPK, DBKeys::ACTIVEINTERNALSPK}) {
|
||||
LoadResult spkm_res = LoadRecords(pwallet, batch, spk_key,
|
||||
[&seen_spks, &spk_key] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& strErr) {
|
||||
[&seen_spks, &spk_key] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& strErr) {
|
||||
uint8_t output_type;
|
||||
key >> output_type;
|
||||
uint256 id;
|
||||
|
@ -1134,7 +1134,7 @@ static DBErrors LoadDecryptionKeys(CWallet* pwallet, DatabaseBatch& batch) EXCLU
|
|||
|
||||
// Load decryption key (mkey) records
|
||||
LoadResult mkey_res = LoadRecords(pwallet, batch, DBKeys::MASTER_KEY,
|
||||
[] (CWallet* pwallet, DataStream& key, CDataStream& value, std::string& err) {
|
||||
[] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) {
|
||||
if (!LoadEncryptionKey(pwallet, key, value, err)) {
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue