├── .nvmrc ├── __tests__ ├── unit │ ├── core-snapshots │ │ └── .gitkeep │ ├── core-container │ │ └── __stubs__ │ │ │ ├── config │ │ │ ├── exceptions.json │ │ │ ├── delegates.json │ │ │ ├── peers.json │ │ │ ├── plugins.js │ │ │ └── network.json │ │ │ ├── plugin-c.js │ │ │ ├── plugin-a.js │ │ │ ├── plugin-b.js │ │ │ └── plugins.js │ ├── core-magistrate │ │ └── handlers │ │ │ ├── __mocks__ │ │ │ ├── transaction-error.ts │ │ │ ├── transaction-reader.ts │ │ │ └── wallet-repository.ts │ │ │ └── __fixtures__ │ │ │ └── index.ts │ ├── core-p2p │ │ ├── mocks │ │ │ ├── p2p │ │ │ │ ├── peer-storage.ts │ │ │ │ ├── network-monitor.ts │ │ │ │ └── peer-processor.ts │ │ │ ├── transaction-pool.ts │ │ │ ├── request.ts │ │ │ ├── state.ts │ │ │ ├── logger.ts │ │ │ ├── p2p.ts │ │ │ ├── scworker.ts │ │ │ └── blockchain.ts │ │ ├── utils │ │ │ ├── check-dns.test.ts │ │ │ └── is-whitelist.test.ts │ │ └── socket-server │ │ │ └── versions │ │ │ └── internal │ │ │ └── handlers │ │ │ └── blockchain.test.ts │ ├── core-transaction-pool │ │ └── mocks │ │ │ ├── database.ts │ │ │ └── state.ts │ ├── core-database │ │ ├── mocks │ │ │ └── emitter.ts │ │ └── __fixtures__ │ │ │ └── wallets.json │ ├── core-state │ │ ├── mocks │ │ │ ├── state.ts │ │ │ ├── index.ts │ │ │ ├── transactionPool.ts │ │ │ ├── logger.ts │ │ │ ├── p2p.ts │ │ │ ├── config.ts │ │ │ └── p2p │ │ │ │ ├── network-monitor.ts │ │ │ │ └── peer-storage.ts │ │ ├── __fixtures__ │ │ │ └── wallets.json │ │ └── stores │ │ │ └── transactions.test.ts │ ├── core-blockchain │ │ └── mocks │ │ │ ├── index.ts │ │ │ ├── logger.ts │ │ │ ├── p2p.ts │ │ │ ├── config.ts │ │ │ ├── transactionPool.ts │ │ │ └── p2p │ │ │ ├── network-monitor.ts │ │ │ └── peer-storage.ts │ ├── core-forger │ │ └── __fixtures__ │ │ │ └── delegate.ts │ ├── core-logger-signale │ │ └── logger.test.ts │ ├── crypto │ │ ├── constants.test.ts │ │ ├── transactions │ │ │ └── __fixtures__ │ │ │ │ └── wallet.ts │ │ ├── crypto │ │ │ └── fixtures │ │ │ │ └── crypto.json │ │ ├── blocks │ │ │ └── __fixtures__ │ │ │ │ └── wallet.ts │ │ ├── identities │ │ │ ├── wif.test.ts │ │ │ ├── fixture.json │ │ │ └── private-key.test.ts │ │ └── utils │ │ │ ├── number-to-hex.test.ts │ │ │ └── network-list.ts │ ├── core-jest-matchers │ │ ├── fields │ │ │ ├── address.test.ts │ │ │ └── public-key.test.ts │ │ ├── transactions │ │ │ └── types │ │ │ │ ├── ipfs.test.ts │ │ │ │ ├── vote.test.ts │ │ │ │ └── transfer.test.ts │ │ └── models │ │ │ └── wallet.test.ts │ ├── core-logger-winston │ │ └── logger.test.ts │ ├── core-http-utils │ │ └── mocks │ │ │ └── core-container.ts │ └── core-utils │ │ └── mocks │ │ └── core-container.ts ├── utils │ ├── generators │ │ └── index.ts │ ├── helpers │ │ └── index.ts │ ├── fixtures │ │ ├── unitnet │ │ │ ├── index.ts │ │ │ ├── wallets.ts │ │ │ └── block-model.ts │ │ ├── testnet │ │ │ ├── passphrases.ts │ │ │ ├── index.ts │ │ │ └── block-model.ts │ │ └── index.ts │ ├── config │ │ ├── index.js │ │ ├── testnet │ │ │ └── peers.json │ │ └── unitnet │ │ │ └── peers.json │ └── index.ts ├── integration │ ├── core-p2p │ │ └── mocks │ │ │ └── p2p-options.ts │ ├── core-magistrate │ │ └── mocks │ │ │ ├── database.ts │ │ │ └── state.ts │ ├── core-tester-cli │ │ ├── commands │ │ │ └── send │ │ │ │ └── fixtures.ts │ │ └── __fixtures__ │ │ │ ├── transaction-response-1.json │ │ │ ├── wallet-1.json │ │ │ └── identities.json │ ├── core-blockchain │ │ └── __support__ │ │ │ └── setup.ts │ ├── core-vote-report │ │ └── server.test.ts │ ├── core-transactions │ │ └── __support__ │ │ │ └── setup.ts │ └── core-api │ │ └── services │ │ └── transaction-raw.json ├── e2e │ ├── lib │ │ └── config │ │ │ ├── nodes │ │ │ ├── core0 │ │ │ │ ├── peers.json │ │ │ │ └── .env │ │ │ ├── core1 │ │ │ │ ├── peers.json │ │ │ │ └── .env │ │ │ ├── core2 │ │ │ │ ├── peers.json │ │ │ │ └── .env │ │ │ ├── core3 │ │ │ │ ├── peers.json │ │ │ │ └── .env │ │ │ ├── core4 │ │ │ │ ├── peers.json │ │ │ │ └── .env │ │ │ └── Dockerfile │ │ │ ├── peer-discovery │ │ │ ├── Dockerfile │ │ │ ├── package.json │ │ │ └── index.js │ │ │ └── nginx │ │ │ └── nginx.conf │ ├── tsconfig.json │ ├── img │ │ ├── core-e2e-banner.png │ │ └── docker-architecture.png │ ├── .gitignore │ └── tests │ │ └── scenarios │ │ └── scenario1 │ │ ├── multisignature │ │ └── shared.js │ │ ├── multisig-htlc-claim │ │ └── shared.js │ │ ├── multisig-htlc-refund │ │ └── shared.js │ │ ├── doublespend-mix │ │ └── config.js │ │ ├── transactions-valid │ │ └── config.js │ │ ├── htlc-refund │ │ └── shared.js │ │ ├── config.js │ │ ├── htlc-claim │ │ └── shared.js │ │ ├── insufficient-balance │ │ └── config.js │ │ ├── doublespend │ │ └── config.js │ │ ├── chained-tx │ │ └── utils.js │ │ └── pool-restart │ │ └── 3.stop-node.action.js └── helpers │ ├── index.ts │ └── rest-client.ts ├── docker ├── .gitignore ├── purge_all.sh ├── config │ ├── devnet.env │ ├── mainnet.env │ └── testnet.env └── Dockerfile ├── .prettierignore ├── CODEOWNERS ├── packages ├── crypto │ ├── src │ │ ├── networks │ │ │ ├── testnet │ │ │ │ ├── exceptions.json │ │ │ │ ├── index.ts │ │ │ │ └── network.json │ │ │ ├── unitnet │ │ │ │ ├── exceptions.json │ │ │ │ ├── index.ts │ │ │ │ └── network.json │ │ │ ├── index.ts │ │ │ ├── devnet │ │ │ │ ├── exceptions.json │ │ │ │ ├── index.ts │ │ │ │ └── network.json │ │ │ └── mainnet │ │ │ │ ├── exceptions.json │ │ │ │ ├── index.ts │ │ │ │ └── network.json │ │ ├── constants.ts │ │ ├── utils │ │ │ └── bignum.ts │ │ ├── managers │ │ │ ├── index.ts │ │ │ └── network.ts │ │ ├── interfaces │ │ │ ├── crypto.ts │ │ │ ├── managers.ts │ │ │ ├── identities.ts │ │ │ ├── message.ts │ │ │ └── index.ts │ │ ├── blocks │ │ │ └── index.ts │ │ ├── identities │ │ │ ├── index.ts │ │ │ └── private-key.ts │ │ ├── crypto │ │ │ └── index.ts │ │ ├── types.ts │ │ ├── transactions │ │ │ ├── index.ts │ │ │ └── types │ │ │ │ └── index.ts │ │ └── enums.ts │ ├── banner.png │ └── tsconfig.json ├── core-wallet-api │ ├── src │ │ ├── index.ts │ │ └── defaults.ts │ └── tsconfig.json ├── core │ ├── bin │ │ ├── run.cmd │ │ └── config │ │ │ ├── devnet │ │ │ ├── delegates.json │ │ │ └── .env │ │ │ ├── mainnet │ │ │ ├── delegates.json │ │ │ ├── peers.json │ │ │ └── .env │ │ │ └── testnet │ │ │ ├── peers.json │ │ │ └── .env │ ├── src │ │ ├── index.ts │ │ ├── enums.ts │ │ ├── types.ts │ │ ├── hooks │ │ │ └── init │ │ │ │ └── config.ts │ │ ├── helpers │ │ │ └── prompts.ts │ │ ├── process-manager.ts │ │ └── commands │ │ │ ├── core │ │ │ └── status.ts │ │ │ ├── relay │ │ │ └── status.ts │ │ │ └── forger │ │ │ └── status.ts │ └── tsconfig.json ├── core-api │ ├── src │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ └── repository.ts │ │ ├── handlers │ │ │ ├── entities │ │ │ │ ├── transformer.ts │ │ │ │ └── index.ts │ │ │ ├── shared │ │ │ │ ├── schemas │ │ │ │ │ ├── address.ts │ │ │ │ │ ├── public-key.ts │ │ │ │ │ ├── username.ts │ │ │ │ │ ├── generic-name.ts │ │ │ │ │ ├── wallet-id.ts │ │ │ │ │ ├── block-id.ts │ │ │ │ │ ├── pagination.ts │ │ │ │ │ └── index.ts │ │ │ │ └── transformers │ │ │ │ │ └── fee-statistics.ts │ │ │ ├── node │ │ │ │ ├── index.ts │ │ │ │ └── schema.ts │ │ │ ├── peers │ │ │ │ ├── index.ts │ │ │ │ ├── transformer.ts │ │ │ │ └── schema.ts │ │ │ ├── blockchain │ │ │ │ ├── index.ts │ │ │ │ └── routes.ts │ │ │ ├── rounds │ │ │ │ ├── schema.ts │ │ │ │ ├── transformer.ts │ │ │ │ ├── index.ts │ │ │ │ ├── routes.ts │ │ │ │ └── controller.ts │ │ │ ├── blocks │ │ │ │ └── index.ts │ │ │ ├── delegates │ │ │ │ └── index.ts │ │ │ ├── locks │ │ │ │ ├── index.ts │ │ │ │ └── transformer.ts │ │ │ ├── votes │ │ │ │ └── index.ts │ │ │ ├── wallets │ │ │ │ └── index.ts │ │ │ └── transactions │ │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── services │ │ │ └── index.ts │ │ └── plugins │ │ │ └── pagination │ │ │ └── config.ts │ └── tsconfig.json ├── core-interfaces │ ├── src │ │ ├── shared │ │ │ ├── index.ts │ │ │ └── interfaces.ts │ │ ├── core-logger │ │ │ ├── index.ts │ │ │ └── logger.ts │ │ ├── core-blockchain │ │ │ └── index.ts │ │ ├── core-container │ │ │ └── index.ts │ │ ├── core-event-emitter │ │ │ └── index.ts │ │ ├── core-database │ │ │ ├── database-model │ │ │ │ ├── index.ts │ │ │ │ └── database-model.ts │ │ │ ├── search │ │ │ │ ├── index.ts │ │ │ │ └── search-parameter-converter.ts │ │ │ ├── business-repository │ │ │ │ ├── parameters.ts │ │ │ │ └── index.ts │ │ │ ├── database-repository │ │ │ │ ├── index.ts │ │ │ │ ├── wallets-repository.ts │ │ │ │ ├── repository.ts │ │ │ │ └── rounds-repository.ts │ │ │ ├── event-types.ts │ │ │ └── index.ts │ │ ├── core-transaction-pool │ │ │ └── index.ts │ │ ├── core-state │ │ │ ├── index.ts │ │ │ └── service.ts │ │ ├── core-p2p │ │ │ ├── peer-verifier.ts │ │ │ ├── peer-processor.ts │ │ │ ├── index.ts │ │ │ ├── peer-service.ts │ │ │ └── peer-connector.ts │ │ └── index.ts │ └── tsconfig.json ├── core-tester-cli │ ├── bin │ │ ├── run.cmd │ │ └── run │ ├── src │ │ ├── index.ts │ │ ├── logger.ts │ │ ├── shared │ │ │ └── htlc-secret.ts │ │ ├── flags.ts │ │ └── utils.ts │ └── tsconfig.json ├── core-blockchain │ ├── src │ │ ├── replay │ │ │ └── index.ts │ │ ├── processor │ │ │ ├── index.ts │ │ │ └── handlers │ │ │ │ ├── invalid-generator-handler.ts │ │ │ │ ├── verification-failed-handler.ts │ │ │ │ ├── nonce-out-of-order-handler.ts │ │ │ │ ├── already-forged-handler.ts │ │ │ │ ├── incompatible-transactions-handler.ts │ │ │ │ └── index.ts │ │ ├── utils │ │ │ └── index.ts │ │ ├── index.ts │ │ └── defaults.ts │ └── tsconfig.json ├── core-magistrate-transactions │ ├── src │ │ ├── defaults.ts │ │ ├── handlers │ │ │ ├── utils.ts │ │ │ ├── index.ts │ │ │ └── magistrate-handler.ts │ │ ├── index.ts │ │ └── events.ts │ └── tsconfig.json ├── core-forger │ ├── src │ │ ├── index.ts │ │ ├── interfaces.ts │ │ └── defaults.ts │ └── tsconfig.json ├── core-jest-matchers │ ├── src │ │ ├── fields │ │ │ ├── index.ts │ │ │ ├── public-key.ts │ │ │ └── address.ts │ │ ├── models │ │ │ ├── index.ts │ │ │ ├── wallet.ts │ │ │ └── delegate.ts │ │ ├── blockchain │ │ │ └── index.ts │ │ ├── transactions │ │ │ ├── index.ts │ │ │ └── types │ │ │ │ ├── index.ts │ │ │ │ ├── ipfs.ts │ │ │ │ ├── vote.ts │ │ │ │ ├── transfer.ts │ │ │ │ ├── multi-payment.ts │ │ │ │ ├── multi-signature.ts │ │ │ │ └── second-signature.ts │ │ ├── api │ │ │ └── index.ts │ │ ├── functional │ │ │ └── index.ts │ │ └── index.ts │ └── tsconfig.json ├── core-logger-pino │ ├── src │ │ ├── index.ts │ │ ├── defaults.ts │ │ └── plugin.ts │ └── tsconfig.json ├── core-logger-signale │ ├── src │ │ ├── index.ts │ │ ├── defaults.ts │ │ ├── driver.ts │ │ └── plugin.ts │ └── tsconfig.json ├── core-snapshots │ ├── src │ │ ├── defaults.ts │ │ ├── db │ │ │ └── queries │ │ │ │ ├── blocks │ │ │ │ ├── latest.sql │ │ │ │ ├── delete-from-height.sql │ │ │ │ ├── find-by-height.sql │ │ │ │ └── height-range.sql │ │ │ │ ├── rounds │ │ │ │ ├── delete-from-round.sql │ │ │ │ ├── latest.sql │ │ │ │ └── round-range.sql │ │ │ │ └── transactions │ │ │ │ ├── delete-from-timestamp.sql │ │ │ │ ├── timestamp-higher.sql │ │ │ │ └── timestamp-range.sql │ │ └── index.ts │ └── tsconfig.json ├── core-database-postgres │ ├── src │ │ ├── queries │ │ │ ├── blocks │ │ │ │ ├── delete.sql │ │ │ │ ├── find-by-id.sql │ │ │ │ ├── latest.sql │ │ │ │ ├── count.sql │ │ │ │ ├── find-by-height.sql │ │ │ │ ├── recent.sql │ │ │ │ ├── top.sql │ │ │ │ ├── find-by-heights.sql │ │ │ │ ├── headers.sql │ │ │ │ ├── height-range.sql │ │ │ │ ├── common.sql │ │ │ │ ├── statistics.sql │ │ │ │ └── height-range-with-transactions.sql │ │ │ ├── migrations │ │ │ │ ├── create.sql │ │ │ │ └── find.sql │ │ │ ├── rounds │ │ │ │ ├── delete.sql │ │ │ │ └── find.sql │ │ │ ├── transactions │ │ │ │ ├── find-by-id.sql │ │ │ │ ├── forged.sql │ │ │ │ ├── delete-by-block.sql │ │ │ │ ├── find-by-block.sql │ │ │ │ ├── latest-by-block.sql │ │ │ │ ├── statistics.sql │ │ │ │ ├── latest-by-blocks.sql │ │ │ │ ├── find-by-htlc-locks.sql │ │ │ │ └── fee-statistics.sql │ │ │ ├── common │ │ │ │ └── truncate-all-tables.sql │ │ │ └── state-builder │ │ │ │ ├── delegates.sql │ │ │ │ ├── count-type.sql │ │ │ │ ├── second-signatures.sql │ │ │ │ ├── block-rewards.sql │ │ │ │ ├── ipfs.sql │ │ │ │ ├── received-transactions.sql │ │ │ │ ├── multi-signatures.sql │ │ │ │ ├── sent-transactions.sql │ │ │ │ ├── delegates-forged-blocks.sql │ │ │ │ ├── last-forged-blocks.sql │ │ │ │ ├── claimed-locks.sql │ │ │ │ ├── refunded-locks.sql │ │ │ │ └── open-locks.sql │ │ ├── migrations │ │ │ ├── 20190307000000-drop-wallets-table.sql │ │ │ ├── 20191008000000-add-type-index-to-transactions-table.sql │ │ │ ├── 20181204200000-add-timestamp-index-to-blocks-table.sql │ │ │ ├── 20190619000000-drop-id-column-from-rounds-table.sql │ │ │ ├── 20200304000000-add-type_group-index-to-transactions-table.sql │ │ │ ├── 20181204400000-add-recipient_id-index-to-transactions-table.sql │ │ │ ├── 20190917000000-add-asset-column-to-transactions-table.sql │ │ │ ├── 20181129400000-add-block_id-index-to-transactions-table.sql │ │ │ ├── 20181204300000-add-sender_public_key-index-to-transactions-table.sql │ │ │ ├── 20201117000000-add-generator_public_key_height-index-to-blocks-table.sql │ │ │ ├── 20180304100000-create-migrations-table.sql │ │ │ ├── 20190803000000-add-type_group-column-to-transactions-table.sql │ │ │ ├── 20181204100000-add-generator_public_key-index-to-blocks-table.sql │ │ │ ├── 20191003000000-migrate-vendor-field-hex.sql │ │ │ ├── 20190606000000-add-block-id-foreign-key-on-transactions.sql │ │ │ ├── index.ts │ │ │ ├── 20180305200000-create-rounds-table.sql │ │ │ └── 20180305100000-create-wallets-table.sql │ │ ├── models │ │ │ ├── index.ts │ │ │ └── migration.ts │ │ ├── index.ts │ │ ├── interfaces.ts │ │ └── repositories │ │ │ ├── index.ts │ │ │ └── migrations.ts │ └── tsconfig.json ├── core-logger │ ├── src │ │ ├── index.ts │ │ └── plugin.ts │ └── tsconfig.json ├── core-state │ ├── src │ │ ├── index.ts │ │ ├── wallets │ │ │ └── index.ts │ │ ├── defaults.ts │ │ └── stores │ │ │ └── transactions.ts │ └── tsconfig.json ├── core-logger-winston │ ├── src │ │ ├── index.ts │ │ ├── interfaces.ts │ │ └── plugin.ts │ └── tsconfig.json ├── core-transaction-pool │ ├── src │ │ ├── index.ts │ │ ├── factory.ts │ │ ├── interfaces.ts │ │ └── utils.ts │ └── tsconfig.json ├── core-error-tracker-raygun │ ├── src │ │ ├── defaults.ts │ │ └── index.ts │ └── tsconfig.json ├── core-p2p │ ├── src │ │ ├── socket-server │ │ │ ├── utils │ │ │ │ ├── map-addr.ts │ │ │ │ └── get-headers.ts │ │ │ └── versions │ │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── constants.ts │ │ ├── utils │ │ │ ├── is-whitelisted.ts │ │ │ ├── index.ts │ │ │ └── validate-json.ts │ │ └── interfaces.ts │ └── tsconfig.json ├── core-utils │ ├── src │ │ ├── has-some-property.ts │ │ ├── format-timestamp.ts │ │ └── is-whitelisted.ts │ └── tsconfig.json ├── core-container │ ├── tsconfig.json │ └── src │ │ └── index.ts ├── core-database │ ├── tsconfig.json │ └── src │ │ ├── index.ts │ │ ├── factory.ts │ │ ├── plugin.ts │ │ └── repositories │ │ └── utils │ │ ├── limit-rows.ts │ │ └── get-property.ts ├── core-explorer │ ├── tsconfig.json │ └── src │ │ └── defaults.ts ├── core-http-utils │ ├── tsconfig.json │ └── src │ │ ├── plugins │ │ ├── index.ts │ │ ├── content-type.ts │ │ └── whitelist.ts │ │ ├── index.ts │ │ └── server │ │ └── mount.ts ├── core-new-relic │ ├── tsconfig.json │ └── src │ │ └── index.ts ├── core-vote-report │ ├── tsconfig.json │ └── src │ │ ├── defaults.ts │ │ └── index.ts ├── core-webhooks │ ├── tsconfig.json │ └── src │ │ ├── interfaces.ts │ │ ├── defaults.ts │ │ └── server │ │ └── utils.ts ├── core-elasticsearch │ ├── tsconfig.json │ └── src │ │ ├── utils.ts │ │ └── defaults.ts ├── core-event-emitter │ └── tsconfig.json ├── core-transactions │ ├── tsconfig.json │ └── src │ │ ├── index.ts │ │ ├── handlers │ │ └── index.ts │ │ └── utils.ts ├── core-error-tracker-bugsnag │ ├── tsconfig.json │ └── src │ │ ├── defaults.ts │ │ └── index.ts ├── core-error-tracker-rollbar │ ├── tsconfig.json │ └── src │ │ ├── defaults.ts │ │ └── index.ts ├── core-error-tracker-sentry │ ├── tsconfig.json │ └── src │ │ ├── defaults.ts │ │ └── index.ts ├── core-exchange-json-rpc │ ├── tsconfig.json │ └── src │ │ └── defaults.ts ├── core-magistrate-crypto │ ├── tsconfig.json │ └── src │ │ ├── index.ts │ │ ├── builders │ │ └── index.ts │ │ └── transactions │ │ ├── index.ts │ │ └── utils │ │ └── business-schema.ts └── core-error-tracker-airbrake │ ├── tsconfig.json │ └── src │ ├── defaults.ts │ └── index.ts ├── .yarnrc ├── banner.jpg ├── banner.png ├── renovate.json ├── tslint-config.json ├── delegate └── assets │ ├── register_delegate.png │ ├── register_delegate2.png │ ├── register_delegate3.png │ └── register_delegate4.png ├── .lintstagedrc.json ├── .prettierrc.json ├── .codecov.yml ├── benchmark ├── block │ ├── deserialize │ │ ├── methods.js │ │ ├── 0.js │ │ └── 150.js │ ├── serialize.js │ └── serializeWithTransactions.js ├── transaction │ ├── deserialize │ │ ├── methods.js │ │ └── 0.js │ └── serialize │ │ └── 0.js ├── fixtures │ ├── transaction │ │ └── serialized │ │ │ └── 0.txt │ └── block │ │ └── serialized │ │ └── no-transactions.txt └── helpers.js ├── .editorconfig ├── lerna.json ├── .codacy.yml ├── upgrade └── 2.1.0 │ ├── exchange.sh │ └── normal.sh ├── vagrant ├── centos │ ├── 6 │ │ └── Vagrantfile │ └── 7 │ │ └── Vagrantfile ├── debian │ ├── 8_10 │ │ └── Vagrantfile │ └── 9_4 │ │ └── Vagrantfile └── ubuntu │ ├── 16_04 │ └── Vagrantfile │ └── 18_04 │ └── Vagrantfile ├── plugins └── iop │ └── package.json └── tsconfig.json /.nvmrc: -------------------------------------------------------------------------------- 1 | 12.16.0 2 | -------------------------------------------------------------------------------- /__tests__/unit/core-snapshots/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docker/.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | snapshots -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .coverage 2 | dist 3 | docs 4 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @faustbrian @kristjank @supaiku0 @air1one 2 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/testnet/exceptions.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/unitnet/exceptions.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | child-concurrency 1 2 | --install.ignore-engines true 3 | -------------------------------------------------------------------------------- /__tests__/utils/generators/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./wallets"; 2 | -------------------------------------------------------------------------------- /packages/core-wallet-api/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./plugin"; 2 | -------------------------------------------------------------------------------- /packages/core/bin/run.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | node "%~dp0\run" %* 4 | -------------------------------------------------------------------------------- /packages/core/src/index.ts: -------------------------------------------------------------------------------- 1 | export { run } from "@oclif/command"; 2 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/config/exceptions.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /packages/core-api/src/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./repository"; 2 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/shared/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./interfaces"; 2 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-logger/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./logger"; 2 | -------------------------------------------------------------------------------- /packages/core-tester-cli/bin/run.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | node "%~dp0\run" %* 4 | -------------------------------------------------------------------------------- /packages/core-tester-cli/src/index.ts: -------------------------------------------------------------------------------- 1 | export { run } from "@oclif/command"; 2 | -------------------------------------------------------------------------------- /packages/core/bin/config/devnet/delegates.json: -------------------------------------------------------------------------------- 1 | { 2 | "secrets": [] 3 | } 4 | -------------------------------------------------------------------------------- /packages/core/bin/config/mainnet/delegates.json: -------------------------------------------------------------------------------- 1 | { 2 | "secrets": [] 3 | } 4 | -------------------------------------------------------------------------------- /banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/banner.jpg -------------------------------------------------------------------------------- /banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/banner.png -------------------------------------------------------------------------------- /packages/core-blockchain/src/replay/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./replay-blockchain"; 2 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-blockchain/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./blockchain"; 2 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-container/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./container"; 2 | -------------------------------------------------------------------------------- /packages/core-magistrate-transactions/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = {}; 2 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/processor/index.ts: -------------------------------------------------------------------------------- 1 | export * from "../processor/block-processor"; 2 | -------------------------------------------------------------------------------- /packages/core-forger/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./plugin"; 2 | export * from "./delegate"; 3 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/fields/index.ts: -------------------------------------------------------------------------------- 1 | import "./address"; 2 | import "./public-key"; 3 | -------------------------------------------------------------------------------- /packages/core-logger-pino/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./driver"; 2 | export * from "./plugin"; 3 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-event-emitter/index.ts: -------------------------------------------------------------------------------- 1 | export { EventEmitter } from "events"; 2 | -------------------------------------------------------------------------------- /packages/core-logger-signale/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./driver"; 2 | export * from "./plugin"; 3 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | chunkSize: 50000, 3 | }; 4 | -------------------------------------------------------------------------------- /__tests__/unit/core-magistrate/handlers/__mocks__/transaction-error.ts: -------------------------------------------------------------------------------- 1 | export class TransactionError {} 2 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/database-model/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./database-model"; 2 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/config/delegates.json: -------------------------------------------------------------------------------- 1 | { 2 | "secrets": ["this is a test"] 3 | } 4 | -------------------------------------------------------------------------------- /__tests__/integration/core-p2p/mocks/p2p-options.ts: -------------------------------------------------------------------------------- 1 | export * from "../../../../packages/core-p2p/src/defaults"; 2 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/delete.sql: -------------------------------------------------------------------------------- 1 | DELETE 2 | FROM blocks 3 | WHERE id IN (${ids:list}) 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/find-by-id.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | WHERE id = ${id} 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/migrations/create.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO migrations (name) VALUES (${name}) 2 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/rounds/delete.sql: -------------------------------------------------------------------------------- 1 | DELETE 2 | FROM rounds 3 | WHERE round >= ${round} 4 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/blocks/latest.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | ORDER BY height DESC LIMIT 1 4 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/rounds/delete-from-round.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM rounds 2 | WHERE round > ${round} 3 | -------------------------------------------------------------------------------- /packages/crypto/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/packages/crypto/banner.png -------------------------------------------------------------------------------- /packages/crypto/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const SATOSHI: number = 1e8; 2 | export const ARKTOSHI: number = SATOSHI; 3 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/p2p/peer-storage.ts: -------------------------------------------------------------------------------- 1 | export const getStorage = { 2 | getPeers: () => undefined, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20190307000000-drop-wallets-table.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS "wallets"; 2 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/latest.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | ORDER BY height DESC LIMIT 1 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/migrations/find.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM migrations 3 | WHERE name = ${name} 4 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/models/index.ts: -------------------------------------------------------------------------------- 1 | import "./delegate"; 2 | import "./transaction"; 3 | import "./wallet"; 4 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/blocks/delete-from-height.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM blocks 2 | WHERE height > ${height} 3 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/blocks/find-by-height.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | WHERE height = ${height} 4 | -------------------------------------------------------------------------------- /packages/crypto/src/utils/bignum.ts: -------------------------------------------------------------------------------- 1 | import { BigNumber } from "@arkecosystem/utils"; 2 | 3 | export { BigNumber }; 4 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["config:base", ":preserveSemverRanges"], 3 | "baseBranches": ["develop"] 4 | } 5 | -------------------------------------------------------------------------------- /tslint-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "build", "dist"] 4 | } 5 | -------------------------------------------------------------------------------- /__tests__/utils/helpers/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./api"; 2 | export * from "./blockchain"; 3 | export * from "./container"; 4 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./tick-sync-tracker"; 2 | export * from "./validate-generator"; 3 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/count.sql: -------------------------------------------------------------------------------- 1 | SELECT COUNT (DISTINCT "height") AS "count" 2 | FROM blocks 3 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/find-by-height.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | WHERE height = ${height} 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/recent.sql: -------------------------------------------------------------------------------- 1 | SELECT id 2 | FROM blocks 3 | ORDER BY TIMESTAMP DESC LIMIT 10 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/top.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | ORDER BY height DESC LIMIT ${top} 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/find-by-id.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM transactions 3 | WHERE id = ${id} 4 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-transaction-pool/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./connection"; 2 | export * from "./processor"; 3 | -------------------------------------------------------------------------------- /packages/core-logger/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./manager"; 2 | export * from "./logger"; 3 | export * from "./plugin"; 4 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core0/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [], 3 | "sources": ["http://peerdiscovery:3000/"] 4 | } 5 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core1/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [], 3 | "sources": ["http://peerdiscovery:3000/"] 4 | } 5 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core2/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [], 3 | "sources": ["http://peerdiscovery:3000/"] 4 | } 5 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core3/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [], 3 | "sources": ["http://peerdiscovery:3000/"] 4 | } 5 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core4/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [], 3 | "sources": ["http://peerdiscovery:3000/"] 4 | } 5 | -------------------------------------------------------------------------------- /__tests__/unit/core-magistrate/handlers/__fixtures__/index.ts: -------------------------------------------------------------------------------- 1 | import * as Assets from "./assets"; 2 | 3 | export { Assets }; 4 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/p2p/network-monitor.ts: -------------------------------------------------------------------------------- 1 | export const getMonitor = { 2 | getNetworkState: () => undefined, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./defaults"; 2 | export * from "./blockchain"; 3 | export * from "./plugin"; 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/forged.sql: -------------------------------------------------------------------------------- 1 | SELECT id 2 | FROM transactions 3 | WHERE id IN (${ids:list}) 4 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./defaults"; 2 | export * from "./manager"; 3 | export * from "./plugin"; 4 | -------------------------------------------------------------------------------- /packages/core-state/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./plugin"; 2 | import * as Wallets from "./wallets"; 3 | 4 | export { Wallets }; 5 | -------------------------------------------------------------------------------- /packages/crypto/src/managers/index.ts: -------------------------------------------------------------------------------- 1 | export { configManager } from "./config"; 2 | export { NetworkManager } from "./network"; 3 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM telus/build-essential 2 | FROM python 3 | FROM node:12 4 | 5 | WORKDIR /ark-core 6 | 7 | -------------------------------------------------------------------------------- /__tests__/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["../helpers/transaction-factory.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /__tests__/helpers/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./rest-client"; 2 | export * from "./transaction-factory"; 3 | export * from "./block-factory"; -------------------------------------------------------------------------------- /__tests__/integration/core-magistrate/mocks/database.ts: -------------------------------------------------------------------------------- 1 | export const database = { 2 | getForgedTransactionsIds: () => [], 3 | }; 4 | -------------------------------------------------------------------------------- /__tests__/unit/core-transaction-pool/mocks/database.ts: -------------------------------------------------------------------------------- 1 | export const database = { 2 | getForgedTransactionsIds: () => [], 3 | }; 4 | -------------------------------------------------------------------------------- /__tests__/utils/fixtures/unitnet/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./delegates"; 2 | export * from "./wallets"; 3 | export * from "./blocks"; 4 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/entities/transformer.ts: -------------------------------------------------------------------------------- 1 | export const transformEntity = (entity: any) => { 2 | return entity; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/find-by-heights.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | WHERE height IN (${heights:list}) 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/headers.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | WHERE height BETWEEN ${start} AND ${end} 4 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/blockchain/index.ts: -------------------------------------------------------------------------------- 1 | import "./dispatch"; 2 | import "./execute-on-entry"; 3 | import "./transition"; 4 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/transactions/index.ts: -------------------------------------------------------------------------------- 1 | import "./types"; 2 | import "./valid"; 3 | import "./valid-second-signature"; 4 | -------------------------------------------------------------------------------- /packages/core-logger-signale/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | logLevel: process.env.CORE_LOG_LEVEL || "info", 3 | }; 4 | -------------------------------------------------------------------------------- /packages/core-logger-winston/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./driver"; 2 | export * from "./formatter"; 3 | export * from "./plugin"; 4 | -------------------------------------------------------------------------------- /packages/core-magistrate-transactions/src/handlers/utils.ts: -------------------------------------------------------------------------------- 1 | export const packageNameRegex = new RegExp("^[a-z0-9@/.~_-]{1,214}$"); 2 | -------------------------------------------------------------------------------- /packages/core-transaction-pool/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./connection"; 2 | export * from "./manager"; 3 | export * from "./plugin"; 4 | -------------------------------------------------------------------------------- /__tests__/e2e/img/core-e2e-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/__tests__/e2e/img/core-e2e-banner.png -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/p2p/peer-processor.ts: -------------------------------------------------------------------------------- 1 | export const getProcessor = { 2 | validateAndAcceptPeer: () => undefined, 3 | }; 4 | -------------------------------------------------------------------------------- /delegate/assets/register_delegate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/delegate/assets/register_delegate.png -------------------------------------------------------------------------------- /delegate/assets/register_delegate2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/delegate/assets/register_delegate2.png -------------------------------------------------------------------------------- /delegate/assets/register_delegate3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/delegate/assets/register_delegate3.png -------------------------------------------------------------------------------- /delegate/assets/register_delegate4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/delegate/assets/register_delegate4.png -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/common/truncate-all-tables.sql: -------------------------------------------------------------------------------- 1 | TRUNCATE TABLE blocks, rounds, transactions RESTART IDENTITY; 2 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/api/index.ts: -------------------------------------------------------------------------------- 1 | import "./block"; 2 | import "./peer"; 3 | import "./response"; 4 | import "./transaction"; 5 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/transactions/delete-from-timestamp.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM transactions 2 | WHERE timestamp > ${timestamp} 3 | -------------------------------------------------------------------------------- /packages/crypto/src/interfaces/crypto.ts: -------------------------------------------------------------------------------- 1 | export interface IDecryptResult { 2 | privateKey: Buffer; 3 | compressed: boolean; 4 | } 5 | -------------------------------------------------------------------------------- /packages/crypto/src/interfaces/managers.ts: -------------------------------------------------------------------------------- 1 | export interface IMilestone { 2 | index: number; 3 | data: { [key: string]: any }; 4 | } 5 | -------------------------------------------------------------------------------- /.lintstagedrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.ts": ["yarn lint", "prettier --write", "git add"], 3 | "*.{json,md}": ["prettier --write", "git add"] 4 | } 5 | -------------------------------------------------------------------------------- /__tests__/e2e/img/docker-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internet-of-People/hydra-core/HEAD/__tests__/e2e/img/docker-architecture.png -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/delete-by-block.sql: -------------------------------------------------------------------------------- 1 | DELETE 2 | FROM transactions 3 | WHERE block_id IN (${ids:list}) 4 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-state/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./service"; 2 | export * from "./state-store"; 3 | export * from "./wallets"; 4 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/rounds/latest.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM rounds 3 | ORDER BY round DESC, balance, public_key DESC 4 | LIMIT 1 5 | -------------------------------------------------------------------------------- /packages/core/src/enums.ts: -------------------------------------------------------------------------------- 1 | export enum ProcessState { 2 | Errored = "errored", 3 | Online = "online", 4 | Stopped = "stopped", 5 | } 6 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/find-by-block.sql: -------------------------------------------------------------------------------- 1 | SELECT id, serialized 2 | FROM transactions 3 | WHERE block_id = ${id} 4 | -------------------------------------------------------------------------------- /packages/core-error-tracker-raygun/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | apiKey: process.env.CORE_ERROR_TRACKER_RAYGUN_API_KEY, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/search/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./search-parameter-converter"; 2 | export * from "./search-parameters"; 3 | -------------------------------------------------------------------------------- /packages/core-magistrate-transactions/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as Handlers from "./handlers"; 2 | export { Handlers }; 3 | export * from "./plugin"; 4 | -------------------------------------------------------------------------------- /packages/core-state/src/wallets/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./temp-wallet-manager"; 2 | export * from "./wallet-manager"; 3 | export * from "./wallet"; 4 | -------------------------------------------------------------------------------- /__tests__/unit/core-database/mocks/emitter.ts: -------------------------------------------------------------------------------- 1 | export const emitter = { 2 | on: jest.fn(), 3 | emit: jest.fn(), 4 | once: jest.fn(), 5 | }; 6 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/mocks/state.ts: -------------------------------------------------------------------------------- 1 | export const state = { 2 | getStore: () => ({ 3 | getLastBlock: () => undefined, 4 | }), 5 | }; 6 | -------------------------------------------------------------------------------- /packages/core-api/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./defaults"; 2 | export * from "./server"; 3 | export * from "./interfaces"; 4 | export * from "./plugin"; 5 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "singleQuote": false, 4 | "tabWidth": 4, 5 | "trailingComma": "all", 6 | "useTabs": false 7 | } 8 | -------------------------------------------------------------------------------- /__tests__/utils/config/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | passphrase: "clay harbor enemy utility margin pretty hub comic piece aerobic umbrella acquire", 3 | }; 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/height-range.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM blocks 3 | WHERE height BETWEEN ${start} AND ${end} 4 | ORDER BY height ASC 5 | -------------------------------------------------------------------------------- /packages/crypto/src/blocks/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./block"; 2 | export * from "./deserializer"; 3 | export * from "./factory"; 4 | export * from "./serializer"; 5 | -------------------------------------------------------------------------------- /packages/crypto/src/interfaces/identities.ts: -------------------------------------------------------------------------------- 1 | export interface IKeyPair { 2 | publicKey: string; 3 | privateKey: string; 4 | compressed: boolean; 5 | } 6 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/transaction-pool.ts: -------------------------------------------------------------------------------- 1 | export const transactionPool = { 2 | getTransactionsForForging: jest.fn(), 3 | getPoolSize: jest.fn(), 4 | }; 5 | -------------------------------------------------------------------------------- /__tests__/utils/config/testnet/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [ 3 | { 4 | "ip": "0.0.0.99", 5 | "port": 4000 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /__tests__/utils/config/unitnet/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [ 3 | { 4 | "ip": "0.0.0.99", 5 | "port": 4000 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/rounds/find.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM rounds 3 | WHERE round = ${round} 4 | ORDER BY balance DESC, 5 | public_key ASC 6 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/delegates.sql: -------------------------------------------------------------------------------- 1 | SELECT sender_public_key, 2 | asset 3 | FROM transactions 4 | WHERE type = 2 AND type_group = 1 -------------------------------------------------------------------------------- /packages/core-p2p/src/socket-server/utils/map-addr.ts: -------------------------------------------------------------------------------- 1 | import { process } from "ipaddr.js"; 2 | 3 | export const mapAddr = (addr: string) => process(addr).toString(); 4 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "packages/**/src/defaults.ts" 3 | - "packages/**/src/index.ts" 4 | - "packages/**/src/plugin.ts" 5 | - "packages/core-interfaces" 6 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/peer-discovery/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12 2 | 3 | COPY index.js . 4 | COPY package.json . 5 | 6 | RUN npm install 7 | 8 | CMD [ "node", "index.js" ] 9 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/mocks/index.ts: -------------------------------------------------------------------------------- 1 | import { container } from "./container"; 2 | 3 | jest.mock("@arkecosystem/core-container", () => { 4 | return container; 5 | }); 6 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/mocks/transactionPool.ts: -------------------------------------------------------------------------------- 1 | export const transactionPool = { 2 | buildWallets: () => undefined, 3 | acceptChainedBlock: () => undefined, 4 | }; 5 | -------------------------------------------------------------------------------- /__tests__/utils/fixtures/testnet/passphrases.ts: -------------------------------------------------------------------------------- 1 | import * as delegates from "../../config/testnet/delegates.json"; 2 | 3 | export const delegatesSecrets = delegates.secrets; 4 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/schemas/address.ts: -------------------------------------------------------------------------------- 1 | import Joi from "@hapi/joi"; 2 | 3 | export const address = Joi.string() 4 | .alphanum() 5 | .length(34); 6 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/schemas/public-key.ts: -------------------------------------------------------------------------------- 1 | import Joi from "@hapi/joi"; 2 | 3 | export const publicKey = Joi.string() 4 | .hex() 5 | .length(66); 6 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | databaseRollback: { 3 | maxBlockRewind: 10000, 4 | steps: 1000, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/latest-by-block.sql: -------------------------------------------------------------------------------- 1 | SELECT id, serialized 2 | FROM transactions 3 | WHERE block_id = ${id} 4 | ORDER BY sequence ASC 5 | -------------------------------------------------------------------------------- /packages/core-state/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | storage: { 3 | maxLastBlocks: 100, 4 | maxLastTransactionIds: 10000, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /packages/core/bin/config/testnet/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [ 3 | { 4 | "ip": "127.0.0.1", 5 | "port": 4700 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /__tests__/unit/core-blockchain/mocks/index.ts: -------------------------------------------------------------------------------- 1 | import { container } from "./container"; 2 | 3 | jest.mock("@arkecosystem/core-container", () => { 4 | return container; 5 | }); 6 | -------------------------------------------------------------------------------- /__tests__/utils/fixtures/testnet/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./delegates"; 2 | export * from "./blocks101to155"; 3 | export * from "./blocks2to100"; 4 | export * from "./passphrases"; 5 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/count-type.sql: -------------------------------------------------------------------------------- 1 | SELECT COUNT(id) as "count" 2 | FROM transactions 3 | WHERE type = ${type} AND type_group = ${typeGroup} 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/second-signatures.sql: -------------------------------------------------------------------------------- 1 | SELECT sender_public_key, 2 | asset 3 | FROM transactions 4 | WHERE type = 1 AND type_group = 1 -------------------------------------------------------------------------------- /packages/core-p2p/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./enums"; 2 | export * from "./network-state"; 3 | export * from "./peer"; 4 | export * from "./plugin"; 5 | export * from "./utils"; 6 | -------------------------------------------------------------------------------- /packages/core-utils/src/has-some-property.ts: -------------------------------------------------------------------------------- 1 | export const hasSomeProperty = (object, props): boolean => { 2 | return props.some(prop => object.hasOwnProperty(prop)); 3 | }; 4 | -------------------------------------------------------------------------------- /__tests__/e2e/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | package-lock.json 4 | 5 | # Editor directories and files 6 | .idea 7 | .vscode 8 | *.suo 9 | *.ntvs* 10 | *.njsproj 11 | *.sln -------------------------------------------------------------------------------- /__tests__/unit/core-magistrate/handlers/__mocks__/transaction-reader.ts: -------------------------------------------------------------------------------- 1 | export const transactionReader = { 2 | // tslint:disable-next-line:no-empty 3 | read: () => {}, 4 | }; 5 | -------------------------------------------------------------------------------- /__tests__/utils/fixtures/unitnet/wallets.ts: -------------------------------------------------------------------------------- 1 | export { wallets } from "../../config/unitnet/wallets.json"; 2 | export { wallets2ndSig } from "../../config/unitnet/wallets2ndSig.json"; 3 | -------------------------------------------------------------------------------- /packages/core-tester-cli/bin/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('@oclif/command').run() 4 | .then(require('@oclif/command/flush')) 5 | .catch(require('@oclif/errors/handle')) 6 | -------------------------------------------------------------------------------- /packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/crypto/src/interfaces/message.ts: -------------------------------------------------------------------------------- 1 | export interface IMessage { 2 | readonly publicKey: string; 3 | readonly signature: string; 4 | readonly message: string; 5 | } 6 | -------------------------------------------------------------------------------- /packages/crypto/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-api/src/services/index.ts: -------------------------------------------------------------------------------- 1 | import { ServerCache } from "./cache"; 2 | import { transformerService } from "./transformer"; 3 | 4 | export { ServerCache, transformerService }; 5 | -------------------------------------------------------------------------------- /packages/core-api/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20191008000000-add-type-index-to-transactions-table.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX IF NOT EXISTS "transactions_type" ON ${schema~}.transactions ("type"); 2 | -------------------------------------------------------------------------------- /packages/core-forger/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-logger/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-p2p/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/transactions/timestamp-higher.sql: -------------------------------------------------------------------------------- 1 | SELECT id, sequence, serialized FROM transactions 2 | WHERE timestamp > ${start} 3 | ORDER BY timestamp, sequence 4 | -------------------------------------------------------------------------------- /packages/core-state/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-tester-cli/src/logger.ts: -------------------------------------------------------------------------------- 1 | import pino from "pino"; 2 | 3 | export const logger = pino({ 4 | name: "core-tester-cli", 5 | safe: true, 6 | prettyPrint: true, 7 | }); 8 | -------------------------------------------------------------------------------- /packages/core-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/request.ts: -------------------------------------------------------------------------------- 1 | export const request = { 2 | event: undefined, 3 | socket: { 4 | terminate: jest.fn(), 5 | destroy: jest.fn(), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /benchmark/block/deserialize/methods.js: -------------------------------------------------------------------------------- 1 | const { 2 | Blocks 3 | } = require('@arkecosystem/crypto') 4 | 5 | exports.deserialize = data => { 6 | return Blocks.Block.deserialize(data) 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/processor/handlers/invalid-generator-handler.ts: -------------------------------------------------------------------------------- 1 | import { BlockHandler } from "./block-handler"; 2 | 3 | export class InvalidGeneratorHandler extends BlockHandler {} 4 | -------------------------------------------------------------------------------- /packages/core-blockchain/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-container/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-database/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-explorer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-http-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/shared/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface IRoundInfo { 2 | round: number; 3 | nextRound: number; 4 | maxDelegates: number; 5 | roundHeight: number; 6 | } 7 | -------------------------------------------------------------------------------- /packages/core-interfaces/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-logger-pino/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-new-relic/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-snapshots/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-tester-cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-vote-report/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-wallet-api/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-webhooks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /docker/purge_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker stop $(docker ps -aq) 4 | docker rm $(docker ps -aq) 5 | docker rmi $(docker images -q) 6 | docker volume prune -f 7 | docker network prune -f 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20181204200000-add-timestamp-index-to-blocks-table.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX IF NOT EXISTS "transactions_timestamp" ON ${schema~}.transactions ("timestamp"); 2 | -------------------------------------------------------------------------------- /packages/core-elasticsearch/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-event-emitter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-logger-signale/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-logger-winston/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-transaction-pool/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-transactions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/index.ts: -------------------------------------------------------------------------------- 1 | export { devnet } from "./devnet"; 2 | export { mainnet } from "./mainnet"; 3 | export { testnet } from "./testnet"; 4 | export { unitnet } from "./unitnet"; 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /__tests__/unit/core-forger/__fixtures__/delegate.ts: -------------------------------------------------------------------------------- 1 | export const delegate = { 2 | username: "arkxdev", 3 | publicKey: "0310ad026647eed112d1a46145eed58b8c19c67c505a67f1199361a511ce7860c0", 4 | }; 5 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/schemas/username.ts: -------------------------------------------------------------------------------- 1 | import Joi from "@hapi/joi"; 2 | 3 | export const username = Joi.string() 4 | .regex(/^[a-z0-9!@$&_.]+$/) 5 | .min(1) 6 | .max(20); 7 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20190619000000-drop-id-column-from-rounds-table.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE rounds DROP COLUMN id, ADD PRIMARY KEY (round, public_key); 2 | DROP INDEX rounds_unique; 3 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20200304000000-add-type_group-index-to-transactions-table.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX IF NOT EXISTS "transactions_type_group" ON ${schema~}.transactions ("type_group"); 2 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./model"; 2 | export * from "./block"; 3 | export * from "./migration"; 4 | export * from "./round"; 5 | export * from "./transaction"; 6 | -------------------------------------------------------------------------------- /packages/core-database-postgres/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-error-tracker-bugsnag/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-error-tracker-raygun/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-error-tracker-rollbar/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-error-tracker-sentry/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-exchange-json-rpc/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/functional/index.ts: -------------------------------------------------------------------------------- 1 | import "./accepted"; 2 | import "./entity"; 3 | import "./forged"; 4 | import "./rejected"; 5 | import "./unconfirmed"; 6 | import "./vote-balance"; 7 | -------------------------------------------------------------------------------- /packages/core-magistrate-crypto/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/peer-discovery/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "peerdiscovery", 3 | "description": "Peer discovery app", 4 | "dependencies": { 5 | "express": "4.17.1" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/block-rewards.sql: -------------------------------------------------------------------------------- 1 | SELECT generator_public_key, 2 | SUM ("reward"+"total_fee") AS "reward" 3 | FROM blocks 4 | GROUP BY "generator_public_key" 5 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/statistics.sql: -------------------------------------------------------------------------------- 1 | SELECT COUNT ("id") AS "count", 2 | SUM ("fee") AS "totalFee", 3 | SUM ("amount") AS "totalAmount" 4 | FROM transactions 5 | -------------------------------------------------------------------------------- /packages/core-error-tracker-airbrake/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-magistrate-transactions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": ["src/**/**.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/mocks/logger.ts: -------------------------------------------------------------------------------- 1 | export const logger = { 2 | info: console.log, 3 | warn: console.log, 4 | error: console.error, 5 | debug: console.log, 6 | verbose: console.log, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20181204400000-add-recipient_id-index-to-transactions-table.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX IF NOT EXISTS "transactions_recipient_id" ON ${schema~}.transactions ("recipient_id"); 2 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20190917000000-add-asset-column-to-transactions-table.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE transactions DROP COLUMN IF EXISTS asset; 2 | ALTER TABLE transactions ADD COLUMN asset JSONB; 3 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/ipfs.sql: -------------------------------------------------------------------------------- 1 | SELECT sender_public_key, 2 | asset 3 | FROM transactions 4 | WHERE type = 5 AND type_group = 1 5 | ORDER BY timestamp DESC, sequence ASC 6 | -------------------------------------------------------------------------------- /packages/core-p2p/src/socket-server/versions/index.ts: -------------------------------------------------------------------------------- 1 | import * as internal from "./internal"; 2 | import * as peer from "./peer"; 3 | import * as utils from "./utils"; 4 | 5 | export { internal, peer, utils }; 6 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/multisignature/shared.js: -------------------------------------------------------------------------------- 1 | const transactions = { 2 | multisigRegistration: {} // this will be filled by 1.create-multisig-registration 3 | } 4 | 5 | module.exports = transactions; -------------------------------------------------------------------------------- /__tests__/unit/core-blockchain/mocks/logger.ts: -------------------------------------------------------------------------------- 1 | export const logger = { 2 | info: console.log, 3 | warn: console.log, 4 | error: console.error, 5 | debug: console.log, 6 | verbose: console.log, 7 | }; 8 | -------------------------------------------------------------------------------- /benchmark/transaction/deserialize/methods.js: -------------------------------------------------------------------------------- 1 | const { 2 | Transactions 3 | } = require('@arkecosystem/crypto') 4 | 5 | exports.deserialize = data => { 6 | return Transactions.Deserializer.deserialize(data) 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20181129400000-add-block_id-index-to-transactions-table.sql: -------------------------------------------------------------------------------- 1 | -- Constraints 2 | CREATE INDEX IF NOT EXISTS "transactions_block_id" ON ${schema~}.transactions ("block_id"); 3 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/latest-by-blocks.sql: -------------------------------------------------------------------------------- 1 | SELECT id, 2 | block_id, 3 | serialized 4 | FROM transactions 5 | WHERE block_id IN (${ids:list}) 6 | ORDER BY sequence ASC 7 | -------------------------------------------------------------------------------- /packages/core-forger/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | import { SCClientSocket } from "socketcluster-client"; 2 | 3 | export interface IRelayHost { 4 | hostname: string; 5 | port: number; 6 | socket?: SCClientSocket; 7 | } 8 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "3.5.0", 3 | "npmClient": "yarn", 4 | "packages": [ 5 | "packages/*", 6 | "plugins/*" 7 | ], 8 | "useWorkspaces": true, 9 | "version": "2.7.24" 10 | } -------------------------------------------------------------------------------- /packages/core-container/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Container as container } from "@arkecosystem/core-interfaces"; 2 | import { Container } from "./container"; 3 | 4 | export const app: container.IContainer = new Container(); 5 | -------------------------------------------------------------------------------- /packages/core-forger/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | hosts: [ 3 | { 4 | hostname: "127.0.0.1", 5 | port: process.env.CORE_P2P_PORT || 4000, 6 | }, 7 | ], 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/node/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerRoutes } from "./routes"; 3 | 4 | export const register = (server: Hapi.Server): void => { 5 | registerRoutes(server); 6 | }; 7 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/peers/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerRoutes } from "./routes"; 3 | 4 | export const register = (server: Hapi.Server): void => { 5 | registerRoutes(server); 6 | }; 7 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20181204300000-add-sender_public_key-index-to-transactions-table.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX IF NOT EXISTS "transactions_sender_public_key" ON ${schema~}.transactions ("sender_public_key"); 2 | -------------------------------------------------------------------------------- /packages/core-error-tracker-airbrake/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | projectId: process.env.CORE_ERROR_TRACKER_AIRBRAKE_PROJECT_ID, 3 | projectKey: process.env.CORE_ERROR_TRACKER_AIRBRAKE_PROJECT_KEY, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/core-wallet-api/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | server: { 3 | host: process.env.CORE_WALLET_API_HOST || "0.0.0.0", 4 | port: process.env.CORE_WALLET_API_PORT || 4040, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/blockchain/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerRoutes } from "./routes"; 3 | 4 | export const register = (server: Hapi.Server): void => { 5 | registerRoutes(server); 6 | }; 7 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/received-transactions.sql: -------------------------------------------------------------------------------- 1 | SELECT recipient_id, 2 | SUM ("amount") AS "amount" 3 | FROM transactions 4 | WHERE type = 0 AND type_group = 1 5 | GROUP BY "recipient_id" 6 | -------------------------------------------------------------------------------- /packages/core-elasticsearch/src/utils.ts: -------------------------------------------------------------------------------- 1 | export const first = (values: T[]): T => { 2 | return values[0]; 3 | }; 4 | 5 | export const last = (values: T[]): T => { 6 | return values[values.length - 1]; 7 | }; 8 | -------------------------------------------------------------------------------- /packages/core-error-tracker-bugsnag/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | apiKey: process.env.CORE_ERROR_TRACKER_BUGSNAG_API_KEY, 3 | metaData: { 4 | network: process.env.CORE_NETWORK_NAME, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /packages/core-error-tracker-rollbar/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | accessToken: process.env.CORE_ERROR_TRACKER_ROLLBAR_ACCESS_TOKEN, 3 | captureUncaught: true, 4 | captureUnhandledRejections: true, 5 | }; 6 | -------------------------------------------------------------------------------- /.codacy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | exclude_paths: 3 | - 'benchmark/**/*' 4 | - 'deprecated/**/*' 5 | - 'docker/**/*' 6 | - 'scripts/**/*' 7 | - 'upgrade/**/*' 8 | - 'vagrant/**/*' 9 | - '**.sql' 10 | - '**.sh' 11 | - '**.md' 12 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/schemas/generic-name.ts: -------------------------------------------------------------------------------- 1 | import Joi from "@hapi/joi"; 2 | 3 | export const genericName = Joi.string() 4 | .regex(/^[a-zA-Z0-9]+(( - |[ ._-])[a-zA-Z0-9]+)*[.]?$/) 5 | .min(1) 6 | .max(40); 7 | -------------------------------------------------------------------------------- /packages/crypto/src/identities/index.ts: -------------------------------------------------------------------------------- 1 | export { Address } from "./address"; 2 | export { Keys } from "./keys"; 3 | export { PrivateKey } from "./private-key"; 4 | export { PublicKey } from "./public-key"; 5 | export { WIF } from "./wif"; 6 | -------------------------------------------------------------------------------- /__tests__/integration/core-tester-cli/commands/send/fixtures.ts: -------------------------------------------------------------------------------- 1 | export const nodeStatusResponse = { 2 | data: { 3 | synced: true, 4 | now: 2, 5 | blocksCount: 0, 6 | timestamp: 90273881, 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-api/src/interfaces/repository.ts: -------------------------------------------------------------------------------- 1 | export interface IRepository { 2 | databaseService: any; 3 | cache: any; 4 | model: any; 5 | query: any; 6 | columns: string[]; 7 | 8 | getModel(): object; 9 | } 10 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20201117000000-add-generator_public_key_height-index-to-blocks-table.sql: -------------------------------------------------------------------------------- 1 | CREATE INDEX IF NOT EXISTS "blocks_generator_public_key_height" ON ${schema~}.blocks ("generator_public_key", "height"); 2 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/multi-signatures.sql: -------------------------------------------------------------------------------- 1 | SELECT sender_public_key, 2 | asset, 3 | version 4 | FROM transactions 5 | WHERE type = 4 AND type_group = 1 6 | ORDER BY (timestamp + sequence) DESC 7 | -------------------------------------------------------------------------------- /packages/core-database/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./manager"; 2 | export * from "./database-service-factory"; 3 | export * from "./database-service"; 4 | export * from "./repositories/wallets-business-repository"; 5 | export * from "./plugin"; 6 | -------------------------------------------------------------------------------- /packages/core-error-tracker-sentry/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | dsn: process.env.CORE_ERROR_TRACKER_SENTRY_DSN, 3 | debug: true, 4 | attachStacktrace: true, 5 | environment: process.env.CORE_NETWORK_NAME, 6 | }; 7 | -------------------------------------------------------------------------------- /__tests__/unit/core-logger-signale/logger.test.ts: -------------------------------------------------------------------------------- 1 | import { SignaleLogger } from "../../../packages/core-logger-signale/src"; 2 | import { expectLogger } from "../shared/logger"; 3 | 4 | expectLogger(() => new SignaleLogger({ logLevel: "info" })); 5 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/rounds/schema.ts: -------------------------------------------------------------------------------- 1 | import Joi from "@hapi/joi"; 2 | 3 | export const delegates: object = { 4 | params: { 5 | id: Joi.number() 6 | .integer() 7 | .min(1), 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20180304100000-create-migrations-table.sql: -------------------------------------------------------------------------------- 1 | -- Table Definition 2 | CREATE TABLE IF NOT EXISTS ${schema~}.migrations ( 3 | "id" SERIAL PRIMARY KEY, 4 | "name" VARCHAR(255) UNIQUE NOT NULL 5 | ); 6 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20190803000000-add-type_group-column-to-transactions-table.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE transactions DROP COLUMN IF EXISTS type_group; 2 | ALTER TABLE transactions ADD COLUMN type_group INTEGER NOT NULL DEFAULT 1; 3 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/business-repository/parameters.ts: -------------------------------------------------------------------------------- 1 | export interface IParameters { 2 | offset?: number; 3 | limit?: number; 4 | orderBy?: string; 5 | [key: string]: object | number | string | boolean; 6 | } 7 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./postgres-connection"; 2 | export * from "./migrations"; 3 | export * from "./state-builder"; 4 | export * from "./models"; 5 | export * from "./repositories"; 6 | export * from "./plugin"; 7 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-p2p/peer-verifier.ts: -------------------------------------------------------------------------------- 1 | export interface IPeerVerificationResult { 2 | readonly myHeight: number; 3 | readonly hisHeight: number; 4 | readonly highestCommonHeight: number; 5 | readonly forked: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /packages/core-tester-cli/src/shared/htlc-secret.ts: -------------------------------------------------------------------------------- 1 | export const htlcSecretHex = "c27f1ce845d8c29eebc9006be932b604fd06755521b1a8b0be4204c65377151a"; 2 | export const htlcSecretHashHex = "9c1a3815d49e0c9f78b872bfb017e825ea2db708158b70815526a830c85912b4"; 3 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/mocks/p2p.ts: -------------------------------------------------------------------------------- 1 | import { getMonitor } from "./p2p/network-monitor"; 2 | import { getStorage } from "./p2p/peer-storage"; 3 | 4 | export const p2p = { 5 | getStorage: () => getStorage, 6 | getMonitor: () => getMonitor, 7 | }; 8 | -------------------------------------------------------------------------------- /__tests__/utils/index.ts: -------------------------------------------------------------------------------- 1 | import "@arkecosystem/core-jest-matchers"; 2 | 3 | import * as fixtures from "./fixtures"; 4 | import * as generators from "./generators"; 5 | import * as helpers from "./helpers"; 6 | 7 | export { fixtures, generators, helpers }; 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20181204100000-add-generator_public_key-index-to-blocks-table.sql: -------------------------------------------------------------------------------- 1 | DROP INDEX IF EXISTS "blocks_unique"; 2 | CREATE INDEX IF NOT EXISTS "blocks_generator_public_key" ON ${schema~}.blocks ("generator_public_key"); 3 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/common.sql: -------------------------------------------------------------------------------- 1 | SELECT MAX("height") AS "height", 2 | "id", 3 | "previous_block", 4 | "timestamp" 5 | FROM blocks 6 | WHERE "id" IN (${ids:list}) 7 | GROUP BY "id" 8 | ORDER BY "height" DESC 9 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/business-repository/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./wallets-business-repository"; 2 | export * from "./parameters"; 3 | export * from "./blocks-business-repository"; 4 | export * from "./transactions-business-repository"; 5 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/rounds/round-range.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | round, 3 | balance, 4 | public_key 5 | FROM 6 | rounds 7 | WHERE 8 | round BETWEEN ${startRound} AND ${endRound} 9 | ORDER BY 10 | round, balance DESC, public_key 11 | -------------------------------------------------------------------------------- /packages/core-transactions/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as Errors from "./errors"; 2 | import * as Handlers from "./handlers"; 3 | import * as Interfaces from "./interfaces"; 4 | 5 | export * from "./transaction-reader"; 6 | export { Errors, Handlers, Interfaces }; 7 | -------------------------------------------------------------------------------- /packages/crypto/src/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./block"; 2 | export * from "./crypto"; 3 | export * from "./identities"; 4 | export * from "./managers"; 5 | export * from "./message"; 6 | export * from "./networks"; 7 | export * from "./transactions"; 8 | -------------------------------------------------------------------------------- /__tests__/unit/core-blockchain/mocks/p2p.ts: -------------------------------------------------------------------------------- 1 | import { getMonitor } from "./p2p/network-monitor"; 2 | import { getStorage } from "./p2p/peer-storage"; 3 | 4 | export const p2p = { 5 | getStorage: () => getStorage, 6 | getMonitor: () => getMonitor, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20191003000000-migrate-vendor-field-hex.sql: -------------------------------------------------------------------------------- 1 | UPDATE transactions SET vendor_field_hex = ('\x' || ENCODE(vendor_field_hex, 'escape'))::BYTEA; 2 | 3 | ALTER TABLE transactions RENAME vendor_field_hex TO vendor_field; 4 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/sent-transactions.sql: -------------------------------------------------------------------------------- 1 | SELECT sender_public_key, 2 | SUM ("amount") AS "amount", 3 | SUM ("fee") AS "fee", 4 | COUNT ("id") AS "nonce" 5 | FROM transactions 6 | GROUP BY "sender_public_key" 7 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/mocks/config.ts: -------------------------------------------------------------------------------- 1 | import genesisBlock from "../../../utils/config/testnet/genesisBlock.json"; 2 | 3 | export const config = { 4 | "network.nethash": genesisBlock.payloadHash, 5 | genesisBlock, 6 | "state.maxLastBlocks": 50, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/core-explorer/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | server: { 3 | host: process.env.CORE_EXPLORER_HOST || "0.0.0.0", 4 | port: process.env.CORE_EXPLORER_PORT || 4200, 5 | }, 6 | path: process.env.CORE_EXPLORER_PATH, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/core-vote-report/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | host: process.env.CORE_VOTE_REPORT_HOST || "0.0.0.0", 3 | port: process.env.CORE_VOTE_REPORT_PORT || 4006, 4 | delegateRows: process.env.CORE_VOTE_REPORT_DELEGATE_ROWS || 80, 5 | }; 6 | -------------------------------------------------------------------------------- /__tests__/unit/core-blockchain/mocks/config.ts: -------------------------------------------------------------------------------- 1 | import genesisBlock from "../../../utils/config/testnet/genesisBlock.json"; 2 | 3 | export const config = { 4 | "network.nethash": genesisBlock.payloadHash, 5 | genesisBlock, 6 | "state.maxLastBlocks": 50, 7 | }; 8 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/state.ts: -------------------------------------------------------------------------------- 1 | import { genesisBlock } from "../../../utils/fixtures/unitnet/block-model"; 2 | 3 | export const state = { 4 | getStore: () => ({ 5 | getLastBlock: () => genesisBlock, 6 | forkedBlock: undefined, 7 | }), 8 | }; 9 | -------------------------------------------------------------------------------- /benchmark/block/deserialize/0.js: -------------------------------------------------------------------------------- 1 | const { 2 | deserialize 3 | } = require('./methods') 4 | 5 | const data = require('../../helpers').getFixture('block/serialized/no-transactions.txt'); 6 | 7 | exports['core'] = () => { 8 | return deserialize(data); 9 | }; 10 | -------------------------------------------------------------------------------- /benchmark/block/deserialize/150.js: -------------------------------------------------------------------------------- 1 | const { 2 | deserialize 3 | } = require('./methods') 4 | 5 | const data = require('../../helpers').getFixture('block/serialized/transactions.txt'); 6 | 7 | exports['core'] = () => { 8 | return deserialize(data); 9 | }; 10 | -------------------------------------------------------------------------------- /benchmark/transaction/deserialize/0.js: -------------------------------------------------------------------------------- 1 | const { 2 | deserialize 3 | } = require('./methods') 4 | 5 | const data = require('../../helpers').getFixture('transaction/serialized/0.txt'); 6 | 7 | exports['core'] = () => { 8 | return deserialize(data); 9 | }; 10 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/database-repository/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./transactions-repository"; 2 | export * from "./rounds-repository"; 3 | export * from "./wallets-repository"; 4 | export * from "./blocks-repository"; 5 | export * from "./repository"; 6 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-state/service.ts: -------------------------------------------------------------------------------- 1 | import { IStateStore } from "./state-store"; 2 | 3 | export interface IStateService { 4 | getBlocks(): any; // @TODO: add type 5 | getTransactions(): any; // @TODO: add type 6 | getStore(): IStateStore; 7 | } 8 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/devnet/exceptions.json: -------------------------------------------------------------------------------- 1 | { 2 | "blocks": [], 3 | "blocksTransactions": {}, 4 | "transactions": [], 5 | "outlookTable": {}, 6 | "transactionIdFixTable": {}, 7 | "wrongTransactionOrder": {}, 8 | "negativeBalances": {} 9 | } -------------------------------------------------------------------------------- /packages/crypto/src/networks/mainnet/exceptions.json: -------------------------------------------------------------------------------- 1 | { 2 | "blocks": [], 3 | "blocksTransactions": {}, 4 | "transactions": [], 5 | "outlookTable": {}, 6 | "transactionIdFixTable": {}, 7 | "wrongTransactionOrder": {}, 8 | "negativeBalances": {} 9 | } -------------------------------------------------------------------------------- /packages/core-logger/src/plugin.ts: -------------------------------------------------------------------------------- 1 | import { LoggerManager } from "./manager"; 2 | 3 | export const plugin = { 4 | pkg: require("../package.json"), 5 | alias: "log-manager", 6 | async register() { 7 | return new LoggerManager(); 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /packages/core-database/src/factory.ts: -------------------------------------------------------------------------------- 1 | import { Database } from "@arkecosystem/core-interfaces"; 2 | 3 | export class ConnectionFactory { 4 | public async make(connection: Database.IConnection): Promise { 5 | return connection.make(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/core/src/types.ts: -------------------------------------------------------------------------------- 1 | export type CommandFlags = Record; 2 | 3 | export type EnvironmentVars = Record; 4 | 5 | export type Options = Record; 6 | 7 | export type ProcessOptions = Record<"name" | "script" | "args", string>; 8 | -------------------------------------------------------------------------------- /benchmark/block/serialize.js: -------------------------------------------------------------------------------- 1 | const { 2 | Blocks 3 | } = require('@arkecosystem/crypto') 4 | 5 | const data = require('../helpers').getJSONFixture('block/deserialized/no-transactions'); 6 | 7 | exports['core'] = () => { 8 | return Blocks.Block.serialize(data); 9 | }; 10 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/statistics.sql: -------------------------------------------------------------------------------- 1 | SELECT SUM ("number_of_transactions") AS "numberOfTransactions", 2 | SUM ("total_fee") AS "totalFee", 3 | SUM ("total_amount") AS "totalAmount", 4 | COUNT (DISTINCT "height") AS "count" 5 | FROM blocks 6 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/event-types.ts: -------------------------------------------------------------------------------- 1 | export enum DatabaseEvents { 2 | PRE_CONNECT = "database.preConnect", 3 | POST_CONNECT = "database.postConnect", 4 | PRE_DISCONNECT = "database.preDisconnect", 5 | POST_DISCONNECT = "database.postDisconnect", 6 | } 7 | -------------------------------------------------------------------------------- /packages/core-magistrate-crypto/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as Builders from "./builders"; 2 | import * as Enums from "./enums"; 3 | import * as Interfaces from "./interfaces"; 4 | import * as Transactions from "./transactions"; 5 | 6 | export { Builders, Enums, Interfaces, Transactions }; 7 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/config/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [ 3 | { 4 | "ip": "127.0.0.1", 5 | "port": 4102 6 | }, 7 | { 8 | "ip": "127.0.0.1", 9 | "port": 4202 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /packages/core-http-utils/src/plugins/index.ts: -------------------------------------------------------------------------------- 1 | export { hapiAjv } from "./hapi-ajv"; 2 | export { contentType } from "./content-type"; 3 | export { corsHeaders } from "./cors-headers"; 4 | export { transactionPayload } from "./transaction-payload"; 5 | export { whitelist } from "./whitelist"; 6 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/transactions/types/index.ts: -------------------------------------------------------------------------------- 1 | import "./delegate-registration"; 2 | import "./delegate-resignation"; 3 | import "./ipfs"; 4 | import "./multi-payment"; 5 | import "./multi-signature"; 6 | import "./second-signature"; 7 | import "./transfer"; 8 | import "./vote"; 9 | -------------------------------------------------------------------------------- /packages/core-transactions/src/handlers/index.ts: -------------------------------------------------------------------------------- 1 | import { transactionHandlerRegistry as Registry } from "./handler-registry"; 2 | import { TransactionHandler, TransactionHandlerConstructor } from "./transaction"; 3 | 4 | export { Registry, TransactionHandler, TransactionHandlerConstructor }; 5 | -------------------------------------------------------------------------------- /benchmark/transaction/serialize/0.js: -------------------------------------------------------------------------------- 1 | const { 2 | Transactions 3 | } = require('@arkecosystem/crypto') 4 | 5 | const data = require('../../helpers').getJSONFixture('transaction/deserialized/0'); 6 | 7 | exports['core'] = () => { 8 | return Transactions.Utils.toBytes(data); 9 | }; 10 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/rounds/transformer.ts: -------------------------------------------------------------------------------- 1 | import { Utils } from "@arkecosystem/crypto"; 2 | 3 | export const transformRoundDelegate = model => { 4 | return { 5 | publicKey: model.publicKey, 6 | votes: Utils.BigNumber.make(model.balance).toFixed(), 7 | }; 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-logger-pino/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | levels: { 3 | console: process.env.CORE_LOG_LEVEL || "debug", 4 | file: process.env.CORE_LOG_LEVEL_FILE || "trace", 5 | }, 6 | fileRotator: { 7 | interval: "1d", 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/logger.ts: -------------------------------------------------------------------------------- 1 | export const logger = { 2 | info: jest.fn().mockImplementation(console.log), 3 | warn: jest.fn().mockImplementation(console.log), 4 | error: jest.fn().mockImplementation(console.error), 5 | debug: jest.fn().mockImplementation(console.log), 6 | }; 7 | -------------------------------------------------------------------------------- /packages/core-elasticsearch/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | server: { 3 | host: "0.0.0.0", 4 | port: 4007, 5 | whitelist: ["*"], 6 | }, 7 | client: { 8 | nodes: ["http://localhost:9200"], 9 | }, 10 | chunkSize: 5000, 11 | }; 12 | -------------------------------------------------------------------------------- /packages/core-http-utils/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as plugins from "./plugins"; 2 | import { createServer } from "./server/create"; 3 | import { monitorServer } from "./server/monitor"; 4 | import { mountServer } from "./server/mount"; 5 | 6 | export { createServer, monitorServer, mountServer, plugins }; 7 | -------------------------------------------------------------------------------- /__tests__/integration/core-tester-cli/__fixtures__/transaction-response-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "accept": ["4743f493f3f0e119b8330ea95de500e9823e51802ca3391ece96c326634e183a"], 3 | "excess": [], 4 | "invalid": [], 5 | "broadcast": ["4743f493f3f0e119b8330ea95de500e9823e51802ca3391ece96c326634e183a"] 6 | } 7 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/schemas/wallet-id.ts: -------------------------------------------------------------------------------- 1 | import Joi from "@hapi/joi"; 2 | 3 | import { address } from "./address"; 4 | import { publicKey } from "./public-key"; 5 | import { username } from "./username"; 6 | 7 | export const walletId = Joi.alternatives().try(username, address, publicKey); 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20190606000000-add-block-id-foreign-key-on-transactions.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE transactions DROP CONSTRAINT IF EXISTS "transactions_block_id_fkey"; 2 | ALTER TABLE transactions ADD CONSTRAINT "transactions_block_id_fkey" FOREIGN KEY (block_id) REFERENCES blocks (id); 3 | -------------------------------------------------------------------------------- /packages/crypto/src/crypto/index.ts: -------------------------------------------------------------------------------- 1 | import * as bip38 from "./bip38"; 2 | 3 | export { bip38 }; 4 | export { Hash } from "./hash"; 5 | export { HashAlgorithms } from "./hash-algorithms"; 6 | export { HDWallet } from "./hdwallet"; 7 | export { Message } from "./message"; 8 | export { Slots } from "./slots"; 9 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/config/plugins.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "./plugin-a": { 3 | enabled: true, 4 | }, 5 | "./plugin-b": { 6 | enabled: true, 7 | property: "value", 8 | }, 9 | "./plugin-c": { 10 | enabled: true, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/blocks/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerMethods } from "./methods"; 3 | import { registerRoutes } from "./routes"; 4 | 5 | export const register = (server: Hapi.Server): void => { 6 | registerMethods(server); 7 | registerRoutes(server); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/delegates/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerMethods } from "./methods"; 3 | import { registerRoutes } from "./routes"; 4 | 5 | export const register = (server: Hapi.Server): void => { 6 | registerMethods(server); 7 | registerRoutes(server); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/entities/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerMethods } from "./methods"; 3 | import { registerRoutes } from "./routes"; 4 | 5 | export const register = (server: Hapi.Server): void => { 6 | registerMethods(server); 7 | registerRoutes(server); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/locks/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerMethods } from "./methods"; 3 | import { registerRoutes } from "./routes"; 4 | 5 | export const register = (server: Hapi.Server): void => { 6 | registerMethods(server); 7 | registerRoutes(server); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/rounds/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerMethods } from "./methods"; 3 | import { registerRoutes } from "./routes"; 4 | 5 | export const register = (server: Hapi.Server): void => { 6 | registerMethods(server); 7 | registerRoutes(server); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/votes/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerMethods } from "./methods"; 3 | import { registerRoutes } from "./routes"; 4 | 5 | export const register = (server: Hapi.Server): void => { 6 | registerMethods(server); 7 | registerRoutes(server); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/wallets/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerMethods } from "./methods"; 3 | import { registerRoutes } from "./routes"; 4 | 5 | export const register = (server: Hapi.Server): void => { 6 | registerMethods(server); 7 | registerRoutes(server); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/delegates-forged-blocks.sql: -------------------------------------------------------------------------------- 1 | SELECT generator_public_key, 2 | SUM ("total_fee") AS "total_fees", 3 | SUM ("reward") AS "total_rewards", 4 | COUNT ("total_amount") AS "total_produced" 5 | FROM blocks 6 | GROUP BY "generator_public_key" 7 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/index.ts: -------------------------------------------------------------------------------- 1 | import "jest-extended"; 2 | 3 | import "./api"; 4 | import "./blockchain"; 5 | import "./fields"; 6 | import "./functional"; 7 | import "./models"; 8 | import "./transactions"; 9 | 10 | import "./fields"; 11 | import "./models"; 12 | import "./transactions"; 13 | -------------------------------------------------------------------------------- /packages/core-transaction-pool/src/factory.ts: -------------------------------------------------------------------------------- 1 | import { TransactionPool } from "@arkecosystem/core-interfaces"; 2 | 3 | export class ConnectionFactory { 4 | public async make(connection: TransactionPool.IConnection): Promise { 5 | return connection.make(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/devnet/index.ts: -------------------------------------------------------------------------------- 1 | import exceptions from "./exceptions.json"; 2 | import genesisBlock from "./genesisBlock.json"; 3 | import milestones from "./milestones.json"; 4 | import network from "./network.json"; 5 | 6 | export const devnet = { exceptions, genesisBlock, milestones, network }; 7 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/mainnet/index.ts: -------------------------------------------------------------------------------- 1 | import exceptions from "./exceptions.json"; 2 | import genesisBlock from "./genesisBlock.json"; 3 | import milestones from "./milestones.json"; 4 | import network from "./network.json"; 5 | 6 | export const mainnet = { exceptions, genesisBlock, milestones, network }; 7 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/testnet/index.ts: -------------------------------------------------------------------------------- 1 | import exceptions from "./exceptions.json"; 2 | import genesisBlock from "./genesisBlock.json"; 3 | import milestones from "./milestones.json"; 4 | import network from "./network.json"; 5 | 6 | export const testnet = { exceptions, genesisBlock, milestones, network }; 7 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/unitnet/index.ts: -------------------------------------------------------------------------------- 1 | import exceptions from "./exceptions.json"; 2 | import genesisBlock from "./genesisBlock.json"; 3 | import milestones from "./milestones.json"; 4 | import network from "./network.json"; 5 | 6 | export const unitnet = { exceptions, genesisBlock, milestones, network }; 7 | -------------------------------------------------------------------------------- /__tests__/unit/core-magistrate/handlers/__mocks__/wallet-repository.ts: -------------------------------------------------------------------------------- 1 | export const walletRepository = { 2 | // tslint:disable-next-line:no-empty 3 | findByPublicKey: publicKey => {}, 4 | // tslint:disable-next-line:no-empty 5 | index: () => {}, 6 | getIndex: () => ({ values: () => [] }), 7 | }; 8 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/utils/check-dns.test.ts: -------------------------------------------------------------------------------- 1 | import { checkDNS } from "../../../../packages/core-p2p/src/utils"; 2 | 3 | describe("Check DNS", () => { 4 | it("should be ok", async () => { 5 | const response = await checkDNS(["1.1.1.1"]); 6 | expect(response).toBe("1.1.1.1"); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /__tests__/unit/core-transaction-pool/mocks/state.ts: -------------------------------------------------------------------------------- 1 | export const state = { 2 | getStore: () => ({ 3 | cacheTransactions: () => undefined, 4 | getLastBlock: () => ({ data: { height: 0 } }), 5 | getLastHeight: () => 1, 6 | clearCachedTransactionIds: () => undefined, 7 | }), 8 | }; 9 | -------------------------------------------------------------------------------- /benchmark/block/serializeWithTransactions.js: -------------------------------------------------------------------------------- 1 | const { 2 | Blocks 3 | } = require('@arkecosystem/crypto') 4 | 5 | const data = require('../helpers').getJSONFixture('block/deserialized/transactions'); 6 | 7 | exports['core'] = () => { 8 | return Blocks.Block.serializeWithTransactions(data); 9 | }; 10 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/transactions/index.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { registerMethods } from "./methods"; 3 | import { registerRoutes } from "./routes"; 4 | 5 | export const register = (server: Hapi.Server): void => { 6 | registerMethods(server); 7 | registerRoutes(server); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./database-repository"; 2 | export * from "./business-repository"; 3 | export * from "./database-connection"; 4 | export * from "./database-service"; 5 | export * from "./event-types"; 6 | export * from "./search"; 7 | export * from "./database-model"; 8 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | events { 2 | worker_connections 4096; ## Default: 1024 3 | } 4 | http { 5 | server { 6 | listen 4900; 7 | 8 | location ~ /core(\d+)(.*)$ { 9 | resolver 127.0.0.11; 10 | proxy_pass http://core$1:4003$2; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /__tests__/integration/core-magistrate/mocks/state.ts: -------------------------------------------------------------------------------- 1 | export const state = { 2 | getStore: () => ({ 3 | cacheTransactions: () => undefined, 4 | getLastBlock: () => ({ data: { height: 0 } }), 5 | getLastHeight: () => 1, 6 | clearCachedTransactionIds: () => undefined, 7 | }), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/index.ts: -------------------------------------------------------------------------------- 1 | import { readdirSync } from "fs"; 2 | import { loadQueryFile } from "../utils"; 3 | 4 | export const migrations = readdirSync(__dirname) 5 | .filter(name => name.substr(-4).toLowerCase() === '.sql') 6 | .sort() 7 | .map(name => loadQueryFile(__dirname, name)); 8 | -------------------------------------------------------------------------------- /packages/core-webhooks/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface IWebhook { 2 | id?: string; 3 | token?: string; 4 | 5 | event: string; 6 | target: string; 7 | enabled: boolean; 8 | conditions: Array<{ 9 | key: string; 10 | value: any; 11 | condition: string; 12 | }>; 13 | } 14 | -------------------------------------------------------------------------------- /packages/crypto/src/types.ts: -------------------------------------------------------------------------------- 1 | import * as networks from "./networks"; 2 | 3 | export type NetworkType = 4 | | typeof networks.mainnet.network 5 | | typeof networks.devnet.network 6 | | typeof networks.testnet.network 7 | | typeof networks.unitnet.network; 8 | 9 | export type NetworkName = keyof typeof networks; 10 | -------------------------------------------------------------------------------- /__tests__/integration/core-tester-cli/__fixtures__/wallet-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "DNjuJEDQkhrJ7cA9FZ2iVXt5anYiM8Jtc9", 3 | "publicKey": "03bbfb43ecb5a54a1e227bb37b5812b5321213838d376e2b455b6af78442621dec", 4 | "username": "arkx", 5 | "secondPublicKey": null, 6 | "balance": 42159020792234, 7 | "isDelegate": true 8 | } 9 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/find-by-htlc-locks.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM transactions 3 | WHERE 4 | type IN (9, 10) 5 | AND 6 | type_group = 1 7 | AND 8 | ( 9 | asset->'refund'->'lockTransactionId' ?| array[${ids}] 10 | OR 11 | asset->'claim'->'lockTransactionId' ?| array[${ids}] 12 | ) 13 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/search/search-parameter-converter.ts: -------------------------------------------------------------------------------- 1 | import { IParameters } from "../business-repository"; 2 | import { ISearchParameters } from "./search-parameters"; 3 | 4 | export interface IISearchParameterConverter { 5 | convert(params: IParameters, orderBy?: any, paginate?: any): ISearchParameters; 6 | } 7 | -------------------------------------------------------------------------------- /packages/core-logger-winston/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | import TransportStream from "winston-transport"; 2 | 3 | export interface ITransportStream extends TransportStream { 4 | name: string; 5 | } 6 | 7 | export interface ITransport { 8 | package?: string; 9 | constructor: string; 10 | options: Record; 11 | } 12 | -------------------------------------------------------------------------------- /packages/core-magistrate-crypto/src/builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./business-registration"; 2 | export * from "./business-resignation"; 3 | export * from "./business-update"; 4 | export * from "./bridgechain-registration"; 5 | export * from "./bridgechain-resignation"; 6 | export * from "./bridgechain-update"; 7 | export * from "./entity"; 8 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/last-forged-blocks.sql: -------------------------------------------------------------------------------- 1 | SELECT id, 2 | height, 3 | generator_public_key, 4 | TIMESTAMP 5 | FROM blocks 6 | WHERE height IN ( 7 | SELECT MAX(height) AS last_block_height 8 | FROM blocks 9 | GROUP BY generator_public_key 10 | ) 11 | ORDER BY TIMESTAMP DESC 12 | -------------------------------------------------------------------------------- /packages/core-magistrate-crypto/src/transactions/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./business-registration"; 2 | export * from "./business-resignation"; 3 | export * from "./business-update"; 4 | export * from "./bridgechain-registration"; 5 | export * from "./bridgechain-resignation"; 6 | export * from "./bridgechain-update"; 7 | export * from "./entity"; 8 | -------------------------------------------------------------------------------- /upgrade/2.1.0/exchange.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ~/ark-core 4 | pm2 delete ark-core 5 | pm2 delete ark-core-relay 6 | git reset --hard 7 | git pull 8 | git checkout master 9 | yarn run bootstrap 10 | yarn run upgrade 11 | 12 | pm2 --name 'ark-core-relay' start ~/ark-core/packages/core/dist/index.js -- relay --network mainnet 13 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/plugin-c.js: -------------------------------------------------------------------------------- 1 | exports.plugin = { 2 | pkg: { 3 | name: "stub/plugin-c", 4 | version: "1.0.0", 5 | }, 6 | alias: "stub-plugin-c", 7 | register(container, options) { 8 | return { 9 | container, 10 | options, 11 | }; 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /__tests__/unit/crypto/constants.test.ts: -------------------------------------------------------------------------------- 1 | import "jest-extended"; 2 | import * as constants from "../../../packages/crypto/src/constants"; 3 | 4 | describe("Constants", () => { 5 | it("satoshi is valid", () => { 6 | expect(constants.SATOSHI).toBeDefined(); 7 | expect(constants.SATOSHI).toBe(100000000); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/schemas/block-id.ts: -------------------------------------------------------------------------------- 1 | import Joi from "@hapi/joi"; 2 | 3 | export const blockId = Joi.alternatives().try( 4 | Joi.string() 5 | .min(1) 6 | .max(20) 7 | .regex(/^[0-9]+$/, "decimal non-negative integer"), 8 | Joi.string() 9 | .length(64) 10 | .hex(), 11 | ); 12 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/database-repository/wallets-repository.ts: -------------------------------------------------------------------------------- 1 | import { IWallet } from "../../core-state/wallets"; 2 | import { IRepository } from "./repository"; 3 | 4 | export interface IWalletsRepository extends IRepository { 5 | all(): Promise; 6 | findByAddress(address: string): Promise; 7 | } 8 | -------------------------------------------------------------------------------- /packages/core-magistrate-transactions/src/handlers/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./business-registration"; 2 | export * from "./business-resignation"; 3 | export * from "./business-update"; 4 | export * from "./bridgechain-registration"; 5 | export * from "./bridgechain-resignation"; 6 | export * from "./bridgechain-update"; 7 | export * from "./entity"; 8 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/p2p.ts: -------------------------------------------------------------------------------- 1 | import { getMonitor } from "./p2p/network-monitor"; 2 | import { getProcessor } from "./p2p/peer-processor"; 3 | import { getStorage } from "./p2p/peer-storage"; 4 | 5 | export const p2p = { 6 | getMonitor: () => getMonitor, 7 | getStorage: () => getStorage, 8 | getProcessor: () => getProcessor, 9 | }; 10 | -------------------------------------------------------------------------------- /__tests__/integration/core-tester-cli/__fixtures__/identities.json: -------------------------------------------------------------------------------- 1 | { 2 | "passphrase": "this is a top secret passphrase", 3 | "publicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", 4 | "privateKey": "d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712", 5 | "address": "D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib" 6 | } 7 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/claimed-locks.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | SUM(amount) as "amount", recipient_id 3 | FROM 4 | transactions 5 | WHERE 6 | id 7 | IN ( 8 | SELECT asset->'claim'->>'lockTransactionId' 9 | FROM 10 | transactions 11 | WHERE 12 | type IN (9) 13 | AND 14 | type_group = 1 15 | ) 16 | GROUP BY 17 | recipient_id; -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-p2p/peer-processor.ts: -------------------------------------------------------------------------------- 1 | export interface IAcceptNewPeerOptions { 2 | seed?: boolean; 3 | lessVerbose?: boolean; 4 | } 5 | 6 | export interface IPeerProcessor { 7 | validateAndAcceptPeer(peer, options?: IAcceptNewPeerOptions): Promise; 8 | validatePeerIp(peer, options?: IAcceptNewPeerOptions): boolean; 9 | } 10 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/plugin-a.js: -------------------------------------------------------------------------------- 1 | exports.plugin = { 2 | pkg: { 3 | name: "stub/plugin-a", 4 | version: "1.0.0", 5 | }, 6 | alias: "stub-plugin-a", 7 | register(container, options) { 8 | return { 9 | container, 10 | options, 11 | }; 12 | }, 13 | deregister() {}, 14 | }; 15 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/plugin-b.js: -------------------------------------------------------------------------------- 1 | exports.plugin = { 2 | pkg: { 3 | name: "stub/plugin-b", 4 | version: "1.0.0", 5 | }, 6 | alias: "stub-plugin-b", 7 | register(container, options) { 8 | return { 9 | container, 10 | options, 11 | }; 12 | }, 13 | deregister() {}, 14 | }; 15 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/processor/handlers/verification-failed-handler.ts: -------------------------------------------------------------------------------- 1 | import { BlockProcessorResult } from "../block-processor"; 2 | import { BlockHandler } from "./block-handler"; 3 | 4 | export class VerificationFailedHandler extends BlockHandler { 5 | public async execute(): Promise { 6 | return super.execute(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/refunded-locks.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | SUM(amount) as "amount", sender_public_key 3 | FROM 4 | transactions 5 | WHERE 6 | id 7 | IN ( 8 | SELECT asset->'refund'->>'lockTransactionId' 9 | FROM 10 | transactions 11 | WHERE 12 | type IN (10) 13 | AND 14 | type_group = 1 15 | ) 16 | GROUP BY 17 | sender_public_key; -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/database-repository/repository.ts: -------------------------------------------------------------------------------- 1 | import { IModel } from "../database-model"; 2 | 3 | export interface IRepository { 4 | getModel(): IModel; 5 | 6 | truncate(): Promise; 7 | 8 | insert(item: object | object[], db?: any): Promise; 9 | 10 | update(item: object | object[]): Promise; 11 | } 12 | -------------------------------------------------------------------------------- /upgrade/2.1.0/normal.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ~/ark-core 4 | pm2 delete all 5 | git reset --hard 6 | git pull 7 | git checkout master 8 | yarn run bootstrap 9 | yarn run upgrade 10 | 11 | # If you do not use Core Commander you can skip this step. 12 | cd ~/core-commander 13 | git reset --hard 14 | git pull 15 | git checkout master 16 | bash commander.sh 17 | -------------------------------------------------------------------------------- /benchmark/fixtures/transaction/serialized/0.txt: -------------------------------------------------------------------------------- 1 | ff0117004df0760303d7dfe44e771039334f4712fb95ad355254f674c8f5d286503199157b7bf7c35780969800000000000d5472616e73616374696f6e203700c2eb0b00000000000000001759e7dc56557733804418f0ea6fd3b2573a9aabdd3045022100bac5b7699748a891b39ff5439e16ea1a694e93954b248be6b8082da01e5386310220129eb06a58b9f80d36ea3cdc903e6cc0240bbe1d371339ffe15c87742af1427d 2 | -------------------------------------------------------------------------------- /packages/core-state/src/stores/transactions.ts: -------------------------------------------------------------------------------- 1 | import { OrderedCappedMap } from "@arkecosystem/core-utils"; 2 | import { Interfaces } from "@arkecosystem/crypto"; 3 | 4 | export class TransactionStore extends OrderedCappedMap { 5 | public push(value: Interfaces.ITransactionData): void { 6 | this.set(value.id, value); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /__tests__/utils/fixtures/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./testnet"; // export testnet by default, if we want a different one we import from its path 2 | 3 | export const htlcSecretHex = "c27f1ce845d8c29eebc9006be932b604fd06755521b1a8b0be4204c65377151a"; 4 | // SHA256(c2 7f ...) = 9c 1a ... 5 | export const htlcSecretHashHex = "9c1a3815d49e0c9f78b872bfb017e825ea2db708158b70815526a830c85912b4"; 6 | -------------------------------------------------------------------------------- /packages/core-tester-cli/src/flags.ts: -------------------------------------------------------------------------------- 1 | import { flags } from "@oclif/command"; 2 | 3 | export const satoshiFlag = flags.build({ 4 | parse: input => { 5 | const value = Number(input); 6 | 7 | if (value < 1 / 1e8) { 8 | throw new Error(`Expected number greater than 1 satoshi.`); 9 | } 10 | 11 | return value; 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/multisig-htlc-claim/shared.js: -------------------------------------------------------------------------------- 1 | const transactions = { 2 | multisigRegistration: {} // this will be filled by 1.create-multisig-registration 3 | }; 4 | const lockTransactions = { 5 | normal: {} 6 | }; 7 | const claimTransactions = { 8 | normal: {} 9 | } 10 | 11 | module.exports = { transactions, lockTransactions, claimTransactions }; -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/multisig-htlc-refund/shared.js: -------------------------------------------------------------------------------- 1 | const transactions = { 2 | multisigRegistration: {} // this will be filled by 1.create-multisig-registration 3 | }; 4 | const lockTransactions = { 5 | normal: {} 6 | }; 7 | const refundTransactions = { 8 | normal: {} 9 | } 10 | 11 | module.exports = { transactions, lockTransactions, refundTransactions }; -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/transformers/fee-statistics.ts: -------------------------------------------------------------------------------- 1 | export const transformFeeStatistics = (model: any) => { 2 | return { 3 | type: model.type, 4 | fees: { 5 | minFee: parseInt(model.minFee, 10), 6 | maxFee: parseInt(model.maxFee, 10), 7 | avgFee: parseInt(model.avgFee, 10), 8 | }, 9 | }; 10 | }; 11 | -------------------------------------------------------------------------------- /packages/core-new-relic/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import newrelic from "newrelic"; 3 | 4 | export const plugin: Container.IPluginDescriptor = { 5 | pkg: require("../package.json"), 6 | alias: "error-tracker", 7 | async register(container: Container.IContainer, options) { 8 | return newrelic; 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /packages/core-transactions/src/utils.ts: -------------------------------------------------------------------------------- 1 | import { Interfaces, Managers, Utils } from "@arkecosystem/crypto"; 2 | 3 | export const isRecipientOnActiveNetwork = (transaction: Interfaces.ITransactionData): boolean => { 4 | return ( 5 | Utils.Base58.decodeCheck(transaction.recipientId).readUInt8(0) === 6 | Managers.configManager.get("network.pubKeyHash") 7 | ); 8 | }; 9 | -------------------------------------------------------------------------------- /vagrant/centos/6/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "centos/6" 3 | config.vm.provision :shell, path: "../../bootstrap.sh" 4 | config.vm.network "private_network", ip: "192.168.33.10" 5 | config.vm.provider "virtualbox" do |vb| 6 | vb.memory = "2048" 7 | vb.cpus = 2 8 | end 9 | config.vm.synced_folder "../../../", "/vagrant" 10 | end 11 | -------------------------------------------------------------------------------- /vagrant/centos/7/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "centos/7" 3 | config.vm.provision :shell, path: "../../bootstrap.sh" 4 | config.vm.network "private_network", ip: "192.168.33.10" 5 | config.vm.provider "virtualbox" do |vb| 6 | vb.memory = "2048" 7 | vb.cpus = 2 8 | end 9 | config.vm.synced_folder "../../../", "/vagrant" 10 | end 11 | -------------------------------------------------------------------------------- /benchmark/helpers.js: -------------------------------------------------------------------------------- 1 | const { readFileSync } = require("fs"); 2 | const { resolve } = require("path"); 3 | 4 | exports.createBlocks = count => new Array(count).fill(require("./fixtures/block")); 5 | 6 | exports.getFixture = value => readFileSync(resolve(__dirname, `./fixtures/${value}`)).toString().trim(); 7 | 8 | exports.getJSONFixture = value => require(resolve(__dirname, `./fixtures/${value}`)); 9 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/locks/transformer.ts: -------------------------------------------------------------------------------- 1 | import { formatTimestamp } from "@arkecosystem/core-utils"; 2 | import { Interfaces } from "@arkecosystem/crypto"; 3 | 4 | export const transformLock = (lock: Interfaces.IHtlcLock) => { 5 | return { 6 | ...lock, 7 | amount: lock.amount.toFixed(), 8 | timestamp: formatTimestamp(lock.timestamp), 9 | }; 10 | }; 11 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | import { Database } from "@arkecosystem/core-interfaces"; 2 | 3 | export interface IMigration { 4 | id: number; 5 | name: string; 6 | } 7 | 8 | export interface IColumnDescriptor { 9 | name: string; 10 | supportedOperators?: Database.SearchOperator[]; 11 | prop?: string; 12 | init?: any; 13 | def?: any; 14 | } 15 | -------------------------------------------------------------------------------- /packages/core-webhooks/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | enabled: process.env.CORE_WEBHOOKS_ENABLED, 3 | server: { 4 | host: process.env.CORE_WEBHOOKS_HOST || "0.0.0.0", 5 | port: process.env.CORE_WEBHOOKS_PORT || 4004, 6 | whitelist: ["127.0.0.1", "::ffff:127.0.0.1"], 7 | }, 8 | timeout: process.env.CORE_WEBHOOKS_TIMEOUT || 1500, 9 | }; 10 | -------------------------------------------------------------------------------- /packages/core-magistrate-transactions/src/events.ts: -------------------------------------------------------------------------------- 1 | export enum MagistrateApplicationEvents { 2 | BusinessRegistered = "business.registered", 3 | BusinessResigned = "business.resigned", 4 | BusinessUpdate = "business.updated", 5 | BridgechainRegistered = "bridgechain.registered", 6 | BridgechainResigned = "bridgechain.resigned", 7 | BridgechainUpdate = "bridgechain.updated", 8 | } 9 | -------------------------------------------------------------------------------- /packages/crypto/src/transactions/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./builders"; 2 | export * from "./deserializer"; 3 | export * from "./factory"; 4 | export * from "./serializer"; 5 | export * from "./signer"; 6 | export * from "./types"; 7 | export * from "./utils"; 8 | export * from "./verifier"; 9 | 10 | export { transactionRegistry as TransactionRegistry, TransactionConstructor } from "./registry"; 11 | -------------------------------------------------------------------------------- /vagrant/debian/8_10/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "debian/jessie64" 3 | config.vm.provision :shell, path: "../../bootstrap.sh" 4 | config.vm.network "private_network", ip: "192.168.33.10" 5 | config.vm.provider "virtualbox" do |vb| 6 | vb.memory = "2048" 7 | vb.cpus = 2 8 | end 9 | config.vm.synced_folder "../../../", "/vagrant" 10 | end 11 | -------------------------------------------------------------------------------- /vagrant/debian/9_4/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "debian/stretch64" 3 | config.vm.provision :shell, path: "../../bootstrap.sh" 4 | config.vm.network "private_network", ip: "192.168.33.10" 5 | config.vm.provider "virtualbox" do |vb| 6 | vb.memory = "2048" 7 | vb.cpus = 2 8 | end 9 | config.vm.synced_folder "../../../", "/vagrant" 10 | end 11 | -------------------------------------------------------------------------------- /vagrant/ubuntu/16_04/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "ubuntu/xenial64" 3 | config.vm.provision :shell, path: "../../bootstrap.sh" 4 | config.vm.network "private_network", ip: "192.168.33.10" 5 | config.vm.provider "virtualbox" do |vb| 6 | vb.memory = "2048" 7 | vb.cpus = 2 8 | end 9 | config.vm.synced_folder "../../../", "/vagrant" 10 | end 11 | -------------------------------------------------------------------------------- /vagrant/ubuntu/18_04/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "ubuntu/bionic64" 3 | config.vm.provision :shell, path: "../../bootstrap.sh" 4 | config.vm.network "private_network", ip: "192.168.33.10" 5 | config.vm.provider "virtualbox" do |vb| 6 | vb.memory = "2048" 7 | vb.cpus = 2 8 | end 9 | config.vm.synced_folder "../../../", "/vagrant" 10 | end 11 | -------------------------------------------------------------------------------- /__tests__/unit/crypto/transactions/__fixtures__/wallet.ts: -------------------------------------------------------------------------------- 1 | import { Wallets } from "@arkecosystem/core-state"; 2 | import { Utils } from "@arkecosystem/crypto"; 3 | 4 | export const wallet = { 5 | address: "ANBkoGqWeTSiaEVgVzSKZd3jS7UWzv9PSo", 6 | balance: Utils.BigNumber.make(4527654310), 7 | publicKey: "03287bfebba4c7881a0509717e71b34b63f31e40021c321f89ae04f84be6d6ac37", 8 | } as Wallets.Wallet; 9 | -------------------------------------------------------------------------------- /packages/core-p2p/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const constants = { 2 | MAX_DOWNLOAD_BLOCKS: 400, // maximum number of blocks we can download at once 3 | DEFAULT_MAX_PAYLOAD: 20 * 1024 * 1024, // default maxPayload value on the server WS socket 4 | DEFAULT_MAX_PAYLOAD_CLIENT: 100 * 1024, // default maxPayload value on the client WS socket 5 | KILOBYTE: 1024, 6 | MAX_PEERS_GETPEERS: 2000, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/core-p2p/src/utils/is-whitelisted.ts: -------------------------------------------------------------------------------- 1 | import nm from "nanomatch"; 2 | 3 | export const isWhitelisted = (whitelist: string[], ip: string): boolean => { 4 | if (Array.isArray(whitelist)) { 5 | for (const item of whitelist) { 6 | if (nm.isMatch(ip, item)) { 7 | return true; 8 | } 9 | } 10 | } 11 | 12 | return false; 13 | }; 14 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/doublespend-mix/config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = { 4 | events: { 5 | newBlock: { 6 | 5: ["0.0.transfer-new-wallet.action"], 7 | 9: ["0.1.init-2ndsig.action"], 8 | 15: ["1.0.doublespend.action", "1.1.doublespend2ndsig.action"], 9 | 20: ["2.check-tx.test"], 10 | }, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /__tests__/unit/crypto/crypto/fixtures/crypto.json: -------------------------------------------------------------------------------- 1 | { 2 | "ripemd160": "a830d7beb04eb7549ce990fb7dc962e499a27230", 3 | "sha1": "0a4d55a8d778e5022fab701977c5d840bbc486d0", 4 | "sha256": "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e", 5 | "hash160": "bdfb69557966d026975bebe914692bf08490d8ca", 6 | "hash256": "42a873ac3abd02122d27e80486c6fa1ef78694e8505fcec9cbcc8a7728ba8949" 7 | } 8 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/transactions-valid/config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = { 4 | events: { 5 | newBlock: { 6 | 13: ["0.0.transfer-new-wallet.action"], 7 | 15: ["0.1.init-2ndsig.action"], 8 | 19: ["1.0.transaction.action", "1.1.transaction2ndsig.action"], 9 | 22: ["2.check-tx.test"], 10 | }, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /__tests__/unit/core-blockchain/mocks/transactionPool.ts: -------------------------------------------------------------------------------- 1 | export const transactionPool = { 2 | buildWallets: () => undefined, 3 | acceptChainedBlock: () => undefined, 4 | removeTransactionsById: () => undefined, 5 | flush: () => undefined, 6 | getAllTransactions: () => [], 7 | addTransactions: () => undefined, 8 | walletManager: { 9 | reset: () => undefined, 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/plugins.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require("path"); 2 | 3 | module.exports = { 4 | [resolve(__dirname, "./plugin-a")]: { 5 | enabled: true, 6 | }, 7 | [resolve(__dirname, "./plugin-b")]: { 8 | enabled: true, 9 | property: "value", 10 | }, 11 | [resolve(__dirname, "./plugin-c")]: { 12 | enabled: true, 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /__tests__/unit/crypto/blocks/__fixtures__/wallet.ts: -------------------------------------------------------------------------------- 1 | import { Wallets } from "@arkecosystem/core-state"; 2 | import { BigNumber } from "../../../../../packages/crypto/src/utils"; 3 | 4 | export const wallet = { 5 | address: "DTRdbaUW3RQQSL5By4G43JVaeHiqfVp9oh", 6 | balance: BigNumber.make(4527654310), 7 | publicKey: "034da006f958beba78ec54443df4a3f52237253f7ae8cbdb17dccf3feaa57f3126", 8 | } as Wallets.Wallet; 9 | -------------------------------------------------------------------------------- /__tests__/unit/core-blockchain/mocks/p2p/network-monitor.ts: -------------------------------------------------------------------------------- 1 | export const getMonitor = { 2 | getNetworkHeight: () => 1, 3 | updateNetworkStatus: () => undefined, 4 | checkNetworkHealth: () => undefined, 5 | downloadBlocksFromHeight: () => [], 6 | start: () => undefined, 7 | refreshPeersAfterFork: () => undefined, 8 | broadcastBlock: () => undefined, 9 | hasPeers: () => false, 10 | }; 11 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/scworker.ts: -------------------------------------------------------------------------------- 1 | class SCWorker { 2 | public scServer = { 3 | addMiddleware: jest.fn(), 4 | on: jest.fn(), 5 | MIDDLEWARE_HANDSHAKE_WS: undefined, 6 | MIDDLEWARE_EMIT: undefined, 7 | }; 8 | 9 | public sendToMaster = jest.fn().mockImplementation((data, cb) => cb(undefined, {})); 10 | } 11 | 12 | jest.mock("socketcluster/scworker", () => SCWorker); 13 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/mocks/p2p/network-monitor.ts: -------------------------------------------------------------------------------- 1 | export const getMonitor = { 2 | getNetworkHeight: () => 1, 3 | updateNetworkStatus: () => undefined, 4 | // tslint:disable-next-line: no-empty 5 | checkNetworkHealth: () => {}, 6 | downloadBlocksFromHeight: () => [], 7 | refreshPeersAfterFork: () => undefined, 8 | broadcastBlock: () => undefined, 9 | hasPeers: () => false, 10 | }; 11 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/mocks/p2p/peer-storage.ts: -------------------------------------------------------------------------------- 1 | export const getStorage = { 2 | getNetworkHeight: () => 1, 3 | updateNetworkStatus: () => undefined, 4 | // tslint:disable-next-line: no-empty 5 | checkNetworkHealth: () => {}, 6 | downloadBlocksFromHeight: () => [], 7 | refreshPeersAfterFork: () => undefined, 8 | broadcastBlock: () => undefined, 9 | hasPeers: () => false, 10 | }; 11 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/models/migration.ts: -------------------------------------------------------------------------------- 1 | import { IColumnDescriptor } from "../interfaces"; 2 | import { Model } from "./model"; 3 | 4 | export class Migration extends Model { 5 | protected columnsDescriptor: IColumnDescriptor[] = [ 6 | { 7 | name: "name", 8 | }, 9 | ]; 10 | 11 | public getTable(): string { 12 | return "migrations"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/core-p2p/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export { checkDNS } from "./check-dns"; 2 | export { checkNTP } from "./check-ntp"; 3 | export { buildRateLimiter } from "./build-rate-limiter"; 4 | export { isWhitelisted } from "./is-whitelisted"; 5 | export { socketEmit } from "./socket"; 6 | export { validateJSON } from "./validate-json"; 7 | export { isValidVersion } from "./is-valid-version"; 8 | export { codec } from "./sc-codec"; 9 | -------------------------------------------------------------------------------- /packages/core-p2p/src/utils/validate-json.ts: -------------------------------------------------------------------------------- 1 | import { Validation } from "@arkecosystem/crypto"; 2 | import ip from "ip"; 3 | 4 | export const validateJSON = (data, schema) => { 5 | Validation.validator.addFormat("ip", { 6 | type: "string", 7 | validate: value => ip.isV4Format(value) || ip.isV6Format(value), 8 | }); 9 | 10 | return Validation.validator.validate(schema, data); 11 | }; 12 | -------------------------------------------------------------------------------- /__tests__/unit/core-blockchain/mocks/p2p/peer-storage.ts: -------------------------------------------------------------------------------- 1 | export const getStorage = { 2 | getNetworkHeight: () => 1, 3 | updateNetworkStatus: () => undefined, 4 | // tslint:disable-next-line: no-empty 5 | checkNetworkHealth: () => {}, 6 | downloadBlocksFromHeight: () => [], 7 | refreshPeersAfterFork: () => undefined, 8 | broadcastBlock: () => undefined, 9 | hasPeers: () => false, 10 | }; 11 | -------------------------------------------------------------------------------- /benchmark/fixtures/block/serialized/no-transactions.txt: -------------------------------------------------------------------------------- 1 | 0000000052f0760313000000a099b7651f0e5eb89600000000ac23fc06000000002f6859000000000000000000000000c0120000e5a7e9b5a8a8e2f47f7d8a532e0e9c43d44052dc6c6339ad57246e9a339665e303a46f2547d20b47003c1c376788db5a54d67264df2ae914f70bf453b6a1fa1b3a304402204e31f1ae02cbcf2bb936e225f9f9db332ac275577b777a389b2d713e48b78c9002203f11c4ee0d30d2e10b2cb4a7fb59569e761571971ffe1be5abaa32fdc42a056b 2 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20180305200000-create-rounds-table.sql: -------------------------------------------------------------------------------- 1 | -- Table Definition 2 | CREATE TABLE IF NOT EXISTS ${schema~}.rounds ( 3 | "id" SERIAL PRIMARY KEY, 4 | "public_key" VARCHAR(66) NOT NULL, 5 | "balance" BIGINT NOT NULL, 6 | "round" BIGINT NOT NULL 7 | ); 8 | 9 | -- Constraints 10 | CREATE UNIQUE INDEX IF NOT EXISTS "rounds_unique" ON rounds ("round", "public_key"); 11 | -------------------------------------------------------------------------------- /__tests__/utils/fixtures/testnet/block-model.ts: -------------------------------------------------------------------------------- 1 | import { Blocks, Managers } from "@arkecosystem/crypto"; 2 | import { genesisBlock as GB } from "../../config/testnet/genesisBlock"; 3 | 4 | Managers.configManager.setFromPreset("testnet"); 5 | Managers.configManager.getMilestone().aip11 = false; 6 | 7 | export const genesisBlock = Blocks.BlockFactory.fromData(GB); 8 | 9 | Managers.configManager.getMilestone().aip11 = true; 10 | -------------------------------------------------------------------------------- /__tests__/utils/fixtures/unitnet/block-model.ts: -------------------------------------------------------------------------------- 1 | import { Blocks, Managers } from "@arkecosystem/crypto"; 2 | import { genesisBlock as GB } from "../../config/unitnet/genesisBlock"; 3 | 4 | Managers.configManager.setFromPreset("unitnet"); 5 | Managers.configManager.getMilestone().aip11 = false; 6 | 7 | export const genesisBlock = Blocks.BlockFactory.fromData(GB); 8 | 9 | Managers.configManager.getMilestone().aip11 = true; 10 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/processor/handlers/nonce-out-of-order-handler.ts: -------------------------------------------------------------------------------- 1 | import { BlockProcessorResult } from "../block-processor"; 2 | import { BlockHandler } from "./block-handler"; 3 | 4 | export class NonceOutOfOrderHandler extends BlockHandler { 5 | public async execute(): Promise { 6 | await super.execute(); 7 | 8 | return BlockProcessorResult.Rejected; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/transactions/fee-statistics.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | type_group, 3 | type, 4 | AVG(fee)::int8 as "avg", 5 | MIN(fee)::int8 as "min", 6 | MAX(fee)::int8 as "max", 7 | SUM(fee)::int8 as "sum" 8 | FROM 9 | transactions 10 | WHERE 11 | transactions.timestamp >= ${age} AND fee >= ${minFee} 12 | GROUP BY 13 | type_group, type 14 | ORDER BY 15 | type_group, type 16 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-p2p/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./index"; 2 | export * from "./network-monitor"; 3 | export * from "./network-state"; 4 | export * from "./peer-communicator"; 5 | export * from "./peer-connector"; 6 | export * from "./peer-processor"; 7 | export * from "./peer-service"; 8 | export * from "./peer-storage"; 9 | export * from "./peer-verifier"; 10 | export * from "./peer"; 11 | export * from "./server"; 12 | -------------------------------------------------------------------------------- /packages/core-magistrate-crypto/src/transactions/utils/business-schema.ts: -------------------------------------------------------------------------------- 1 | export const businessSchema = { 2 | name: { 3 | $ref: "genericName", 4 | }, 5 | website: { 6 | $ref: "uri", 7 | }, 8 | vat: { 9 | type: "string", 10 | minLength: 8, 11 | maxLength: 15, 12 | $ref: "alphanumeric", 13 | }, 14 | repository: { 15 | $ref: "uri", 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/blocks/height-range.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | id, 3 | version, 4 | timestamp, 5 | previous_block, 6 | height, 7 | number_of_transactions, 8 | total_amount, 9 | total_fee, 10 | reward, 11 | payload_length, 12 | payload_hash, 13 | generator_public_key, 14 | block_signature 15 | FROM 16 | blocks 17 | WHERE 18 | height BETWEEN ${start} AND ${end} 19 | ORDER BY 20 | height 21 | -------------------------------------------------------------------------------- /packages/core-tester-cli/src/utils.ts: -------------------------------------------------------------------------------- 1 | import clipboardy from "clipboardy"; 2 | 3 | export const copyToClipboard = data => { 4 | clipboardy.writeSync(JSON.stringify(data)); 5 | }; 6 | 7 | export const handleOutput = (opts, data) => { 8 | if (opts.copy) { 9 | return copyToClipboard(data); 10 | } 11 | 12 | if (opts.log) { 13 | return console.log(data); 14 | } 15 | 16 | return data; 17 | }; 18 | -------------------------------------------------------------------------------- /__tests__/unit/crypto/identities/wif.test.ts: -------------------------------------------------------------------------------- 1 | import "jest-extended"; 2 | 3 | import { WIF } from "../../../../packages/crypto/src/identities/wif"; 4 | import { data, passphrase } from "./fixture.json"; 5 | 6 | describe("Identities - WIF", () => { 7 | describe("fromPassphrase", () => { 8 | it("should be OK", () => { 9 | expect(WIF.fromPassphrase(passphrase)).toBe(data.wif); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/processor/handlers/already-forged-handler.ts: -------------------------------------------------------------------------------- 1 | import { BlockProcessorResult } from "../block-processor"; 2 | import { BlockHandler } from "./block-handler"; 3 | 4 | export class AlreadyForgedHandler extends BlockHandler { 5 | public async execute(): Promise { 6 | await super.execute(); 7 | 8 | return BlockProcessorResult.DiscardedButCanBeBroadcasted; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/processor/handlers/incompatible-transactions-handler.ts: -------------------------------------------------------------------------------- 1 | import { BlockProcessorResult } from "../block-processor"; 2 | import { BlockHandler } from "./block-handler"; 3 | 4 | export class IncompatibleTransactionsHandler extends BlockHandler { 5 | public async execute(): Promise { 6 | await super.execute(); 7 | 8 | return BlockProcessorResult.Rejected; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/database-repository/rounds-repository.ts: -------------------------------------------------------------------------------- 1 | import { IRepository } from "./repository"; 2 | 3 | export interface IRound { 4 | id: number; 5 | publicKey: string; 6 | balance: string; 7 | round: number; 8 | } 9 | 10 | export interface IRoundsRepository extends IRepository { 11 | findById(id: number): Promise; 12 | delete(id: number, db?: any): Promise; 13 | } 14 | -------------------------------------------------------------------------------- /__tests__/unit/crypto/utils/number-to-hex.test.ts: -------------------------------------------------------------------------------- 1 | import "jest-extended"; 2 | 3 | import { numberToHex } from "../../../../packages/crypto/src/utils"; 4 | 5 | describe("NumberToHex", () => { 6 | it("should be ok", () => { 7 | expect(numberToHex(10)).toBe("0a"); 8 | expect(numberToHex(1)).toBe("01"); 9 | expect(numberToHex(16)).toBe("10"); 10 | expect(numberToHex(16, 4)).toBe("0010"); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/blockchain/routes.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { BlockchainController } from "./controller"; 3 | 4 | export const registerRoutes = (server: Hapi.Server): void => { 5 | const controller = new BlockchainController(); 6 | server.bind(controller); 7 | 8 | server.route({ 9 | method: "GET", 10 | path: "/blockchain", 11 | handler: controller.index, 12 | }); 13 | }; 14 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/peers/transformer.ts: -------------------------------------------------------------------------------- 1 | import { app } from "@arkecosystem/core-container"; 2 | 3 | export const transformPeer = model => { 4 | return { 5 | ip: model.ip, 6 | port: +app.resolveOptions("p2p").server.port, 7 | ports: model.ports, 8 | version: model.version, 9 | height: model.state ? model.state.height : model.height, 10 | latency: model.latency, 11 | }; 12 | }; 13 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core0/.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=debug 2 | CORE_LOG_LEVEL_FILE=trace 3 | 4 | CORE_DB_PORT=5432 5 | 6 | CORE_P2P_HOST=0.0.0.0 7 | CORE_P2P_PORT=4000 8 | 9 | CORE_WEBHOOKS_HOST=0.0.0.0 10 | CORE_WEBHOOKS_PORT=4004 11 | 12 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 13 | CORE_EXCHANGE_JSON_RPC_PORT=8080 14 | 15 | CORE_API_HOST=0.0.0.0 16 | CORE_API_PORT=4003 17 | 18 | CORE_WALLET_API_HOST=0.0.0.0 19 | CORE_WALLET_API_PORT=4040 20 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core1/.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=debug 2 | CORE_LOG_LEVEL_FILE=trace 3 | 4 | CORE_DB_PORT=5432 5 | 6 | CORE_P2P_HOST=0.0.0.0 7 | CORE_P2P_PORT=4000 8 | 9 | CORE_WEBHOOKS_HOST=0.0.0.0 10 | CORE_WEBHOOKS_PORT=4004 11 | 12 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 13 | CORE_EXCHANGE_JSON_RPC_PORT=8080 14 | 15 | CORE_API_HOST=0.0.0.0 16 | CORE_API_PORT=4003 17 | 18 | CORE_WALLET_API_HOST=0.0.0.0 19 | CORE_WALLET_API_PORT=4040 20 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core2/.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=debug 2 | CORE_LOG_LEVEL_FILE=trace 3 | 4 | CORE_DB_PORT=5432 5 | 6 | CORE_P2P_HOST=0.0.0.0 7 | CORE_P2P_PORT=4000 8 | 9 | CORE_WEBHOOKS_HOST=0.0.0.0 10 | CORE_WEBHOOKS_PORT=4004 11 | 12 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 13 | CORE_EXCHANGE_JSON_RPC_PORT=8080 14 | 15 | CORE_API_HOST=0.0.0.0 16 | CORE_API_PORT=4003 17 | 18 | CORE_WALLET_API_HOST=0.0.0.0 19 | CORE_WALLET_API_PORT=4040 20 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core3/.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=debug 2 | CORE_LOG_LEVEL_FILE=trace 3 | 4 | CORE_DB_PORT=5432 5 | 6 | CORE_P2P_HOST=0.0.0.0 7 | CORE_P2P_PORT=4000 8 | 9 | CORE_WEBHOOKS_HOST=0.0.0.0 10 | CORE_WEBHOOKS_PORT=4004 11 | 12 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 13 | CORE_EXCHANGE_JSON_RPC_PORT=8080 14 | 15 | CORE_API_HOST=0.0.0.0 16 | CORE_API_PORT=4003 17 | 18 | CORE_WALLET_API_HOST=0.0.0.0 19 | CORE_WALLET_API_PORT=4040 20 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/nodes/core4/.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=debug 2 | CORE_LOG_LEVEL_FILE=trace 3 | 4 | CORE_DB_PORT=5432 5 | 6 | CORE_P2P_HOST=0.0.0.0 7 | CORE_P2P_PORT=4000 8 | 9 | CORE_WEBHOOKS_HOST=0.0.0.0 10 | CORE_WEBHOOKS_PORT=4004 11 | 12 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 13 | CORE_EXCHANGE_JSON_RPC_PORT=8080 14 | 15 | CORE_API_HOST=0.0.0.0 16 | CORE_API_PORT=4003 17 | 18 | CORE_WALLET_API_HOST=0.0.0.0 19 | CORE_WALLET_API_PORT=4040 20 | -------------------------------------------------------------------------------- /packages/core-http-utils/src/server/mount.ts: -------------------------------------------------------------------------------- 1 | import { app } from "@arkecosystem/core-container"; 2 | 3 | export const mountServer = async (name, server) => { 4 | try { 5 | await server.start(); 6 | 7 | app.resolvePlugin("logger").info(`${name} Server running at: ${server.info.uri}`); 8 | 9 | return server; 10 | } catch (error) { 11 | app.forceExit(`Could not start ${name} Server!`, error); 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-logger/logger.ts: -------------------------------------------------------------------------------- 1 | export interface ILogger { 2 | make(): ILogger; 3 | getLogger(): T; 4 | 5 | log(level: string, message: any): boolean; 6 | error(message: any): boolean; 7 | warn(message: any): boolean; 8 | info(message: any): boolean; 9 | debug(message: any): boolean; 10 | verbose(message: any): boolean; 11 | 12 | suppressConsoleOutput(suppress?: boolean): void; 13 | } 14 | -------------------------------------------------------------------------------- /packages/crypto/src/identities/private-key.ts: -------------------------------------------------------------------------------- 1 | import { NetworkType } from "../types"; 2 | import { Keys } from "./keys"; 3 | 4 | export class PrivateKey { 5 | public static fromPassphrase(passphrase: string): string { 6 | return Keys.fromPassphrase(passphrase).privateKey; 7 | } 8 | 9 | public static fromWIF(wif: string, network?: NetworkType): string { 10 | return Keys.fromWIF(wif, network).privateKey; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/blocks/height-range-with-transactions.sql: -------------------------------------------------------------------------------- 1 | SELECT *, 2 | (SELECT NULLIF(ARRAY 3 | (SELECT encode(serialized, 'hex') 4 | FROM transactions 5 | WHERE transactions.block_id = blocks.id 6 | ORDER BY transactions.sequence ASC 7 | ), '{}') AS transactions) 8 | FROM blocks 9 | WHERE height 10 | BETWEEN ${start} AND ${end} 11 | ORDER BY height ASC -------------------------------------------------------------------------------- /packages/core-exchange-json-rpc/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const defaults = { 2 | enabled: process.env.CORE_EXCHANGE_JSON_RPC_ENABLED, 3 | host: process.env.CORE_EXCHANGE_JSON_RPC_HOST || "0.0.0.0", 4 | port: process.env.CORE_EXCHANGE_JSON_RPC_PORT || 8080, 5 | allowRemote: false, 6 | whitelist: ["127.0.0.1", "::ffff:127.0.0.1"], 7 | database: process.env.CORE_EXCHANGE_JSON_RPC_DATABASE || `${process.env.CORE_PATH_DATA}/json-rpc.sqlite`, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core-http-utils/src/plugins/content-type.ts: -------------------------------------------------------------------------------- 1 | export const contentType = { 2 | name: "content-type", 3 | version: "0.1.0", 4 | register(server, options) { 5 | server.ext({ 6 | type: "onPreHandler", 7 | async method(request, h) { 8 | request.headers["content-type"] = "application/json"; 9 | 10 | return h.continue; 11 | }, 12 | }); 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /packages/core-snapshots/src/db/queries/transactions/timestamp-range.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | id, 3 | version, 4 | nonce, 5 | block_id, 6 | sequence, 7 | timestamp, 8 | sender_public_key, 9 | recipient_id, 10 | type, 11 | type_group, 12 | vendor_field, 13 | amount, 14 | fee, 15 | serialized, 16 | asset 17 | FROM 18 | transactions 19 | WHERE 20 | timestamp BETWEEN ${start} AND ${end} 21 | ORDER BY 22 | timestamp, 23 | sequence 24 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/htlc-refund/shared.js: -------------------------------------------------------------------------------- 1 | const transactions = { 2 | lockTransactions: { // this will be filled by 1.create-lock-txs 3 | normal: {}, 4 | notSender: {}, 5 | lockNotExpired: {} 6 | }, 7 | refundTransactions: { // this will be filled by 2.create-refund-txs 8 | normal: {}, 9 | notSender: {}, 10 | lockNotExpired: {} 11 | }, 12 | } 13 | 14 | module.exports = transactions; -------------------------------------------------------------------------------- /__tests__/unit/crypto/identities/fixture.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "privateKey": "d8839c2432bfd0a67ef10a804ba991eabba19f154a3d707917681d45822a5712", 4 | "publicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192", 5 | "address": "D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib", 6 | "wif": "SGq4xLgZKCGxs7bjmwnBrWcT4C1ADFEermj846KC97FSv1WFD1dA" 7 | }, 8 | "passphrase": "this is a top secret passphrase" 9 | } 10 | -------------------------------------------------------------------------------- /packages/core/src/hooks/init/config.ts: -------------------------------------------------------------------------------- 1 | import { Hook } from "@oclif/config"; 2 | import { configManager } from "../../helpers/config"; 3 | 4 | // tslint:disable-next-line:only-arrow-functions 5 | export const init: Hook<"init"> = async function({ config }) { 6 | configManager.setup(config); 7 | 8 | if (config.version.includes("next") && configManager.get("channel") !== "next") { 9 | configManager.set("channel", "next"); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /packages/core-blockchain/src/processor/handlers/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./accept-block-handler"; 2 | export * from "./already-forged-handler"; 3 | export * from "./block-handler"; 4 | export * from "./exception-handler"; 5 | export * from "./incompatible-transactions-handler"; 6 | export * from "./invalid-generator-handler"; 7 | export * from "./nonce-out-of-order-handler"; 8 | export * from "./unchained-handler"; 9 | export * from "./verification-failed-handler"; 10 | -------------------------------------------------------------------------------- /packages/core-error-tracker-rollbar/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import Rollbar from "rollbar"; 3 | import { defaults } from "./defaults"; 4 | 5 | export const plugin: Container.IPluginDescriptor = { 6 | pkg: require("../package.json"), 7 | defaults, 8 | alias: "error-tracker", 9 | async register(container: Container.IContainer, options) { 10 | return new Rollbar(options); 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/repositories/index.ts: -------------------------------------------------------------------------------- 1 | import { BlocksRepository } from "./blocks"; 2 | import { MigrationsRepository } from "./migrations"; 3 | import { RoundsRepository } from "./rounds"; 4 | import { TransactionsRepository } from "./transactions"; 5 | 6 | export const repositories = { 7 | blocks: BlocksRepository, 8 | migrations: MigrationsRepository, 9 | rounds: RoundsRepository, 10 | transactions: TransactionsRepository, 11 | }; 12 | -------------------------------------------------------------------------------- /packages/core-error-tracker-airbrake/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import AirBrake from "airbrake-js"; 3 | import { defaults } from "./defaults"; 4 | 5 | export const plugin: Container.IPluginDescriptor = { 6 | pkg: require("../package.json"), 7 | defaults, 8 | alias: "error-tracker", 9 | async register(container: Container.IContainer, options) { 10 | return new AirBrake(options); 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/crypto/src/managers/network.ts: -------------------------------------------------------------------------------- 1 | import { INetworkConfig } from "../interfaces/networks"; 2 | import * as networks from "../networks"; 3 | import { NetworkName } from "../types"; 4 | 5 | export class NetworkManager { 6 | public static all(): Record { 7 | return networks; 8 | } 9 | 10 | public static findByName(name: NetworkName): INetworkConfig { 11 | return networks[name.toLowerCase()]; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/schemas/pagination.ts: -------------------------------------------------------------------------------- 1 | import { app } from "@arkecosystem/core-container"; 2 | import Joi from "@hapi/joi"; 3 | 4 | export const pagination = { 5 | page: Joi.number() 6 | .integer() 7 | .positive(), 8 | offset: Joi.number() 9 | .integer() 10 | .min(0), 11 | limit: Joi.number() 12 | .integer() 13 | .min(1) 14 | .max(app.resolveOptions("api").pagination.limit), 15 | }; 16 | -------------------------------------------------------------------------------- /packages/core-magistrate-transactions/src/handlers/magistrate-handler.ts: -------------------------------------------------------------------------------- 1 | import { Handlers } from "@arkecosystem/core-transactions"; 2 | import { Managers } from "@arkecosystem/crypto"; 3 | 4 | export abstract class MagistrateTransactionHandler extends Handlers.TransactionHandler { 5 | public async isActivated(): Promise { 6 | const milestone = Managers.configManager.getMilestone(); 7 | return milestone.aip11 === true && !milestone.aip36; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/core-error-tracker-sentry/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import Sentry from "@sentry/node"; 3 | import { defaults } from "./defaults"; 4 | 5 | export const plugin: Container.IPluginDescriptor = { 6 | pkg: require("../package.json"), 7 | defaults, 8 | alias: "error-tracker", 9 | async register(container: Container.IContainer, options) { 10 | Sentry.init(options); 11 | 12 | return Sentry; 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/mocks/blockchain.ts: -------------------------------------------------------------------------------- 1 | import { database } from "./database"; 2 | 3 | export const blockchain = { 4 | getLastBlock: jest.fn().mockReturnValue({ data: { height: 1, timestamp: 222 }, getHeader: () => ({}) }), 5 | getLastDownloadedBlock: jest.fn(), 6 | forceWakeup: jest.fn(), 7 | handleIncomingBlock: jest.fn(), 8 | pingBlock: jest.fn().mockReturnValue(false), 9 | pushPingBlock: jest.fn(), 10 | getBlockPing: jest.fn(), 11 | 12 | database, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/core/bin/config/mainnet/peers.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [ 3 | { 4 | "ip": "35.195.150.223", 5 | "port": 4701 6 | }, 7 | { 8 | "ip": "34.76.165.50", 9 | "port": 4701 10 | }, 11 | { 12 | "ip": "35.231.24.181", 13 | "port": 4701 14 | }, 15 | { 16 | "ip": "34.93.248.166", 17 | "port": 4701 18 | } 19 | ], 20 | "sources": [] 21 | } 22 | -------------------------------------------------------------------------------- /__tests__/integration/core-blockchain/__support__/setup.ts: -------------------------------------------------------------------------------- 1 | import { app } from "@arkecosystem/core-container"; 2 | import { setUpContainer } from "../../../utils/helpers/container"; 3 | 4 | jest.setTimeout(60000); 5 | 6 | process.env.CORE_RESET_DATABASE = "1"; 7 | 8 | export const setUp = async (options = {}) => 9 | setUpContainer({ 10 | ...options, 11 | exit: "@arkecosystem/core-blockchain", 12 | }); 13 | 14 | export const tearDown = async (): Promise => app.tearDown(); 15 | -------------------------------------------------------------------------------- /__tests__/unit/core-jest-matchers/fields/address.test.ts: -------------------------------------------------------------------------------- 1 | import "../../../../packages/core-jest-matchers/src/fields/address"; 2 | 3 | describe(".toBeAddress", () => { 4 | test("passes when given a valid address", () => { 5 | expect("DARiJqhogp2Lu6bxufUFQQMuMyZbxjCydN").toBeAddress(); 6 | }); 7 | 8 | test("fails when not given a valid address", () => { 9 | expect(expect("invalid-address").toBeAddress).toThrowError("Expected value to be a valid address"); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/shared/schemas/index.ts: -------------------------------------------------------------------------------- 1 | import { address } from "./address"; 2 | import { blockId } from "./block-id"; 3 | import { genericName } from "./generic-name"; 4 | import { orderBy } from "./order-by"; 5 | import { pagination } from "./pagination"; 6 | import { publicKey } from "./public-key"; 7 | import { username } from "./username"; 8 | import { walletId } from "./wallet-id"; 9 | 10 | export { address, blockId, genericName, orderBy, pagination, publicKey, username, walletId }; 11 | -------------------------------------------------------------------------------- /packages/core/src/helpers/prompts.ts: -------------------------------------------------------------------------------- 1 | import prompts from "prompts"; 2 | 3 | export const confirm = async (message: string, yesCallback: any, noCallback?: any): Promise => { 4 | const { confirm } = await prompts([ 5 | { 6 | type: "confirm", 7 | name: "confirm", 8 | message, 9 | }, 10 | ]); 11 | 12 | if (confirm) { 13 | await yesCallback(); 14 | } else if (noCallback) { 15 | await noCallback(); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = { 4 | enabledTests: [ 5 | "chained-tx", 6 | "doublespend", 7 | "doublespend-mix", 8 | "insufficient-balance", 9 | //'pool-restart', 10 | "transactions-valid", 11 | "htlc-claim", 12 | "htlc-refund", 13 | "multisignature", 14 | "multisig-htlc-claim", 15 | "multisig-htlc-refund", 16 | "business-bridgechain" 17 | ], 18 | }; 19 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/__fixtures__/wallets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "address": "APnhwwyTbMiykJwYbGhYjNgtHiVJDSEhSn", 4 | "publicKey": "035b63b4668ee261c16ca91443f3371e2fe349e131cb7bf5f8a3e93a3ddfdfc788" 5 | }, 6 | { 7 | "address": "Aa4M1zL3a74L51f1AvEsLmBTsKLKrkRScU", 8 | "publicKey": "0308c0d019cd9c0c59618e3b86afc584078b54a85a025c9f30a8bdc82cdc8e1252" 9 | }, 10 | { 11 | "address": "fake_address", 12 | "publicKey": "fake_publicKey" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/htlc-claim/shared.js: -------------------------------------------------------------------------------- 1 | const transactions = { 2 | lockTransactions: { // this will be filled by 1.create-lock-txs 3 | normal: {}, 4 | wrongSecret: {}, 5 | notRecipient: {}, 6 | lockExpired: {} 7 | }, 8 | claimTransactions: { // this will be filled by 2.create-claim-txs 9 | normal: {}, 10 | wrongSecret: {}, 11 | notRecipient: {}, 12 | lockExpired: {} 13 | }, 14 | } 15 | 16 | module.exports = transactions; -------------------------------------------------------------------------------- /__tests__/unit/core-database/__fixtures__/wallets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "address": "APnhwwyTbMiykJwYbGhYjNgtHiVJDSEhSn", 4 | "publicKey": "035b63b4668ee261c16ca91443f3371e2fe349e131cb7bf5f8a3e93a3ddfdfc788" 5 | }, 6 | { 7 | "address": "Aa4M1zL3a74L51f1AvEsLmBTsKLKrkRScU", 8 | "publicKey": "0308c0d019cd9c0c59618e3b86afc584078b54a85a025c9f30a8bdc82cdc8e1252" 9 | }, 10 | { 11 | "address": "fake_address", 12 | "publicKey": "fake_publicKey" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /__tests__/unit/core-logger-winston/logger.test.ts: -------------------------------------------------------------------------------- 1 | import { WinstonLogger } from "../../../packages/core-logger-winston/src"; 2 | import { expectLogger } from "../shared/logger"; 3 | 4 | expectLogger( 5 | () => 6 | new WinstonLogger({ 7 | transports: [ 8 | { 9 | constructor: "Console", 10 | options: { 11 | level: "debug", 12 | }, 13 | }, 14 | ], 15 | }), 16 | ); 17 | -------------------------------------------------------------------------------- /packages/core/src/process-manager.ts: -------------------------------------------------------------------------------- 1 | import { Foreman, ProcessIdentifier } from "@typeskrift/foreman"; 2 | import { ExecaSyncReturnValue } from "execa"; 3 | 4 | class ProcessManager extends Foreman { 5 | public restart(id: ProcessIdentifier): ExecaSyncReturnValue { 6 | return super.restart(id, { "update-env": true }); 7 | } 8 | 9 | public list(): Array> { 10 | return super.list() || []; 11 | } 12 | } 13 | 14 | export const processManager = new ProcessManager(); 15 | -------------------------------------------------------------------------------- /packages/core-database/src/plugin.ts: -------------------------------------------------------------------------------- 1 | import { Container, Logger } from "@arkecosystem/core-interfaces"; 2 | import { ConnectionManager } from "./manager"; 3 | 4 | export const plugin: Container.IPluginDescriptor = { 5 | pkg: require("../package.json"), 6 | alias: "database-manager", 7 | async register(container: Container.IContainer, options) { 8 | container.resolvePlugin("logger").info("Starting Database Manager"); 9 | 10 | return new ConnectionManager(); 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/core-database/src/repositories/utils/limit-rows.ts: -------------------------------------------------------------------------------- 1 | import { Database } from "@arkecosystem/core-interfaces"; 2 | /** 3 | * Return some rows by an offset and a limit. 4 | */ 5 | export = (rows: ReadonlyArray, params: Database.IParameters) => { 6 | if (params.offset || params.limit) { 7 | const offset = params.offset || 0; 8 | const limit = params.limit ? offset + params.limit : rows.length; 9 | 10 | return rows.slice(offset, limit); 11 | } 12 | 13 | return rows; 14 | }; 15 | -------------------------------------------------------------------------------- /docker/config/devnet.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=info 2 | CORE_LOG_LEVEL_FILE=info 3 | 4 | CORE_DB_HOST=postgres-hydra 5 | CORE_DB_PORT=5432 6 | 7 | CORE_P2P_HOST=0.0.0.0 8 | CORE_P2P_PORT=4702 9 | 10 | CORE_WEBHOOKS_HOST=0.0.0.0 11 | CORE_WEBHOOKS_PORT=4704 12 | 13 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 14 | CORE_EXCHANGE_JSON_RPC_PORT=8080 15 | 16 | CORE_API_HOST=0.0.0.0 17 | CORE_API_PORT=4703 18 | 19 | CORE_WALLET_API_HOST=0.0.0.0 20 | CORE_WALLET_API_PORT=4040 21 | 22 | CORE_API_RATE_LIMIT=true 23 | CORE_API_RATE_LIMIT_USER_LIMIT=1000 -------------------------------------------------------------------------------- /docker/config/mainnet.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=info 2 | CORE_LOG_LEVEL_FILE=info 3 | 4 | CORE_DB_HOST=postgres-hydra 5 | CORE_DB_PORT=5432 6 | 7 | CORE_P2P_HOST=0.0.0.0 8 | CORE_P2P_PORT=4701 9 | 10 | CORE_WEBHOOKS_HOST=0.0.0.0 11 | CORE_WEBHOOKS_PORT=4704 12 | 13 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 14 | CORE_EXCHANGE_JSON_RPC_PORT=8080 15 | 16 | CORE_API_HOST=0.0.0.0 17 | CORE_API_PORT=4703 18 | 19 | CORE_WALLET_API_HOST=0.0.0.0 20 | CORE_WALLET_API_PORT=4040 21 | 22 | CORE_API_RATE_LIMIT=true 23 | CORE_API_RATE_LIMIT_USER_LIMIT=1000 -------------------------------------------------------------------------------- /packages/crypto/src/networks/unitnet/network.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unitnet", 3 | "messagePrefix": "UNIT message:\n", 4 | "bip32": { 5 | "public": 70617039, 6 | "private": 70615956 7 | }, 8 | "pubKeyHash": 23, 9 | "nethash": "a63b5a3858afbca23edefac885be74d59f1a26985548a4082f4f479e74fcc348", 10 | "wif": 186, 11 | "slip44": 1, 12 | "aip20": 0, 13 | "client": { 14 | "token": "UARK", 15 | "symbol": "UѦ", 16 | "explorer": "http://uexplorer.ark.io" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/core-error-tracker-raygun/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import raygun from "raygun"; 3 | import { defaults } from "./defaults"; 4 | 5 | export const plugin: Container.IPluginDescriptor = { 6 | pkg: require("../package.json"), 7 | defaults, 8 | alias: "error-tracker", 9 | async register(container: Container.IContainer, options: Container.IPluginOptions) { 10 | return new raygun.Client().init((options as unknown) as raygun.raygun.RaygunOptions); 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /__tests__/unit/core-container/__stubs__/config/network.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testnet", 3 | "messagePrefix": "TEST message:\n", 4 | "bip32": { 5 | "public": 70617039, 6 | "private": 70615956 7 | }, 8 | "pubKeyHash": 23, 9 | "nethash": "d9acd04bde4234a81addb8482333b4ac906bed7be5a9970ce8ada428bd083192", 10 | "wif": 186, 11 | "slip44": 1, 12 | "aip20": 0, 13 | "client": { 14 | "token": "TARK", 15 | "symbol": "TѦ", 16 | "explorer": "http://texplorer.ark.io" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12-buster 2 | 3 | ARG USE_DEV_NPM= 4 | COPY ./ /root/core-hydra 5 | 6 | RUN apt-get update 7 | RUN apt-get install -y git python make g++ libjemalloc-dev 8 | 9 | RUN [ "$USE_DEV_NPM" = "yes" ] && yarn config set registry https://npm.iop.technology || /bin/true 10 | RUN cd ~/core-hydra && yarn setup 11 | 12 | COPY docker/docker-entrypoint.sh /usr/local/bin/ 13 | RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat 14 | 15 | ENTRYPOINT ["docker-entrypoint.sh"] 16 | CMD ["testnet","genesis","auto_forge"] 17 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/node/schema.ts: -------------------------------------------------------------------------------- 1 | import joi from "@hapi/joi"; 2 | 3 | export const fees: object = { 4 | query: { 5 | days: joi 6 | .number() 7 | .integer() 8 | .min(1) 9 | .max(30) 10 | .default(7), 11 | }, 12 | }; 13 | 14 | export const debug: object = { 15 | query: { 16 | lines: joi 17 | .number() 18 | .integer() 19 | .min(1) 20 | .max(10000) 21 | .default(1000), 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /packages/core-database/src/repositories/utils/get-property.ts: -------------------------------------------------------------------------------- 1 | export const getProperty = (item: any, prop: string): any => { 2 | for (const [key, value] of Object.entries(item)) { 3 | if (key === prop) { 4 | return value; 5 | } 6 | 7 | if (value && value.constructor.name === "Object") { 8 | const result = getProperty(value, prop); 9 | if (result !== undefined) { 10 | return result; 11 | } 12 | } 13 | } 14 | 15 | return undefined; 16 | }; 17 | -------------------------------------------------------------------------------- /packages/core/bin/config/devnet/.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=debug 2 | CORE_LOG_LEVEL_FILE=trace 3 | 4 | CORE_DB_HOST=localhost 5 | CORE_DB_PORT=5432 6 | 7 | CORE_P2P_HOST=0.0.0.0 8 | CORE_P2P_PORT=4702 9 | 10 | CORE_WEBHOOKS_HOST=0.0.0.0 11 | CORE_WEBHOOKS_PORT=4704 12 | 13 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 14 | CORE_EXCHANGE_JSON_RPC_PORT=8080 15 | 16 | CORE_API_HOST=0.0.0.0 17 | CORE_API_PORT=4703 18 | 19 | CORE_WALLET_API_HOST=0.0.0.0 20 | CORE_WALLET_API_PORT=4040 21 | 22 | CORE_API_RATE_LIMIT=true 23 | CORE_API_RATE_LIMIT_USER_LIMIT=1000 24 | -------------------------------------------------------------------------------- /packages/core/bin/config/mainnet/.env: -------------------------------------------------------------------------------- 1 | CORE_LOG_LEVEL=info 2 | CORE_LOG_LEVEL_FILE=info 3 | 4 | CORE_DB_HOST=localhost 5 | CORE_DB_PORT=5432 6 | 7 | CORE_P2P_HOST=0.0.0.0 8 | CORE_P2P_PORT=4701 9 | 10 | CORE_WEBHOOKS_HOST=0.0.0.0 11 | CORE_WEBHOOKS_PORT=4704 12 | 13 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 14 | CORE_EXCHANGE_JSON_RPC_PORT=8080 15 | 16 | CORE_API_HOST=0.0.0.0 17 | CORE_API_PORT=4703 18 | 19 | CORE_WALLET_API_HOST=0.0.0.0 20 | CORE_WALLET_API_PORT=4040 21 | 22 | CORE_API_RATE_LIMIT=true 23 | CORE_API_RATE_LIMIT_USER_LIMIT=1000 24 | -------------------------------------------------------------------------------- /docker/config/testnet.env: -------------------------------------------------------------------------------- 1 | CORE_ENV=test 2 | CORE_LOG_LEVEL=info 3 | CORE_LOG_LEVEL_FILE=info 4 | 5 | CORE_DB_HOST=postgres-hydra 6 | CORE_DB_PORT=5432 7 | 8 | CORE_P2P_HOST=0.0.0.0 9 | CORE_P2P_PORT=4700 10 | 11 | CORE_WEBHOOKS_HOST=0.0.0.0 12 | CORE_WEBHOOKS_PORT=4704 13 | 14 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 15 | CORE_EXCHANGE_JSON_RPC_PORT=8080 16 | 17 | CORE_API_HOST=0.0.0.0 18 | CORE_API_PORT=4703 19 | 20 | CORE_WALLET_API_HOST=0.0.0.0 21 | CORE_WALLET_API_PORT=4040 22 | 23 | CORE_API_RATE_LIMIT=true 24 | CORE_API_RATE_LIMIT_USER_LIMIT=1000 -------------------------------------------------------------------------------- /packages/crypto/src/networks/devnet/network.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "devnet", 3 | "messagePrefix": "DHYD message:\n", 4 | "bip32": { 5 | "public": 3238350511, 6 | "private": 1307001159 7 | }, 8 | "pubKeyHash": 90, 9 | "nethash": "30b7368d1f78264d479c3adb38246ddde7cad58e72af51f1da9b27e04f4a005d", 10 | "wif": 85, 11 | "slip44": 1, 12 | "aip20": 1, 13 | "client": { 14 | "token": "DHYD", 15 | "symbol": "DĦ", 16 | "explorer": "https://dev.explorer.hydraledger.tech" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /__tests__/integration/core-vote-report/server.test.ts: -------------------------------------------------------------------------------- 1 | import "jest-extended"; 2 | 3 | import got from "got"; 4 | import { setUp, tearDown } from "./__support__/setup"; 5 | 6 | beforeAll(async () => await setUp()); 7 | afterAll(async () => await tearDown()); 8 | 9 | describe("Server", () => { 10 | it("should render the page", async () => { 11 | const { body, statusCode } = await got.get("http://localhost:4006/"); 12 | 13 | expect(statusCode).toBe(200); 14 | expect(body).toContain("Top 51 Delegates Stats"); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /__tests__/unit/core-jest-matchers/fields/public-key.test.ts: -------------------------------------------------------------------------------- 1 | import "../../../../packages/core-jest-matchers/src/fields/public-key"; 2 | 3 | describe(".toBePublicKey", () => { 4 | test("passes when given a valid public key", () => { 5 | expect("022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d").toBePublicKey(); 6 | }); 7 | 8 | test("fails when not given a valid public key", () => { 9 | expect(expect("invalid-pubkey").toBePublicKey).toThrowError("Expected value to be a valid public key"); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/repositories/migrations.ts: -------------------------------------------------------------------------------- 1 | import { IMigration } from "../interfaces"; 2 | import { Migration } from "../models"; 3 | import { queries } from "../queries"; 4 | import { Repository } from "./repository"; 5 | 6 | export class MigrationsRepository extends Repository { 7 | public async findByName(name: string): Promise { 8 | return this.db.oneOrNone(queries.migrations.find, { name }); 9 | } 10 | 11 | public getModel(): Migration { 12 | return new Migration(this.pgp); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/testnet/network.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testnet", 3 | "messagePrefix": "HYD message:\n", 4 | "bip32": { 5 | "public": 3238356586, 6 | "private": 1307006829 7 | }, 8 | "pubKeyHash": 128, 9 | "nethash": "4e0c60c1aac313d3c6b6dec58dc73b0a7ef4a8ead50b714b94be7d22f6e3e4aa", 10 | "wif": 179, 11 | "slip44": 1, 12 | "aip20": 0, 13 | "client": { 14 | "token": "THYD", 15 | "symbol": "TĦ", 16 | "explorer": "https://test.explorer.hydraledger.tech" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/core-webhooks/src/server/utils.ts: -------------------------------------------------------------------------------- 1 | import Boom from "@hapi/boom"; 2 | import { IWebhook } from "../interfaces"; 3 | 4 | export const transformResource = (model): IWebhook => { 5 | return { 6 | id: model.id, 7 | event: model.event, 8 | target: model.target, 9 | token: model.token, 10 | enabled: model.enabled, 11 | conditions: model.conditions, 12 | }; 13 | }; 14 | 15 | export const respondWithResource = data => { 16 | return data ? { data: transformResource(data) } : Boom.notFound(); 17 | }; 18 | -------------------------------------------------------------------------------- /packages/crypto/src/networks/mainnet/network.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mainnet", 3 | "messagePrefix": "HYD message:\n", 4 | "bip32": { 5 | "public": 3238353751, 6 | "private": 1307004399 7 | }, 8 | "pubKeyHash": 100, 9 | "nethash": "802b6c0522a4b4005751f10ee507018dd8e1bcb6d81ef1e123899e0d2f5538db", 10 | "wif": 111, 11 | "slip44": 4741444, 12 | "aip20": 4741444, 13 | "client": { 14 | "token": "HYD", 15 | "symbol": "Ħ", 16 | "explorer": "https://explorer.hydraledger.tech" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/core/bin/config/testnet/.env: -------------------------------------------------------------------------------- 1 | CORE_ENV=test 2 | CORE_LOG_LEVEL=debug 3 | CORE_LOG_LEVEL_FILE=trace 4 | 5 | CORE_DB_HOST=localhost 6 | CORE_DB_PORT=5432 7 | 8 | CORE_P2P_HOST=0.0.0.0 9 | CORE_P2P_PORT=4700 10 | 11 | CORE_WEBHOOKS_HOST=0.0.0.0 12 | CORE_WEBHOOKS_PORT=4704 13 | 14 | CORE_EXCHANGE_JSON_RPC_HOST=0.0.0.0 15 | CORE_EXCHANGE_JSON_RPC_PORT=8080 16 | 17 | CORE_API_HOST=0.0.0.0 18 | CORE_API_PORT=4703 19 | 20 | CORE_WALLET_API_HOST=0.0.0.0 21 | CORE_WALLET_API_PORT=4040 22 | 23 | CORE_API_RATE_LIMIT=true 24 | CORE_API_RATE_LIMIT_USER_LIMIT=1000 25 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/peers/schema.ts: -------------------------------------------------------------------------------- 1 | import Joi from "@hapi/joi"; 2 | import { peerIteratees } from "../shared/iteratees"; 3 | import { orderBy, pagination } from "../shared/schemas"; 4 | 5 | export const index: object = { 6 | query: { 7 | ...pagination, 8 | ...{ 9 | ip: Joi.string().ip(), 10 | version: Joi.string(), 11 | orderBy: orderBy(peerIteratees), 12 | }, 13 | }, 14 | }; 15 | 16 | export const show: object = { 17 | params: { 18 | ip: Joi.string().ip(), 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/rounds/routes.ts: -------------------------------------------------------------------------------- 1 | import Hapi from "@hapi/hapi"; 2 | import { RoundsController } from "./controller"; 3 | import * as Schema from "./schema"; 4 | 5 | export const registerRoutes = (server: Hapi.Server): void => { 6 | const controller = new RoundsController(); 7 | server.bind(controller); 8 | 9 | server.route({ 10 | method: "GET", 11 | path: "/rounds/{id}/delegates", 12 | handler: controller.delegates, 13 | options: { 14 | validate: Schema.delegates, 15 | }, 16 | }); 17 | }; 18 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-database/database-model/database-model.ts: -------------------------------------------------------------------------------- 1 | import { SearchOperator } from "../search"; 2 | 3 | export interface ISearchableField { 4 | fieldName: string; 5 | supportedOperators: SearchOperator[]; 6 | } 7 | 8 | export interface IModel { 9 | getName(): string; 10 | 11 | getTable(): string; 12 | 13 | query(): any; 14 | 15 | getColumnSet(): any; 16 | 17 | /* A list of fields on this model that can be queried, and each search-operator they support */ 18 | getSearchableFields(): ISearchableField[]; 19 | } 20 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-p2p/peer-service.ts: -------------------------------------------------------------------------------- 1 | import { INetworkMonitor } from "./network-monitor"; 2 | import { IPeerCommunicator } from "./peer-communicator"; 3 | import { IPeerConnector } from "./peer-connector"; 4 | import { IPeerProcessor } from "./peer-processor"; 5 | import { IPeerStorage } from "./peer-storage"; 6 | 7 | export interface IPeerService { 8 | getStorage(): IPeerStorage; 9 | getProcessor(): IPeerProcessor; 10 | getConnector(): IPeerConnector; 11 | getCommunicator(): IPeerCommunicator; 12 | getMonitor(): INetworkMonitor; 13 | } 14 | -------------------------------------------------------------------------------- /__tests__/unit/core-http-utils/mocks/core-container.ts: -------------------------------------------------------------------------------- 1 | jest.mock("@arkecosystem/core-container", () => { 2 | return { 3 | app: { 4 | resolvePlugin: name => { 5 | if (name === "logger") { 6 | return { 7 | info: jest.fn(), 8 | warn: jest.fn(), 9 | error: jest.fn(), 10 | debug: jest.fn(), 11 | }; 12 | } 13 | 14 | return {}; 15 | }, 16 | }, 17 | }; 18 | }); 19 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as Blockchain from "./core-blockchain"; 2 | import * as Container from "./core-container"; 3 | import * as Database from "./core-database"; 4 | import * as EventEmitter from "./core-event-emitter"; 5 | import * as Logger from "./core-logger"; 6 | import * as P2P from "./core-p2p"; 7 | import * as State from "./core-state"; 8 | import * as TransactionPool from "./core-transaction-pool"; 9 | import * as Shared from "./shared"; 10 | 11 | export { Container, Logger, Blockchain, TransactionPool, EventEmitter, P2P, Database, Shared, State }; 12 | -------------------------------------------------------------------------------- /__tests__/unit/core-utils/mocks/core-container.ts: -------------------------------------------------------------------------------- 1 | jest.mock("@arkecosystem/core-container", () => { 2 | return { 3 | app: { 4 | getConfig: () => { 5 | return { 6 | config: { milestones: [{ activeDelegates: 51, height: 1 }] }, 7 | getMilestone: () => ({ 8 | epoch: "2017-03-21T13:00:00.000Z", 9 | activeDelegates: 51, 10 | height: 1, 11 | }), 12 | }; 13 | }, 14 | }, 15 | }; 16 | }); 17 | -------------------------------------------------------------------------------- /packages/core-logger-signale/src/driver.ts: -------------------------------------------------------------------------------- 1 | import { Logger } from "@arkecosystem/core-interfaces"; 2 | import { AbstractLogger } from "@arkecosystem/core-logger"; 3 | import { Signale } from "signale"; 4 | 5 | export class SignaleLogger extends AbstractLogger { 6 | protected logger: Signale; 7 | 8 | public make(): Logger.ILogger { 9 | this.logger = new Signale(this.options); 10 | 11 | return this; 12 | } 13 | 14 | protected getLevels(): Record { 15 | return { 16 | verbose: "note", 17 | }; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/core-transaction-pool/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | import { TransactionPool } from "@arkecosystem/core-interfaces"; 2 | import { Interfaces } from "@arkecosystem/crypto"; 3 | 4 | export interface ITransactionsCached { 5 | added: Interfaces.ITransactionData[]; 6 | notAdded: Interfaces.ITransactionData[]; 7 | } 8 | 9 | export interface ITransactionsProcessed { 10 | added: Interfaces.ITransaction[]; 11 | notAdded: TransactionPool.IAddTransactionResponse[]; 12 | } 13 | 14 | export interface IDynamicFeeMatch { 15 | broadcast: boolean; 16 | enterPool: boolean; 17 | } 18 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/insufficient-balance/config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = { 4 | events: { 5 | newBlock: { 6 | 5: ["0.0.transfer-new-wallet.action"], 7 | 7: ["0.1.init-2ndsig.action"], 8 | 17: [ 9 | "1.0.transfer.action", 10 | "1.1.transfer2ndsig.action", 11 | "1.2.vote.action", 12 | "1.3.delreg.action", 13 | "1.4.2ndsigreg.action", 14 | ], 15 | 19: ["2.check-tx.test"], 16 | }, 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/fields/public-key.ts: -------------------------------------------------------------------------------- 1 | import { Identities } from "@arkecosystem/crypto"; 2 | 3 | export {}; 4 | 5 | declare global { 6 | namespace jest { 7 | // tslint:disable-next-line:interface-name 8 | interface Matchers { 9 | toBePublicKey(): R; 10 | } 11 | } 12 | } 13 | 14 | expect.extend({ 15 | toBePublicKey: received => { 16 | return { 17 | message: () => "Expected value to be a valid public key", 18 | pass: Identities.PublicKey.validate(received), 19 | }; 20 | }, 21 | }); 22 | -------------------------------------------------------------------------------- /packages/core-vote-report/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import { defaults } from "./defaults"; 3 | import { startServer } from "./server"; 4 | 5 | export const plugin: Container.IPluginDescriptor = { 6 | pkg: require("../package.json"), 7 | defaults, 8 | alias: "vote-report", 9 | async register(container: Container.IContainer, options) { 10 | return startServer(options); 11 | }, 12 | async deregister(container: Container.IContainer) { 13 | await container.resolvePlugin("vote-report").stop(); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/queries/state-builder/open-locks.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | id, amount, timestamp, vendor_field, 3 | sender_public_key, asset, recipient_id, 4 | NOT EXISTS (SELECT id WHERE id IN ( 5 | SELECT COALESCE( 6 | asset->'refund'->>'lockTransactionId', 7 | asset->'claim'->>'lockTransactionId' 8 | ) 9 | FROM transactions 10 | WHERE 11 | type IN (9, 10) 12 | AND 13 | type_group = 1) 14 | ) as "open" 15 | FROM transactions 16 | WHERE 17 | type = 8 18 | AND 19 | type_group = 1; -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/fields/address.ts: -------------------------------------------------------------------------------- 1 | import { Identities } from "@arkecosystem/crypto"; 2 | 3 | export {}; 4 | 5 | declare global { 6 | namespace jest { 7 | // tslint:disable-next-line:interface-name 8 | interface Matchers { 9 | toBeAddress(): R; 10 | } 11 | } 12 | } 13 | 14 | expect.extend({ 15 | toBeAddress: (received, argument) => { 16 | return { 17 | message: () => "Expected value to be a valid address", 18 | pass: Identities.Address.validate(received, argument), 19 | }; 20 | }, 21 | }); 22 | -------------------------------------------------------------------------------- /__tests__/e2e/lib/config/peer-discovery/index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | 4 | const ips = {}; 5 | const sources = []; 6 | app.get('/', function (req, res) { 7 | console.log(`received peer discovery request from ${req.ip} !`); 8 | if (!ips[req.ip]) { 9 | ips[req.ip] = true; 10 | sources.push({ ip: req.ip, port: 4000 }); 11 | } 12 | console.log(`responding with ${JSON.stringify(sources)}`); 13 | res.send(sources); 14 | }) 15 | 16 | app.listen(3000, function () { 17 | console.log('Peer discovery app listening on port 3000!') 18 | }) -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/doublespend/config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = { 4 | events: { 5 | newBlock: { 6 | 5: ["0.0.transfer-new-wallet.action"], 7 | 7: ["0.1.init-2ndsig.action"], 8 | 16: [ 9 | "1.0.doubletransfer.action", 10 | "1.1.doubletransfer2ndsig.action", 11 | "1.2.doublevote.action", 12 | "1.3.doubledelreg.action", 13 | "1.4.double2ndsigreg.action", 14 | ], 15 | 19: ["2.check-tx.test"], 16 | }, 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /packages/core-api/src/plugins/pagination/config.ts: -------------------------------------------------------------------------------- 1 | // Based on https://github.com/fknop/hapi-pagination 2 | 3 | import Joi from "@hapi/joi"; 4 | 5 | export const getConfig = options => { 6 | const { error, value } = Joi.validate(options, { 7 | query: Joi.object({ 8 | limit: Joi.object({ 9 | default: Joi.number() 10 | .integer() 11 | .positive() 12 | .default(100), 13 | }), 14 | }), 15 | }); 16 | 17 | return { error: error || undefined, config: error ? undefined : value }; 18 | }; 19 | -------------------------------------------------------------------------------- /plugins/iop/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@internet-of-people/hydra-plugin-container", 3 | "version": "5.0.4", 4 | "description": "A plugin for Hydra blockchain nodes that add Morpheus and Coeus specific custom transaction types and a layer 2 consensus with its own states.", 5 | "author": { 6 | "url": "https://hydraledger.tech/", 7 | "name": "Internet of People", 8 | "email": "dev@iop-ventures.com" 9 | }, 10 | "private": true, 11 | "license": "GPL-3.0-or-later", 12 | "dependencies": { 13 | "@internet-of-people/hydra-plugin": "5.0.4" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /__tests__/unit/core-state/stores/transactions.test.ts: -------------------------------------------------------------------------------- 1 | import { TransactionStore } from "../../../../packages/core-state/src/stores/transactions"; 2 | import { genesisBlock } from "../../../utils/config/testnet/genesisBlock"; 3 | 4 | describe("TransactionStore", () => { 5 | it("should push and get a transaction", () => { 6 | const transaction = genesisBlock.transactions[0]; 7 | 8 | const store = new TransactionStore(100); 9 | store.push(transaction); 10 | 11 | expect(store.count()).toBe(1); 12 | expect(store.get(transaction.id)).toEqual(transaction); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /__tests__/unit/crypto/utils/network-list.ts: -------------------------------------------------------------------------------- 1 | import "jest-extended"; 2 | 3 | import { parse } from "path"; 4 | import tg from "tiny-glob/sync"; 5 | 6 | const entries = tg("../../../../packages/crypto/src/networks/**/*.json", { cwd: __dirname }); 7 | 8 | const NETWORKS = {}; 9 | for (const file of entries) { 10 | // tslint:disable-next-line 11 | NETWORKS[parse(file).name] = require(file); 12 | } 13 | 14 | const NETWORKS_LIST = []; 15 | for (const file of entries) { 16 | // tslint:disable-next-line 17 | NETWORKS_LIST.push(require(file)); 18 | } 19 | 20 | module.exports = { NETWORKS, NETWORKS_LIST }; 21 | -------------------------------------------------------------------------------- /packages/core-transaction-pool/src/utils.ts: -------------------------------------------------------------------------------- 1 | import { app } from "@arkecosystem/core-container"; 2 | import { State } from "@arkecosystem/core-interfaces"; 3 | import { Managers } from "@arkecosystem/crypto"; 4 | 5 | export const getMaxTransactionBytes = (): number => { 6 | const height = app 7 | .resolvePlugin("state") 8 | .getStore() 9 | .getLastHeight(); 10 | const maxPayload = Managers.configManager.getMilestone(height).block.maxPayload; 11 | 12 | return maxPayload - 10 * 1024; // max block payload minus 10KB to have some margin for block header size 13 | }; 14 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/socket-server/versions/internal/handlers/blockchain.test.ts: -------------------------------------------------------------------------------- 1 | import "../../../../mocks/core-container"; 2 | 3 | import { blockchain } from "../../../../mocks/blockchain"; 4 | 5 | import { syncBlockchain } from "../../../../../../../packages/core-p2p/src/socket-server/versions/internal"; 6 | 7 | describe("Internal handlers - blockchain", () => { 8 | describe("syncBlockchain", () => { 9 | it("should call blockchain forceWakeup", () => { 10 | syncBlockchain(); 11 | 12 | expect(blockchain.forceWakeup).toHaveBeenCalledTimes(1); 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /packages/core-api/src/handlers/rounds/controller.ts: -------------------------------------------------------------------------------- 1 | import Boom from "@hapi/boom"; 2 | import Hapi from "@hapi/hapi"; 3 | import { Controller } from "../shared/controller"; 4 | 5 | export class RoundsController extends Controller { 6 | public async delegates(request: Hapi.Request, h: Hapi.ResponseToolkit) { 7 | try { 8 | // @ts-ignore 9 | const data = await request.server.methods.v2.rounds.delegates(request); 10 | 11 | return super.respondWithCache(data, h); 12 | } catch (error) { 13 | return Boom.badImplementation(error); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/core-utils/src/format-timestamp.ts: -------------------------------------------------------------------------------- 1 | import { app } from "@arkecosystem/core-container"; 2 | import dayjs, { Dayjs } from "dayjs"; 3 | import utc from "dayjs/plugin/utc"; 4 | 5 | dayjs.extend(utc); 6 | 7 | export const formatTimestamp = ( 8 | epochStamp: number, 9 | ): { 10 | epoch: number; 11 | unix: number; 12 | human: string; 13 | } => { 14 | const timestamp: Dayjs = dayjs.utc(app.getConfig().getMilestone().epoch).add(epochStamp, "second"); 15 | 16 | return { 17 | epoch: epochStamp, 18 | unix: timestamp.unix(), 19 | human: timestamp.toISOString(), 20 | }; 21 | }; 22 | -------------------------------------------------------------------------------- /packages/crypto/src/enums.ts: -------------------------------------------------------------------------------- 1 | export enum TransactionType { 2 | Transfer = 0, 3 | SecondSignature = 1, 4 | DelegateRegistration = 2, 5 | Vote = 3, 6 | MultiSignature = 4, 7 | Ipfs = 5, 8 | MultiPayment = 6, 9 | DelegateResignation = 7, 10 | HtlcLock = 8, 11 | HtlcClaim = 9, 12 | HtlcRefund = 10, 13 | } 14 | 15 | export enum TransactionTypeGroup { 16 | Test = 0, 17 | Core = 1, 18 | 19 | // Everything above is available to anyone 20 | Reserved = 1000, 21 | } 22 | 23 | export enum HtlcLockExpirationType { 24 | EpochTimestamp = 1, 25 | BlockHeight = 2, 26 | } 27 | -------------------------------------------------------------------------------- /__tests__/integration/core-transactions/__support__/setup.ts: -------------------------------------------------------------------------------- 1 | import { app } from "@arkecosystem/core-container"; 2 | import { setUpContainer } from "../../../utils/helpers/container"; 3 | 4 | jest.setTimeout(60000); 5 | 6 | export const setUp = async () => { 7 | try { 8 | return await setUpContainer({ 9 | exit: "@arkecosystem/core-database-postgres", 10 | network: "unitnet", 11 | }); 12 | } catch (error) { 13 | console.error(error.stack); 14 | return undefined; 15 | } 16 | }; 17 | 18 | export const tearDown = async () => { 19 | await app.tearDown(); 20 | }; 21 | -------------------------------------------------------------------------------- /packages/core-http-utils/src/plugins/whitelist.ts: -------------------------------------------------------------------------------- 1 | import { isWhitelisted } from "@arkecosystem/core-utils"; 2 | import Boom from "@hapi/boom"; 3 | 4 | export const whitelist = { 5 | name: "whitelist", 6 | version: "0.1.0", 7 | register(server, options) { 8 | server.ext({ 9 | type: "onRequest", 10 | async method(request, h) { 11 | if (isWhitelisted(options.whitelist, request.info.remoteAddress)) { 12 | return h.continue; 13 | } 14 | 15 | return Boom.forbidden(); 16 | }, 17 | }); 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/transactions/types/ipfs.ts: -------------------------------------------------------------------------------- 1 | import { Enums } from "@arkecosystem/crypto"; 2 | 3 | const { Ipfs } = Enums.TransactionType; 4 | 5 | export {}; 6 | 7 | declare global { 8 | namespace jest { 9 | // tslint:disable-next-line:interface-name 10 | interface Matchers { 11 | toBeIpfsType(): R; 12 | } 13 | } 14 | } 15 | 16 | expect.extend({ 17 | toBeIpfsType: received => { 18 | return { 19 | message: () => "Expected value to be a valid IPFS transaction.", 20 | pass: received.type === Ipfs, 21 | }; 22 | }, 23 | }); 24 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/transactions/types/vote.ts: -------------------------------------------------------------------------------- 1 | import { Enums } from "@arkecosystem/crypto"; 2 | 3 | const { Vote } = Enums.TransactionType; 4 | 5 | export {}; 6 | 7 | declare global { 8 | namespace jest { 9 | // tslint:disable-next-line:interface-name 10 | interface Matchers { 11 | toBeVoteType(): R; 12 | } 13 | } 14 | } 15 | 16 | expect.extend({ 17 | toBeVoteType: received => { 18 | return { 19 | message: () => "Expected value to be a valid VOTE transaction.", 20 | pass: received.type === Vote, 21 | }; 22 | }, 23 | }); 24 | -------------------------------------------------------------------------------- /packages/core-utils/src/is-whitelisted.ts: -------------------------------------------------------------------------------- 1 | import nm from "nanomatch"; 2 | 3 | export const isWhitelisted = (whitelist: string[], remoteAddress: string): boolean => { 4 | if (!Array.isArray(whitelist) || !whitelist.length) { 5 | return true; 6 | } 7 | 8 | if (Array.isArray(whitelist)) { 9 | for (const ip of whitelist) { 10 | try { 11 | if (nm.isMatch(remoteAddress, ip)) { 12 | return true; 13 | } 14 | } catch { 15 | return false; 16 | } 17 | } 18 | } 19 | 20 | return false; 21 | }; 22 | -------------------------------------------------------------------------------- /packages/crypto/src/transactions/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./transaction"; 2 | export * from "./transfer"; 3 | export * from "./second-signature"; 4 | export * from "./delegate-registration"; 5 | export * from "./vote"; 6 | export * from "./multi-signature"; 7 | export * from "./ipfs"; 8 | export * from "./multi-payment"; 9 | export * from "./delegate-resignation"; 10 | export * from "./htlc-lock"; 11 | export * from "./htlc-claim"; 12 | export * from "./htlc-refund"; 13 | export * from "./factory"; 14 | export * from "./internal-transaction-type"; 15 | 16 | import * as schemas from "./schemas"; 17 | 18 | export { schemas }; 19 | -------------------------------------------------------------------------------- /__tests__/unit/core-jest-matchers/transactions/types/ipfs.test.ts: -------------------------------------------------------------------------------- 1 | import "../../../../../packages/core-jest-matchers/src/transactions/types/ipfs"; 2 | 3 | import { Enums } from "@arkecosystem/crypto"; 4 | const { TransactionType } = Enums; 5 | 6 | describe(".toBeIpfsType", () => { 7 | test("passes when given a valid transaction", () => { 8 | expect({ type: TransactionType.Ipfs }).toBeIpfsType(); 9 | }); 10 | 11 | test("fails when given an invalid transaction", () => { 12 | expect(expect({ type: "invalid" }).toBeIpfsType).toThrowError("Expected value to be a valid IPFS transaction."); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /__tests__/unit/core-jest-matchers/transactions/types/vote.test.ts: -------------------------------------------------------------------------------- 1 | import "../../../../../packages/core-jest-matchers/src/transactions/types/vote"; 2 | 3 | import { Enums } from "@arkecosystem/crypto"; 4 | const { TransactionType } = Enums; 5 | 6 | describe(".toBeVoteType", () => { 7 | test("passes when given a valid transaction", () => { 8 | expect({ type: TransactionType.Vote }).toBeVoteType(); 9 | }); 10 | 11 | test("fails when given an invalid transaction", () => { 12 | expect(expect({ type: "invalid" }).toBeVoteType).toThrowError("Expected value to be a valid VOTE transaction."); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/models/wallet.ts: -------------------------------------------------------------------------------- 1 | import { sortBy } from "@arkecosystem/utils"; 2 | import isEqual from "lodash.isequal"; 3 | 4 | export {}; 5 | 6 | declare global { 7 | namespace jest { 8 | // tslint:disable-next-line:interface-name 9 | interface Matchers { 10 | toBeWallet(): R; 11 | } 12 | } 13 | } 14 | 15 | expect.extend({ 16 | toBeWallet: actual => { 17 | return { 18 | message: () => "Expected value to be a valid wallet", 19 | pass: isEqual(sortBy(Object.keys(actual)), ["address", "publicKey"]), 20 | }; 21 | }, 22 | }); 23 | -------------------------------------------------------------------------------- /__tests__/integration/core-api/services/transaction-raw.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "network": 23, 4 | "type": 0, 5 | "timestamp": 0, 6 | "senderPublicKey": "035b63b4668ee261c16ca91443f3371e2fe349e131cb7bf5f8a3e93a3ddfdfc788", 7 | "fee": "0", 8 | "amount": "245098000000000", 9 | "expiration": 0, 10 | "recipientId": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri", 11 | "signature": "304402205fcb0677e06bde7aac3dc776665615f4b93ef8c3ed0fddecef9900e74fcb00f302206958a0c9868ea1b1f3d151bdfa92da1ce24de0b1fcd91933e64fb7971e92f48d", 12 | "id": "db1aa687737858cc9199bfa336f9b1c035915c30aaee60b1e0f8afadfdb946bd" 13 | } 14 | -------------------------------------------------------------------------------- /__tests__/unit/core-p2p/utils/is-whitelist.test.ts: -------------------------------------------------------------------------------- 1 | import { isWhitelisted } from "../../../../packages/core-p2p/src/utils"; 2 | 3 | const whitelist = ["127.0.0.1", "::ffff:127.0.0.1"]; 4 | 5 | describe("isWhitelist", () => { 6 | it("should be ok for 127.0.0.1", () => { 7 | expect(isWhitelisted(whitelist, "127.0.0.1")).toBeTrue(); 8 | }); 9 | 10 | it("should be ok for ::ffff:127.0.0.1", () => { 11 | expect(isWhitelisted(whitelist, "::ffff:127.0.0.1")).toBeTrue(); 12 | }); 13 | 14 | it("should not be ok", () => { 15 | expect(isWhitelisted(whitelist, "dummy")).toBeFalse(); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/core-interfaces/src/core-p2p/peer-connector.ts: -------------------------------------------------------------------------------- 1 | import { SCClientSocket } from "socketcluster-client"; 2 | import { IPeer } from "./peer"; 3 | 4 | export interface IPeerConnector { 5 | all(): SCClientSocket[]; 6 | connection(peer: IPeer): SCClientSocket; 7 | 8 | connect(peer: IPeer, maxPayload?: number): SCClientSocket; 9 | disconnect(peer: IPeer): void; 10 | 11 | emit(peer: IPeer, event: string, data: any): void; 12 | 13 | getError(peer: IPeer): string; 14 | setError(peer: IPeer, error: string): void; 15 | hasError(peer: IPeer, error: string): boolean; 16 | forgetError(peer: IPeer): void; 17 | } 18 | -------------------------------------------------------------------------------- /packages/core-logger-signale/src/plugin.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import { LoggerManager } from "@arkecosystem/core-logger"; 3 | import { defaults } from "./defaults"; 4 | import { SignaleLogger } from "./driver"; 5 | 6 | export const plugin: Container.IPluginDescriptor = { 7 | pkg: require("../package.json"), 8 | defaults, 9 | alias: "logger", 10 | extends: "@arkecosystem/core-logger", 11 | async register(container: Container.IContainer, options) { 12 | return container.resolvePlugin("log-manager").createDriver(new SignaleLogger(options)); 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /packages/core-logger-winston/src/plugin.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import { LoggerManager } from "@arkecosystem/core-logger"; 3 | import { defaults } from "./defaults"; 4 | import { WinstonLogger } from "./driver"; 5 | 6 | export const plugin: Container.IPluginDescriptor = { 7 | pkg: require("../package.json"), 8 | defaults, 9 | alias: "logger", 10 | extends: "@arkecosystem/core-logger", 11 | async register(container: Container.IContainer, options) { 12 | return container.resolvePlugin("log-manager").createDriver(new WinstonLogger(options)); 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@sindresorhus/tsconfig", 3 | "compilerOptions": { 4 | "alwaysStrict": false, 5 | "esModuleInterop": true, 6 | "incremental": true, 7 | "lib": ["es2018"], 8 | "module": "commonjs", 9 | "moduleResolution": "node", 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": false, 12 | "resolveJsonModule": true, 13 | "sourceMap": true, 14 | "strict": false, 15 | "target": "es2018", 16 | "typeRoots": ["node_modules/@types"] 17 | }, 18 | "exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts"] 19 | } 20 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/chained-tx/utils.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | a: { 3 | passphrase: "evil morning ginger report chicken notable result saddle charge profit gloom congress", 4 | address: "AMUN4qrRt1fAsdMXD3knHoBvy6SZ7hZtR2", 5 | }, 6 | b: { 7 | passphrase: "fiber brave sniff leader butter vicious breeze much trouble seek ribbon cram", 8 | address: "AW5wtiimZntaNvxH6QBi7bBpH2rDtFeD8C", 9 | }, 10 | c: { 11 | passphrase: "try anchor tomato hammer list inform runway soap fabric angry hundred slim", 12 | address: "AVFM3dNv2QXoYb9Tez9Qy8zaduKkq1pCAQ", 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/models/delegate.ts: -------------------------------------------------------------------------------- 1 | import { sortBy } from "@arkecosystem/utils"; 2 | import isEqual from "lodash.isequal"; 3 | 4 | export {}; 5 | 6 | declare global { 7 | namespace jest { 8 | // tslint:disable-next-line:interface-name 9 | interface Matchers { 10 | toBeDelegate(): R; 11 | } 12 | } 13 | } 14 | 15 | expect.extend({ 16 | toBeDelegate: actual => { 17 | return { 18 | message: () => "Expected value to be a valid delegate", 19 | pass: isEqual(sortBy(Object.keys(actual)), ["address", "publicKey", "username"]), 20 | }; 21 | }, 22 | }); 23 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/transactions/types/transfer.ts: -------------------------------------------------------------------------------- 1 | import { Enums } from "@arkecosystem/crypto"; 2 | 3 | const { Transfer } = Enums.TransactionType; 4 | 5 | export {}; 6 | 7 | declare global { 8 | namespace jest { 9 | // tslint:disable-next-line:interface-name 10 | interface Matchers { 11 | toBeTransferType(): R; 12 | } 13 | } 14 | } 15 | 16 | expect.extend({ 17 | toBeTransferType: received => { 18 | return { 19 | message: () => "Expected value to be a valid Transfer transaction.", 20 | pass: received.type === Transfer, 21 | }; 22 | }, 23 | }); 24 | -------------------------------------------------------------------------------- /__tests__/unit/core-jest-matchers/models/wallet.test.ts: -------------------------------------------------------------------------------- 1 | import "../../../../packages/core-jest-matchers/src/models/wallet"; 2 | 3 | describe(".toBeWallet", () => { 4 | const wallet = { 5 | address: "DQ7VAW7u171hwDW75R1BqfHbA9yiKRCBSh", 6 | publicKey: "0310ad026647eed112d1a46145eed58b8c19c67c505a67f1199361a511ce7860c0", 7 | }; 8 | 9 | test("passes when given a valid wallet", () => { 10 | expect(wallet).toBeWallet(); 11 | }); 12 | 13 | test("fails when given an invalid wallet", () => { 14 | expect(expect({ fake: "news" }).toBeWallet).toThrowError("Expected value to be a valid wallet"); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/core-database-postgres/src/migrations/20180305100000-create-wallets-table.sql: -------------------------------------------------------------------------------- 1 | -- Table Definition 2 | CREATE TABLE IF NOT EXISTS ${schema~}.wallets ( 3 | "address" VARCHAR(36) PRIMARY KEY NOT NULL, 4 | "public_key" VARCHAR(66) UNIQUE NOT NULL, 5 | "second_public_key" VARCHAR(66) UNIQUE, 6 | "vote" VARCHAR(66), 7 | "username" VARCHAR(64) UNIQUE, 8 | "balance" BIGINT NOT NULL, 9 | "vote_balance" BIGINT NOT NULL, 10 | "produced_blocks" BIGINT NOT NULL, 11 | "missed_blocks" BIGINT NOT NULL 12 | ); 13 | 14 | -- Constraints 15 | CREATE UNIQUE INDEX IF NOT EXISTS "wallets_votes_unique" ON wallets ("public_key", "vote"); 16 | -------------------------------------------------------------------------------- /packages/core-logger-pino/src/plugin.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import { LoggerManager } from "@arkecosystem/core-logger"; 3 | import { defaults } from "./defaults"; 4 | import { PinoLogger } from "./driver"; 5 | 6 | export const plugin: Container.IPluginDescriptor = { 7 | pkg: require("../package.json"), 8 | defaults, 9 | required: true, 10 | alias: "logger", 11 | extends: "@arkecosystem/core-logger", 12 | async register(container: Container.IContainer, options) { 13 | return container.resolvePlugin("log-manager").createDriver(new PinoLogger(options)); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /__tests__/unit/crypto/identities/private-key.test.ts: -------------------------------------------------------------------------------- 1 | import "jest-extended"; 2 | 3 | import { PrivateKey } from "../../../../packages/crypto/src/identities/private-key"; 4 | import { data, passphrase } from "./fixture.json"; 5 | 6 | describe("Identities - Private Key", () => { 7 | describe("fromPassphrase", () => { 8 | it("should be OK", () => { 9 | expect(PrivateKey.fromPassphrase(passphrase)).toBe(data.privateKey); 10 | }); 11 | }); 12 | 13 | describe("fromWIF", () => { 14 | it("should be OK", () => { 15 | expect(PrivateKey.fromWIF(data.wif)).toBe(data.privateKey); 16 | }); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/core-p2p/src/socket-server/utils/get-headers.ts: -------------------------------------------------------------------------------- 1 | import { app } from "@arkecosystem/core-container"; 2 | import { Blockchain } from "@arkecosystem/core-interfaces"; 3 | 4 | export const getHeaders = () => { 5 | const headers = { 6 | version: app.getVersion(), 7 | port: app.resolveOptions("p2p").port, 8 | height: undefined, 9 | }; 10 | 11 | if (app.has("blockchain")) { 12 | const lastBlock = app.resolvePlugin("blockchain").getLastBlock(); 13 | 14 | if (lastBlock) { 15 | headers.height = lastBlock.data.height; 16 | } 17 | } 18 | 19 | return headers; 20 | }; 21 | -------------------------------------------------------------------------------- /__tests__/helpers/rest-client.ts: -------------------------------------------------------------------------------- 1 | import { httpie, IHttpieResponse } from "@arkecosystem/core-utils"; 2 | 3 | export class RestClient { 4 | public static async get(path: string, opts?): Promise> { 5 | return httpie.get(`http://localhost:4003/api/${path}`, opts); 6 | } 7 | 8 | public static async post(path: string, body): Promise> { 9 | return httpie.post(`http://localhost:4003/api/${path}`, { body }); 10 | } 11 | 12 | public static async broadcast(transactions): Promise> { 13 | return this.post("transactions", { transactions }); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/core-error-tracker-bugsnag/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Container } from "@arkecosystem/core-interfaces"; 2 | import bugsnag, { Bugsnag } from "@bugsnag/js"; 3 | import { defaults } from "./defaults"; 4 | 5 | export const plugin: Container.IPluginDescriptor = { 6 | pkg: require("../package.json"), 7 | defaults, 8 | alias: "error-tracker", 9 | async register(container: Container.IContainer, options: Container.IPluginOptions) { 10 | if (!options.apiKey || typeof options.apiKey !== "string") { 11 | throw new Error("Bugsnag plugin config invalid"); 12 | } 13 | return bugsnag(options as Bugsnag.IConfig); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /packages/core/src/commands/core/status.ts: -------------------------------------------------------------------------------- 1 | import { AbstractStatusCommand } from "../../shared/status"; 2 | import { CommandFlags } from "../../types"; 3 | import { BaseCommand } from "../command"; 4 | 5 | export class StatusCommand extends AbstractStatusCommand { 6 | public static description: string = "Show the core status"; 7 | 8 | public static examples: string[] = [`$ ark core:status`]; 9 | 10 | public static flags: CommandFlags = { 11 | ...BaseCommand.flagsNetwork, 12 | }; 13 | 14 | public getClass() { 15 | return StatusCommand; 16 | } 17 | 18 | public getSuffix(): string { 19 | return "core"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/core/src/commands/relay/status.ts: -------------------------------------------------------------------------------- 1 | import { AbstractStatusCommand } from "../../shared/status"; 2 | import { CommandFlags } from "../../types"; 3 | import { BaseCommand } from "../command"; 4 | 5 | export class StatusCommand extends AbstractStatusCommand { 6 | public static description: string = "Show the relay status"; 7 | 8 | public static examples: string[] = [`$ ark relay:status`]; 9 | 10 | public static flags: CommandFlags = { 11 | ...BaseCommand.flagsNetwork, 12 | }; 13 | 14 | public getClass() { 15 | return StatusCommand; 16 | } 17 | 18 | public getSuffix(): string { 19 | return "relay"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/transactions/types/multi-payment.ts: -------------------------------------------------------------------------------- 1 | import { Enums } from "@arkecosystem/crypto"; 2 | 3 | const { MultiPayment } = Enums.TransactionType; 4 | 5 | export {}; 6 | 7 | declare global { 8 | namespace jest { 9 | // tslint:disable-next-line:interface-name 10 | interface Matchers { 11 | toBeMultiPaymentType(): R; 12 | } 13 | } 14 | } 15 | 16 | expect.extend({ 17 | toBeMultiPaymentType: received => { 18 | return { 19 | message: () => "Expected value to be a valid MultiPayment transaction.", 20 | pass: received.type === MultiPayment, 21 | }; 22 | }, 23 | }); 24 | -------------------------------------------------------------------------------- /packages/core-p2p/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | import { P2P } from "@arkecosystem/core-interfaces"; 2 | 3 | export interface IPeerData { 4 | ip: string; 5 | ports: P2P.IPeerPorts; 6 | version: string; 7 | } 8 | 9 | export interface IPeerConfig { 10 | version: string; 11 | network: { 12 | version: string; 13 | name: string; 14 | nethash: string; 15 | explorer: string; 16 | token: { 17 | name: string; 18 | symbol: string; 19 | }; 20 | }; 21 | plugins: P2P.IPeerPlugins; 22 | } 23 | 24 | export interface IPeerPingResponse { 25 | state: P2P.IPeerState; 26 | config: IPeerConfig; 27 | } 28 | -------------------------------------------------------------------------------- /packages/core/src/commands/forger/status.ts: -------------------------------------------------------------------------------- 1 | import { AbstractStatusCommand } from "../../shared/status"; 2 | import { CommandFlags } from "../../types"; 3 | import { BaseCommand } from "../command"; 4 | 5 | export class StatusCommand extends AbstractStatusCommand { 6 | public static description: string = "Show the forger status"; 7 | 8 | public static examples: string[] = [`$ ark forger:status`]; 9 | 10 | public static flags: CommandFlags = { 11 | ...BaseCommand.flagsNetwork, 12 | }; 13 | 14 | public getClass() { 15 | return StatusCommand; 16 | } 17 | 18 | public getSuffix(): string { 19 | return "forger"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/transactions/types/multi-signature.ts: -------------------------------------------------------------------------------- 1 | import { Enums } from "@arkecosystem/crypto"; 2 | 3 | const { MultiSignature } = Enums.TransactionType; 4 | 5 | export {}; 6 | 7 | declare global { 8 | namespace jest { 9 | // tslint:disable-next-line:interface-name 10 | interface Matchers { 11 | toBeMultiSignatureType(): R; 12 | } 13 | } 14 | } 15 | 16 | expect.extend({ 17 | toBeMultiSignatureType: received => { 18 | return { 19 | message: () => "Expected value to be a valid MultiSignature transaction.", 20 | pass: received.type === MultiSignature, 21 | }; 22 | }, 23 | }); 24 | -------------------------------------------------------------------------------- /__tests__/e2e/tests/scenarios/scenario1/pool-restart/3.stop-node.action.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const util = require("util"); 4 | const exec = util.promisify(require("child_process").exec); 5 | 6 | /** 7 | * Create a transaction to be added to the pool and shut down the node 8 | * @param {Object} options = { } 9 | * @return {void} 10 | */ 11 | module.exports = async options => { 12 | const commandStopNode = `docker ps --format "{{.Names}}" | grep node1_ark | xargs -I {} sh -c 'docker exec -d {} bash killpid.sh'`; // sending SIGINT for graceful shutdown 13 | const { stdout, stderr } = await exec(commandStopNode); 14 | console.log(`[pool-clear] killed node1 process`); 15 | }; 16 | -------------------------------------------------------------------------------- /__tests__/unit/core-jest-matchers/transactions/types/transfer.test.ts: -------------------------------------------------------------------------------- 1 | import "../../../../../packages/core-jest-matchers/src/transactions/types/transfer"; 2 | 3 | import { Enums } from "@arkecosystem/crypto"; 4 | const { TransactionType } = Enums; 5 | 6 | describe(".toBeTransferType", () => { 7 | test("passes when given a valid transaction", () => { 8 | expect({ type: TransactionType.Transfer }).toBeTransferType(); 9 | }); 10 | 11 | test("fails when given an invalid transaction", () => { 12 | expect(expect({ type: "invalid" }).toBeTransferType).toThrowError( 13 | "Expected value to be a valid Transfer transaction.", 14 | ); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/core-jest-matchers/src/transactions/types/second-signature.ts: -------------------------------------------------------------------------------- 1 | import { Enums } from "@arkecosystem/crypto"; 2 | 3 | const { SecondSignature } = Enums.TransactionType; 4 | 5 | export {}; 6 | 7 | declare global { 8 | namespace jest { 9 | // tslint:disable-next-line:interface-name 10 | interface Matchers { 11 | toBeSecondSignatureType(): R; 12 | } 13 | } 14 | } 15 | 16 | expect.extend({ 17 | toBeSecondSignatureType: received => { 18 | return { 19 | message: () => "Expected value to be a valid SecondSignature transaction.", 20 | pass: received.type === SecondSignature, 21 | }; 22 | }, 23 | }); 24 | --------------------------------------------------------------------------------