16#include <boost/test/unit_test.hpp>
29 auto parsed_descs =
Parse(desc_str, keys, error,
false);
31 if (!success)
return nullptr;
32 auto& desc = parsed_descs.at(0);
34 const int64_t range_start = 0, range_end = 1, next_index = 0, timestamp = 1;
36 WalletDescriptor w_desc(std::move(desc), timestamp, range_start, range_end, next_index);
38 LOCK(keystore.cs_wallet);
40 return Assert(keystore.AddWalletDescriptor(w_desc, keys,
"",
false));
47 for (
int i = 0; i < 2; i++) {
54 std::unique_ptr<interfaces::Chain>& chain =
m_node.
chain;
81 std::string desc_str =
"pk(" +
EncodeSecret(keys[0]) +
")";
86 result = spk_manager->IsMine(scriptPubKey);
112 std::string desc_str =
"pk(" +
EncodeSecret(uncompressedKey) +
")";
117 result = spk_manager->IsMine(scriptPubKey);
143 std::string desc_str =
"pkh(" +
EncodeSecret(keys[0]) +
")";
148 result = spk_manager->IsMine(scriptPubKey);
174 std::string desc_str =
"pkh(" +
EncodeSecret(uncompressedKey) +
")";
179 result = spk_manager->IsMine(scriptPubKey);
213 std::string desc_str =
"sh(pkh(" +
EncodeSecret(keys[0]) +
"))";
219 result = spk_manager->IsMine(scriptPubKey);
245 std::string desc_str =
"sh(sh(" +
EncodeSecret(keys[0]) +
"))";
273 std::string desc_str =
"wsh(sh(" +
EncodeSecret(keys[0]) +
"))";
299 std::string desc_str =
"wsh(wpkh(" +
EncodeSecret(keys[0]) +
"))";
327 std::string desc_str =
"wsh(wsh(" +
EncodeSecret(keys[0]) +
"))";
352 std::string desc_str =
"wpkh(" +
EncodeSecret(keys[0]) +
")";
357 result = spk_manager->IsMine(scriptPubKey);
385 std::string desc_str =
"wpkh(" +
EncodeSecret(uncompressedKey) +
")";
434 result = spk_manager->IsMine(scriptPubKey);
471 result = spk_manager->IsMine(scriptPubKey);
514 result = spk_manager->IsMine(scriptPubKey);
598 result = spk_manager->IsMine(scriptPubKey);
606 std::string desc_str =
"combo(" +
EncodeSecret(keys[0]) +
")";
621 result = spk_manager->IsMine(scriptPubKey);
626 result = spk_manager->IsMine(scriptPubKey);
632 result = spk_manager->IsMine(scriptPubKey);
642 result = spk_manager->IsMine(scriptPubKey);
650 std::string desc_str =
"tr(" +
EncodeSecret(keys[0]) +
")";
660 result = spk_manager->IsMine(scriptPubKey);
671 scriptPubKey.
clear();
686 scriptPubKey.
clear();
687 scriptPubKey <<
OP_0 <<
"aabb"_hex;
701 scriptPubKey.
clear();
702 scriptPubKey <<
OP_16 <<
"aabb"_hex;
716 scriptPubKey.
clear();
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
#define Assert(val)
Identity function.
An encapsulated private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
virtual bool AddKey(const CKey &key)
RecursiveMutex cs_KeyStore
Utility class to construct Taproot outputs from internal key and script tree.
WitnessV1Taproot GetOutput()
Compute scriptPubKey (after Finalize()).
TaprootBuilder & Finalize(const XOnlyPubKey &internal_key)
Finalize the construction.
bool IsFullyValid() const
Determine if this pubkey is fully valid.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
void SetupLegacyScriptPubKeyMan()
Make a Legacy(Data)SPKM and set it for all types, internal, and external.
isminetype IsMine(const CScript &script) const override
std::unordered_set< CScript, SaltedSipHasher > GetScriptPubKeys() const override
Returns a set of all the scriptPubKeys that this ScriptPubKeyMan watches.
bool AddCScript(const CScript &redeemScript) override
Descriptor with some wallet metadata.
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
CKey GenerateRandomKey(bool compressed) noexcept
std::string EncodeSecret(const CKey &key)
""_hex is a compile-time user-defined literal returning a std::array<std::byte>, equivalent to ParseH...
wallet::ScriptPubKeyMan * CreateDescriptor(CWallet &keystore, const std::string &desc_str, const bool success)
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase(MockableData records)
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
BOOST_AUTO_TEST_CASE(bnb_search_test)
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::vector< unsigned char > ToByteVector(const T &in)
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
std::unique_ptr< interfaces::Chain > chain
is a home for public enum and struct type definitions that are used by internally by wallet code,...