| 261 | } |
| 262 | |
| 263 | bool 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 | |
| 315 | int64_t GetBlockCost(const CBlock& block) |
| 316 | { |
no test coverage detected