@@ -92,11 +92,11 @@ static bool CreateSig(const BaseSignatureCreator& creator, SignatureData& sigdat
92
92
/* *
93
93
* Sign scriptPubKey using signature made with creator.
94
94
* Signatures are returned in scriptSigRet (or returns false if scriptPubKey can't be signed),
95
- * unless whichTypeRet is TX_SCRIPTHASH , in which case scriptSigRet is the redemption script.
95
+ * unless whichTypeRet is TxoutType::SCRIPTHASH , in which case scriptSigRet is the redemption script.
96
96
* Returns false if scriptPubKey could not be completely satisfied.
97
97
*/
98
98
static bool SignStep (const SigningProvider& provider, const BaseSignatureCreator& creator, const CScript& scriptPubKey,
99
- std::vector<valtype>& ret, txnouttype & whichTypeRet, SigVersion sigversion, SignatureData& sigdata)
99
+ std::vector<valtype>& ret, TxoutType & whichTypeRet, SigVersion sigversion, SignatureData& sigdata)
100
100
{
101
101
CScript scriptRet;
102
102
uint160 h160;
@@ -108,15 +108,15 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
108
108
109
109
switch (whichTypeRet)
110
110
{
111
- case TX_NONSTANDARD :
112
- case TX_NULL_DATA :
113
- case TX_WITNESS_UNKNOWN :
111
+ case TxoutType::NONSTANDARD :
112
+ case TxoutType::NULL_DATA :
113
+ case TxoutType::WITNESS_UNKNOWN :
114
114
return false ;
115
- case TX_PUBKEY :
115
+ case TxoutType::PUBKEY :
116
116
if (!CreateSig (creator, sigdata, provider, sig, CPubKey (vSolutions[0 ]), scriptPubKey, sigversion)) return false ;
117
117
ret.push_back (std::move (sig));
118
118
return true ;
119
- case TX_PUBKEYHASH : {
119
+ case TxoutType::PUBKEYHASH : {
120
120
CKeyID keyID = CKeyID (uint160 (vSolutions[0 ]));
121
121
CPubKey pubkey;
122
122
if (!GetPubKey (provider, sigdata, keyID, pubkey)) {
@@ -129,7 +129,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
129
129
ret.push_back (ToByteVector (pubkey));
130
130
return true ;
131
131
}
132
- case TX_SCRIPTHASH :
132
+ case TxoutType::SCRIPTHASH :
133
133
h160 = uint160 (vSolutions[0 ]);
134
134
if (GetCScript (provider, sigdata, CScriptID{h160}, scriptRet)) {
135
135
ret.push_back (std::vector<unsigned char >(scriptRet.begin (), scriptRet.end ()));
@@ -139,7 +139,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
139
139
sigdata.missing_redeem_script = h160;
140
140
return false ;
141
141
142
- case TX_MULTISIG : {
142
+ case TxoutType::MULTISIG : {
143
143
size_t required = vSolutions.front ()[0 ];
144
144
ret.push_back (valtype ()); // workaround CHECKMULTISIG bug
145
145
for (size_t i = 1 ; i < vSolutions.size () - 1 ; ++i) {
@@ -159,11 +159,11 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
159
159
}
160
160
return ok;
161
161
}
162
- case TX_WITNESS_V0_KEYHASH :
162
+ case TxoutType::WITNESS_V0_KEYHASH :
163
163
ret.push_back (vSolutions[0 ]);
164
164
return true ;
165
165
166
- case TX_WITNESS_V0_SCRIPTHASH :
166
+ case TxoutType::WITNESS_V0_SCRIPTHASH :
167
167
CRIPEMD160 ().Write (&vSolutions[0 ][0 ], vSolutions[0 ].size ()).Finalize (h160.begin ());
168
168
if (GetCScript (provider, sigdata, CScriptID{h160}, scriptRet)) {
169
169
ret.push_back (std::vector<unsigned char >(scriptRet.begin (), scriptRet.end ()));
@@ -198,44 +198,44 @@ bool ProduceSignature(const SigningProvider& provider, const BaseSignatureCreato
198
198
if (sigdata.complete ) return true ;
199
199
200
200
std::vector<valtype> result;
201
- txnouttype whichType;
201
+ TxoutType whichType;
202
202
bool solved = SignStep (provider, creator, fromPubKey, result, whichType, SigVersion::BASE, sigdata);
203
203
bool P2SH = false ;
204
204
CScript subscript;
205
205
sigdata.scriptWitness .stack .clear ();
206
206
207
- if (solved && whichType == TX_SCRIPTHASH )
207
+ if (solved && whichType == TxoutType::SCRIPTHASH )
208
208
{
209
209
// Solver returns the subscript that needs to be evaluated;
210
210
// the final scriptSig is the signatures from that
211
211
// and then the serialized subscript:
212
212
subscript = CScript (result[0 ].begin (), result[0 ].end ());
213
213
sigdata.redeem_script = subscript;
214
- solved = solved && SignStep (provider, creator, subscript, result, whichType, SigVersion::BASE, sigdata) && whichType != TX_SCRIPTHASH ;
214
+ solved = solved && SignStep (provider, creator, subscript, result, whichType, SigVersion::BASE, sigdata) && whichType != TxoutType::SCRIPTHASH ;
215
215
P2SH = true ;
216
216
}
217
217
218
- if (solved && whichType == TX_WITNESS_V0_KEYHASH )
218
+ if (solved && whichType == TxoutType::WITNESS_V0_KEYHASH )
219
219
{
220
220
CScript witnessscript;
221
221
witnessscript << OP_DUP << OP_HASH160 << ToByteVector (result[0 ]) << OP_EQUALVERIFY << OP_CHECKSIG;
222
- txnouttype subType;
222
+ TxoutType subType;
223
223
solved = solved && SignStep (provider, creator, witnessscript, result, subType, SigVersion::WITNESS_V0, sigdata);
224
224
sigdata.scriptWitness .stack = result;
225
225
sigdata.witness = true ;
226
226
result.clear ();
227
227
}
228
- else if (solved && whichType == TX_WITNESS_V0_SCRIPTHASH )
228
+ else if (solved && whichType == TxoutType::WITNESS_V0_SCRIPTHASH )
229
229
{
230
230
CScript witnessscript (result[0 ].begin (), result[0 ].end ());
231
231
sigdata.witness_script = witnessscript;
232
- txnouttype subType;
233
- solved = solved && SignStep (provider, creator, witnessscript, result, subType, SigVersion::WITNESS_V0, sigdata) && subType != TX_SCRIPTHASH && subType != TX_WITNESS_V0_SCRIPTHASH && subType != TX_WITNESS_V0_KEYHASH ;
232
+ TxoutType subType;
233
+ solved = solved && SignStep (provider, creator, witnessscript, result, subType, SigVersion::WITNESS_V0, sigdata) && subType != TxoutType::SCRIPTHASH && subType != TxoutType::WITNESS_V0_SCRIPTHASH && subType != TxoutType::WITNESS_V0_KEYHASH ;
234
234
result.push_back (std::vector<unsigned char >(witnessscript.begin (), witnessscript.end ()));
235
235
sigdata.scriptWitness .stack = result;
236
236
sigdata.witness = true ;
237
237
result.clear ();
238
- } else if (solved && whichType == TX_WITNESS_UNKNOWN ) {
238
+ } else if (solved && whichType == TxoutType::WITNESS_UNKNOWN ) {
239
239
sigdata.witness = true ;
240
240
}
241
241
@@ -301,11 +301,11 @@ SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nI
301
301
302
302
// Get scripts
303
303
std::vector<std::vector<unsigned char >> solutions;
304
- txnouttype script_type = Solver (txout.scriptPubKey , solutions);
304
+ TxoutType script_type = Solver (txout.scriptPubKey , solutions);
305
305
SigVersion sigversion = SigVersion::BASE;
306
306
CScript next_script = txout.scriptPubKey ;
307
307
308
- if (script_type == TX_SCRIPTHASH && !stack.script .empty () && !stack.script .back ().empty ()) {
308
+ if (script_type == TxoutType::SCRIPTHASH && !stack.script .empty () && !stack.script .back ().empty ()) {
309
309
// Get the redeemScript
310
310
CScript redeem_script (stack.script .back ().begin (), stack.script .back ().end ());
311
311
data.redeem_script = redeem_script;
@@ -315,7 +315,7 @@ SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nI
315
315
script_type = Solver (next_script, solutions);
316
316
stack.script .pop_back ();
317
317
}
318
- if (script_type == TX_WITNESS_V0_SCRIPTHASH && !stack.witness .empty () && !stack.witness .back ().empty ()) {
318
+ if (script_type == TxoutType::WITNESS_V0_SCRIPTHASH && !stack.witness .empty () && !stack.witness .back ().empty ()) {
319
319
// Get the witnessScript
320
320
CScript witness_script (stack.witness .back ().begin (), stack.witness .back ().end ());
321
321
data.witness_script = witness_script;
@@ -328,7 +328,7 @@ SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nI
328
328
stack.witness .clear ();
329
329
sigversion = SigVersion::WITNESS_V0;
330
330
}
331
- if (script_type == TX_MULTISIG && !stack.script .empty ()) {
331
+ if (script_type == TxoutType::MULTISIG && !stack.script .empty ()) {
332
332
// Build a map of pubkey -> signature by matching sigs to pubkeys:
333
333
assert (solutions.size () > 1 );
334
334
unsigned int num_pubkeys = solutions.size ()-2 ;
@@ -454,13 +454,13 @@ bool IsSegWitOutput(const SigningProvider& provider, const CScript& script)
454
454
{
455
455
std::vector<valtype> solutions;
456
456
auto whichtype = Solver (script, solutions);
457
- if (whichtype == TX_WITNESS_V0_SCRIPTHASH || whichtype == TX_WITNESS_V0_KEYHASH || whichtype == TX_WITNESS_UNKNOWN ) return true ;
458
- if (whichtype == TX_SCRIPTHASH ) {
457
+ if (whichtype == TxoutType::WITNESS_V0_SCRIPTHASH || whichtype == TxoutType::WITNESS_V0_KEYHASH || whichtype == TxoutType::WITNESS_UNKNOWN ) return true ;
458
+ if (whichtype == TxoutType::SCRIPTHASH ) {
459
459
auto h160 = uint160 (solutions[0 ]);
460
460
CScript subscript;
461
461
if (provider.GetCScript (CScriptID{h160}, subscript)) {
462
462
whichtype = Solver (subscript, solutions);
463
- if (whichtype == TX_WITNESS_V0_SCRIPTHASH || whichtype == TX_WITNESS_V0_KEYHASH || whichtype == TX_WITNESS_UNKNOWN ) return true ;
463
+ if (whichtype == TxoutType::WITNESS_V0_SCRIPTHASH || whichtype == TxoutType::WITNESS_V0_KEYHASH || whichtype == TxoutType::WITNESS_UNKNOWN ) return true ;
464
464
}
465
465
}
466
466
return false ;
0 commit comments