6
6
#include < script/sign.h>
7
7
8
8
#include < key.h>
9
- #include < keystore.h>
10
9
#include < policy/policy.h>
11
10
#include < primitives/transaction.h>
12
11
#include < script/standard.h>
15
14
16
15
typedef std::vector<unsigned char > valtype;
17
16
18
- TransactionSignatureCreator::TransactionSignatureCreator (const CKeyStore* keystoreIn , const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn ), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {}
17
+ TransactionSignatureCreator::TransactionSignatureCreator (const SigningProvider* provider , const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(provider ), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {}
19
18
20
19
bool TransactionSignatureCreator::CreateSig (std::vector<unsigned char >& vchSig, const CKeyID& address, const CScript& scriptCode, SigVersion sigversion) const
21
20
{
22
21
CKey key;
23
- if (!keystore ->GetKey (address, key))
22
+ if (!m_provider ->GetKey (address, key))
24
23
return false ;
25
24
26
25
// Signing with uncompressed keys is disabled in witness scripts
@@ -91,12 +90,12 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
91
90
else
92
91
{
93
92
CPubKey vch;
94
- creator.KeyStore ().GetPubKey (keyID, vch);
93
+ creator.Provider ().GetPubKey (keyID, vch);
95
94
ret.push_back (ToByteVector (vch));
96
95
}
97
96
return true ;
98
97
case TX_SCRIPTHASH:
99
- if (creator.KeyStore ().GetCScript (uint160 (vSolutions[0 ]), scriptRet)) {
98
+ if (creator.Provider ().GetCScript (uint160 (vSolutions[0 ]), scriptRet)) {
100
99
ret.push_back (std::vector<unsigned char >(scriptRet.begin (), scriptRet.end ()));
101
100
return true ;
102
101
}
@@ -112,7 +111,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
112
111
113
112
case TX_WITNESS_V0_SCRIPTHASH:
114
113
CRIPEMD160 ().Write (&vSolutions[0 ][0 ], vSolutions[0 ].size ()).Finalize (h160.begin ());
115
- if (creator.KeyStore ().GetCScript (h160, scriptRet)) {
114
+ if (creator.Provider ().GetCScript (h160, scriptRet)) {
116
115
ret.push_back (std::vector<unsigned char >(scriptRet.begin (), scriptRet.end ()));
117
116
return true ;
118
117
}
@@ -206,27 +205,27 @@ void UpdateTransaction(CMutableTransaction& tx, unsigned int nIn, const Signatur
206
205
UpdateInput (tx.vin [nIn], data);
207
206
}
208
207
209
- bool SignSignature (const CKeyStore &keystore , const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType)
208
+ bool SignSignature (const SigningProvider &provider , const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType)
210
209
{
211
210
assert (nIn < txTo.vin .size ());
212
211
213
212
CTransaction txToConst (txTo);
214
- TransactionSignatureCreator creator (&keystore , &txToConst, nIn, amount, nHashType);
213
+ TransactionSignatureCreator creator (&provider , &txToConst, nIn, amount, nHashType);
215
214
216
215
SignatureData sigdata;
217
216
bool ret = ProduceSignature (creator, fromPubKey, sigdata);
218
217
UpdateTransaction (txTo, nIn, sigdata);
219
218
return ret;
220
219
}
221
220
222
- bool SignSignature (const CKeyStore &keystore , const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType)
221
+ bool SignSignature (const SigningProvider &provider , const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType)
223
222
{
224
223
assert (nIn < txTo.vin .size ());
225
224
CTxIn& txin = txTo.vin [nIn];
226
225
assert (txin.prevout .n < txFrom.vout .size ());
227
226
const CTxOut& txout = txFrom.vout [txin.prevout .n ];
228
227
229
- return SignSignature (keystore , txout.scriptPubKey , txTo, nIn, txout.nValue , nHashType);
228
+ return SignSignature (provider , txout.scriptPubKey , txTo, nIn, txout.nValue , nHashType);
230
229
}
231
230
232
231
static std::vector<valtype> CombineMultisig (const CScript& scriptPubKey, const BaseSignatureChecker& checker,
@@ -427,13 +426,13 @@ bool DummySignatureCreator::CreateSig(std::vector<unsigned char>& vchSig, const
427
426
return true ;
428
427
}
429
428
430
- bool IsSolvable (const CKeyStore& store , const CScript& script)
429
+ bool IsSolvable (const SigningProvider& provider , const CScript& script)
431
430
{
432
431
// This check is to make sure that the script we created can actually be solved for and signed by us
433
432
// if we were to have the private keys. This is just to make sure that the script is valid and that,
434
433
// if found in a transaction, we would still accept and relay that transaction. In particular,
435
434
// it will reject witness outputs that require signing with an uncompressed public key.
436
- DummySignatureCreator creator (&store );
435
+ DummySignatureCreator creator (&provider );
437
436
SignatureData sigs;
438
437
// Make sure that STANDARD_SCRIPT_VERIFY_FLAGS includes SCRIPT_VERIFY_WITNESS_PUBKEYTYPE, the most
439
438
// important property this function is designed to test for.
0 commit comments