MCPcopy Create free account
hub / github.com/LUX-Core/lux / CheckBlockSignature

Method CheckBlockSignature

src/primitives/block.cpp:263–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263bool CBlock::CheckBlockSignature() const
264{
265 if (IsProofOfWork())
266 return vchBlockSig.empty();
267
268 if (IsProofOfStake()) {
269 // if we are trying to sign
270 // a complete proof-of-stake block
271 return vtx[0].vout[0].IsEmpty();
272 } else {
273
274 std::vector<valtype> vSolutions;
275 txnouttype whichType;
276
277 const CTxOut& txout = vtx[1].vout[1];
278
279 if (!Solver(txout.scriptPubKey, whichType, vSolutions))
280 return false;
281
282 if (whichType == TX_PUBKEY)
283 {
284 valtype& vchPubKey = vSolutions[0];
285 CPubKey pubkey(vchPubKey);
286 if (!pubkey.IsValid())
287 return false;
288
289 if (vchBlockSig.empty())
290 return false;
291
292 return pubkey.VerifyECDSA(GetHash(), vchBlockSig);
293 }
294 else if(whichType == TX_PUBKEYHASH)
295 {
296 valtype& vchPubKey = vSolutions[0];
297 CKeyID keyID;
298 keyID = CKeyID(uint160(vchPubKey));
299 CPubKey pubkey(vchPubKey);
300
301 if (!pubkey.IsValid())
302 return false;
303
304 if (vchBlockSig.empty())
305 return false;
306
307 return pubkey.VerifyECDSA(GetHash(), vchBlockSig);
308
309 }
310 }
311
312 return false;
313}
314
315int64_t GetBlockCost(const CBlock& block)
316{

Callers 1

ProcessNewBlockFunction · 0.80

Calls 7

SolverFunction · 0.85
VerifyECDSAMethod · 0.80
CKeyIDClass · 0.50
uint160Class · 0.50
emptyMethod · 0.45
IsEmptyMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected