scripted-diff: rename CBasicKeyStore to FillableSigningProvider
-BEGIN VERIFY SCRIPT- git grep -l "CBasicKeyStore" | xargs sed -i -e 's/CBasicKeyStore/FillableSigningProvider/g' -END VERIFY SCRIPT-
This commit is contained in:
parent
a913e3f2fb
commit
d9becff4e1
23 changed files with 58 additions and 58 deletions
|
@ -375,7 +375,7 @@ reported in the debug.log file.
|
||||||
|
|
||||||
Re-architecting the core code so there are better-defined interfaces
|
Re-architecting the core code so there are better-defined interfaces
|
||||||
between the various components is a goal, with any necessary locking
|
between the various components is a goal, with any necessary locking
|
||||||
done by the components (e.g. see the self-contained `CBasicKeyStore` class
|
done by the components (e.g. see the self-contained `FillableSigningProvider` class
|
||||||
and its `cs_KeyStore` lock for example).
|
and its `cs_KeyStore` lock for example).
|
||||||
|
|
||||||
Threads
|
Threads
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
// paid to a TX_PUBKEYHASH.
|
// paid to a TX_PUBKEYHASH.
|
||||||
//
|
//
|
||||||
static std::vector<CMutableTransaction>
|
static std::vector<CMutableTransaction>
|
||||||
SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
|
SetupDummyInputs(FillableSigningProvider& keystoreRet, CCoinsViewCache& coinsRet)
|
||||||
{
|
{
|
||||||
std::vector<CMutableTransaction> dummyTransactions;
|
std::vector<CMutableTransaction> dummyTransactions;
|
||||||
dummyTransactions.resize(2);
|
dummyTransactions.resize(2);
|
||||||
|
@ -55,7 +55,7 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
|
||||||
// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
|
// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
|
||||||
static void CCoinsCaching(benchmark::State& state)
|
static void CCoinsCaching(benchmark::State& state)
|
||||||
{
|
{
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
CCoinsView coinsDummy;
|
CCoinsView coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
|
|
@ -557,7 +557,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
|
||||||
|
|
||||||
if (!registers.count("privatekeys"))
|
if (!registers.count("privatekeys"))
|
||||||
throw std::runtime_error("privatekeys register variable must be set.");
|
throw std::runtime_error("privatekeys register variable must be set.");
|
||||||
CBasicKeyStore tempKeystore;
|
FillableSigningProvider tempKeystore;
|
||||||
UniValue keysObj = registers["privatekeys"];
|
UniValue keysObj = registers["privatekeys"];
|
||||||
|
|
||||||
for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) {
|
for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) {
|
||||||
|
@ -631,7 +631,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CBasicKeyStore& keystore = tempKeystore;
|
const FillableSigningProvider& keystore = tempKeystore;
|
||||||
|
|
||||||
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
|
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
|
||||||
void CBasicKeyStore::ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey)
|
void FillableSigningProvider::ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_KeyStore);
|
AssertLockHeld(cs_KeyStore);
|
||||||
CKeyID key_id = pubkey.GetID();
|
CKeyID key_id = pubkey.GetID();
|
||||||
|
@ -32,7 +32,7 @@ void CBasicKeyStore::ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
|
bool FillableSigningProvider::GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
|
||||||
{
|
{
|
||||||
CKey key;
|
CKey key;
|
||||||
if (!GetKey(address, key)) {
|
if (!GetKey(address, key)) {
|
||||||
|
@ -48,7 +48,7 @@ bool CBasicKeyStore::GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) con
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
|
bool FillableSigningProvider::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
mapKeys[pubkey.GetID()] = key;
|
mapKeys[pubkey.GetID()] = key;
|
||||||
|
@ -56,13 +56,13 @@ bool CBasicKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::HaveKey(const CKeyID &address) const
|
bool FillableSigningProvider::HaveKey(const CKeyID &address) const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
return mapKeys.count(address) > 0;
|
return mapKeys.count(address) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<CKeyID> CBasicKeyStore::GetKeys() const
|
std::set<CKeyID> FillableSigningProvider::GetKeys() const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
std::set<CKeyID> set_address;
|
std::set<CKeyID> set_address;
|
||||||
|
@ -72,7 +72,7 @@ std::set<CKeyID> CBasicKeyStore::GetKeys() const
|
||||||
return set_address;
|
return set_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::GetKey(const CKeyID &address, CKey &keyOut) const
|
bool FillableSigningProvider::GetKey(const CKeyID &address, CKey &keyOut) const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
KeyMap::const_iterator mi = mapKeys.find(address);
|
KeyMap::const_iterator mi = mapKeys.find(address);
|
||||||
|
@ -83,23 +83,23 @@ bool CBasicKeyStore::GetKey(const CKeyID &address, CKey &keyOut) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::AddCScript(const CScript& redeemScript)
|
bool FillableSigningProvider::AddCScript(const CScript& redeemScript)
|
||||||
{
|
{
|
||||||
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
|
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
|
||||||
return error("CBasicKeyStore::AddCScript(): redeemScripts > %i bytes are invalid", MAX_SCRIPT_ELEMENT_SIZE);
|
return error("FillableSigningProvider::AddCScript(): redeemScripts > %i bytes are invalid", MAX_SCRIPT_ELEMENT_SIZE);
|
||||||
|
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
mapScripts[CScriptID(redeemScript)] = redeemScript;
|
mapScripts[CScriptID(redeemScript)] = redeemScript;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::HaveCScript(const CScriptID& hash) const
|
bool FillableSigningProvider::HaveCScript(const CScriptID& hash) const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
return mapScripts.count(hash) > 0;
|
return mapScripts.count(hash) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<CScriptID> CBasicKeyStore::GetCScripts() const
|
std::set<CScriptID> FillableSigningProvider::GetCScripts() const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
std::set<CScriptID> set_script;
|
std::set<CScriptID> set_script;
|
||||||
|
@ -109,7 +109,7 @@ std::set<CScriptID> CBasicKeyStore::GetCScripts() const
|
||||||
return set_script;
|
return set_script;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const
|
bool FillableSigningProvider::GetCScript(const CScriptID &hash, CScript& redeemScriptOut) const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
ScriptMap::const_iterator mi = mapScripts.find(hash);
|
ScriptMap::const_iterator mi = mapScripts.find(hash);
|
||||||
|
@ -137,7 +137,7 @@ static bool ExtractPubKey(const CScript &dest, CPubKey& pubKeyOut)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::AddWatchOnly(const CScript &dest)
|
bool FillableSigningProvider::AddWatchOnly(const CScript &dest)
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
setWatchOnly.insert(dest);
|
setWatchOnly.insert(dest);
|
||||||
|
@ -149,7 +149,7 @@ bool CBasicKeyStore::AddWatchOnly(const CScript &dest)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::RemoveWatchOnly(const CScript &dest)
|
bool FillableSigningProvider::RemoveWatchOnly(const CScript &dest)
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
setWatchOnly.erase(dest);
|
setWatchOnly.erase(dest);
|
||||||
|
@ -162,19 +162,19 @@ bool CBasicKeyStore::RemoveWatchOnly(const CScript &dest)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::HaveWatchOnly(const CScript &dest) const
|
bool FillableSigningProvider::HaveWatchOnly(const CScript &dest) const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
return setWatchOnly.count(dest) > 0;
|
return setWatchOnly.count(dest) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicKeyStore::HaveWatchOnly() const
|
bool FillableSigningProvider::HaveWatchOnly() const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
return (!setWatchOnly.empty());
|
return (!setWatchOnly.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
CKeyID GetKeyForDestination(const CBasicKeyStore& store, const CTxDestination& dest)
|
CKeyID GetKeyForDestination(const FillableSigningProvider& store, const CTxDestination& dest)
|
||||||
{
|
{
|
||||||
// Only supports destinations which map to single public keys, i.e. P2PKH,
|
// Only supports destinations which map to single public keys, i.e. P2PKH,
|
||||||
// P2WPKH, and P2SH-P2WPKH.
|
// P2WPKH, and P2SH-P2WPKH.
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <boost/signals2/signal.hpp>
|
#include <boost/signals2/signal.hpp>
|
||||||
|
|
||||||
/** Basic key store, that keeps keys in an address->secret map */
|
/** Basic key store, that keeps keys in an address->secret map */
|
||||||
class CBasicKeyStore : public SigningProvider
|
class FillableSigningProvider : public SigningProvider
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
mutable CCriticalSection cs_KeyStore;
|
mutable CCriticalSection cs_KeyStore;
|
||||||
|
@ -52,6 +52,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Return the CKeyID of the key involved in a script (if there is a unique one). */
|
/** Return the CKeyID of the key involved in a script (if there is a unique one). */
|
||||||
CKeyID GetKeyForDestination(const CBasicKeyStore& store, const CTxDestination& dest);
|
CKeyID GetKeyForDestination(const FillableSigningProvider& store, const CTxDestination& dest);
|
||||||
|
|
||||||
#endif // BITCOIN_KEYSTORE_H
|
#endif // BITCOIN_KEYSTORE_H
|
||||||
|
|
|
@ -73,7 +73,7 @@ std::vector<CTxDestination> GetAllDestinationsForKey(const CPubKey& key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxDestination AddAndGetDestinationForScript(CBasicKeyStore& keystore, const CScript& script, OutputType type)
|
CTxDestination AddAndGetDestinationForScript(FillableSigningProvider& keystore, const CScript& script, OutputType type)
|
||||||
{
|
{
|
||||||
// Add script to keystore
|
// Add script to keystore
|
||||||
keystore.AddCScript(script);
|
keystore.AddCScript(script);
|
||||||
|
|
|
@ -44,7 +44,7 @@ std::vector<CTxDestination> GetAllDestinationsForKey(const CPubKey& key);
|
||||||
* This function will automatically add the script (and any other
|
* This function will automatically add the script (and any other
|
||||||
* necessary scripts) to the keystore.
|
* necessary scripts) to the keystore.
|
||||||
*/
|
*/
|
||||||
CTxDestination AddAndGetDestinationForScript(CBasicKeyStore& keystore, const CScript& script, OutputType);
|
CTxDestination AddAndGetDestinationForScript(FillableSigningProvider& keystore, const CScript& script, OutputType);
|
||||||
|
|
||||||
#endif // BITCOIN_OUTPUTTYPE_H
|
#endif // BITCOIN_OUTPUTTYPE_H
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ static UniValue createmultisig(const JSONRPCRequest& request)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct using pay-to-script-hash:
|
// Construct using pay-to-script-hash:
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
CScript inner;
|
CScript inner;
|
||||||
const CTxDestination dest = AddAndGetMultisigDestination(required, pubkeys, output_type, keystore, inner);
|
const CTxDestination dest = AddAndGetMultisigDestination(required, pubkeys, output_type, keystore, inner);
|
||||||
|
|
||||||
|
|
|
@ -761,7 +761,7 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
const UniValue& keys = request.params[1].get_array();
|
const UniValue& keys = request.params[1].get_array();
|
||||||
for (unsigned int idx = 0; idx < keys.size(); ++idx) {
|
for (unsigned int idx = 0; idx < keys.size(); ++idx) {
|
||||||
UniValue k = keys[idx];
|
UniValue k = keys[idx];
|
||||||
|
|
|
@ -148,7 +148,7 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
|
||||||
vErrorsRet.push_back(entry);
|
vErrorsRet.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival, CBasicKeyStore* keystore, std::map<COutPoint, Coin>& coins, bool is_temp_keystore, const UniValue& hashType)
|
UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival, FillableSigningProvider* keystore, std::map<COutPoint, Coin>& coins, bool is_temp_keystore, const UniValue& hashType)
|
||||||
{
|
{
|
||||||
// Add previous txouts given in the RPC call:
|
// Add previous txouts given in the RPC call:
|
||||||
if (!prevTxsUnival.isNull()) {
|
if (!prevTxsUnival.isNull()) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class CBasicKeyStore;
|
class FillableSigningProvider;
|
||||||
class UniValue;
|
class UniValue;
|
||||||
struct CMutableTransaction;
|
struct CMutableTransaction;
|
||||||
class Coin;
|
class Coin;
|
||||||
|
@ -24,7 +24,7 @@ class COutPoint;
|
||||||
* @param hashType The signature hash type
|
* @param hashType The signature hash type
|
||||||
* @returns JSON object with details of signed transaction
|
* @returns JSON object with details of signed transaction
|
||||||
*/
|
*/
|
||||||
UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxs, CBasicKeyStore* keystore, std::map<COutPoint, Coin>& coins, bool tempKeystore, const UniValue& hashType);
|
UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxs, FillableSigningProvider* keystore, std::map<COutPoint, Coin>& coins, bool tempKeystore, const UniValue& hashType);
|
||||||
|
|
||||||
/** Create a transaction from univalue parameters */
|
/** Create a transaction from univalue parameters */
|
||||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, const UniValue& rbf);
|
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, const UniValue& rbf);
|
||||||
|
|
|
@ -131,8 +131,8 @@ CPubKey HexToPubKey(const std::string& hex_in)
|
||||||
return vchPubKey;
|
return vchPubKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieves a public key for an address from the given CBasicKeyStore
|
// Retrieves a public key for an address from the given FillableSigningProvider
|
||||||
CPubKey AddrToPubKey(CBasicKeyStore* const keystore, const std::string& addr_in)
|
CPubKey AddrToPubKey(FillableSigningProvider* const keystore, const std::string& addr_in)
|
||||||
{
|
{
|
||||||
CTxDestination dest = DecodeDestination(addr_in);
|
CTxDestination dest = DecodeDestination(addr_in);
|
||||||
if (!IsValidDestination(dest)) {
|
if (!IsValidDestination(dest)) {
|
||||||
|
@ -153,7 +153,7 @@ CPubKey AddrToPubKey(CBasicKeyStore* const keystore, const std::string& addr_in)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a multisig address from a given list of public keys, number of signatures required, and the address type
|
// Creates a multisig address from a given list of public keys, number of signatures required, and the address type
|
||||||
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, CBasicKeyStore& keystore, CScript& script_out)
|
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, FillableSigningProvider& keystore, CScript& script_out)
|
||||||
{
|
{
|
||||||
// Gather public keys
|
// Gather public keys
|
||||||
if (required < 1) {
|
if (required < 1) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
|
|
||||||
class CBasicKeyStore;
|
class FillableSigningProvider;
|
||||||
class CPubKey;
|
class CPubKey;
|
||||||
class CScript;
|
class CScript;
|
||||||
struct InitInterfaces;
|
struct InitInterfaces;
|
||||||
|
@ -72,8 +72,8 @@ extern std::string HelpExampleCli(const std::string& methodname, const std::stri
|
||||||
extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
|
extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
|
||||||
|
|
||||||
CPubKey HexToPubKey(const std::string& hex_in);
|
CPubKey HexToPubKey(const std::string& hex_in);
|
||||||
CPubKey AddrToPubKey(CBasicKeyStore* const keystore, const std::string& addr_in);
|
CPubKey AddrToPubKey(FillableSigningProvider* const keystore, const std::string& addr_in);
|
||||||
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, CBasicKeyStore& keystore, CScript& script_out);
|
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, FillableSigningProvider& keystore, CScript& script_out);
|
||||||
|
|
||||||
UniValue DescribeAddress(const CTxDestination& dest);
|
UniValue DescribeAddress(const CTxDestination& dest);
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
|
||||||
{
|
{
|
||||||
CKey key;
|
CKey key;
|
||||||
key.MakeNewKey(true);
|
key.MakeNewKey(true);
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
BOOST_CHECK(keystore.AddKey(key));
|
BOOST_CHECK(keystore.AddKey(key));
|
||||||
|
|
||||||
// 50 orphan transactions:
|
// 50 orphan transactions:
|
||||||
|
|
|
@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE(multisig_IsStandard)
|
||||||
BOOST_AUTO_TEST_CASE(multisig_Sign)
|
BOOST_AUTO_TEST_CASE(multisig_Sign)
|
||||||
{
|
{
|
||||||
// Test SignSignature() (and therefore the version of Solver() that signs transactions)
|
// Test SignSignature() (and therefore the version of Solver() that signs transactions)
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
CKey key[4];
|
CKey key[4];
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(sign)
|
||||||
// scriptPubKey: HASH160 <hash> EQUAL
|
// scriptPubKey: HASH160 <hash> EQUAL
|
||||||
|
|
||||||
// Test SignSignature() (and therefore the version of Solver() that signs transactions)
|
// Test SignSignature() (and therefore the version of Solver() that signs transactions)
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
CKey key[4];
|
CKey key[4];
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(set)
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
// Test the CScript::Set* methods
|
// Test the CScript::Set* methods
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
CKey key[4];
|
CKey key[4];
|
||||||
std::vector<CPubKey> keys;
|
std::vector<CPubKey> keys;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
|
@ -265,7 +265,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CCoinsView coinsDummy;
|
CCoinsView coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
CKey key[6];
|
CKey key[6];
|
||||||
std::vector<CPubKey> keys;
|
std::vector<CPubKey> keys;
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
|
|
|
@ -1199,7 +1199,7 @@ SignatureData CombineSignatures(const CTxOut& txout, const CMutableTransaction&
|
||||||
BOOST_AUTO_TEST_CASE(script_combineSigs)
|
BOOST_AUTO_TEST_CASE(script_combineSigs)
|
||||||
{
|
{
|
||||||
// Test the ProduceSignature's ability to combine signatures function
|
// Test the ProduceSignature's ability to combine signatures function
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
std::vector<CKey> keys;
|
std::vector<CKey> keys;
|
||||||
std::vector<CPubKey> pubkeys;
|
std::vector<CPubKey> pubkeys;
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
|
|
|
@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE(basic_transaction_tests)
|
||||||
// paid to a TX_PUBKEYHASH.
|
// paid to a TX_PUBKEYHASH.
|
||||||
//
|
//
|
||||||
static std::vector<CMutableTransaction>
|
static std::vector<CMutableTransaction>
|
||||||
SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
|
SetupDummyInputs(FillableSigningProvider& keystoreRet, CCoinsViewCache& coinsRet)
|
||||||
{
|
{
|
||||||
std::vector<CMutableTransaction> dummyTransactions;
|
std::vector<CMutableTransaction> dummyTransactions;
|
||||||
dummyTransactions.resize(2);
|
dummyTransactions.resize(2);
|
||||||
|
@ -322,7 +322,7 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_Get)
|
BOOST_AUTO_TEST_CASE(test_Get)
|
||||||
{
|
{
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
CCoinsView coinsDummy;
|
CCoinsView coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
@ -346,7 +346,7 @@ BOOST_AUTO_TEST_CASE(test_Get)
|
||||||
BOOST_CHECK_EQUAL(coins.GetValueIn(CTransaction(t1)), (50+21+22)*CENT);
|
BOOST_CHECK_EQUAL(coins.GetValueIn(CTransaction(t1)), (50+21+22)*CENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateCreditAndSpend(const CBasicKeyStore& keystore, const CScript& outscript, CTransactionRef& output, CMutableTransaction& input, bool success = true)
|
static void CreateCreditAndSpend(const FillableSigningProvider& keystore, const CScript& outscript, CTransactionRef& output, CMutableTransaction& input, bool success = true)
|
||||||
{
|
{
|
||||||
CMutableTransaction outputm;
|
CMutableTransaction outputm;
|
||||||
outputm.nVersion = 1;
|
outputm.nVersion = 1;
|
||||||
|
@ -423,7 +423,7 @@ BOOST_AUTO_TEST_CASE(test_big_witness_transaction)
|
||||||
|
|
||||||
CKey key;
|
CKey key;
|
||||||
key.MakeNewKey(true); // Need to use compressed keys in segwit or the signing will fail
|
key.MakeNewKey(true); // Need to use compressed keys in segwit or the signing will fail
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
BOOST_CHECK(keystore.AddKeyPubKey(key, key.GetPubKey()));
|
BOOST_CHECK(keystore.AddKeyPubKey(key, key.GetPubKey()));
|
||||||
CKeyID hash = key.GetPubKey().GetID();
|
CKeyID hash = key.GetPubKey().GetID();
|
||||||
CScript scriptPubKey = CScript() << OP_0 << std::vector<unsigned char>(hash.begin(), hash.end());
|
CScript scriptPubKey = CScript() << OP_0 << std::vector<unsigned char>(hash.begin(), hash.end());
|
||||||
|
@ -507,7 +507,7 @@ SignatureData CombineSignatures(const CMutableTransaction& input1, const CMutabl
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_witness)
|
BOOST_AUTO_TEST_CASE(test_witness)
|
||||||
{
|
{
|
||||||
CBasicKeyStore keystore, keystore2;
|
FillableSigningProvider keystore, keystore2;
|
||||||
CKey key1, key2, key3, key1L, key2L;
|
CKey key1, key2, key3, key1L, key2L;
|
||||||
CPubKey pubkey1, pubkey2, pubkey3, pubkey1L, pubkey2L;
|
CPubKey pubkey1, pubkey2, pubkey3, pubkey1L, pubkey2L;
|
||||||
key1.MakeNewKey(true);
|
key1.MakeNewKey(true);
|
||||||
|
@ -682,7 +682,7 @@ BOOST_AUTO_TEST_CASE(test_witness)
|
||||||
BOOST_AUTO_TEST_CASE(test_IsStandard)
|
BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
CCoinsView coinsDummy;
|
CCoinsView coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
|
|
@ -161,7 +161,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
|
||||||
CScript p2pkh_scriptPubKey = GetScriptForDestination(PKHash(coinbaseKey.GetPubKey()));
|
CScript p2pkh_scriptPubKey = GetScriptForDestination(PKHash(coinbaseKey.GetPubKey()));
|
||||||
CScript p2wpkh_scriptPubKey = GetScriptForWitness(p2pkh_scriptPubKey);
|
CScript p2wpkh_scriptPubKey = GetScriptForWitness(p2pkh_scriptPubKey);
|
||||||
|
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
BOOST_CHECK(keystore.AddKey(coinbaseKey));
|
BOOST_CHECK(keystore.AddKey(coinbaseKey));
|
||||||
BOOST_CHECK(keystore.AddCScript(p2pk_scriptPubKey));
|
BOOST_CHECK(keystore.AddCScript(p2pk_scriptPubKey));
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ bool CCryptoKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted()) {
|
if (!IsCrypted()) {
|
||||||
return CBasicKeyStore::AddKeyPubKey(key, pubkey);
|
return FillableSigningProvider::AddKeyPubKey(key, pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsLocked()) {
|
if (IsLocked()) {
|
||||||
|
@ -253,7 +253,7 @@ bool CCryptoKeyStore::HaveKey(const CKeyID &address) const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted()) {
|
if (!IsCrypted()) {
|
||||||
return CBasicKeyStore::HaveKey(address);
|
return FillableSigningProvider::HaveKey(address);
|
||||||
}
|
}
|
||||||
return mapCryptedKeys.count(address) > 0;
|
return mapCryptedKeys.count(address) > 0;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted()) {
|
if (!IsCrypted()) {
|
||||||
return CBasicKeyStore::GetKey(address, keyOut);
|
return FillableSigningProvider::GetKey(address, keyOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
|
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
|
||||||
|
@ -279,7 +279,7 @@ bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) co
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted())
|
if (!IsCrypted())
|
||||||
return CBasicKeyStore::GetPubKey(address, vchPubKeyOut);
|
return FillableSigningProvider::GetPubKey(address, vchPubKeyOut);
|
||||||
|
|
||||||
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
|
CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
|
||||||
if (mi != mapCryptedKeys.end())
|
if (mi != mapCryptedKeys.end())
|
||||||
|
@ -288,14 +288,14 @@ bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) co
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check for watch-only pubkeys
|
// Check for watch-only pubkeys
|
||||||
return CBasicKeyStore::GetPubKey(address, vchPubKeyOut);
|
return FillableSigningProvider::GetPubKey(address, vchPubKeyOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<CKeyID> CCryptoKeyStore::GetKeys() const
|
std::set<CKeyID> CCryptoKeyStore::GetKeys() const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (!IsCrypted()) {
|
if (!IsCrypted()) {
|
||||||
return CBasicKeyStore::GetKeys();
|
return FillableSigningProvider::GetKeys();
|
||||||
}
|
}
|
||||||
std::set<CKeyID> set_address;
|
std::set<CKeyID> set_address;
|
||||||
for (const auto& mi : mapCryptedKeys) {
|
for (const auto& mi : mapCryptedKeys) {
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
/** Keystore which keeps the private keys encrypted.
|
/** Keystore which keeps the private keys encrypted.
|
||||||
* It derives from the basic key store, which is used if no encryption is active.
|
* It derives from the basic key store, which is used if no encryption is active.
|
||||||
*/
|
*/
|
||||||
class CCryptoKeyStore : public CBasicKeyStore
|
class CCryptoKeyStore : public FillableSigningProvider
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -488,7 +488,7 @@ static size_t CalculateNestedKeyhashInputSize(bool use_max_sig)
|
||||||
CScript script_pubkey = CScript() << OP_HASH160 << std::vector<unsigned char>(script_id.begin(), script_id.end()) << OP_EQUAL;
|
CScript script_pubkey = CScript() << OP_HASH160 << std::vector<unsigned char>(script_id.begin(), script_id.end()) << OP_EQUAL;
|
||||||
|
|
||||||
// Add inner-script to key store and key to watchonly
|
// Add inner-script to key store and key to watchonly
|
||||||
CBasicKeyStore keystore;
|
FillableSigningProvider keystore;
|
||||||
keystore.AddCScript(inner_script);
|
keystore.AddCScript(inner_script);
|
||||||
keystore.AddKeyPubKey(key, pubkey);
|
keystore.AddKeyPubKey(key, pubkey);
|
||||||
|
|
||||||
|
|
|
@ -1296,7 +1296,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Explicitly make the wallet learn the related scripts for outputs to the
|
* Explicitly make the wallet learn the related scripts for outputs to the
|
||||||
* given key. This is purely to make the wallet file compatible with older
|
* given key. This is purely to make the wallet file compatible with older
|
||||||
* software, as CBasicKeyStore automatically does this implicitly for all
|
* software, as FillableSigningProvider automatically does this implicitly for all
|
||||||
* keys now.
|
* keys now.
|
||||||
*/
|
*/
|
||||||
void LearnRelatedScripts(const CPubKey& key, OutputType);
|
void LearnRelatedScripts(const CPubKey& key, OutputType);
|
||||||
|
|
Loading…
Reference in a new issue