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

Method SignBlock

src/primitives/block.cpp:194–261  ·  view source on GitHub ↗

ppcoin: sign block

Source from the content-addressed store, hash-verified

192typedef std::vector<unsigned char> valtype;
193// ppcoin: sign block
194bool CBlock::SignBlock(const CKeyStore& keystore)
195{
196 std::vector<valtype> vSolutions;
197 txnouttype whichType;
198
199 if(!IsProofOfStake()) {
200 // if we are trying to sign
201 // a complete proof-of-stake block
202 for (unsigned int i = 0; i < vtx[0].vout.size(); i++) {
203 const CTxOut& txout = vtx[0].vout[i];
204
205 if (!Solver(txout.scriptPubKey, whichType, vSolutions))
206 continue;
207
208 if (whichType == TX_PUBKEY) {
209 // Sign
210 CKeyID keyID;
211 keyID = CKeyID(uint160(vSolutions[0]));
212
213 CKey key;
214 if (!keystore.GetKey(keyID, key))
215 return false;
216
217 if (!key.SignECDSA(GetHash(), vchBlockSig))
218 return false;
219
220 return true;
221 }
222 }
223 } else {
224 for (unsigned int j = 0; j < vtx[1].vout.size(); j++) {
225 const CTxOut &txout = vtx[1].vout[j];
226
227 if (!Solver(txout.scriptPubKey, whichType, vSolutions))
228 continue;
229
230 if (whichType != TX_PUBKEY && whichType != TX_PUBKEYHASH) {
231 break;
232 } else if (whichType == TX_PUBKEYHASH) {
233 // Sign
234 CKeyID keyID;
235 keyID = CKeyID(uint160(vSolutions[0]));
236
237 CKey key;
238 if (!keystore.GetKey(keyID, key))
239 return false;
240
241 if (!key.SignECDSA(GetHash(), vchBlockSig))
242 return false;
243
244 return true;
245 } else if (whichType == TX_PUBKEY) {
246 // Sign
247 const valtype& vchPubKey = vSolutions[0];
248 CKey key;
249 CPubKey pubKey(vchPubKey);
250 if (!keystore.GetKey(pubKey.GetID(), key))
251 return false;

Callers 1

GenBlockStakeMethod · 0.80

Calls 8

SolverFunction · 0.85
SignECDSAMethod · 0.80
CKeyIDClass · 0.50
uint160Class · 0.50
sizeMethod · 0.45
GetKeyMethod · 0.45
GetIDMethod · 0.45
GetPubKeyMethod · 0.45

Tested by

no test coverage detected