MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / IsPremineAddressScript

Method IsPremineAddressScript

src/chainparams.cpp:516–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516bool CChainParams::IsPremineAddressScript(const CScript& scriptPubKey, uint32_t height) const {
517 static const int LOCK_TIME = 3 * 365 * 24 * 3600; // 3 years
518 static const int LOCK_STAGES = 3 * 12; // Every month for 3 years
519 assert((uint32_t)consensus.BTGHeight <= height &&
520 height < (uint32_t)(consensus.BTGHeight + consensus.BTGPremineWindow));
521 int block = height - consensus.BTGHeight;
522 int num_unlocked = consensus.BTGPremineWindow * 40 / 100; // 40% unlocked.
523 int num_locked = consensus.BTGPremineWindow - num_unlocked; // 60% time-locked.
524 int stage_lock_time = LOCK_TIME / LOCK_STAGES / consensus.nPowTargetSpacing;
525 int stage_block_height = num_locked / LOCK_STAGES;
526 const std::vector<std::string> pubkeys = vPreminePubkeys[block % vPreminePubkeys.size()]; // Round robin.
527 CScript redeem_script;
528 if (block < num_unlocked) {
529 redeem_script = CltvMultiSigScript(pubkeys, 0);
530 } else {
531 int locked_block = block - num_unlocked;
532 int stage = locked_block / stage_block_height;
533 int lock_time = consensus.BTGHeight + stage_lock_time * (1 + stage);
534 redeem_script = CltvMultiSigScript(pubkeys, lock_time);
535 }
536 CScriptID redeem_script_id(redeem_script);
537 CScript target_scriptPubkey = GetScriptForDestination(redeem_script_id);
538 return scriptPubKey == target_scriptPubkey;
539}

Callers 2

ContextualCheckBlockFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 3

CltvMultiSigScriptFunction · 0.85
GetScriptForDestinationFunction · 0.85
sizeMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64