mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
Locking: Lock cs_KeyStore instead of cs_wallet in legacy keyman
This commit only affects locking behavior and doesn't have other changes.
This commit is contained in:
@@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2PK compressed
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
scriptPubKey = GetScriptForRawPubKey(pubkeys[0]);
|
||||
|
||||
// Keystore does not have key
|
||||
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2PK uncompressed
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
scriptPubKey = GetScriptForRawPubKey(uncompressedPubkey);
|
||||
|
||||
// Keystore does not have key
|
||||
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2PKH compressed
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
scriptPubKey = GetScriptForDestination(PKHash(pubkeys[0]));
|
||||
|
||||
// Keystore does not have key
|
||||
@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2PKH uncompressed
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
scriptPubKey = GetScriptForDestination(PKHash(uncompressedPubkey));
|
||||
|
||||
// Keystore does not have key
|
||||
@@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2SH
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
|
||||
CScript redeemScript = GetScriptForDestination(PKHash(pubkeys[0]));
|
||||
scriptPubKey = GetScriptForDestination(ScriptHash(redeemScript));
|
||||
@@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// (P2PKH inside) P2SH inside P2SH (invalid)
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
|
||||
CScript redeemscript_inner = GetScriptForDestination(PKHash(pubkeys[0]));
|
||||
CScript redeemscript = GetScriptForDestination(ScriptHash(redeemscript_inner));
|
||||
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// (P2PKH inside) P2SH inside P2WSH (invalid)
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
|
||||
CScript redeemscript = GetScriptForDestination(PKHash(pubkeys[0]));
|
||||
CScript witnessscript = GetScriptForDestination(ScriptHash(redeemscript));
|
||||
@@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2WPKH inside P2WSH (invalid)
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
|
||||
CScript witnessscript = GetScriptForDestination(WitnessV0KeyHash(PKHash(pubkeys[0])));
|
||||
scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessscript));
|
||||
@@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// (P2PKH inside) P2WSH inside P2WSH (invalid)
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
|
||||
CScript witnessscript_inner = GetScriptForDestination(PKHash(pubkeys[0]));
|
||||
CScript witnessscript = GetScriptForDestination(WitnessV0ScriptHash(witnessscript_inner));
|
||||
@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2WPKH compressed
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
|
||||
|
||||
scriptPubKey = GetScriptForDestination(WitnessV0KeyHash(PKHash(pubkeys[0])));
|
||||
@@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2WPKH uncompressed
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
|
||||
|
||||
scriptPubKey = GetScriptForDestination(WitnessV0KeyHash(PKHash(uncompressedPubkey)));
|
||||
@@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// scriptPubKey multisig
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
|
||||
scriptPubKey = GetScriptForMultisig(2, {uncompressedPubkey, pubkeys[1]});
|
||||
|
||||
@@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2SH multisig
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
|
||||
|
||||
@@ -271,7 +271,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2WSH multisig with compressed keys
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
|
||||
|
||||
@@ -296,7 +296,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2WSH multisig with uncompressed key
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
|
||||
|
||||
@@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// P2WSH multisig wrapped in P2SH
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
|
||||
CScript witnessScript = GetScriptForMultisig(2, {pubkeys[0], pubkeys[1]});
|
||||
CScript redeemScript = GetScriptForDestination(WitnessV0ScriptHash(witnessScript));
|
||||
@@ -347,7 +347,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// OP_RETURN
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
|
||||
|
||||
scriptPubKey.clear();
|
||||
@@ -360,7 +360,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// witness unspendable
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
|
||||
|
||||
scriptPubKey.clear();
|
||||
@@ -373,7 +373,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// witness unknown
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
|
||||
|
||||
scriptPubKey.clear();
|
||||
@@ -386,7 +386,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
// Nonstandard
|
||||
{
|
||||
CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy());
|
||||
LOCK(keystore.cs_wallet);
|
||||
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
|
||||
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
|
||||
|
||||
scriptPubKey.clear();
|
||||
|
||||
Reference in New Issue
Block a user