mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-09 20:23:35 +01:00
Split up key and script metadata for better type safety
Suggested by Matt Corallo <git@bluematt.me> https://github.com/bitcoin/bitcoin/pull/11403#discussion_r155599383 Combining the maps was probably never a good arrangement but is more problematic now in presence of WitnessV0ScriptHash and WitnessV0KeyHash types.
This commit is contained in:
@@ -423,27 +423,23 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
||||
}
|
||||
wss.fIsEncrypted = true;
|
||||
}
|
||||
else if (strType == "keymeta" || strType == "watchmeta")
|
||||
else if (strType == "keymeta")
|
||||
{
|
||||
CTxDestination keyID;
|
||||
if (strType == "keymeta")
|
||||
{
|
||||
CPubKey vchPubKey;
|
||||
ssKey >> vchPubKey;
|
||||
keyID = vchPubKey.GetID();
|
||||
}
|
||||
else if (strType == "watchmeta")
|
||||
{
|
||||
CScript script;
|
||||
ssKey >> script;
|
||||
keyID = CScriptID(script);
|
||||
}
|
||||
|
||||
CPubKey vchPubKey;
|
||||
ssKey >> vchPubKey;
|
||||
CKeyMetadata keyMeta;
|
||||
ssValue >> keyMeta;
|
||||
wss.nKeyMeta++;
|
||||
|
||||
pwallet->LoadKeyMetadata(keyID, keyMeta);
|
||||
pwallet->LoadKeyMetadata(vchPubKey.GetID(), keyMeta);
|
||||
}
|
||||
else if (strType == "watchmeta")
|
||||
{
|
||||
CScript script;
|
||||
ssKey >> script;
|
||||
CKeyMetadata keyMeta;
|
||||
ssValue >> keyMeta;
|
||||
wss.nKeyMeta++;
|
||||
pwallet->LoadScriptMetadata(CScriptID(script), keyMeta);
|
||||
}
|
||||
else if (strType == "defaultkey")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user