Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
scriptpubkeyman_tests.cpp
Go to the documentation of this file.
1// Copyright (c) 2020 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <chainparams.h>
6#include <key.h>
7#include <script/standard.h>
8#include <test/util/setup_common.h>
10#include <wallet/wallet.h>
11
12#include <boost/test/unit_test.hpp>
13
15
16// Test LegacyScriptPubKeyMan::CanProvide behavior, making sure it returns true
17// for recognized scripts even when keys may not be available for signing.
19 // Set up wallet and keyman variables.
21 LegacyScriptPubKeyMan &keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
22
23 // Make a 1 of 2 multisig script
24 std::vector<CKey> keys(2);
25 std::vector<CPubKey> pubkeys;
26 for (CKey &key : keys) {
27 key.MakeNewKey(true);
28 pubkeys.emplace_back(key.GetPubKey());
29 }
32 SignatureData data;
33
34 // Verify the p2sh(multisig) script is not recognized until the multisig
35 // script is added to the keystore to make it solvable
36 BOOST_CHECK(!keyman.CanProvide(p2sh_script, data));
37 keyman.AddCScript(multisig_script);
38 BOOST_CHECK(keyman.CanProvide(p2sh_script, data));
39}
40
An encapsulated secp256k1 private key.
Definition key.h:28
Serialized script, used inside transaction inputs and outputs.
Definition script.h:431
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition wallet.h:254
NodeContext & m_node
#define BOOST_CHECK(expr)
Definition object.cpp:17
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
BOOST_AUTO_TEST_CASE(CanProvide)
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
Definition standard.cpp:249
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition standard.cpp:240
std::unique_ptr< WalletDatabase > CreateDummyWalletDatabase()
Return object for accessing dummy database with no read/write capabilities.