<?php declare(strict_types = 1);

/*  Idea (c) 2023 Nikita Zhavoronkov, nikzh@nikzh.com
 *  Copyright (c) 2023-2024 3xpl developers, 3@3xpl.com, see CONTRIBUTORS.md
 *  Distributed under the MIT software license, see LICENSE.md  */

/*  This is the main eCash module. It requires a Bitcoin ABC node to run (https://github.com/Bitcoin-ABC/bitcoin-abc)
 *  with `txindex` set to true to run.  */

final class eCashMainModule extends UTXOMainModule implements Module, TransactionSpecials, SupplySpecial, BroadcastTransactionSpecial
{
    function initialize()
    {
        // CoreModule
        $this->blockchain = 'ecash';
        $this->module = 'ecash-main';
        $this->is_main = true;
        $this->currency = 'ecash';
        $this->currency_details = ['name' => 'eCash', 'symbol' => 'XEC', 'decimals' => 2, 'description' => null];
        $this->first_block_date = '2009-01-03';

        // UTXOMainModule
        $this->extra_features = [UTXOSpecialFeatures::HasAddressPrefixes,
                                 UTXOSpecialFeatures::ManualCashAddress,
                                 UTXOSpecialFeatures::Not8Decimals];
        $this->p2pk_prefix1 = '1';
        $this->p2pk_prefix2 = '00';

        $this->tests = [
            // First Bitcoin block with P2PK address
            ['block' => 0, 'result' => 'a:2:{s:6:"events";a:2:{i:0;a:6:{s:11:"transaction";s:64:"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";s:7:"address";s:8:"the-void";s:6:"effect";s:11:"-5000000000";s:5:"block";i:0;s:4:"time";s:19:"2009-01-03 18:15:05";s:8:"sort_key";i:0;}i:1;a:6:{s:11:"transaction";s:64:"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";s:7:"address";s:42:"qp3wjpa3tjlj042z2wv7hahsldgwhwy0rquas9fmzn";s:6:"effect";s:10:"5000000000";s:5:"block";i:0;s:4:"time";s:19:"2009-01-03 18:15:05";s:8:"sort_key";i:1;}}s:10:"currencies";N;}'],
            // Just a modern block with various address types
            ['block' => 800000, 'result' => 'a:2:{s:6:"events";a:47:{i:0;a:6:{s:11:"transaction";s:64:"b0d1f469c4e02a8960cc897b948060990f41e1371723469f8c31a3675b2fe811";s:7:"address";s:8:"the-void";s:6:"effect";s:10:"-625005728";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:0;}i:1;a:6:{s:11:"transaction";s:64:"b0d1f469c4e02a8960cc897b948060990f41e1371723469f8c31a3675b2fe811";s:7:"address";s:42:"qr8ger8kn2fz5cr73cp7ylkqznauyjyzuqhrr7863u";s:6:"effect";s:9:"575005270";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:1;}i:2;a:6:{s:11:"transaction";s:64:"b0d1f469c4e02a8960cc897b948060990f41e1371723469f8c31a3675b2fe811";s:7:"address";s:42:"prfhcnyqnl5cgrnmlfmms675w93ld7mvvqd0y8lz07";s:6:"effect";s:8:"50000458";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:2;}i:3;a:6:{s:11:"transaction";s:64:"50d4175999d734ee458c709cc79740da496056f471048cc5e77c9aaf09517138";s:7:"address";s:42:"qzpptemjy37e60xgx798xqe4t0atmvdkhvuw079y82";s:6:"effect";s:9:"-14486336";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:3;}i:4;a:6:{s:11:"transaction";s:64:"50d4175999d734ee458c709cc79740da496056f471048cc5e77c9aaf09517138";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:5:"25900";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:4;}i:5;a:6:{s:11:"transaction";s:64:"50d4175999d734ee458c709cc79740da496056f471048cc5e77c9aaf09517138";s:7:"address";s:42:"qzpptemjy37e60xgx798xqe4t0atmvdkhvuw079y82";s:6:"effect";s:8:"14460209";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:5;}i:6;a:6:{s:11:"transaction";s:64:"50d4175999d734ee458c709cc79740da496056f471048cc5e77c9aaf09517138";s:7:"address";s:8:"the-void";s:6:"effect";s:3:"227";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:6;}i:7;a:6:{s:11:"transaction";s:64:"59d160f9cee8dc0d1b85071e02094e54c48a7b312c328adbcf101e73d66d1bb6";s:7:"address";s:42:"qzufk7lf0amg9y0djnqyp85dlkaaavew6qhsmtsctc";s:6:"effect";s:10:"-575223464";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:7;}i:8;a:6:{s:11:"transaction";s:64:"59d160f9cee8dc0d1b85071e02094e54c48a7b312c328adbcf101e73d66d1bb6";s:7:"address";s:42:"qzwuz0hk9jwwmt050lpuwn3zh6lnzmjdgqye505rr3";s:6:"effect";s:9:"557969862";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:8;}i:9;a:6:{s:11:"transaction";s:64:"59d160f9cee8dc0d1b85071e02094e54c48a7b312c328adbcf101e73d66d1bb6";s:7:"address";s:42:"qpxhgmd7tpj2yc6nwcex5wv4lzk69mpnn5pputgdex";s:6:"effect";s:8:"17253377";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:9;}i:10;a:6:{s:11:"transaction";s:64:"59d160f9cee8dc0d1b85071e02094e54c48a7b312c328adbcf101e73d66d1bb6";s:7:"address";s:8:"the-void";s:6:"effect";s:3:"225";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:10;}i:11;a:6:{s:11:"transaction";s:64:"77d310debe2f849c41f7ea4184fa6a5df15ad782859b5bb8a59ba63e548ad330";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:7:"-200000";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:11;}i:12;a:6:{s:11:"transaction";s:64:"77d310debe2f849c41f7ea4184fa6a5df15ad782859b5bb8a59ba63e548ad330";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:4:"-546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:12;}i:13;a:6:{s:11:"transaction";s:64:"77d310debe2f849c41f7ea4184fa6a5df15ad782859b5bb8a59ba63e548ad330";s:7:"address";s:39:"script-16825d9fe5d5bb06ee49984c2e63b3ed";s:6:"effect";s:1:"0";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:13;}i:14;a:6:{s:11:"transaction";s:64:"77d310debe2f849c41f7ea4184fa6a5df15ad782859b5bb8a59ba63e548ad330";s:7:"address";s:42:"qzpptemjy37e60xgx798xqe4t0atmvdkhvuw079y82";s:6:"effect";s:3:"546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:14;}i:15;a:6:{s:11:"transaction";s:64:"77d310debe2f849c41f7ea4184fa6a5df15ad782859b5bb8a59ba63e548ad330";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:3:"546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:15;}i:16;a:6:{s:11:"transaction";s:64:"77d310debe2f849c41f7ea4184fa6a5df15ad782859b5bb8a59ba63e548ad330";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:6:"198317";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:16;}i:17;a:6:{s:11:"transaction";s:64:"77d310debe2f849c41f7ea4184fa6a5df15ad782859b5bb8a59ba63e548ad330";s:7:"address";s:8:"the-void";s:6:"effect";s:4:"1137";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:17;}i:18;a:6:{s:11:"transaction";s:64:"a09ae569a3f1a88e13cf24ef54745d94898afcf73e49ed43635925750439bf8d";s:7:"address";s:42:"qq2wkjlpjnumz3ptattdz9xlf70ff42sncxgdmwtxe";s:6:"effect";s:9:"-16197820";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:18;}i:19;a:6:{s:11:"transaction";s:64:"a09ae569a3f1a88e13cf24ef54745d94898afcf73e49ed43635925750439bf8d";s:7:"address";s:42:"qpyrzpjlcp9edwvzag0aj4tf4khsmm7u8ve8wnzrku";s:6:"effect";s:7:"5360192";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:19;}i:20;a:6:{s:11:"transaction";s:64:"a09ae569a3f1a88e13cf24ef54745d94898afcf73e49ed43635925750439bf8d";s:7:"address";s:42:"qp9rf7ndwa3wgs52pgavxh4ap6sjxyz285z5gwm7x5";s:6:"effect";s:8:"10837400";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:20;}i:21;a:6:{s:11:"transaction";s:64:"a09ae569a3f1a88e13cf24ef54745d94898afcf73e49ed43635925750439bf8d";s:7:"address";s:8:"the-void";s:6:"effect";s:3:"228";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:21;}i:22;a:6:{s:11:"transaction";s:64:"af0ca27d5264defe8f15f1f24241cb03bce3bc76a060dd9c7f518453d15da09e";s:7:"address";s:42:"qr68ndfv4xuptsapd8g3exxnngjhy4u6ygh7xmvhqu";s:6:"effect";s:10:"-253006600";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:22;}i:23;a:6:{s:11:"transaction";s:64:"af0ca27d5264defe8f15f1f24241cb03bce3bc76a060dd9c7f518453d15da09e";s:7:"address";s:42:"qr68ndfv4xuptsapd8g3exxnngjhy4u6ygh7xmvhqu";s:6:"effect";s:9:"252806100";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:23;}i:24;a:6:{s:11:"transaction";s:64:"af0ca27d5264defe8f15f1f24241cb03bce3bc76a060dd9c7f518453d15da09e";s:7:"address";s:42:"pr278ejhfun6wy24j7pprpv9k4ywu0n0ss4502uskm";s:6:"effect";s:6:"200000";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:24;}i:25;a:6:{s:11:"transaction";s:64:"af0ca27d5264defe8f15f1f24241cb03bce3bc76a060dd9c7f518453d15da09e";s:7:"address";s:8:"the-void";s:6:"effect";s:3:"500";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:25;}i:26;a:6:{s:11:"transaction";s:64:"e2626834964ae378d2822e44350e0f70946c867c3da6d307415f4f057678e23b";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:6:"-25900";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:26;}i:27;a:6:{s:11:"transaction";s:64:"e2626834964ae378d2822e44350e0f70946c867c3da6d307415f4f057678e23b";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:4:"-546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:27;}i:28;a:6:{s:11:"transaction";s:64:"e2626834964ae378d2822e44350e0f70946c867c3da6d307415f4f057678e23b";s:7:"address";s:39:"script-cd8f81b17835a6704601b27c3bb83ee1";s:6:"effect";s:1:"0";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:28;}i:29;a:6:{s:11:"transaction";s:64:"e2626834964ae378d2822e44350e0f70946c867c3da6d307415f4f057678e23b";s:7:"address";s:42:"qzpptemjy37e60xgx798xqe4t0atmvdkhvuw079y82";s:6:"effect";s:3:"546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:29;}i:30;a:6:{s:11:"transaction";s:64:"e2626834964ae378d2822e44350e0f70946c867c3da6d307415f4f057678e23b";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:3:"546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:30;}i:31;a:6:{s:11:"transaction";s:64:"e2626834964ae378d2822e44350e0f70946c867c3da6d307415f4f057678e23b";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:5:"24217";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:31;}i:32;a:6:{s:11:"transaction";s:64:"e2626834964ae378d2822e44350e0f70946c867c3da6d307415f4f057678e23b";s:7:"address";s:8:"the-void";s:6:"effect";s:4:"1137";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:32;}i:33;a:6:{s:11:"transaction";s:64:"ef00e465c12322130498ba0aaf03249e5dfb03c9d26a3bf570f03262f1137edd";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:5:"-5000";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:33;}i:34;a:6:{s:11:"transaction";s:64:"ef00e465c12322130498ba0aaf03249e5dfb03c9d26a3bf570f03262f1137edd";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:4:"-546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:34;}i:35;a:6:{s:11:"transaction";s:64:"ef00e465c12322130498ba0aaf03249e5dfb03c9d26a3bf570f03262f1137edd";s:7:"address";s:39:"script-44c5664a63dd8a1eafb20e5226eafb66";s:6:"effect";s:1:"0";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:35;}i:36;a:6:{s:11:"transaction";s:64:"ef00e465c12322130498ba0aaf03249e5dfb03c9d26a3bf570f03262f1137edd";s:7:"address";s:42:"qzpptemjy37e60xgx798xqe4t0atmvdkhvuw079y82";s:6:"effect";s:3:"546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:36;}i:37;a:6:{s:11:"transaction";s:64:"ef00e465c12322130498ba0aaf03249e5dfb03c9d26a3bf570f03262f1137edd";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:3:"546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:37;}i:38;a:6:{s:11:"transaction";s:64:"ef00e465c12322130498ba0aaf03249e5dfb03c9d26a3bf570f03262f1137edd";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:4:"3317";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:38;}i:39;a:6:{s:11:"transaction";s:64:"ef00e465c12322130498ba0aaf03249e5dfb03c9d26a3bf570f03262f1137edd";s:7:"address";s:8:"the-void";s:6:"effect";s:4:"1137";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:39;}i:40;a:6:{s:11:"transaction";s:64:"fec9e1edcd662650357a72dee9e87858a0d211f98e1518e93202413ad96100fa";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:7:"-613558";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:40;}i:41;a:6:{s:11:"transaction";s:64:"fec9e1edcd662650357a72dee9e87858a0d211f98e1518e93202413ad96100fa";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:4:"-546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:41;}i:42;a:6:{s:11:"transaction";s:64:"fec9e1edcd662650357a72dee9e87858a0d211f98e1518e93202413ad96100fa";s:7:"address";s:39:"script-d3258232d8b01ee017d23db22363cded";s:6:"effect";s:1:"0";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:42;}i:43;a:6:{s:11:"transaction";s:64:"fec9e1edcd662650357a72dee9e87858a0d211f98e1518e93202413ad96100fa";s:7:"address";s:42:"qzpptemjy37e60xgx798xqe4t0atmvdkhvuw079y82";s:6:"effect";s:3:"546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:43;}i:44;a:6:{s:11:"transaction";s:64:"fec9e1edcd662650357a72dee9e87858a0d211f98e1518e93202413ad96100fa";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:3:"546";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:44;}i:45;a:6:{s:11:"transaction";s:64:"fec9e1edcd662650357a72dee9e87858a0d211f98e1518e93202413ad96100fa";s:7:"address";s:42:"qq4qzcxjzvwrwlfm5zay80p6t6ye3fm42un05u7s5j";s:6:"effect";s:6:"611875";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:45;}i:46;a:6:{s:11:"transaction";s:64:"fec9e1edcd662650357a72dee9e87858a0d211f98e1518e93202413ad96100fa";s:7:"address";s:8:"the-void";s:6:"effect";s:4:"1137";s:5:"block";i:800000;s:4:"time";s:19:"2023-07-08 09:33:00";s:8:"sort_key";i:46;}}s:10:"currencies";N;}'],
        ];
    }
}
