@@ -84,7 +84,7 @@ bool PermitsUncompressed(IsMineSigVersion sigversion)
84
84
return sigversion == IsMineSigVersion::TOP || sigversion == IsMineSigVersion::P2SH;
85
85
}
86
86
87
- bool HaveKeys (const std::vector<valtype>& pubkeys, const LegacyScriptPubKeyMan & keystore)
87
+ bool HaveKeys (const std::vector<valtype>& pubkeys, const LegacyDataSPKM & keystore)
88
88
{
89
89
for (const valtype& pubkey : pubkeys) {
90
90
CKeyID keyID = CPubKey (pubkey).GetID ();
@@ -102,7 +102,7 @@ bool HaveKeys(const std::vector<valtype>& pubkeys, const LegacyScriptPubKeyMan&
102
102
// ! scripts or simply treat any script that has been
103
103
// ! stored in the keystore as spendable
104
104
// NOLINTNEXTLINE(misc-no-recursion)
105
- IsMineResult IsMineInner (const LegacyScriptPubKeyMan & keystore, const CScript& scriptPubKey, IsMineSigVersion sigversion, bool recurse_scripthash=true )
105
+ IsMineResult IsMineInner (const LegacyDataSPKM & keystore, const CScript& scriptPubKey, IsMineSigVersion sigversion, bool recurse_scripthash=true )
106
106
{
107
107
IsMineResult ret = IsMineResult::NO;
108
108
@@ -217,7 +217,7 @@ IsMineResult IsMineInner(const LegacyScriptPubKeyMan& keystore, const CScript& s
217
217
218
218
} // namespace
219
219
220
- isminetype LegacyScriptPubKeyMan ::IsMine (const CScript& script) const
220
+ isminetype LegacyDataSPKM ::IsMine (const CScript& script) const
221
221
{
222
222
switch (IsMineInner (*this , script, IsMineSigVersion::TOP)) {
223
223
case IsMineResult::INVALID:
@@ -231,7 +231,7 @@ isminetype LegacyScriptPubKeyMan::IsMine(const CScript& script) const
231
231
assert (false );
232
232
}
233
233
234
- bool LegacyScriptPubKeyMan ::CheckDecryptionKey (const CKeyingMaterial& master_key)
234
+ bool LegacyDataSPKM ::CheckDecryptionKey (const CKeyingMaterial& master_key)
235
235
{
236
236
{
237
237
LOCK (cs_KeyStore);
@@ -585,7 +585,7 @@ int64_t LegacyScriptPubKeyMan::GetTimeFirstKey() const
585
585
return nTimeFirstKey;
586
586
}
587
587
588
- std::unique_ptr<SigningProvider> LegacyScriptPubKeyMan ::GetSolvingProvider (const CScript& script) const
588
+ std::unique_ptr<SigningProvider> LegacyDataSPKM ::GetSolvingProvider (const CScript& script) const
589
589
{
590
590
return std::make_unique<LegacySigningProvider>(*this );
591
591
}
@@ -721,7 +721,7 @@ void LegacyScriptPubKeyMan::UpdateTimeFirstKey(int64_t nCreateTime)
721
721
NotifyFirstKeyTimeChanged (this , nTimeFirstKey);
722
722
}
723
723
724
- bool LegacyScriptPubKeyMan ::LoadKey (const CKey& key, const CPubKey &pubkey)
724
+ bool LegacyDataSPKM ::LoadKey (const CKey& key, const CPubKey &pubkey)
725
725
{
726
726
return AddKeyPubKeyInner (key, pubkey);
727
727
}
@@ -773,7 +773,7 @@ bool LegacyScriptPubKeyMan::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& s
773
773
return true ;
774
774
}
775
775
776
- bool LegacyScriptPubKeyMan ::LoadCScript (const CScript& redeemScript)
776
+ bool LegacyDataSPKM ::LoadCScript (const CScript& redeemScript)
777
777
{
778
778
/* A sanity check was added in pull #3843 to avoid adding redeemScripts
779
779
* that never can be redeemed. However, old wallets may still contain
@@ -788,18 +788,36 @@ bool LegacyScriptPubKeyMan::LoadCScript(const CScript& redeemScript)
788
788
return FillableSigningProvider::AddCScript (redeemScript);
789
789
}
790
790
791
+ void LegacyDataSPKM::LoadKeyMetadata (const CKeyID& keyID, const CKeyMetadata& meta)
792
+ {
793
+ LOCK (cs_KeyStore);
794
+ mapKeyMetadata[keyID] = meta;
795
+ }
796
+
791
797
void LegacyScriptPubKeyMan::LoadKeyMetadata (const CKeyID& keyID, const CKeyMetadata& meta)
792
798
{
793
799
LOCK (cs_KeyStore);
800
+ LegacyDataSPKM::LoadKeyMetadata (keyID, meta);
794
801
UpdateTimeFirstKey (meta.nCreateTime );
795
- mapKeyMetadata[keyID] = meta;
802
+ }
803
+
804
+ void LegacyDataSPKM::LoadScriptMetadata (const CScriptID& script_id, const CKeyMetadata& meta)
805
+ {
806
+ LOCK (cs_KeyStore);
807
+ m_script_metadata[script_id] = meta;
796
808
}
797
809
798
810
void LegacyScriptPubKeyMan::LoadScriptMetadata (const CScriptID& script_id, const CKeyMetadata& meta)
799
811
{
800
812
LOCK (cs_KeyStore);
813
+ LegacyDataSPKM::LoadScriptMetadata (script_id, meta);
801
814
UpdateTimeFirstKey (meta.nCreateTime );
802
- m_script_metadata[script_id] = meta;
815
+ }
816
+
817
+ bool LegacyDataSPKM::AddKeyPubKeyInner (const CKey& key, const CPubKey& pubkey)
818
+ {
819
+ LOCK (cs_KeyStore);
820
+ return FillableSigningProvider::AddKeyPubKey (key, pubkey);
803
821
}
804
822
805
823
bool LegacyScriptPubKeyMan::AddKeyPubKeyInner (const CKey& key, const CPubKey &pubkey)
@@ -827,7 +845,7 @@ bool LegacyScriptPubKeyMan::AddKeyPubKeyInner(const CKey& key, const CPubKey &pu
827
845
return true ;
828
846
}
829
847
830
- bool LegacyScriptPubKeyMan ::LoadCryptedKey (const CPubKey &vchPubKey, const std::vector<unsigned char > &vchCryptedSecret, bool checksum_valid)
848
+ bool LegacyDataSPKM ::LoadCryptedKey (const CPubKey &vchPubKey, const std::vector<unsigned char > &vchCryptedSecret, bool checksum_valid)
831
849
{
832
850
// Set fDecryptionThoroughlyChecked to false when the checksum is invalid
833
851
if (!checksum_valid) {
@@ -837,7 +855,7 @@ bool LegacyScriptPubKeyMan::LoadCryptedKey(const CPubKey &vchPubKey, const std::
837
855
return AddCryptedKeyInner (vchPubKey, vchCryptedSecret);
838
856
}
839
857
840
- bool LegacyScriptPubKeyMan ::AddCryptedKeyInner (const CPubKey &vchPubKey, const std::vector<unsigned char > &vchCryptedSecret)
858
+ bool LegacyDataSPKM ::AddCryptedKeyInner (const CPubKey &vchPubKey, const std::vector<unsigned char > &vchCryptedSecret)
841
859
{
842
860
LOCK (cs_KeyStore);
843
861
assert (mapKeys.empty ());
@@ -865,13 +883,13 @@ bool LegacyScriptPubKeyMan::AddCryptedKey(const CPubKey &vchPubKey,
865
883
}
866
884
}
867
885
868
- bool LegacyScriptPubKeyMan ::HaveWatchOnly (const CScript &dest) const
886
+ bool LegacyDataSPKM ::HaveWatchOnly (const CScript &dest) const
869
887
{
870
888
LOCK (cs_KeyStore);
871
889
return setWatchOnly.count (dest) > 0 ;
872
890
}
873
891
874
- bool LegacyScriptPubKeyMan ::HaveWatchOnly () const
892
+ bool LegacyDataSPKM ::HaveWatchOnly () const
875
893
{
876
894
LOCK (cs_KeyStore);
877
895
return (!setWatchOnly.empty ());
@@ -905,12 +923,12 @@ bool LegacyScriptPubKeyMan::RemoveWatchOnly(const CScript &dest)
905
923
return true ;
906
924
}
907
925
908
- bool LegacyScriptPubKeyMan ::LoadWatchOnly (const CScript &dest)
926
+ bool LegacyDataSPKM ::LoadWatchOnly (const CScript &dest)
909
927
{
910
928
return AddWatchOnlyInMem (dest);
911
929
}
912
930
913
- bool LegacyScriptPubKeyMan ::AddWatchOnlyInMem (const CScript &dest)
931
+ bool LegacyDataSPKM ::AddWatchOnlyInMem (const CScript &dest)
914
932
{
915
933
LOCK (cs_KeyStore);
916
934
setWatchOnly.insert (dest);
@@ -954,7 +972,7 @@ bool LegacyScriptPubKeyMan::AddWatchOnly(const CScript& dest, int64_t nCreateTim
954
972
return AddWatchOnly (dest);
955
973
}
956
974
957
- void LegacyScriptPubKeyMan ::LoadHDChain (const CHDChain& chain)
975
+ void LegacyDataSPKM ::LoadHDChain (const CHDChain& chain)
958
976
{
959
977
LOCK (cs_KeyStore);
960
978
m_hd_chain = chain;
@@ -975,14 +993,14 @@ void LegacyScriptPubKeyMan::AddHDChain(const CHDChain& chain)
975
993
m_hd_chain = chain;
976
994
}
977
995
978
- void LegacyScriptPubKeyMan ::AddInactiveHDChain (const CHDChain& chain)
996
+ void LegacyDataSPKM ::AddInactiveHDChain (const CHDChain& chain)
979
997
{
980
998
LOCK (cs_KeyStore);
981
999
assert (!chain.seed_id .IsNull ());
982
1000
m_inactive_hd_chains[chain.seed_id ] = chain;
983
1001
}
984
1002
985
- bool LegacyScriptPubKeyMan ::HaveKey (const CKeyID &address) const
1003
+ bool LegacyDataSPKM ::HaveKey (const CKeyID &address) const
986
1004
{
987
1005
LOCK (cs_KeyStore);
988
1006
if (!m_storage.HasEncryptionKeys ()) {
@@ -991,7 +1009,7 @@ bool LegacyScriptPubKeyMan::HaveKey(const CKeyID &address) const
991
1009
return mapCryptedKeys.count (address) > 0 ;
992
1010
}
993
1011
994
- bool LegacyScriptPubKeyMan ::GetKey (const CKeyID &address, CKey& keyOut) const
1012
+ bool LegacyDataSPKM ::GetKey (const CKeyID &address, CKey& keyOut) const
995
1013
{
996
1014
LOCK (cs_KeyStore);
997
1015
if (!m_storage.HasEncryptionKeys ()) {
@@ -1010,7 +1028,7 @@ bool LegacyScriptPubKeyMan::GetKey(const CKeyID &address, CKey& keyOut) const
1010
1028
return false ;
1011
1029
}
1012
1030
1013
- bool LegacyScriptPubKeyMan ::GetKeyOrigin (const CKeyID& keyID, KeyOriginInfo& info) const
1031
+ bool LegacyDataSPKM ::GetKeyOrigin (const CKeyID& keyID, KeyOriginInfo& info) const
1014
1032
{
1015
1033
CKeyMetadata meta;
1016
1034
{
@@ -1030,7 +1048,7 @@ bool LegacyScriptPubKeyMan::GetKeyOrigin(const CKeyID& keyID, KeyOriginInfo& inf
1030
1048
return true ;
1031
1049
}
1032
1050
1033
- bool LegacyScriptPubKeyMan ::GetWatchPubKey (const CKeyID &address, CPubKey &pubkey_out) const
1051
+ bool LegacyDataSPKM ::GetWatchPubKey (const CKeyID &address, CPubKey &pubkey_out) const
1034
1052
{
1035
1053
LOCK (cs_KeyStore);
1036
1054
WatchKeyMap::const_iterator it = mapWatchKeys.find (address);
@@ -1041,7 +1059,7 @@ bool LegacyScriptPubKeyMan::GetWatchPubKey(const CKeyID &address, CPubKey &pubke
1041
1059
return false ;
1042
1060
}
1043
1061
1044
- bool LegacyScriptPubKeyMan ::GetPubKey (const CKeyID &address, CPubKey& vchPubKeyOut) const
1062
+ bool LegacyDataSPKM ::GetPubKey (const CKeyID &address, CPubKey& vchPubKeyOut) const
1045
1063
{
1046
1064
LOCK (cs_KeyStore);
1047
1065
if (!m_storage.HasEncryptionKeys ()) {
@@ -1160,7 +1178,7 @@ void LegacyScriptPubKeyMan::DeriveNewChildKey(WalletBatch &batch, CKeyMetadata&
1160
1178
throw std::runtime_error (std::string (__func__) + " : writing HD chain model failed" );
1161
1179
}
1162
1180
1163
- void LegacyScriptPubKeyMan ::LoadKeyPool (int64_t nIndex, const CKeyPool &keypool)
1181
+ void LegacyDataSPKM ::LoadKeyPool (int64_t nIndex, const CKeyPool &keypool)
1164
1182
{
1165
1183
LOCK (cs_KeyStore);
1166
1184
if (keypool.m_pre_split ) {
@@ -1681,7 +1699,7 @@ std::set<CKeyID> LegacyScriptPubKeyMan::GetKeys() const
1681
1699
return set_address;
1682
1700
}
1683
1701
1684
- std::unordered_set<CScript, SaltedSipHasher> LegacyScriptPubKeyMan ::GetScriptPubKeys () const
1702
+ std::unordered_set<CScript, SaltedSipHasher> LegacyDataSPKM ::GetScriptPubKeys () const
1685
1703
{
1686
1704
LOCK (cs_KeyStore);
1687
1705
std::unordered_set<CScript, SaltedSipHasher> spks;
@@ -1739,7 +1757,7 @@ std::unordered_set<CScript, SaltedSipHasher> LegacyScriptPubKeyMan::GetScriptPub
1739
1757
return spks;
1740
1758
}
1741
1759
1742
- std::unordered_set<CScript, SaltedSipHasher> LegacyScriptPubKeyMan ::GetNotMineScriptPubKeys () const
1760
+ std::unordered_set<CScript, SaltedSipHasher> LegacyDataSPKM ::GetNotMineScriptPubKeys () const
1743
1761
{
1744
1762
LOCK (cs_KeyStore);
1745
1763
std::unordered_set<CScript, SaltedSipHasher> spks;
@@ -1749,7 +1767,7 @@ std::unordered_set<CScript, SaltedSipHasher> LegacyScriptPubKeyMan::GetNotMineSc
1749
1767
return spks;
1750
1768
}
1751
1769
1752
- std::optional<MigrationData> LegacyScriptPubKeyMan ::MigrateToDescriptor ()
1770
+ std::optional<MigrationData> LegacyDataSPKM ::MigrateToDescriptor ()
1753
1771
{
1754
1772
LOCK (cs_KeyStore);
1755
1773
if (m_storage.IsLocked ()) {
@@ -1816,7 +1834,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
1816
1834
WalletDescriptor w_desc (std::move (desc), creation_time, 0 , 0 , 0 );
1817
1835
1818
1836
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
1819
- auto desc_spk_man = std::unique_ptr <DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan ( m_storage, w_desc, m_keypool_size) );
1837
+ auto desc_spk_man = std::make_unique <DescriptorScriptPubKeyMan>(m_storage, w_desc, /* keypool_size= */ 0 );
1820
1838
desc_spk_man->AddDescriptorKey (key, key.GetPubKey ());
1821
1839
desc_spk_man->TopUp ();
1822
1840
auto desc_spks = desc_spk_man->GetScriptPubKeys ();
@@ -1861,7 +1879,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
1861
1879
WalletDescriptor w_desc (std::move (desc), 0 , 0 , chain_counter, 0 );
1862
1880
1863
1881
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
1864
- auto desc_spk_man = std::unique_ptr <DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan ( m_storage, w_desc, m_keypool_size) );
1882
+ auto desc_spk_man = std::make_unique <DescriptorScriptPubKeyMan>(m_storage, w_desc, /* keypool_size= */ 0 );
1865
1883
desc_spk_man->AddDescriptorKey (master_key.key , master_key.key .GetPubKey ());
1866
1884
desc_spk_man->TopUp ();
1867
1885
auto desc_spks = desc_spk_man->GetScriptPubKeys ();
@@ -1923,7 +1941,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
1923
1941
} else {
1924
1942
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
1925
1943
WalletDescriptor w_desc (std::move (desc), creation_time, 0 , 0 , 0 );
1926
- auto desc_spk_man = std::unique_ptr <DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan ( m_storage, w_desc, m_keypool_size) );
1944
+ auto desc_spk_man = std::make_unique <DescriptorScriptPubKeyMan>(m_storage, w_desc, /* keypool_size= */ 0 );
1927
1945
for (const auto & keyid : privkeyids) {
1928
1946
CKey key;
1929
1947
if (!GetKey (keyid, key)) {
@@ -2001,7 +2019,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
2001
2019
return out;
2002
2020
}
2003
2021
2004
- bool LegacyScriptPubKeyMan ::DeleteRecords ()
2022
+ bool LegacyDataSPKM ::DeleteRecords ()
2005
2023
{
2006
2024
LOCK (cs_KeyStore);
2007
2025
WalletBatch batch (m_storage.GetDatabase ());
0 commit comments