diff options
| author | Russell Yanofsky <[email protected]> | 2017-12-08 12:50:46 -0500 |
|---|---|---|
| committer | Russell Yanofsky <[email protected]> | 2017-12-08 12:50:46 -0500 |
| commit | 9c8eca7704e88b3f4ee38cf85bef0f1febc440e5 (patch) | |
| tree | 65a5fb461a02112b1e167e3ecfa522cffcdc4414 /src/wallet/walletdb.cpp | |
| parent | Merge #11847: Make boost::multi_index comparators const (diff) | |
| download | discoin-9c8eca7704e88b3f4ee38cf85bef0f1febc440e5.tar.xz discoin-9c8eca7704e88b3f4ee38cf85bef0f1febc440e5.zip | |
Split up key and script metadata for better type safety
Suggested by Matt Corallo <[email protected]>
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.
Diffstat (limited to 'src/wallet/walletdb.cpp')
| -rw-r--r-- | src/wallet/walletdb.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 5116d6419..efc50f72e 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -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") { |