| 514 | } |
| 515 | |
| 516 | bool 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 | } |