├── .gitignore ├── COPYING.MD ├── LICENSE ├── README.md ├── build └── .gitkeep ├── config ├── .aliases ├── .cshrc ├── curl-nexus ├── do-curls ├── docker-run-tritium ├── nexus-save-data ├── nexus.conf ├── nexus.conf.mainnet ├── nexus.conf.minimal ├── nexus.conf.permissioned-private-client ├── nexus.conf.permissioned-private-seed ├── nexus.conf.standalone-node ├── nexus.conf.testnet └── run-nexus ├── contrib ├── COMMENTS.md └── STYLEGUIDE.md ├── docs ├── .gitkeep ├── API │ ├── COMMANDS │ │ ├── ASSETS.MD │ │ ├── FINANCE.MD │ │ ├── INVOICES.MD │ │ ├── LEDGER.MD │ │ ├── MARKET.MD │ │ ├── NAMES.MD │ │ ├── PROFILES.MD │ │ ├── REGISTER.MD │ │ ├── SESSIONS.MD │ │ ├── SUPPLY.MD │ │ └── SYSTEM.MD │ ├── ERRORS.MD │ ├── FILTERING.MD │ ├── FORMATS.MD │ ├── OPERATORS.MD │ ├── PROTOCOL.MD │ ├── QUERIES.md │ ├── README.MD │ ├── SORTING.MD │ └── TEMPLATES.MD ├── build-linux.md ├── build-mobile.md ├── build-osx.md ├── build-params-reference.md ├── build-win.md ├── how-to-api.md └── how-to-docker.md ├── lisp ├── .gitkeep ├── Dockerfile ├── README ├── RL ├── lisp-allocate-seed-eid.py ├── lisp-debian-install.sh ├── lisp-join.py ├── lisp.config.xtr ├── make-crypto-eid.py ├── provision-lisp.py └── whoarepeers.py ├── makefile.cli ├── release └── .gitkeep ├── sdk ├── .gitignore ├── .gitkeep ├── nexus-sdk-primer.py ├── nexus-sdk-test.py ├── nexus_sdk.py └── nexus_sdk.txt ├── src ├── LLC │ ├── SK.cpp │ ├── aes │ │ ├── aes.c │ │ └── aes.h │ ├── argon2.cpp │ ├── base_uint.cpp │ ├── bignum.cpp │ ├── eckey.cpp │ ├── encrypt.cpp │ ├── falcon │ │ ├── codec.c │ │ ├── common.c │ │ ├── config.h │ │ ├── falcon.c │ │ ├── falcon.h │ │ ├── fft.c │ │ ├── fpr.c │ │ ├── fpr.h │ │ ├── inner.h │ │ ├── keygen.c │ │ ├── rng.c │ │ ├── shake.c │ │ ├── sign.c │ │ └── vrfy.c │ ├── flkey.cpp │ ├── hash │ │ ├── SHA3 │ │ │ ├── sha3.c │ │ │ └── sha3.h │ │ ├── SK.h │ │ ├── SK │ │ │ ├── Keccak-compact64.cpp │ │ │ ├── KeccakDuplex.cpp │ │ │ ├── KeccakDuplex.h │ │ │ ├── KeccakF-1600-interface.h │ │ │ ├── KeccakHash.cpp │ │ │ ├── KeccakHash.h │ │ │ ├── KeccakSponge.cpp │ │ │ ├── KeccakSponge.h │ │ │ ├── SK.cpp │ │ │ ├── brg_endian.h │ │ │ ├── brg_types.h │ │ │ ├── skein.cpp │ │ │ ├── skein.h │ │ │ ├── skein_block.cpp │ │ │ ├── skein_iv.h │ │ │ └── skein_port.h │ │ ├── Skein │ │ │ ├── brg_endian.h │ │ │ ├── brg_types.h │ │ │ ├── skein.c │ │ │ ├── skein.h │ │ │ ├── skein_block.c │ │ │ └── skein_port.h │ │ ├── argon2.h │ │ ├── argon2 │ │ │ ├── argon2.c │ │ │ ├── blake2 │ │ │ │ ├── blake2-impl.h │ │ │ │ ├── blake2.h │ │ │ │ ├── blake2b.c │ │ │ │ ├── blamka-round-opt.h │ │ │ │ └── blamka-round-ref.h │ │ │ ├── core.c │ │ │ ├── core.h │ │ │ ├── encoding.c │ │ │ ├── encoding.h │ │ │ ├── genkat.h │ │ │ ├── opt.c │ │ │ ├── ref.c │ │ │ ├── thread.c │ │ │ └── thread.h │ │ └── macro.h │ ├── include │ │ ├── argon2.h │ │ ├── eckey.h │ │ ├── encrypt.h │ │ ├── flkey.h │ │ ├── key_error.h │ │ ├── random.h │ │ └── x509_cert.h │ ├── kyber │ │ ├── indcpa.c │ │ ├── indcpa.h │ │ ├── kem.c │ │ ├── kem.h │ │ └── params.h │ ├── prime │ │ └── fermat.h │ ├── random.cpp │ ├── types │ │ ├── base_uint.h │ │ ├── bignum.h │ │ ├── typedef.h │ │ └── uint1024.h │ └── x509_cert.cpp ├── LLD │ ├── address.cpp │ ├── binary_key.cpp │ ├── binary_lfu.cpp │ ├── binary_lru.cpp │ ├── cache │ │ ├── binary_key.h │ │ ├── binary_lfu.h │ │ ├── binary_lru.h │ │ └── template_lru.h │ ├── client.cpp │ ├── compress │ │ ├── lz4.c │ │ └── lz4.h │ ├── contract.cpp │ ├── filemap.cpp │ ├── global.cpp │ ├── hash │ │ ├── xxh3.h │ │ ├── xxhash.c │ │ └── xxhash.h │ ├── hashmap.cpp │ ├── hashtree.cpp │ ├── include │ │ ├── .gitkeep │ │ ├── enum.h │ │ ├── global.h │ │ └── version.h │ ├── key.cpp │ ├── keychain │ │ ├── filemap.h │ │ ├── hashmap.h │ │ ├── hashtree.h │ │ └── keychain.h │ ├── ledger.cpp │ ├── legacy.cpp │ ├── local.cpp │ ├── logical.cpp │ ├── register.cpp │ ├── sector.cpp │ ├── session.cpp │ ├── templates │ │ ├── key.h │ │ ├── sector.h │ │ └── transaction.h │ ├── transaction.cpp │ ├── trust.cpp │ └── types │ │ ├── address.h │ │ ├── client.h │ │ ├── contract.h │ │ ├── ledger.h │ │ ├── legacy.h │ │ ├── local.h │ │ ├── logical.h │ │ ├── register.h │ │ ├── session.h │ │ └── trust.h ├── LLP │ ├── apinode.cpp │ ├── base_address.cpp │ ├── base_connection.cpp │ ├── connection.cpp │ ├── data.cpp │ ├── ddos.cpp │ ├── filenode.cpp │ ├── global.cpp │ ├── hosts.cpp │ ├── httpnode.cpp │ ├── include │ │ ├── .gitkeep │ │ ├── base_address.h │ │ ├── config.h │ │ ├── global.h │ │ ├── hosts.h │ │ ├── inv.h │ │ ├── legacy_address.h │ │ ├── lisp.h │ │ ├── manager.h │ │ ├── network.h │ │ ├── permissions.h │ │ ├── port.h │ │ ├── seeds.h │ │ ├── trust_address.h │ │ └── version.h │ ├── inv.cpp │ ├── legacy_address.cpp │ ├── lisp.cpp │ ├── lookup.cpp │ ├── manager.cpp │ ├── miner.cpp │ ├── network.cpp │ ├── packets │ │ ├── http.h │ │ ├── message.h │ │ └── packet.h │ ├── permissions.cpp │ ├── rpcnode.cpp │ ├── seeds.cpp │ ├── server.cpp │ ├── socket.cpp │ ├── templates │ │ ├── base_connection.h │ │ ├── connection.h │ │ ├── data.h │ │ ├── ddos.h │ │ ├── events.h │ │ ├── server.h │ │ ├── socket.h │ │ ├── static.h │ │ └── trigger.h │ ├── time.cpp │ ├── tritium.cpp │ ├── trust_address.cpp │ └── types │ │ ├── apinode.h │ │ ├── filenode.h │ │ ├── httpnode.h │ │ ├── lookup.h │ │ ├── miner.h │ │ ├── rpcnode.h │ │ ├── time.h │ │ └── tritium.h ├── Legacy │ ├── account.cpp │ ├── address.cpp │ ├── addressbook.cpp │ ├── ambassador.cpp │ ├── basickeystore.cpp │ ├── coinbase.cpp │ ├── create.cpp │ ├── crypter.cpp │ ├── cryptokeystore.cpp │ ├── db.cpp │ ├── enum.cpp │ ├── evaluate.cpp │ ├── global.cpp │ ├── include │ │ ├── ambassador.h │ │ ├── constants.h │ │ ├── create.h │ │ ├── enum.h │ │ ├── evaluate.h │ │ ├── global.h │ │ ├── money.h │ │ ├── signature.h │ │ └── trust.h │ ├── keypool.cpp │ ├── keypoolentry.cpp │ ├── keystore.cpp │ ├── legacy.cpp │ ├── masterkey.cpp │ ├── mempool.cpp │ ├── merkle.cpp │ ├── outpoint.cpp │ ├── output.cpp │ ├── reservekey.cpp │ ├── rpc │ │ ├── account.cpp │ │ ├── daemon.cpp │ │ ├── info.cpp │ │ ├── network.cpp │ │ ├── rpc.cpp │ │ ├── types │ │ │ └── rpc.h │ │ └── wallet.cpp │ ├── script.cpp │ ├── secret.cpp │ ├── signature.cpp │ ├── transaction.cpp │ ├── trust.cpp │ ├── trustkey.cpp │ ├── txin.cpp │ ├── txout.cpp │ ├── types │ │ ├── account.h │ │ ├── address.h │ │ ├── coinbase.h │ │ ├── keypoolentry.h │ │ ├── legacy.h │ │ ├── masterkey.h │ │ ├── merkle.h │ │ ├── outpoint.h │ │ ├── output.h │ │ ├── reservekey.h │ │ ├── script.h │ │ ├── secret.h │ │ ├── transaction.h │ │ ├── trustkey.h │ │ ├── txin.h │ │ ├── txout.h │ │ ├── walletkey.h │ │ └── wallettx.h │ ├── wallet.cpp │ ├── wallet │ │ ├── addressbook.h │ │ ├── basickeystore.h │ │ ├── crypter.h │ │ ├── cryptokeystore.h │ │ ├── db.h │ │ ├── keypool.h │ │ ├── keystore.h │ │ ├── wallet.h │ │ └── walletdb.h │ ├── walletdb.cpp │ ├── walletkey.cpp │ └── wallettx.cpp ├── TAO │ ├── API │ │ ├── authentication.cpp │ │ ├── base.cpp │ │ ├── build.cpp │ │ ├── check.cpp │ │ ├── cmd.cpp │ │ ├── commands │ │ │ ├── assets │ │ │ │ ├── initialize.cpp │ │ │ │ ├── json.cpp │ │ │ │ ├── partial.cpp │ │ │ │ ├── tokenize.cpp │ │ │ │ └── verify.cpp │ │ │ ├── finance │ │ │ │ ├── balances.cpp │ │ │ │ ├── burn.cpp │ │ │ │ ├── credit.cpp │ │ │ │ ├── debit.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── json.cpp │ │ │ │ ├── migrate.cpp │ │ │ │ ├── set-stake.cpp │ │ │ │ ├── stake-info.cpp │ │ │ │ └── void.cpp │ │ │ ├── invoices │ │ │ │ ├── cancel.cpp │ │ │ │ ├── create.cpp │ │ │ │ ├── get.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── json.cpp │ │ │ │ └── pay.cpp │ │ │ ├── ledger │ │ │ │ ├── get-block-hash.cpp │ │ │ │ ├── get-block.cpp │ │ │ │ ├── get-info.cpp │ │ │ │ ├── get-transaction.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── list-blocks.cpp │ │ │ │ ├── list-transactions.cpp │ │ │ │ ├── metrics.cpp │ │ │ │ ├── recent-blocks.cpp │ │ │ │ ├── submit-transaction.cpp │ │ │ │ └── sync-status.cpp │ │ │ ├── local │ │ │ │ ├── erase.cpp │ │ │ │ ├── has.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── list.cpp │ │ │ │ └── push.cpp │ │ │ ├── market │ │ │ │ ├── cancel.cpp │ │ │ │ ├── create.cpp │ │ │ │ ├── execute.cpp │ │ │ │ ├── index.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── json.cpp │ │ │ │ ├── list.cpp │ │ │ │ └── user.cpp │ │ │ ├── names │ │ │ │ ├── index.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── lookup.cpp │ │ │ │ ├── names.cpp │ │ │ │ ├── rename.cpp │ │ │ │ └── resolve.cpp │ │ │ ├── network │ │ │ │ ├── initialize.cpp │ │ │ │ └── list.cpp │ │ │ ├── profiles │ │ │ │ ├── create.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── notifications.cpp │ │ │ │ ├── recover.cpp │ │ │ │ ├── status.cpp │ │ │ │ ├── transactions.cpp │ │ │ │ └── update.cpp │ │ │ ├── register │ │ │ │ ├── history.cpp │ │ │ │ ├── import.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── list.cpp │ │ │ │ └── transactions.cpp │ │ │ ├── sessions │ │ │ │ ├── create.cpp │ │ │ │ ├── initialize.cpp │ │ │ │ ├── list.cpp │ │ │ │ ├── load.cpp │ │ │ │ ├── lock.cpp │ │ │ │ ├── save.cpp │ │ │ │ ├── status.cpp │ │ │ │ ├── terminate.cpp │ │ │ │ ├── unlock.cpp │ │ │ │ └── validate.cpp │ │ │ ├── supply │ │ │ │ └── initialize.cpp │ │ │ ├── system │ │ │ │ ├── initialize.cpp │ │ │ │ ├── lisp.cpp │ │ │ │ ├── metrics.cpp │ │ │ │ └── validate.cpp │ │ │ ├── templates │ │ │ │ ├── claim.cpp │ │ │ │ ├── create.cpp │ │ │ │ ├── get.cpp │ │ │ │ ├── history.cpp │ │ │ │ ├── list.cpp │ │ │ │ ├── transactions.cpp │ │ │ │ ├── transfer.cpp │ │ │ │ └── update.cpp │ │ │ └── tokens │ │ │ │ ├── initialize.cpp │ │ │ │ └── list.cpp │ │ ├── conditions.cpp │ │ ├── contracts │ │ │ ├── exchange.cpp │ │ │ ├── expiring.cpp │ │ │ └── verify.cpp │ │ ├── evaluate.cpp │ │ ├── execute.cpp │ │ ├── extract.cpp │ │ ├── filter.cpp │ │ ├── format.cpp │ │ ├── get.cpp │ │ ├── global.cpp │ │ ├── include │ │ │ ├── build.h │ │ │ ├── check.h │ │ │ ├── cmd.h │ │ │ ├── compare.h │ │ │ ├── conditions.h │ │ │ ├── constants.h │ │ │ ├── contracts │ │ │ │ ├── build.h │ │ │ │ └── verify.h │ │ │ ├── evaluate.h │ │ │ ├── execute.h │ │ │ ├── extract.h │ │ │ ├── filter.h │ │ │ ├── format.h │ │ │ ├── get.h │ │ │ ├── global.h │ │ │ ├── json.h │ │ │ ├── list.h │ │ │ └── results.h │ │ ├── indexing │ │ │ ├── build.cpp │ │ │ ├── download.cpp │ │ │ ├── index.cpp │ │ │ ├── initialize.cpp │ │ │ ├── manager.cpp │ │ │ └── refresh.cpp │ │ ├── json.cpp │ │ ├── list.cpp │ │ ├── notifications.cpp │ │ ├── operators │ │ │ ├── array.cpp │ │ │ ├── count.cpp │ │ │ ├── floor.cpp │ │ │ ├── initialize.cpp │ │ │ ├── lookup.cpp │ │ │ ├── max.cpp │ │ │ ├── mean.cpp │ │ │ ├── min.cpp │ │ │ ├── mode.cpp │ │ │ └── sum.cpp │ │ ├── results.cpp │ │ ├── transaction.cpp │ │ └── types │ │ │ ├── accounts.h │ │ │ ├── authentication.h │ │ │ ├── base.h │ │ │ ├── commands.h │ │ │ ├── commands │ │ │ ├── assets.h │ │ │ ├── crypto.h │ │ │ ├── finance.h │ │ │ ├── invoices.h │ │ │ ├── ledger.h │ │ │ ├── local.h │ │ │ ├── market.h │ │ │ ├── names.h │ │ │ ├── network.h │ │ │ ├── profiles.h │ │ │ ├── register.h │ │ │ ├── sessions.h │ │ │ ├── supply.h │ │ │ ├── system.h │ │ │ ├── templates.h │ │ │ └── tokens.h │ │ │ ├── contracts │ │ │ ├── exchange.h │ │ │ ├── expiring.h │ │ │ └── params.h │ │ │ ├── exception.h │ │ │ ├── function.h │ │ │ ├── indexing.h │ │ │ ├── notifications.h │ │ │ ├── operator.h │ │ │ ├── operators │ │ │ ├── array.h │ │ │ ├── count.h │ │ │ ├── floor.h │ │ │ ├── initialize.h │ │ │ ├── lookup.h │ │ │ ├── max.h │ │ │ ├── mean.h │ │ │ ├── min.h │ │ │ ├── mode.h │ │ │ └── sum.h │ │ │ ├── standard.h │ │ │ └── transaction.h │ ├── Ledger │ │ ├── base_minter.cpp │ │ ├── block.cpp │ │ ├── chainstate.cpp │ │ ├── checkpoints.cpp │ │ ├── client.cpp │ │ ├── constants.cpp │ │ ├── create.cpp │ │ ├── credentials.cpp │ │ ├── difficulty.cpp │ │ ├── dispatch.cpp │ │ ├── genesis.cpp │ │ ├── genesis_block.cpp │ │ ├── include │ │ │ ├── ambassador.h │ │ │ ├── chainstate.h │ │ │ ├── checkpoints.h │ │ │ ├── constants.h │ │ │ ├── create.h │ │ │ ├── developer.h │ │ │ ├── difficulty.h │ │ │ ├── dispatch.h │ │ │ ├── enum.h │ │ │ ├── genesis_block.h │ │ │ ├── prime.h │ │ │ ├── process.h │ │ │ ├── retarget.h │ │ │ ├── stake.h │ │ │ ├── stake_change.h │ │ │ ├── supply.h │ │ │ └── timelocks.h │ │ ├── locator.cpp │ │ ├── mempool.cpp │ │ ├── merkle.cpp │ │ ├── prime.cpp │ │ ├── process.cpp │ │ ├── retarget.cpp │ │ ├── stake.cpp │ │ ├── stake_change.cpp │ │ ├── stake_minter.cpp │ │ ├── state.cpp │ │ ├── supply.cpp │ │ ├── syncblock.cpp │ │ ├── timelocks.cpp │ │ ├── transaction.cpp │ │ ├── tritium.cpp │ │ ├── tritium_minter.cpp │ │ └── types │ │ │ ├── block.h │ │ │ ├── client.h │ │ │ ├── credentials.h │ │ │ ├── genesis.h │ │ │ ├── locator.h │ │ │ ├── mempool.h │ │ │ ├── merkle.h │ │ │ ├── pinunlock.h │ │ │ ├── stake_minter.h │ │ │ ├── state.h │ │ │ ├── syncblock.h │ │ │ ├── transaction.h │ │ │ ├── tritium.h │ │ │ └── tritium_minter.h │ ├── Operation │ │ ├── .gitkeep │ │ ├── append.cpp │ │ ├── claim.cpp │ │ ├── coinbase.cpp │ │ ├── condition.cpp │ │ ├── contract.cpp │ │ ├── cost.cpp │ │ ├── create.cpp │ │ ├── credit.cpp │ │ ├── debit.cpp │ │ ├── execute.cpp │ │ ├── fee.cpp │ │ ├── genesis.cpp │ │ ├── include │ │ │ ├── .gitkeep │ │ │ ├── append.h │ │ │ ├── claim.h │ │ │ ├── coinbase.h │ │ │ ├── constants.h │ │ │ ├── cost.h │ │ │ ├── create.h │ │ │ ├── credit.h │ │ │ ├── debit.h │ │ │ ├── enum.h │ │ │ ├── execute.h │ │ │ ├── fee.h │ │ │ ├── genesis.h │ │ │ ├── legacy.h │ │ │ ├── migrate.h │ │ │ ├── transfer.h │ │ │ ├── trust.h │ │ │ ├── validate.h │ │ │ └── write.h │ │ ├── legacy.cpp │ │ ├── migrate.cpp │ │ ├── transfer.cpp │ │ ├── trust.cpp │ │ ├── types │ │ │ ├── condition.h │ │ │ ├── contract.h │ │ │ └── stream.h │ │ ├── validate.cpp │ │ └── write.cpp │ └── Register │ │ ├── .gitkeep │ │ ├── address.cpp │ │ ├── basevm.cpp │ │ ├── build.cpp │ │ ├── create.cpp │ │ ├── include │ │ ├── .gitkeep │ │ ├── build.h │ │ ├── constants.h │ │ ├── create.h │ │ ├── enum.h │ │ ├── names.h │ │ ├── reserved.h │ │ ├── rollback.h │ │ ├── unpack.h │ │ └── verify.h │ │ ├── names.cpp │ │ ├── object.cpp │ │ ├── rollback.cpp │ │ ├── state.cpp │ │ ├── types │ │ ├── address.h │ │ ├── basevm.h │ │ ├── exception.h │ │ ├── object.h │ │ ├── state.h │ │ ├── stream.h │ │ └── value.h │ │ ├── unpack.cpp │ │ └── verify.cpp ├── Util │ ├── args.cpp │ ├── base58.cpp │ ├── base64.cpp │ ├── config.cpp │ ├── datastream.cpp │ ├── debug.cpp │ ├── encoding.cpp │ ├── encoding │ │ └── include │ │ │ └── utf-8.h │ ├── filesystem.cpp │ ├── hex.cpp │ ├── include │ │ ├── allocators.h │ │ ├── args.h │ │ ├── base58.h │ │ ├── base64.h │ │ ├── config.h │ │ ├── convert.h │ │ ├── cvdef.h │ │ ├── daemon.h │ │ ├── debug.h │ │ ├── encoding.h │ │ ├── filesystem.h │ │ ├── hex.h │ │ ├── interface.h │ │ ├── json.h │ │ ├── math.h │ │ ├── memory.h │ │ ├── mutex.h │ │ ├── runtime.h │ │ ├── signals.h │ │ ├── softfloat.h │ │ ├── sorting.h │ │ ├── string.h │ │ ├── urlencode.h │ │ └── version.h │ ├── memory.cpp │ ├── signals.cpp │ ├── softfloat.cpp │ ├── string.cpp │ ├── templates │ │ ├── autofile.h │ │ ├── basestream.h │ │ ├── containers.h │ │ ├── datastream.h │ │ ├── flatdata.h │ │ ├── mruset.h │ │ ├── serialize.h │ │ ├── singleton.h │ │ └── typename.h │ ├── types │ │ ├── condition_variable.h │ │ ├── lock_shared_ptr.h │ │ ├── lock_unique_ptr.h │ │ └── precision.h │ └── version.cpp └── main.cpp ├── tests ├── .gitkeep ├── bench │ ├── LLD │ │ ├── binary_key.cpp │ │ ├── binary_lru.cpp │ │ ├── ledger.cpp │ │ ├── register.cpp │ │ └── template_lru.cpp │ ├── TAO │ │ ├── Ledger │ │ │ └── sigchain.cpp │ │ ├── Operation │ │ │ ├── create.cpp │ │ │ └── validate.cpp │ │ └── Register │ │ │ └── object.cpp │ └── main.cpp ├── live │ └── main.cpp ├── smoke │ ├── README.md │ ├── api │ │ ├── api_call.sh │ │ ├── assets.sh │ │ ├── finance.sh │ │ ├── ledger.sh │ │ ├── supply.sh │ │ ├── system.sh │ │ ├── test.sh │ │ ├── tokens.sh │ │ └── users.sh │ ├── examples │ │ └── nexus.conf.publictestnet │ ├── mainnet-setup-for-debugger.sh │ ├── makefile.unix.test │ ├── public-testnet-setup.sh │ ├── rpctest.sh │ ├── run-start-nexus-test.sh │ ├── setup-for-debugger.sh │ ├── setup-for-debugger2.sh │ ├── setup-two-local-test-nodes.sh │ ├── start-local-testnet.sh │ └── startminerfortest.sh └── unit │ ├── LLC │ ├── aes.cpp │ ├── argon2.cpp │ ├── fermat.cpp │ ├── test_falcon.c │ ├── test_genkat.c │ └── uint1024.cpp │ ├── LLP │ ├── base_address.cpp │ └── trust_address.cpp │ ├── Legacy │ ├── mempool.cpp │ └── utxo.cpp │ ├── TAO │ ├── API │ │ ├── assets.cpp │ │ ├── crypto.cpp │ │ ├── finance.cpp │ │ ├── names.cpp │ │ ├── supply.cpp │ │ ├── tokens.cpp │ │ ├── users.cpp │ │ ├── util.cpp │ │ └── util.h │ ├── Ledger │ │ ├── block.cpp │ │ ├── mempool.cpp │ │ ├── prime.cpp │ │ ├── sigchain.cpp │ │ ├── stake.cpp │ │ ├── stakepool.cpp │ │ └── transaction.cpp │ ├── Operation │ │ ├── claim.cpp │ │ ├── conditions.cpp │ │ ├── contract.cpp │ │ ├── credit.cpp │ │ ├── debit.cpp │ │ ├── erase.cpp │ │ ├── fees.cpp │ │ ├── migrate.cpp │ │ ├── names.cpp │ │ ├── register.cpp │ │ ├── transfer.cpp │ │ ├── trust.cpp │ │ ├── validate.cpp │ │ └── write.cpp │ └── Register │ │ ├── objects.cpp │ │ ├── rollback.cpp │ │ └── testvm.cpp │ ├── Util │ ├── hex.cpp │ └── math.cpp │ ├── catch2 │ ├── catch.hpp │ ├── catch_reporter_automake.hpp │ ├── catch_reporter_sonarqube.hpp │ ├── catch_reporter_tap.hpp │ └── catch_reporter_teamcity.hpp │ └── main.cpp └── win_build.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.o 3 | *.P 4 | *.d 5 | *.D 6 | *.bat 7 | *.exe 8 | *.Debug 9 | *.a 10 | *.Release 11 | *.kate-swp 12 | *.db 13 | *.vscode 14 | *.qm 15 | *.log 16 | *.so 17 | nexus 18 | .cproject 19 | .project 20 | /.settings/ 21 | -------------------------------------------------------------------------------- /COPYING.MD: -------------------------------------------------------------------------------- 1 | (c) Copyright Nexus Developers 2014 - 2019 2 | 3 | You are free to copy and use this source code, but are you prepared to improve it? 4 | 5 | The MIT License (MIT) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2014 - 2019 Nexus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nexus 2 | 3 | Nexus is a high performance Application Framework that provides a Peer to Peer electronic cash system with support for real-time smart contracts powered with a 64-bit register virtual machine. Nexus technology is developed to improve the overall security, scalability, and usability of Internet driven Applications. 4 | 5 | ## Branching 6 | 7 | We use a very strict branching logic for our development. The branch 'merging' is the main development branch, which contains the most up-to-date code. The branch 'master' is the stable branch, that contains releases. If you are compiling from source, ensure you use the 'master' branch or pull from a release tag. The branch 'staging' is for pre-releases, so if you would like to test out new features before full release, but want to ensure they are mostly stable, use 'staging'. 8 | 9 | ## Building 10 | 11 | We use Make to build our project to multiple platforms. Please read out build documentation for instructions and options. 12 | 13 | [Build Options](docs/build-params-reference.md) 14 | 15 | [Linux](docs/build-linux.md) 16 | 17 | [Windows](docs/build-win.md) 18 | 19 | [OSX](docs/build-osx.md) 20 | 21 | [iPhone OS / Android OS](docs/build-mobile.md) 22 | 23 | ## Developing 24 | 25 | Developing on Nexus has been designed to be powerful, yet simple to use. Tritium++ packages features from SQL Queries, filters, sorting, statistical operators, functions, variables, and much more. The API uses a RESTFul HTTP-JSON protocol, so that you can access the power of Smart Contracts on Nexus from very basic web experience to advanced capabilities. The API is always expanding, so if you find any bugs or wish to suggest improvements, please use the Issues tracker and submit your feedback. 26 | 27 | ## License 28 | 29 | Nexus is released under the terms of the MIT license. See [COPYING](COPYING.MD) for more 30 | information or see https://opensource.org/licenses/MIT. 31 | 32 | ## Contributing 33 | 34 | If you would like to contribute as always submit a pull request. All code contributions should follow the comments and style guides. See [COMMENTS](contrib/COMMENTS.md) or [STYLEGUIDE](contrib/STYLEGUIDE.md) for more information. 35 | -------------------------------------------------------------------------------- /build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/build/.gitkeep -------------------------------------------------------------------------------- /config/.cshrc: -------------------------------------------------------------------------------- 1 | unset autologout 2 | source /root/.aliases 3 | -------------------------------------------------------------------------------- /config/do-curls: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh -f 2 | # 3 | # do-curls 4 | # 5 | # Sequentially do a bunch of curl-nexus calls. Note that the output from some APIs 6 | # are input to subsequent APIs. So you will manually need to modify the contents 7 | # of this file. Note the intent of this file is a cut-and-paste source. 8 | # 9 | alias cn "/nexus/curl-nexus" 10 | 11 | cn "accounts/create?username=dino&password=dinopassword&pin=1234" 12 | cn "accounts/login?pin=1234&username=dino&password=dino-password" 13 | cn "accounts/transactions?genesis=$GENID&page=0&limit=3&verbose=1" 14 | cn "accounts/notifications?genesis=$GENID&page=0&limit=3&verbose=0" 15 | 16 | cn "assets/create?pin=1234&session=$SES&data=dino-data&name=dino-asset" 17 | cn "assets/get?pin=1234&name=dino-asset" 18 | cn "assets/transfer?pin=1234>&session=$SES>&username=&name=dino-asset" 19 | cn "assets/tokenize/asset?asset_name=dino-asset&token_name=dino-token" 20 | cn "assets/history?name=dino-asset" 21 | 22 | cn "tokens/create?pin=1234&session=$SES&type=token&identifier=1&supply=1000&name=dino-token" 23 | cn "tokens/get?name=dino-token&type=token" 24 | cn "tokens/create?pin=1234&session=$SES&type=account" 25 | cn "tokens/get?name=dino-token&type=token" 26 | cn "tokens/debit?pin=1234&session=$SES&amount=10&name_from=dino&name_to=nancy" 27 | cn "tokens/credit?pin=1234&session=$SES&&txid=$TXIDX&amount=10&address_to=$ADDR" 28 | 29 | cn "supply/createitem?pin=1234&data=dino-item-data&session=$SES" 30 | cn "supply/getitem?address=$ADDR" 31 | cn "supply/updateitem?pin=1234&data=item-data&session=$SES&address=$ADDR" 32 | cn "supply/transfer?pin=1234&session=$SES&address=$ADDR&destination=$NEW_ADDR" 33 | cn "supply/history?address=$ADDR" 34 | -------------------------------------------------------------------------------- /config/docker-run-tritium: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # docker-run-tritium 4 | # 5 | # This script is used on your host OS to create and start a docker container 6 | # that runs the Nexus Daemon and the lispers.net LISP subsystem for a client 7 | # (non-seed) node.. 8 | # 9 | # You can run this script multiple times and it will create as many containers 10 | # as you wish. The docker image "tritium" must already be built by using 11 | # "docker build". 12 | # 13 | # Note the port number allocated to get to the lispers.net webpage interface 14 | # can be found in the PORTS column of "docker ps". 15 | # 16 | # Usage: docker-run-tritium [ ] [] 17 | # 18 | HOSTNAME=`hostname | cut -d "." -f 1` 19 | RAND=`python -c "import random as r; print hex(r.randint(0, 0xffffffff))[2::]"` 20 | if [ -z "$3" ] ; then 21 | NAME="nexus-$HOSTNAME-$RAND" 22 | else 23 | NAME="$3" 24 | fi 25 | 26 | # 27 | # When one container is running, we use port 9090 for accessing the lispers.net 28 | # restful API. If a user wants to run multiple containers, then use a random 29 | # 30 | CONTAINER=`sudo docker ps | egrep nexus-$HOSTNAME | egrep 9090` 31 | if [ -z "$CONTAINER" ] ; then 32 | LPORT="9090" 33 | NPORT="8080" 34 | MPORT="9336" 35 | TPORT="8336" 36 | else 37 | LPORT="" 38 | NPORT="" 39 | MPORT="" 40 | TPORT="" 41 | fi 42 | 43 | # 44 | # Create container. 45 | # 46 | sudo docker create -p $NPORT:8080 -p $LPORT:9090 -p $MPORT:9336 \ 47 | -p $TPORT:8336 -v /:/hostOS -e "EID4=$1" -e "EID6=$2" \ 48 | -e "NAME=$NAME" -e "HOSTOS_HOME=$HOME" --privileged --name $NAME \ 49 | -h $NAME -ti tritium > /dev/null 50 | 51 | # 52 | # Startup container. 53 | # 54 | echo "Starting container '$NAME' ..." 55 | sudo docker start $NAME > /dev/null 56 | -------------------------------------------------------------------------------- /config/nexus-save-data: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # nexus-save-data 4 | # 5 | # Usage: nexus-save-datadir 6 | # 7 | 8 | DEST="/hostOS$HOSTOS_HOME/.Nexus_Core_Data_BETA" 9 | if [ ! -d $DEST ] ; then 10 | echo "Nexus data directory $DEST does not exist" 11 | exit 12 | fi 13 | 14 | # 15 | # debug.log could be enourmous, don't copy it. If you want it comment out line 16 | # below. 17 | # 18 | rm -f /root/.Nexus/debug.log 19 | 20 | # 21 | # Do the copy. 22 | # 23 | echo -n "Copying /root/.Nexus -> $DEST ... " 24 | cp -r /root/.Nexus/* $DEST 25 | echo "done" 26 | 27 | 28 | -------------------------------------------------------------------------------- /config/nexus.conf: -------------------------------------------------------------------------------- 1 | nexus.conf.minimal -------------------------------------------------------------------------------- /config/nexus.conf.mainnet: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example nexus.conf for the Legacy Mainnet. Tailor it to your deployment. Do not change 3 | # the nexus command line. Any options, put here. 4 | # 5 | # This configuration file is for the 'merging' branch. 6 | # 7 | 8 | #this will launch the process into the background 9 | daemon=1 10 | 11 | #default RPC user/pass. PLEASE CHANGE THESE TO SUITABLE VALUES 12 | rpcuser=username 13 | rpcpassword=password 14 | 15 | #default API user/pass. PLEASE CHANGE THESE TO SUITABLE VALUES 16 | apiuser=username 17 | apipassword=password 18 | 19 | #OPTIONAL: Allows API authentication to be disabled 20 | #apiauth=0 21 | 22 | #OPTIONAL: Sets log file verobosity, default 0 23 | #verbose=0 24 | 25 | #OPTIONAL: enable mining server (for a remote miner to connect to) 26 | #mining=1 27 | 28 | #OPTIONAL: enable staking (to generate blocks inside the process) 29 | #stake=1 30 | 31 | #OPTIONAL: if your application requires multiple users 32 | #multiuser=1 33 | 34 | #OPTIONAL: allows you to specifically disable the processing of notifications (on by default) 35 | #processnotifications=0 36 | 37 | #OPTIONAL: Allows the node to automatically log in with sig chain credentials and unlock the node for Mining, Staking, and Notifications 38 | #autologin=1 39 | #username=testuser 40 | #password=testpassword 41 | #pin=1234 42 | 43 | #OPTIONAL: If autologin is set to 1, this additional setting will create the signature chain if it does not exist 44 | #autocreate=0 45 | 46 | #OPTIONAL: seed node to force connect to 47 | #connect=node1.nexusoft.io 48 | 49 | -------------------------------------------------------------------------------- /config/nexus.conf.minimal: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example nexus.conf. Tailor it to your deployment. Do not change 3 | # the nexus command line. Any options, put here. 4 | # 5 | # This configuration file is for the 'master' branch. 6 | # 7 | rpcuser=username 8 | rpcpassword=password 9 | apiuser=username 10 | apipassword=password 11 | daemon=1 12 | #mining=1 13 | #stake=1 14 | -------------------------------------------------------------------------------- /config/nexus.conf.permissioned-private-client: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example nexus.conf. Tailor it to your deployment. Do not change 3 | # the nexus command line. Any options, put here. 4 | # 5 | 6 | #default RPC user/pass. PLEASE CHANGE THESE TO SUITABLE VALUES 7 | rpcuser=username 8 | rpcpassword=password 9 | rpcremote=1 10 | 11 | #default API user/pass to blank for private network and disable authentication of API requests 12 | apiauth=0 13 | apiuser= 14 | apipassword= 15 | apiremote=1 16 | 17 | rpcallowip=127.0.0.1 18 | testnet=100 19 | addnode=240.0.255.1 20 | addnode=240.0.255.2 21 | beta=0 22 | fastsync=1 23 | server=1 24 | daemon=1 25 | threads=10 26 | verbose=3 27 | maxconnections=16 28 | private=1 29 | apisessions=1 30 | nodns=1 31 | argon2=1 32 | -------------------------------------------------------------------------------- /config/nexus.conf.permissioned-private-seed: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example seed-node configuration for a private blockchain. If there 3 | # is more than one seed node used, only one must use the generate statement. 4 | # 5 | #default RPC user/pass. PLEASE CHANGE THESE TO SUITABLE VALUES 6 | rpcuser=username 7 | rpcpassword=password 8 | rpcremote=1 9 | 10 | #default API user/pass to blank for private network and disable authentication of API requests 11 | apiauth=0 12 | apiuser= 13 | apipassword= 14 | apiremote=1 15 | 16 | rpcallowip=127.0.0.1 17 | testnet=100 18 | beta=0 19 | fastsync=1 20 | server=1 21 | daemon=1 22 | threads=10 23 | verbose=3 24 | maxconnections=16 25 | private=1 26 | apisessions=1 27 | pmanager=1 28 | generate=one-seed 29 | argon2_memory=4 30 | nodns=1 31 | argon2=1 32 | -------------------------------------------------------------------------------- /config/nexus.conf.standalone-node: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example nexus.conf for a Tritium Testnet for a single node. 3 | # 4 | # This configuration file is for the 'merging' branch. 5 | # 6 | 7 | #default RPC user/pass. PLEASE CHANGE THESE TO SUITABLE VALUES 8 | rpcuser=username 9 | rpcpassword=password 10 | 11 | #default API user/pass. PLEASE CHANGE THESE TO SUITABLE VALUES 12 | apiuser=username 13 | apipassword=password 14 | 15 | # API user/pass with no authentication. Use with caution. 16 | #apiuser= 17 | #apipassword= 18 | #apiauth=0 19 | 20 | rpcallowip=127.0.0.1 21 | testnet=1 22 | beta=0 23 | fastsync=1 24 | server=1 25 | daemon=1 26 | threads=10 27 | verbose=3 28 | maxconnections=16 29 | private=1 30 | multiuser=1 31 | indexheight=1 32 | generate=password 33 | #argon2_memory=4 34 | #nodns=1 35 | #argon2=1 36 | -------------------------------------------------------------------------------- /config/nexus.conf.testnet: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example nexus.conf for a Tritium Testnet. Tailor it to your deployment. Do not change 3 | # the nexus command line. Any options, put here. 4 | # 5 | # This configuration file is for the 'merging' branch. 6 | # 7 | 8 | #this value can be any integer value, to make it simple to create new testnets on the fly. 9 | testnet=20 10 | 11 | #default RPC user/pass. PLEASE CHANGE THESE TO SUITABLE VALUES 12 | rpcuser=username 13 | rpcpassword=password 14 | 15 | #default API user/pass. PLEASE CHANGE THESE TO SUITABLE VALUES 16 | apiuser=username 17 | apipassword=password 18 | 19 | #this will launch the process into the background 20 | daemon=1 21 | 22 | #this allows you to control how much data is output to the console 23 | verbose=2 24 | 25 | #OPTIONAL: seed node to force connect to 26 | #connect=myseed.dns.com 27 | 28 | #OPTIONAL: enable mining server (for a remote miner to connect to) 29 | #mining=1 30 | 31 | #OPTIONAL: enable staking (to generate blocks inside the process) 32 | #stake=1 33 | 34 | #OPTIONAL: for private testnets and private networks (used for DEMO's) 35 | #private=1 36 | #generate=password 37 | 38 | #OPTIONAL: if your application requires multiple users 39 | #multiuser=1 40 | 41 | #OPTIONAL: allows you to specifically disable the processing of notifications (on by default) 42 | #processnotifications=0 43 | 44 | #OPTIONAL: Allows the node to automatically log in with sig chain credentials and unlock the node for Mining, Staking, and Notifications 45 | #autologin=1 46 | #username=testuser 47 | #password=testpassword 48 | #pin=1234 49 | 50 | #OPTIONAL: If autologin is set to 1, this additional setting will create the signature chain if it does not exist 51 | #autocreate=0 52 | -------------------------------------------------------------------------------- /config/run-nexus: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # run-nexus 4 | # 5 | # Launch Nexus Daemon. Check to see if nexus data directory /root/.Nexus needs 6 | # to be created and point to the host OS file system. 7 | # 8 | 9 | # 10 | # Default to creating a symlink. 11 | # 12 | DATA_DIR="/hostOS$HOSTOS_HOME/.Nexus_Core_Data_BETA" 13 | 14 | # 15 | # If no HOSTOS_HOME env variable, then create the directory and run locally 16 | # out of it. That is, no connection to host OS file system. User must move 17 | # nexus.conif into /root/.Nexus. 18 | # 19 | if [ -z "$HOSTOS_HOME" ]; then 20 | mkdir /root/.Nexus 21 | fi 22 | 23 | # 24 | # If this is first innvocation of the nexus daemon after container creation, 25 | # then setup /root/.Nexus directory. Point to host OS file system. If that 26 | # directory does not exist, create it and copy a default nexus.conf to it. 27 | # 28 | cd /nexus 29 | if [ ! -d "/root/.Nexus" ]; then 30 | if [ ! -d $DATA_DIR ]; then 31 | echo -n "Create nexus data directory $DATA_DIR ... " 32 | mkdir $DATA_DIR 33 | cp /nexus/nexus.conf.default $DATA_DIR/nexus.conf 34 | echo "done" 35 | fi 36 | echo -n "Symlink nexus data directory /root/.Nexus -> $DATA_DIR ... " 37 | ln -sf $DATA_DIR /root/.Nexus 38 | echo "done" 39 | fi 40 | 41 | # 42 | # Startup daemon. Check /root/.Nexus/nexus.conf for daemon parameterization. 43 | # 44 | ./nexus & 45 | -------------------------------------------------------------------------------- /contrib/COMMENTS.md: -------------------------------------------------------------------------------- 1 | # Comments Guide 2 | 3 | Comments in this library should be written as you develop new code. The practice of "code now, comment later" will leave you in a hole of procrastination that will inevitably lead to comment spurts. We would like to see comments describe functions fully, and sub comments describe blocks of code in full sentences. 4 | 5 | 6 | ## Header Files 7 | 8 | Comments should be included to support Doxygen building over methods and classes in header files. 9 | 10 | ``` 11 | /** Test Class 12 | * 13 | * Description of the class. 14 | * Can be in as many lines as needed. 15 | * 16 | **/ 17 | class Test 18 | { 19 | public: 20 | 21 | /** Describe Data Member. **/ 22 | uint32_t nDataMember; 23 | 24 | /** Function 25 | * 26 | * Function Description 27 | * 28 | * @param[in] nArg The argument for... 29 | * @param[out] nRet The argument outputed for... 30 | * 31 | * @return returns the... 32 | * 33 | **/ 34 | bool Function(uint32_t nArg, uint32_t& nRet); 35 | } 36 | ``` 37 | 38 | ## Source Files 39 | 40 | Inside the corresponding source files, the method description should be non-doxygen, and be a repeat of the function description from the headers. 41 | 42 | ``` 43 | /* Function Description */ 44 | bool Test::Function(uint32_t nArg, uint32_t& nRet) 45 | { 46 | /* Brief Description of Local Variable. */ 47 | uin32_t nSum = 0; 48 | 49 | /* Brief Description of Process. */ 50 | for(int i = 0; i < 10; i++) 51 | { 52 | nSum += nSum; 53 | } 54 | } 55 | ``` 56 | -------------------------------------------------------------------------------- /docs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/docs/.gitkeep -------------------------------------------------------------------------------- /docs/build-osx.md: -------------------------------------------------------------------------------- 1 | ### Installing Dependencies ### 2 | 3 | ##### Install Xcode Tools and Brew ##### 4 | 5 | Open Finder, go to Utilities, and open Terminal. 6 | 7 | To install the xcode command line tools, run: 8 | 9 | * xcode-select --install 10 | 11 | Click Install, then Agree. When its done, run: 12 | 13 | * ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 14 | 15 | Press ENTER to continue when prompted, then type your password to install. When it finishes, run: 16 | 17 | * brew install berkeley-db git miniupnpc openssl 18 | * echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile 19 | * source ~/.bash_profile 20 | 21 | ### To build the command line version (CLI) ##### 22 | 23 | Make sure you are in your home directory, or the directory you would like the source code to be. 24 | 25 | * git clone --depth 1 https://github.com/Nexusoft/Nexus.git 26 | * cd Nexus 27 | * make -f makefile.cli 28 | -------------------------------------------------------------------------------- /lisp/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/lisp/.gitkeep -------------------------------------------------------------------------------- /lisp/RL: -------------------------------------------------------------------------------- 1 | #!/bin/tcsh 2 | # 3 | # RL - Restart LISP Wrapper Script 4 | # 5 | # Nexus/LISP wrapper script to start the lispers.net LISP subsystem. 6 | # This script makes two calls. One to a provisioning program that will 7 | # provision the lisp.config and setup kernel routes in the routing table. 8 | # And the other to start the lispers.net LISP subsystem. 9 | # 10 | # This script is used by either a client or seed nexus/lisp node. And can be 11 | # run inside a docker container or natively on most unix derived OS platforms. 12 | # 13 | # The lispers.net code does not run natively on Windows. You must install 14 | # docker on the platform to run it. 15 | # 16 | #------------------------------------------------------------------------------ 17 | 18 | # 19 | # Default to docker default device of eth0. If you are running natively, you 20 | # pick your interface where your default route points to. Run the following 21 | # to find out: "ip route | egrep default". 22 | # 23 | set device = "eth0" 24 | 25 | # 26 | # If caller does a "setenv EID4 " and "setenv EID6 ", the 27 | # EID values will be passed to provision-lisp.py to provision the lisp.config 28 | # file with the supplied EIDs. Otherwise, random values will be created. 29 | # 30 | if ($?EID4 == 0) then 31 | set EID4 = "" 32 | endif 33 | if ($?EID6 == 0) then 34 | set EID6 = "" 35 | endif 36 | 37 | # 38 | # Go into directory where RL resides. 39 | # 40 | cd `dirname $0` 41 | 42 | # 43 | # Provision lisp.config and/or reinstall kernel routes. 44 | # 45 | python provision-lisp.py $device $EID4 $EID6 46 | 47 | # 48 | # Start the lispers.net LISP subsystem, quietly. 49 | # 50 | /lispers.net/RESTART-LISP -9090 $device > /dev/null 51 | exit 52 | -------------------------------------------------------------------------------- /lisp/lisp-debian-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # lisp-debian-install.sh 4 | # 5 | # This script is used to install the lispers.net LISP implementation on a 6 | # debian system used with Nexus use-cases. It installs the python dependencies 7 | # and networking tools to run LISP on a Nexus node. 8 | # 9 | # Run this script in the LLL-TAO/lisp directory. 10 | # 11 | # To start LISP, use the RL script. 12 | # 13 | sudo apt-get update && sudo apt-get -yq install \ 14 | gcc libc-dev python python-dev libffi-dev openssl libpcap-dev \ 15 | curl wget iptables iproute2 tcpdump tcsh sudo traceroute iputils-ping \ 16 | net-tools procps emacs jq 17 | 18 | # 19 | # Install LISP release in /lispers.net directory. 20 | # 21 | sudo mkdir /lispers.net; cd /lispers.net; curl --insecure -L https://www.dropbox.com/s/e87heamhl9t5asz/lisp-nexus.tgz | sudo gzip -dc | sudo tar -xf - 22 | 23 | # 24 | # Install python modules the lispers.net directory depends on. 25 | # 26 | sudo python /lispers.net/get-pip.py 27 | sudo pip install -r /lispers.net/pip-requirements.txt 28 | 29 | # 30 | # Copy LISP startup config. 31 | # 32 | cd - 33 | sudo cp RL /lispers.net/RL 34 | sudo cp provision-lisp.py /lispers.net/provision-lisp.py 35 | sudo cp lisp.config.xtr /lispers.net/lisp.config.xtr 36 | sudo cp lisp-join.py /lispers.net/lisp-join.py 37 | sudo cp make-crypto-eid.py /lispers.net/make-crypto-eid.py 38 | exit 39 | -------------------------------------------------------------------------------- /lisp/whoarepeers.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # whoarepeers.py 4 | # 5 | # Ask getpeerinfo to get peers, and if an EID peer, lig the EID so the 6 | # LISP mapping system can return an rloc-name. This gives an operator a rough 7 | # idea who owns and manages the nexus node. 8 | # 9 | 10 | import commands 11 | 12 | peerinfo = "/nexus/nexus getpeerinfo | egrep addr" 13 | lig = ('python -O /lispers.net/lisp-lig.pyo "[200]{}" to node1.nexusoft.io' + \ 14 | "| egrep rloc-name") 15 | 16 | peers = commands.getoutput(peerinfo) 17 | if (peers == ""): 18 | print "No peers" 19 | exit(0) 20 | #endif 21 | peers = peers.split("\n") 22 | 23 | for peer in peers: 24 | p = peer.split(":")[1] 25 | p = p.replace(' "', '') 26 | pp = (p + " ...").ljust(25) 27 | print "Found peer {}".format(pp), 28 | 29 | if (pp[0:4] == "240." or pp[0:2] == "fe"): 30 | out = commands.getoutput(lig.format(p)) 31 | out = out.split() 32 | print out[-1] 33 | else: 34 | print "underlay" 35 | #endif 36 | #endfor 37 | 38 | 39 | -------------------------------------------------------------------------------- /release/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/release/.gitkeep -------------------------------------------------------------------------------- /sdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.pyo 3 | -------------------------------------------------------------------------------- /sdk/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/sdk/.gitkeep -------------------------------------------------------------------------------- /src/LLC/SK.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | namespace LLC 17 | { 18 | /* Implementation of SK function caches */ 19 | LLD::TemplateLRU, uint64_t> cache64 (32); 20 | LLD::TemplateLRU, uint256_t> cache256 (32); 21 | LLD::TemplateLRU, uint512_t> cache512 (32); 22 | LLD::TemplateLRU, uint1024_t> cache1024 (32); 23 | } 24 | -------------------------------------------------------------------------------- /src/LLC/hash/SK/SK.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | namespace LLC 17 | { 18 | /* Implementation of SK function caches */ 19 | LLD::TemplateLRU, uint64_t> cache64 (32); 20 | LLD::TemplateLRU, uint256_t> cache256 (32); 21 | LLD::TemplateLRU, uint512_t> cache512 (32); 22 | LLD::TemplateLRU, uint1024_t> cache1024 (32); 23 | } 24 | -------------------------------------------------------------------------------- /src/LLC/hash/Skein/skein_port.h: -------------------------------------------------------------------------------- 1 | #ifndef _SKEIN_PORT_H_ 2 | #define _SKEIN_PORT_H_ 3 | /******************************************************************* 4 | ** 5 | ** Platform-specific definitions for Skein hash function. 6 | ** 7 | ** Source code author: Doug Whiting, 2008. 8 | ** 9 | ** This algorithm and source code is released to the public domain. 10 | ** 11 | ** Many thanks to Brian Gladman for his portable header files, which 12 | ** have been modified slightly here, to handle a few more platforms. 13 | ** 14 | ** To port Skein to an "unsupported" platform, change the definitions 15 | ** in this file appropriately. 16 | ** 17 | ********************************************************************/ 18 | 19 | #include "brg_types.h" /* get integer type definitions */ 20 | 21 | typedef unsigned int uint_t; /* native unsigned integer */ 22 | typedef uint_8t u08b_t; /* 8-bit unsigned integer */ 23 | typedef uint_64t u64b_t; /* 64-bit unsigned integer */ 24 | 25 | /* 26 | * Skein is "natively" little-endian (unlike SHA-xxx), for optimal 27 | * performance on x86 CPUs. The Skein code requires the following 28 | * definitions for dealing with endianness: 29 | * 30 | * Skein_Put64_LSB_First 31 | * Skein_Get64_LSB_First 32 | * Skein_Swap64 33 | * 34 | * In the reference code, these functions are implemented in a 35 | * very portable (and thus slow) fashion, for clarity. See the file 36 | * "skein_port.h" in the Optimized_Code directory for ways to make 37 | * these functions fast(er) on x86 platforms. 38 | */ 39 | 40 | u64b_t Skein_Swap64(u64b_t w64); 41 | void Skein_Put64_LSB_First(u08b_t *dst,const u64b_t *src,size_t bCnt); 42 | void Skein_Get64_LSB_First(u64b_t *dst,const u08b_t *src,size_t wCnt); 43 | 44 | #endif /* ifndef _SKEIN_PORT_H_ */ 45 | -------------------------------------------------------------------------------- /src/LLC/hash/argon2/encoding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 reference source code package - reference C implementations 3 | * 4 | * Copyright 2015 5 | * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves 6 | * 7 | * You may use this work under the terms of a Creative Commons CC0 1.0 8 | * License/Waiver or the Apache Public License 2.0, at your option. The terms of 9 | * these licenses can be found at: 10 | * 11 | * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 12 | * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * You should have received a copy of both of these licenses along with this 15 | * software. If not, they may be obtained at the above URLs. 16 | */ 17 | 18 | #ifndef ENCODING_H 19 | #define ENCODING_H 20 | #include 21 | 22 | #define ARGON2_MAX_DECODED_LANES UINT32_C(255) 23 | #define ARGON2_MIN_DECODED_SALT_LEN UINT32_C(8) 24 | #define ARGON2_MIN_DECODED_OUT_LEN UINT32_C(12) 25 | 26 | /* 27 | * encode an Argon2 hash string into the provided buffer. 'dst_len' 28 | * contains the size, in characters, of the 'dst' buffer; if 'dst_len' 29 | * is less than the number of required characters (including the 30 | * terminating 0), then this function returns ARGON2_ENCODING_ERROR. 31 | * 32 | * on success, ARGON2_OK is returned. 33 | */ 34 | int encode_string(char *dst, size_t dst_len, argon2_context *ctx, 35 | argon2_type type); 36 | 37 | /* 38 | * Decodes an Argon2 hash string into the provided structure 'ctx'. 39 | * The only fields that must be set prior to this call are ctx.saltlen and 40 | * ctx.outlen (which must be the maximal salt and out length values that are 41 | * allowed), ctx.salt and ctx.out (which must be buffers of the specified 42 | * length), and ctx.pwd and ctx.pwdlen which must hold a valid password. 43 | * 44 | * Invalid input string causes an error. On success, the ctx is valid and all 45 | * fields have been initialized. 46 | * 47 | * Returned value is ARGON2_OK on success, other ARGON2_ codes on error. 48 | */ 49 | int decode_string(argon2_context *ctx, const char *str, argon2_type type); 50 | 51 | /* Returns the length of the encoded byte stream with length len */ 52 | size_t b64len(uint32_t len); 53 | 54 | /* Returns the length of the encoded number num */ 55 | size_t numlen(uint32_t num); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/LLC/hash/argon2/genkat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 reference source code package - reference C implementations 3 | * 4 | * Copyright 2015 5 | * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves 6 | * 7 | * You may use this work under the terms of a Creative Commons CC0 1.0 8 | * License/Waiver or the Apache Public License 2.0, at your option. The terms of 9 | * these licenses can be found at: 10 | * 11 | * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 12 | * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * You should have received a copy of both of these licenses along with this 15 | * software. If not, they may be obtained at the above URLs. 16 | */ 17 | 18 | #ifndef ARGON2_KAT_H 19 | #define ARGON2_KAT_H 20 | 21 | #include "core.h" 22 | 23 | /* 24 | * Initial KAT function that prints the inputs to the file 25 | * @param blockhash Array that contains pre-hashing digest 26 | * @param context Holds inputs 27 | * @param type Argon2 type 28 | * @pre blockhash must point to INPUT_INITIAL_HASH_LENGTH bytes 29 | * @pre context member pointers must point to allocated memory of size according 30 | * to the length values 31 | */ 32 | void initial_kat(const uint8_t *blockhash, const argon2_context *context, 33 | argon2_type type); 34 | 35 | /* 36 | * Function that prints the output tag 37 | * @param out output array pointer 38 | * @param outlen digest length 39 | * @pre out must point to @a outlen bytes 40 | **/ 41 | void print_tag(const void *out, uint32_t outlen); 42 | 43 | /* 44 | * Function that prints the internal state at given moment 45 | * @param instance pointer to the current instance 46 | * @param pass current pass number 47 | * @pre instance must have necessary memory allocated 48 | **/ 49 | void internal_kat(const argon2_instance_t *instance, uint32_t pass); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/LLC/hash/argon2/thread.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 reference source code package - reference C implementations 3 | * 4 | * Copyright 2015 5 | * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves 6 | * 7 | * You may use this work under the terms of a Creative Commons CC0 1.0 8 | * License/Waiver or the Apache Public License 2.0, at your option. The terms of 9 | * these licenses can be found at: 10 | * 11 | * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 12 | * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * You should have received a copy of both of these licenses along with this 15 | * software. If not, they may be obtained at the above URLs. 16 | */ 17 | 18 | #if !defined(ARGON2_NO_THREADS) 19 | 20 | #include "thread.h" 21 | #if defined(_WIN32) 22 | #include 23 | #endif 24 | 25 | int argon2_thread_create(argon2_thread_handle_t *handle, 26 | argon2_thread_func_t func, void *args) { 27 | if(NULL == handle || func == NULL) { 28 | return -1; 29 | } 30 | #if defined(_WIN32) 31 | *handle = _beginthreadex(NULL, 0, func, args, 0, NULL); 32 | return *handle != 0 ? 0 : -1; 33 | #else 34 | return pthread_create(handle, NULL, func, args); 35 | #endif 36 | } 37 | 38 | int argon2_thread_join(argon2_thread_handle_t handle) { 39 | #if defined(_WIN32) 40 | if(WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) { 41 | return CloseHandle((HANDLE)handle) != 0 ? 0 : -1; 42 | } 43 | return -1; 44 | #else 45 | return pthread_join(handle, NULL); 46 | #endif 47 | } 48 | 49 | void argon2_thread_exit(void) { 50 | #if defined(_WIN32) 51 | _endthreadex(0); 52 | #else 53 | pthread_exit(NULL); 54 | #endif 55 | } 56 | 57 | #endif /* ARGON2_NO_THREADS */ 58 | -------------------------------------------------------------------------------- /src/LLC/hash/macro.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLC_HASH_MACRO_H 16 | #define NEXUS_LLC_HASH_MACRO_H 17 | 18 | #define BEGIN(a) ((char*)&(a)) 19 | #define END(a) ((char*)&((&(a))[1])) 20 | #define UBEGIN(a) ((uint8_t*)&(a)) 21 | #define UEND(a) ((uint8_t*)&((&(a))[1])) 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/LLC/include/encrypt.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | #include 18 | 19 | namespace LLC 20 | { 21 | 22 | /** Encrypt 23 | * 24 | * Encrypts the data using the AES 256 function and the specified symmetric key. 25 | * . 26 | * 27 | * @param[in] vchKey The symmetric key to use for the encryption. 28 | * @param[in] vchPlainText The plain text data bytes to be encrypted. 29 | * @param[out] vchEncrypted The encrypted data. 30 | * 31 | * @return True if the data was encrypted successfully. 32 | * 33 | **/ 34 | bool EncryptAES256(const std::vector& vchKey, const std::vector& vchPlainText, std::vector &vchEncrypted); 35 | 36 | 37 | /** Decrypt 38 | * 39 | * Decrypts the data using the AES 256 function and the specified symmetric key. 40 | * 41 | * @param[in] vchKey The symmetric key to use for the encryption. 42 | * @param[in] vchEncrypted The encrypted data to be decrypted. 43 | * @param[out] vchPlainText The decrypted plain text data. 44 | * 45 | * @return True if the data was decrypted successfully. 46 | * 47 | **/ 48 | bool DecryptAES256(const std::vector& vchKey, const std::vector& vchEncrypted, std::vector &vchPlainText); 49 | 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/LLC/include/key_error.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLC_INCLUDE_KEY_ERROR_H 16 | #define NEXUS_LLC_INCLUDE_KEY_ERROR_H 17 | 18 | #include 19 | 20 | 21 | namespace LLC 22 | { 23 | /** Key Runtime Error Wrapper. **/ 24 | class key_error : public std::runtime_error 25 | { 26 | public: 27 | explicit key_error(const std::string& str) : std::runtime_error(str) {} 28 | }; 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/LLC/kyber/indcpa.h: -------------------------------------------------------------------------------- 1 | #ifndef INDCPA_H 2 | #define INDCPA_H 3 | 4 | #include 5 | #include "params.h" 6 | #include "polyvec.h" 7 | 8 | #define gen_matrix KYBER_NAMESPACE(gen_matrix) 9 | void gen_matrix(polyvec *a, const uint8_t seed[KYBER_SYMBYTES], int transposed); 10 | 11 | #define indcpa_keypair KYBER_NAMESPACE(indcpa_keypair) 12 | void indcpa_keypair(uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES], 13 | uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES]); 14 | 15 | #define indcpa_keypair_seed KYBER_NAMESPACE(indcpa_keypair_seed) 16 | void indcpa_keypair_seed(uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES], 17 | uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES], 18 | uint8_t buf[KYBER_SEEDBYTES]); 19 | 20 | #define indcpa_enc KYBER_NAMESPACE(indcpa_enc) 21 | void indcpa_enc(uint8_t c[KYBER_INDCPA_BYTES], 22 | const uint8_t m[KYBER_INDCPA_MSGBYTES], 23 | const uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES], 24 | const uint8_t coins[KYBER_SYMBYTES]); 25 | 26 | #define indcpa_dec KYBER_NAMESPACE(indcpa_dec) 27 | void indcpa_dec(uint8_t m[KYBER_INDCPA_MSGBYTES], 28 | const uint8_t c[KYBER_INDCPA_BYTES], 29 | const uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES]); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/LLC/kyber/kem.h: -------------------------------------------------------------------------------- 1 | #ifndef KEM_H 2 | #define KEM_H 3 | 4 | #include 5 | #include "params.h" 6 | 7 | #define CRYPTO_SECRETKEYBYTES KYBER_SECRETKEYBYTES 8 | #define CRYPTO_PUBLICKEYBYTES KYBER_PUBLICKEYBYTES 9 | #define CRYPTO_CIPHERTEXTBYTES KYBER_CIPHERTEXTBYTES 10 | #define CRYPTO_BYTES KYBER_SSBYTES 11 | 12 | #if (KYBER_K == 2) 13 | #ifdef KYBER_90S 14 | #define CRYPTO_ALGNAME "Kyber512-90s" 15 | #else 16 | #define CRYPTO_ALGNAME "Kyber512" 17 | #endif 18 | #elif (KYBER_K == 3) 19 | #ifdef KYBER_90S 20 | #define CRYPTO_ALGNAME "Kyber768-90s" 21 | #else 22 | #define CRYPTO_ALGNAME "Kyber768" 23 | #endif 24 | #elif (KYBER_K == 4) 25 | #ifdef KYBER_90S 26 | #define CRYPTO_ALGNAME "Kyber1024-90s" 27 | #else 28 | #define CRYPTO_ALGNAME "Kyber1024" 29 | #endif 30 | #endif 31 | 32 | #define crypto_kem_keypair KYBER_NAMESPACE(keypair) 33 | int crypto_kem_keypair(uint8_t *pk, uint8_t *sk); 34 | 35 | #define crypto_kem_keypair_seed KYBER_NAMESPACE(keypair_seed) 36 | int crypto_kem_keypair_seed(uint8_t *pk, uint8_t *sk, uint8_t *seed); 37 | 38 | #define crypto_kem_enc KYBER_NAMESPACE(enc) 39 | int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk); 40 | 41 | #define crypto_kem_dec KYBER_NAMESPACE(dec) 42 | int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/LLC/types/typedef.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLC_TYPES_TYPEDEF_H 16 | #define NEXUS_LLC_TYPES_TYPEDEF_H 17 | 18 | #include 19 | 20 | namespace LLC 21 | { 22 | 23 | /** CPrivKey is a serialized private key, with all parameters included **/ 24 | typedef std::vector > CPrivKey; 25 | 26 | 27 | /** CSecret is a serialization of just the secret parameter **/ 28 | typedef std::vector > CSecret; 29 | 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/LLC/types/uint1024.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLC_TYPES_UINT1024_H 16 | #define NEXUS_LLC_TYPES_UINT1024_H 17 | 18 | #include 19 | 20 | typedef base_uint<128> uint128_t; 21 | typedef base_uint<256> uint256_t; 22 | typedef base_uint<512> uint512_t; 23 | typedef base_uint<576> uint576_t; 24 | typedef base_uint<1024> uint1024_t; 25 | typedef base_uint<1056> uint1056_t; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/LLD/include/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/src/LLD/include/.gitkeep -------------------------------------------------------------------------------- /src/LLD/include/enum.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLD_INCLUDE_ENUM_H 16 | #define NEXUS_LLD_INCLUDE_ENUM_H 17 | 18 | namespace LLD 19 | { 20 | 21 | /** FLAGS 22 | * 23 | * Database flags for keychains and sector. 24 | * 25 | **/ 26 | enum FLAGS 27 | { 28 | APPEND = (1 << 1), 29 | READONLY = (1 << 2), 30 | CREATE = (1 << 3), 31 | WRITE = (1 << 4), 32 | FORCE = (1 << 5) 33 | }; 34 | 35 | 36 | /** STATE 37 | * 38 | * Database states in the keychains. 39 | * 40 | **/ 41 | enum STATE 42 | { 43 | EMPTY = 0, 44 | READY = 1, 45 | TRANSACTION = 2 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/LLD/include/version.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To The Voice of The People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLD_INCLUDE_VERSION_H 16 | #define NEXUS_LLD_INCLUDE_VERSION_H 17 | 18 | #include 19 | #include 20 | 21 | #define DATABASE_MAJOR 0 22 | #define DATABASE_MINOR 1 23 | #define DATABASE_PATCH 1 24 | #define DATABASE_BUILD 0 25 | 26 | namespace LLD 27 | { 28 | 29 | /* Used for features in the database. */ 30 | const uint32_t DATABASE_VERSION = 31 | 1000000 * DATABASE_MAJOR 32 | + 10000 * DATABASE_MINOR 33 | + 100 * DATABASE_PATCH 34 | + 1 * DATABASE_BUILD; 35 | 36 | 37 | /* The database type used (Berklee DB or Lower Level Database) */ 38 | #ifdef USE_LLD 39 | const std::string DATABASE_NAME("LLD"); 40 | #else 41 | const std::string DATABASE_NAME("BDB"); 42 | #endif 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/LLD/transaction.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | namespace LLD 18 | { 19 | 20 | /* Default Constructor */ 21 | SectorTransaction::SectorTransaction() 22 | : mapTransactions() 23 | , setKeychain() 24 | , mapIndex() 25 | , setErasedData() 26 | , ssJournal(SER_LLD, DATABASE_VERSION) 27 | { 28 | } 29 | 30 | 31 | /* Default Destructor */ 32 | SectorTransaction::~SectorTransaction() 33 | { 34 | } 35 | 36 | 37 | /* Function to Erase a Key from the Keychain. */ 38 | bool SectorTransaction::EraseTransaction(const std::vector &vKey) 39 | { 40 | /* Add the erased data to the map. */ 41 | setErasedData.insert(vKey); 42 | 43 | /* Delete from transactions map if exists. */ 44 | if(mapTransactions.count(vKey)) 45 | mapTransactions.erase(vKey); 46 | 47 | /* Delete from keychain if exists. */ 48 | if(setKeychain.count(vKey)) 49 | setKeychain.erase(vKey); 50 | 51 | /* Delete from indexes if exists. */ 52 | if(mapIndex.count(vKey)) 53 | mapIndex.erase(vKey); 54 | 55 | return true; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/LLD/trust.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | 18 | 19 | namespace LLD 20 | { 21 | 22 | /** The Database Constructor. To determine file location and the Bytes per Record. **/ 23 | TrustDB::TrustDB(const uint8_t nFlagsIn, const uint32_t nBucketsIn, const uint32_t nCacheIn) 24 | : SectorDatabase(std::string("_TRUST") 25 | , nFlagsIn 26 | , nBucketsIn 27 | , nCacheIn) 28 | { 29 | } 30 | 31 | 32 | /* Default Destructor */ 33 | TrustDB::~TrustDB() 34 | { 35 | } 36 | 37 | 38 | /* Writes a trust key to the ledger DB. */ 39 | bool TrustDB::WriteTrustKey(const uint576_t& hashKey, const Legacy::TrustKey& key) 40 | { 41 | return Write(hashKey, key); 42 | } 43 | 44 | 45 | /* Reads a trust key from the ledger DB. */ 46 | bool TrustDB::ReadTrustKey(const uint576_t& hashKey, Legacy::TrustKey& key) 47 | { 48 | return Read(hashKey, key); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/LLP/include/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/src/LLP/include/.gitkeep -------------------------------------------------------------------------------- /src/LLP/include/lisp.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace LLP 21 | { 22 | /** RLOC 23 | * 24 | * Encapsulates a LISP RLOC (Routable LOCation) 25 | * 26 | **/ 27 | class RLOC 28 | { 29 | public: 30 | 31 | /* The network interface name as described by the host OS */ 32 | std::string strInterface; 33 | 34 | /* The translated IP address. If this node is behind a NAT then this will contain 35 | * the public IP address of the node's location */ 36 | std::string strTranslatedRLOC; 37 | 38 | /* The hostname of this RLOC */ 39 | std::string strRLOCName; 40 | }; 41 | 42 | /** RLOC 43 | * 44 | * Encapsulates a LISP EID (Endpoint IDentifier) 45 | * 46 | **/ 47 | class EID 48 | { 49 | public: 50 | /* The IPV4 or IPV6 LISP assigned address */ 51 | std::string strAddress; 52 | 53 | /* LISP instance ID showing which Nexus Network the node is on*/ 54 | std::string strInstanceID; 55 | 56 | /* Lis of RLOC's mapped to this EID*/ 57 | std::vector vRLOCs; 58 | }; 59 | 60 | /** GetEIDs 61 | * 62 | * Invokes the lispers.net API to obtain the EIDs and RLOCs used by this node 63 | * 64 | **/ 65 | std::map GetEIDs(); 66 | 67 | /** LispersAPIRequest 68 | * 69 | * Makes a request to the lispers.net API for the desired endpoint 70 | * 71 | * @param[in] strEndPoint The API endpoint to query 72 | * 73 | * @return The response string from the lispers.net API. 74 | * 75 | **/ 76 | std::string LispersAPIRequest(std::string strEndPoint); 77 | 78 | 79 | 80 | } -------------------------------------------------------------------------------- /src/LLP/include/permissions.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | /** CheckPermissions 22 | * 23 | * IP Filtering Definitions. IP's are Filtered By Ports. 24 | * 25 | * @param[in] strAddress the IP address to check. 26 | * @param[in] nPort The port number to check. 27 | * 28 | * @return Returns true if address is permissable, false otherwise. 29 | * 30 | **/ 31 | bool CheckPermissions(const std::string &strAddress, const uint16_t nPort); 32 | -------------------------------------------------------------------------------- /src/LLP/include/seeds.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLP_INCLUDE_SEEDS_H 16 | #define NEXUS_LLP_INCLUDE_SEEDS_H 17 | 18 | #include 19 | #include 20 | 21 | namespace LLP 22 | { 23 | 24 | /** DNS_SeedNodes 25 | * 26 | * These addresses are the first point of contact on the P2P network 27 | * They are established and maintained by the owners of each domain. 28 | * 29 | **/ 30 | extern const std::vector DNS_SeedNodes; 31 | 32 | 33 | /** DNS_SeedNodes_Testnet 34 | * 35 | * Testnet seed nodes. 36 | * 37 | **/ 38 | extern const std::vector DNS_SeedNodes_Testnet; 39 | 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/LLP/seeds.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | #include 14 | 15 | namespace LLP 16 | { 17 | 18 | /* These addresses are the first point of contact on the P2P network 19 | * They are established and maintained by the owners of each domain. */ 20 | const std::vector DNS_SeedNodes = 21 | { 22 | //viz DNS seeds 23 | "node1.nexus.io", 24 | "node2.nexus.io", 25 | "node3.nexus.io", 26 | "node4.nexus.io", 27 | "node5.nexus.io", 28 | 29 | //Radiant DNS seeds 30 | "nexus1.cryptowise.cloud", 31 | "nexus2.cryptowise.cloud", 32 | "nexus3.cryptowise.cloud", 33 | "nexus4.cryptowise.cloud", 34 | "nexus5.cryptowise.cloud", 35 | }; 36 | 37 | 38 | /* Testnet seed nodes. */ 39 | const std::vector DNS_SeedNodes_Testnet = 40 | { 41 | "node1.nexus.io", 42 | "node2.nexus.io", 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /src/LLP/templates/connection.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLP_TEMPLATES_CONNECTION_H 16 | #define NEXUS_LLP_TEMPLATES_CONNECTION_H 17 | 18 | 19 | #include 20 | #include 21 | 22 | namespace LLP 23 | { 24 | 25 | /** Connection 26 | * 27 | * A Default Connection class that handles the Reading of a default Packet Type. 28 | * 29 | **/ 30 | class Connection : public BaseConnection 31 | { 32 | public: 33 | 34 | 35 | /** Default Constructor **/ 36 | Connection(); 37 | 38 | 39 | /** Constructor **/ 40 | Connection(const Socket &SOCKET_IN, DDOS_Filter* DDOS_IN, bool fDDOSIn = false, bool fOutgoing = false); 41 | 42 | 43 | /** Constructor **/ 44 | Connection(DDOS_Filter* DDOS_IN, bool fDDOSIn = false, bool fOutgoing = false); 45 | 46 | 47 | /** Default destructor **/ 48 | virtual ~Connection(); 49 | 50 | 51 | /** ReadPacket 52 | * 53 | * Regular Connection Read Packet Method. 54 | * 55 | **/ 56 | void ReadPacket() final; 57 | 58 | }; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/LLP/templates/events.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LLP_TEMPLATES_EVENTS_H 16 | #define NEXUS_LLP_TEMPLATES_EVENTS_H 17 | 18 | namespace LLP 19 | { 20 | 21 | /* Events for LLP packet processing. */ 22 | struct EVENTS 23 | { 24 | enum 25 | { 26 | HEADER = 0, 27 | PACKET = 1, 28 | CONNECT = 2, 29 | DISCONNECT = 3, 30 | GENERIC = 4, 31 | FAILED = 5, 32 | PROCESSED = 6, 33 | }; 34 | }; 35 | 36 | 37 | /* Disonnect reason flags */ 38 | struct DISCONNECT 39 | { 40 | enum 41 | { 42 | TIMEOUT = 7, 43 | ERRORS = 8, 44 | POLL_ERROR = 9, 45 | POLL_EMPTY = 10, 46 | DDOS = 11, 47 | FORCE = 12, 48 | PEER = 13, 49 | BUFFER = 14, 50 | TIMEOUT_WRITE = 15, 51 | }; 52 | }; 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/LLP/templates/static.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace LLP 21 | { 22 | 23 | /* Forward Declared Static Templates. */ 24 | template<> std::atomic BaseConnection::REQUESTS; 25 | template<> std::atomic BaseConnection::PACKETS; 26 | template<> std::atomic BaseConnection::REQUESTS; 27 | template<> std::atomic BaseConnection::PACKETS; 28 | template<> std::atomic BaseConnection::REQUESTS; 29 | template<> std::atomic BaseConnection::PACKETS; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/Legacy/account.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | namespace Legacy 17 | { 18 | 19 | /* The default constructor. */ 20 | Account::Account() 21 | : vchPubKey ( ) 22 | { 23 | } 24 | 25 | 26 | /* Copy Constructor. */ 27 | Account::Account(const Account& account) 28 | : vchPubKey (account.vchPubKey) 29 | { 30 | } 31 | 32 | 33 | /* Move Constructor. */ 34 | Account::Account(Account&& account) noexcept 35 | : vchPubKey (std::move(account.vchPubKey)) 36 | { 37 | } 38 | 39 | 40 | /* Copy Assignment. */ 41 | Account& Account::operator=(const Account& account) 42 | { 43 | vchPubKey = account.vchPubKey; 44 | 45 | return *this; 46 | } 47 | 48 | 49 | /* Move Assignment. **/ 50 | Account& Account::operator=(Account&& account) noexcept 51 | { 52 | vchPubKey = std::move(account.vchPubKey); 53 | 54 | return *this; 55 | } 56 | 57 | 58 | /* Default Destructor */ 59 | Account::~Account() 60 | { 61 | } 62 | 63 | 64 | /* Clears the current public key value. */ 65 | void Account::SetNull() 66 | { 67 | vchPubKey.clear(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Legacy/include/constants.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LEGACY_INCLUDE_CONSTANTS_H 16 | #define NEXUS_LEGACY_INCLUDE_CONSTANTS_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | 25 | namespace Legacy 26 | { 27 | 28 | /** Byte vector representation of false. **/ 29 | const std::vector vchFalse(0); 30 | 31 | 32 | /** Byte vector representation of zero. **/ 33 | const std::vector vchZero(0); 34 | 35 | 36 | /** Byte vector representation of true. **/ 37 | const std::vector vchTrue(1, 1); 38 | 39 | 40 | /** Big Number representation of zero. **/ 41 | const LLC::CBigNum bnZero(0); 42 | 43 | 44 | /** Big Number representation of one. **/ 45 | const LLC::CBigNum bnOne(1); 46 | 47 | 48 | /** Big Number representation of false. **/ 49 | const LLC::CBigNum bnFalse(0); 50 | 51 | 52 | /** Big Number representation of true. **/ 53 | const LLC::CBigNum bnTrue(1); 54 | 55 | 56 | /** Maximum size of numeric values. **/ 57 | const size_t nMaxNumSize = 4; 58 | 59 | 60 | /** string used to sign Nexus messages **/ 61 | const std::string strMessageMagic = "Nexus Signed Message:\n"; 62 | 63 | 64 | /** Old legacy outdated threshold, currently a placeholder. **/ 65 | const int64_t LOCKTIME_THRESHOLD = 500000000; 66 | 67 | 68 | /** The network current transaction version. **/ 69 | const uint32_t TRANSACTION_CURRENT_VERSION = 2; 70 | 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/Legacy/include/global.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace Legacy 19 | { 20 | #ifndef NO_WALLET 21 | extern Legacy::RPC* Commands; 22 | #endif 23 | 24 | /** Initialize 25 | * 26 | * Instantiate global instances of the API. 27 | * 28 | **/ 29 | bool Initialize(); 30 | 31 | 32 | /** Shutdown 33 | * 34 | * Delete global instances of the API. 35 | * 36 | **/ 37 | void Shutdown(); 38 | } 39 | -------------------------------------------------------------------------------- /src/Legacy/keypoolentry.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | namespace Legacy 18 | { 19 | 20 | /* The default constructor. */ 21 | KeyPoolEntry::KeyPoolEntry() 22 | : nTime (runtime::unifiedtimestamp()) 23 | , vchPubKey ( ) 24 | { 25 | } 26 | 27 | 28 | /* Copy Constructor. */ 29 | KeyPoolEntry::KeyPoolEntry(const KeyPoolEntry& entry) 30 | : nTime (entry.nTime) 31 | , vchPubKey (entry.vchPubKey) 32 | { 33 | } 34 | 35 | 36 | /* Move Constructor. */ 37 | KeyPoolEntry::KeyPoolEntry(KeyPoolEntry&& entry) noexcept 38 | : nTime (std::move(entry.nTime)) 39 | , vchPubKey (std::move(entry.vchPubKey)) 40 | { 41 | } 42 | 43 | 44 | /* Copy Assignment. */ 45 | KeyPoolEntry& KeyPoolEntry::operator=(const KeyPoolEntry& entry) 46 | { 47 | nTime = entry.nTime; 48 | vchPubKey = entry.vchPubKey; 49 | 50 | return *this; 51 | } 52 | 53 | 54 | /* Move Assignment. */ 55 | KeyPoolEntry& KeyPoolEntry::operator=(KeyPoolEntry&& entry) noexcept 56 | { 57 | nTime = std::move(entry.nTime); 58 | vchPubKey = std::move(entry.vchPubKey); 59 | 60 | return *this; 61 | } 62 | 63 | 64 | /* Default Destructor */ 65 | KeyPoolEntry::~KeyPoolEntry() 66 | { 67 | } 68 | 69 | 70 | /* Constructor */ 71 | KeyPoolEntry::KeyPoolEntry(const std::vector& vchPubKeyIn) 72 | : nTime (runtime::unifiedtimestamp()) 73 | , vchPubKey (vchPubKeyIn) 74 | { 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/Legacy/keystore.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | namespace Legacy 17 | { 18 | 19 | /* Retrieve the public key for a key in the key store. */ 20 | bool KeyStore::GetPubKey(const NexusAddress& address, std::vector& vchPubKeyOut) const 21 | { 22 | LLC::ECKey key; 23 | if(!GetKey(address, key)) 24 | return false; 25 | vchPubKeyOut = key.GetPubKey(); 26 | return true; 27 | } 28 | 29 | 30 | /* Retrieve the private key associated with an address. */ 31 | bool KeyStore::GetSecret(const NexusAddress& address, LLC::CSecret& vchSecret, bool& fCompressed) const 32 | { 33 | LLC::ECKey key; 34 | if(!GetKey(address, key)) 35 | return false; 36 | 37 | vchSecret = key.GetSecret(fCompressed); 38 | 39 | return true; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/Legacy/outpoint.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | 18 | namespace Legacy 19 | { 20 | 21 | /* Default Constructor. */ 22 | OutPoint::OutPoint() 23 | : hash (0) 24 | , n (-1) 25 | { 26 | } 27 | 28 | 29 | /* Copy Constructor. */ 30 | OutPoint::OutPoint(const OutPoint& out) 31 | : hash (out.hash) 32 | , n (out.n) 33 | { 34 | } 35 | 36 | 37 | /* Move Constructor. */ 38 | OutPoint::OutPoint(OutPoint&& out) noexcept 39 | : hash (std::move(out.hash)) 40 | , n (std::move(out.n)) 41 | { 42 | } 43 | 44 | 45 | /* Copy assignment. */ 46 | OutPoint& OutPoint::operator=(const OutPoint& out) 47 | { 48 | hash = out.hash; 49 | n = out.n; 50 | 51 | return *this; 52 | } 53 | 54 | 55 | /* Move assignment. */ 56 | OutPoint& OutPoint::operator=(OutPoint&& out) noexcept 57 | { 58 | hash = std::move(out.hash); 59 | n = std::move(out.n); 60 | 61 | return *this; 62 | } 63 | 64 | 65 | /* Constructor */ 66 | OutPoint::OutPoint(const uint512_t& hashIn, const uint32_t nIn) 67 | : hash (hashIn) 68 | , n (nIn) 69 | { 70 | } 71 | 72 | 73 | /* Destructor. */ 74 | OutPoint::~OutPoint() 75 | { 76 | } 77 | 78 | 79 | /* Full object debug output */ 80 | std::string OutPoint::ToString() const 81 | { 82 | return debug::safe_printstr("OutPoint(", hash.SubString(), ", ", n, ")"); 83 | } 84 | 85 | 86 | /* Dump the full object to the console (stdout) */ 87 | void OutPoint::print() const 88 | { 89 | debug::log(0, ToString()); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/Legacy/output.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | #include /* for FormatMoney() */ 19 | 20 | namespace Legacy 21 | { 22 | 23 | /* Copy Constructor. */ 24 | Output::Output(const Output& out) 25 | : walletTx (out.walletTx) 26 | , i (out.i) 27 | , nDepth (out.nDepth) 28 | { 29 | } 30 | 31 | 32 | /* Move Constructor. */ 33 | Output::Output(Output&& out) noexcept 34 | : walletTx (out.walletTx) 35 | , i (std::move(out.i)) 36 | , nDepth (std::move(out.nDepth)) 37 | { 38 | } 39 | 40 | 41 | /* Initializes this Output with the provided parameter values */ 42 | Output::Output(const WalletTx& walletTxIn, const uint32_t iIn, const uint32_t nDepthIn) 43 | : walletTx (walletTxIn) 44 | , i (iIn) 45 | , nDepth (nDepthIn) 46 | { 47 | } 48 | 49 | 50 | /* Destructor */ 51 | Output::~Output() 52 | { 53 | } 54 | 55 | 56 | /* Generate a string representation of this output. */ 57 | std::string Output::ToString() const 58 | { 59 | return debug::safe_printstr("Output(", walletTx.GetHash().SubString(10), ", ", i, ", ", nDepth, ") [", FormatMoney(walletTx.vout[i].nValue), "]"); 60 | } 61 | 62 | 63 | /* Print a string representation of this output */ 64 | void Output::print() const 65 | { 66 | debug::log(0, ToString()); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/Legacy/rpc/daemon.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | /* Global TAO namespace. */ 25 | namespace Legacy 26 | { 27 | /* stop" 28 | * Stop Nexus server */ 29 | encoding::json RPC::Stop(const encoding::json& params, const bool fHelp) 30 | { 31 | if(fHelp || params.size() != 0) 32 | return std::string("stop - Stop Nexus server."); 33 | // Shutdown will take long enough that the response should get back 34 | Shutdown(); 35 | return "Nexus server stopping"; 36 | } 37 | 38 | /* getconnectioncount 39 | Returns the number of connections to other nodes */ 40 | encoding::json RPC::GetConnectionCount(const encoding::json& params, const bool fHelp) 41 | { 42 | if(fHelp || params.size() != 0) 43 | return std::string( 44 | "getconnectioncount" 45 | " - Returns the number of connections to other nodes."); 46 | 47 | return GetTotalConnectionCount(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Legacy/types/account.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_LEGACY_TYPES_ACCOUNT_H 16 | #define NEXUS_LEGACY_TYPES_ACCOUNT_H 17 | 18 | #include 19 | 20 | #include 21 | 22 | 23 | namespace Legacy 24 | { 25 | 26 | /** @class Account 27 | * 28 | * Account information. 29 | * 30 | * A wallet account contains the public key value for an account/Nexus address 31 | * (which is not stored here). These are used to store public keys in the wallet database. 32 | * 33 | * Database key is acc 34 | **/ 35 | class Account 36 | { 37 | public: 38 | 39 | /** Public key for the account **/ 40 | std::vector vchPubKey; 41 | 42 | 43 | //serialization methods 44 | IMPLEMENT_SERIALIZE 45 | ( 46 | if(!(nSerType & SER_GETHASH)) 47 | READWRITE(nSerVersion); 48 | 49 | READWRITE(vchPubKey); 50 | ) 51 | 52 | 53 | /** The default constructor. **/ 54 | Account(); 55 | 56 | 57 | /** Copy Constructor. **/ 58 | Account(const Account& account); 59 | 60 | 61 | /** Move Constructor. **/ 62 | Account(Account&& account) noexcept; 63 | 64 | 65 | /** Copy Assignment. **/ 66 | Account& operator=(const Account& account); 67 | 68 | 69 | /** Move Assignment. **/ 70 | Account& operator=(Account&& account) noexcept; 71 | 72 | 73 | /** Default Destructor **/ 74 | ~Account(); 75 | 76 | 77 | /** SetNull 78 | * 79 | * Clears the current public key value. 80 | * 81 | **/ 82 | void SetNull(); 83 | }; 84 | 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /src/Legacy/walletkey.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | namespace Legacy 17 | { 18 | /* Default Constructor */ 19 | WalletKey::WalletKey(const uint64_t nExpires) 20 | : vchPrivKey ( ) 21 | , nTimeCreated (nExpires ? runtime::unifiedtimestamp() : 0) 22 | , nTimeExpires (nExpires) 23 | , strComment ( ) 24 | { 25 | } 26 | 27 | 28 | /* Copy Constructor. */ 29 | WalletKey::WalletKey(const WalletKey& key) 30 | : vchPrivKey (key.vchPrivKey) 31 | , nTimeCreated (key.nTimeCreated) 32 | , nTimeExpires (key.nTimeExpires) 33 | , strComment (key.strComment) 34 | { 35 | } 36 | 37 | 38 | /* Move Constructor. */ 39 | WalletKey::WalletKey(WalletKey&& key) noexcept 40 | : vchPrivKey (std::move(key.vchPrivKey)) 41 | , nTimeCreated (std::move(key.nTimeCreated)) 42 | , nTimeExpires (std::move(key.nTimeExpires)) 43 | , strComment (std::move(key.strComment)) 44 | { 45 | } 46 | 47 | 48 | /* Copy Assignment. */ 49 | WalletKey& WalletKey::operator=(const WalletKey& key) 50 | { 51 | vchPrivKey = key.vchPrivKey; 52 | nTimeCreated = key.nTimeCreated; 53 | nTimeExpires = key.nTimeExpires; 54 | strComment = key.strComment; 55 | 56 | return *this; 57 | } 58 | 59 | 60 | /* Move Assignment. */ 61 | WalletKey& WalletKey::operator=(WalletKey&& key) noexcept 62 | { 63 | vchPrivKey = std::move(key.vchPrivKey); 64 | nTimeCreated = std::move(key.nTimeCreated); 65 | nTimeExpires = std::move(key.nTimeExpires); 66 | strComment = std::move(key.strComment); 67 | 68 | return *this; 69 | } 70 | 71 | 72 | /* Default Destructor */ 73 | WalletKey::~WalletKey() 74 | { 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/TAO/API/commands/finance/credit.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | 21 | /* Global TAO namespace. */ 22 | namespace TAO::API 23 | { 24 | /* Credit an incoming debit from recipient. */ 25 | encoding::json Finance::Credit(const encoding::json& jParams, const bool fHelp) 26 | { 27 | /* Get the transaction id. */ 28 | const uint512_t hashTx = 29 | ExtractHash(jParams); 30 | 31 | /* Extract some parameters from input data. */ 32 | const TAO::Register::Address hashCredit = 33 | ExtractAddress(jParams, "", "default"); 34 | 35 | /* Check for tritium credits. */ 36 | std::vector vContracts(0); 37 | if(!BuildContracts(jParams, hashTx, vContracts, BuildCredit)) 38 | throw Exception(-43, "No valid contracts in tx."); 39 | 40 | /* Build response JSON boilerplate. */ 41 | return BuildResponse(jParams, hashCredit, vContracts); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/TAO/API/commands/finance/void.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | /* Global TAO namespace. */ 23 | namespace TAO::API 24 | { 25 | /* Reverses a debit or transfer transaction that the caller has made */ 26 | encoding::json Finance::Void(const encoding::json& jParams, const bool fHelp) 27 | { 28 | /* Get the transaction id. */ 29 | const uint512_t hashTx = 30 | ExtractHash(jParams); 31 | 32 | /* Check for tritium credits. */ 33 | std::vector vContracts(0); 34 | if(!BuildContracts(jParams, hashTx, vContracts, BuildVoid)) 35 | throw Exception(-43, "No valid contracts in tx."); 36 | 37 | /* Build response JSON boilerplate. */ 38 | return BuildResponse(jParams, vContracts); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/TAO/API/commands/invoices/json.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | /* Global TAO namespace. */ 17 | namespace TAO::API 18 | { 19 | /* Returns the JSON representation of this invoice */ 20 | encoding::json Invoices::InvoiceToJSON(const TAO::Register::Object& rObject, const uint256_t& hashRegister) 21 | { 22 | /* The JSON to return */ 23 | encoding::json jRet = 24 | RegisterToJSON(rObject, hashRegister); 25 | 26 | /* Check for recipient to find status. */ 27 | if(jRet.find("json") != jRet.end()) 28 | { 29 | /* Get the recipient genesis hash from the invoice data so that we can use it to calculate the status*/ 30 | const uint256_t hashRecipient = 31 | uint256_t(jRet["json"]["recipient"].get()); 32 | 33 | /* Add status */ 34 | jRet["json"]["status"] = get_status(rObject, hashRecipient); 35 | } 36 | 37 | return jRet; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/TAO/API/commands/ledger/get-block-hash.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | /* Global TAO namespace. */ 34 | namespace TAO::API 35 | { 36 | /* Retrieves the blockhash for the given height. */ 37 | encoding::json Ledger::GetBlockHash(const encoding::json& jParams, const bool fHelp) 38 | { 39 | /* Check that the node is configured to index blocks by height */ 40 | if(!config::GetBoolArg("-indexheight")) 41 | throw Exception(-79, "[getblockhash] requires the daemon to be started with the -indexheight flag."); 42 | 43 | /* Convert the incoming height string to an int*/ 44 | const uint32_t nHeight = 45 | ExtractInteger(jParams, "height", TAO::Ledger::ChainState::nBestHeight.load()); 46 | 47 | /* Read the block state from the the ledger DB using the height index */ 48 | TAO::Ledger::BlockState tBlock; 49 | if(!LLD::Ledger->ReadBlock(nHeight, tBlock)) 50 | throw Exception(-83, "Block not found"); 51 | 52 | /* Build our response. */ 53 | const encoding::json jRet = 54 | {{ "hash", tBlock.GetHash().GetHex() }}; 55 | 56 | return jRet; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/TAO/API/commands/local/erase.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | /* Global TAO namespace. */ 20 | namespace TAO::API 21 | { 22 | /* Check that a record exists in local database */ 23 | encoding::json Local::Erase(const encoding::json& jParams, const bool fHelp) 24 | { 25 | /* Check for our parameters. */ 26 | if(!CheckParameter(jParams, "table", "string")) 27 | throw Exception(-81, "missing or invalid parameter [table=string]"); 28 | 29 | /* Get our table to list items from. */ 30 | const std::string& strTable = 31 | jParams["table"].get(); 32 | 33 | /* Check for our parameters. */ 34 | if(!CheckParameter(jParams, "key", "string, number")) 35 | throw Exception(-81, "missing or invalid parameter [key=string]"); 36 | 37 | /* Get our table to list items from. */ 38 | const std::string& strKey = 39 | jParams["key"].is_number() ? debug::safe_printstr(jParams["key"].get()) : jParams["key"].get(); 40 | 41 | /* Check local database for record. */ 42 | return {{ "success", LLD::Local->EraseRecord(strTable, strKey) }}; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/TAO/API/commands/local/has.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | /* Global TAO namespace. */ 20 | namespace TAO::API 21 | { 22 | /* Check that a record exists in local database */ 23 | encoding::json Local::Has(const encoding::json& jParams, const bool fHelp) 24 | { 25 | /* Check for our parameters. */ 26 | if(!CheckParameter(jParams, "table", "string")) 27 | throw Exception(-81, "missing or invalid parameter [table=string]"); 28 | 29 | /* Get our table to list items from. */ 30 | const std::string& strTable = 31 | jParams["table"].get(); 32 | 33 | /* Check for our parameters. */ 34 | if(!CheckParameter(jParams, "key", "string, number")) 35 | throw Exception(-81, "missing or invalid parameter [key=string]"); 36 | 37 | /* Get our table to list items from. */ 38 | const std::string& strKey = 39 | jParams["key"].is_number() ? debug::safe_printstr(jParams["key"].get()) : jParams["key"].get(); 40 | 41 | /* Check local database for record. */ 42 | return {{ "exists", LLD::Local->HasRecord(strTable, strKey) }}; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/TAO/API/commands/local/push.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | /* Global TAO namespace. */ 20 | namespace TAO::API 21 | { 22 | /* Check that a record exists in local database */ 23 | encoding::json Local::Push(const encoding::json& jParams, const bool fHelp) 24 | { 25 | /* Check for our parameters. */ 26 | if(!CheckParameter(jParams, "table", "string")) 27 | throw Exception(-81, "missing or invalid parameter [table=string]"); 28 | 29 | /* Get our table to list items from. */ 30 | const std::string& strTable = 31 | jParams["table"].get(); 32 | 33 | /* Check for our parameters. */ 34 | if(!CheckParameter(jParams, "key", "string, number")) 35 | throw Exception(-81, "missing or invalid parameter [key=string]"); 36 | 37 | /* Get our table to list items from. */ 38 | const std::string& strKey = 39 | jParams["key"].is_number() ? debug::safe_printstr(jParams["key"].get()) : jParams["key"].get(); 40 | 41 | /* Check for our parameters. */ 42 | if(!CheckParameter(jParams, "value", "string")) 43 | throw Exception(-81, "missing or invalid parameter [value=string]"); 44 | 45 | /* Get our table to list items from. */ 46 | const std::string& strValue = 47 | jParams["value"].get(); 48 | 49 | /* Check local database for record. */ 50 | return {{ "success", LLD::Local->PushRecord(strTable, strKey, strValue) }}; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/TAO/API/commands/names/lookup.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | /* Global TAO namespace. */ 23 | namespace TAO::API 24 | { 25 | /* Cancel an active order in market. */ 26 | encoding::json Names::Lookup(const encoding::json& jParams, const bool fHelp) 27 | { 28 | /* Extract our address for name lookup. */ 29 | if(!CheckParameter(jParams, "address", "string")) 30 | throw Exception(-11, "Missing Parameter [address]"); 31 | 32 | /* Build our response object. */ 33 | const TAO::Register::Address hashAddress = 34 | TAO::Register::Address(jParams["address"].get()); 35 | 36 | /* Handle for NXS hardcoded token name. */ 37 | uint256_t hashName; 38 | if(!LLD::Logical->ReadPTR(hashAddress, hashName)) 39 | throw Exception(-22, "No PTR Record found: Address has no valid name index"); 40 | 41 | /* Get the name object now. */ 42 | TAO::Register::Object tName; 43 | if(!LLD::Register->ReadObject(hashName, tName)) 44 | throw Exception(-12, "Object does not exist"); 45 | 46 | /* Build our response object. */ 47 | encoding::json jRet = 48 | RegisterToJSON(tName, hashName); 49 | 50 | /* Filter out our expected fieldnames if specified. */ 51 | FilterFieldname(jParams, jRet); 52 | 53 | return jRet; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/TAO/API/commands/network/initialize.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | /* Global TAO namespace. */ 24 | namespace TAO::API 25 | { 26 | /* Standard initialization function. */ 27 | void Network::Initialize() 28 | { 29 | /* Populate our operators. */ 30 | Operators::Initialize(mapOperators); 31 | 32 | 33 | /* Handle for all LIST operations. */ 34 | mapFunctions["list"] = Function 35 | ( 36 | std::bind 37 | ( 38 | &Network::List, 39 | this, 40 | std::placeholders::_1, 41 | std::placeholders::_2 42 | ) 43 | , "node, peer" 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/TAO/API/commands/register/import.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | /* Global TAO namespace. */ 18 | namespace TAO::API 19 | { 20 | /* Copies objects of an API instance, indexed by our name. */ 21 | void Register::Import(const std::string& strAPI) 22 | { 23 | /* Catch if API doesn't exist. */ 24 | if(!Commands::Has(strAPI)) 25 | return; 26 | 27 | /* Copy our standards from given API objects. */ 28 | Commands::Instance(strAPI)->Export(mapStandards, strAPI); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/TAO/API/commands/sessions/terminate.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | /* Global TAO namespace. */ 25 | namespace TAO::API 26 | { 27 | /* Login to a user account. */ 28 | encoding::json Sessions::Terminate(const encoding::json& jParams, const bool fHelp) 29 | { 30 | /* Get the genesis-id. */ 31 | const uint256_t hashGenesis = 32 | Authentication::Caller(jParams); 33 | 34 | /* Check for an active session. */ 35 | if(!Authentication::Active(hashGenesis)) 36 | throw Exception(-234, "Session does not exist"); 37 | 38 | /* Check for authenticated sigchain. */ 39 | if(config::fMultiuser.load() && config::GetBoolArg("-terminateauth", true) && !Authentication::Authenticate(jParams)) 40 | throw Exception(-333, "Account failed to authenticate"); 41 | 42 | /* Stop stake minter if running. Minter ignores request if not running, so safe to just call both */ 43 | TAO::Ledger::StakeMinter::GetInstance().Stop(); 44 | 45 | /* Check if we have set to clear session too. */ 46 | if(ExtractBoolean(jParams, "clear") && LLD::Sessions) 47 | LLD::Sessions->EraseSession(hashGenesis); 48 | 49 | /* Terminate our session now. */ 50 | Authentication::Terminate(jParams); 51 | 52 | return BuildResponse(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/TAO/API/commands/system/lisp.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | 20 | /* Global TAO namespace. */ 21 | namespace TAO::API 22 | { 23 | /* Queries the lisp api and returns the EID's for this node. */ 24 | encoding::json System::LispEIDs(const encoding::json& jParams, const bool fHelp) 25 | { 26 | /* Build our return object. */ 27 | encoding::json jRet = encoding::json::array(); 28 | 29 | /* Query the LISP API. */ 30 | std::map mapEIDs = LLP::GetEIDs(); 31 | for(const auto& rEID : mapEIDs) 32 | { 33 | /* Build our EID object. */ 34 | encoding::json jEID = 35 | { 36 | { "instance-id", rEID.second.strInstanceID }, 37 | { "eid" , rEID.second.strAddress } 38 | }; 39 | 40 | /* Add our according RLOC's. */ 41 | encoding::json jRLOCs = encoding::json::array(); 42 | for(const auto& rRLOC : rEID.second.vRLOCs) 43 | { 44 | /* Add our RLOC data to ret. */ 45 | const encoding::json jRLOC = 46 | { 47 | { "interface", rRLOC.strInterface }, 48 | { "rloc-name", rRLOC.strRLOCName }, 49 | { "rloc" , rRLOC.strTranslatedRLOC } 50 | }; 51 | 52 | jRLOCs.push_back(jRLOC); 53 | } 54 | 55 | /* Add RLOC's to EID object. */ 56 | jEID["rlocs"] = jRLOCs; 57 | jRet.push_back(jEID); 58 | } 59 | 60 | return jRet; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/TAO/API/commands/templates/claim.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | 22 | /* Global TAO namespace. */ 23 | namespace TAO::API 24 | { 25 | /* Claim an incoming transfer from recipient. */ 26 | encoding::json Templates::Claim(const encoding::json& jParams, const bool fHelp) 27 | { 28 | /* Check for txid parameter. */ 29 | if(jParams.find("txid") == jParams.end()) 30 | throw Exception(-50, "Missing txid."); 31 | 32 | /* Get the transaction id. */ 33 | const uint512_t hashTx = 34 | uint512_t(jParams["txid"].get()); 35 | 36 | /* Check for tritium credits. */ 37 | std::vector vContracts(0); 38 | if(!BuildContracts(jParams, hashTx, vContracts, BuildClaim)) 39 | throw Exception(-43, "No valid contracts in tx."); 40 | 41 | /* Build response JSON boilerplate. */ 42 | return BuildResponse(jParams, vContracts); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/TAO/API/commands/templates/get.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /* Global TAO namespace. */ 26 | namespace TAO::API 27 | { 28 | /* Get the data from a digital asset */ 29 | encoding::json Templates::Get(const encoding::json& jParams, const bool fHelp) 30 | { 31 | /* Get the Register address. */ 32 | const TAO::Register::Address hashRegister = ExtractAddress(jParams); 33 | 34 | /* Get the token / account object. */ 35 | TAO::Register::Object tObject; 36 | if(!LLD::Register->ReadObject(hashRegister, tObject, TAO::Ledger::FLAGS::LOOKUP)) 37 | throw Exception(-13, "Object not found"); 38 | 39 | /* Now lets check our expected types match. */ 40 | if(!CheckStandard(jParams, tObject)) 41 | throw Exception(-49, "Unsupported type for name/address"); 42 | 43 | /* Build our response object. */ 44 | encoding::json jRet = 45 | StandardToJSON(jParams, tObject, hashRegister); 46 | 47 | /* Filter out our expected fieldnames if specified. */ 48 | FilterFieldname(jParams, jRet); 49 | 50 | return jRet; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/TAO/API/include/cmd.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_API_INCLUDE_CMD_H 16 | #define NEXUS_TAO_API_INCLUDE_CMD_H 17 | 18 | namespace TAO 19 | { 20 | namespace API 21 | { 22 | /** CommandLineAPI 23 | * 24 | * Executes an API call from the commandline. 25 | * 26 | * @param[in] argc The total input arguments. 27 | * @param[in] argv The argument characters. 28 | * 29 | **/ 30 | int CommandLineAPI(int argc, char** argv, int argn); 31 | 32 | 33 | /** CommandLineRPC 34 | * 35 | * Executes an RPC call from the commandline. 36 | * 37 | * @param[in] argc The total input arguments. 38 | * @param[in] argv The argument characters. 39 | * 40 | **/ 41 | int CommandLineRPC(int argc, char** argv, int argn); 42 | 43 | } 44 | 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/TAO/API/include/conditions.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | #pragma once 14 | 15 | #include 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | 22 | /** AddExpires 23 | * 24 | * Checks the params for the existence of the "expires" field. 25 | * 26 | * @param[in] params The parameters passed in the request 27 | * @param[in] hashCaller The genesis hash of the API caller 28 | * @param[in] contract The contract to add the conditions to 29 | * @param[in] fTokenizedDebit flag indicating if the contract is a debit to a tokenized asset 30 | * 31 | **/ 32 | void AddExpires(const encoding::json& params, const uint256_t& hashCaller, TAO::Operation::Contract& contract, bool fTokenizedDebit); 33 | 34 | 35 | /** AddVoid 36 | * 37 | * Creates a void contract for the specified transaction 38 | * 39 | * @param[in] contract The contract to void 40 | * @param[in] the ID of the contract in the transaction 41 | * @param[out] voidContract The void contract to be created 42 | * 43 | * @return True if a void contract was created. 44 | * 45 | **/ 46 | bool AddVoid(const TAO::Operation::Contract& contract, const uint32_t nContract, TAO::Operation::Contract &voidContract); 47 | 48 | }/* End TAO namespace */ 49 | -------------------------------------------------------------------------------- /src/TAO/API/include/contracts/verify.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #include 16 | 17 | /* Forward declarations. */ 18 | namespace TAO::Operation { class Contract; } 19 | 20 | 21 | /* Global TAO namespace. */ 22 | namespace TAO::API::Contracts 23 | { 24 | 25 | /** Verify 26 | * 27 | * Verify that a given contract is wel formed and the binary data matches pattern. 28 | * 29 | * @param[in] rContract The contract we are checking against. 30 | * 31 | * @return true if contract matches, false otherwise. 32 | * 33 | **/ 34 | bool Verify(const std::vector vByteCode, const TAO::Operation::Contract& rContract); 35 | } 36 | -------------------------------------------------------------------------------- /src/TAO/API/include/evaluate.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace TAO::Register { class Object; } 19 | 20 | namespace TAO::API 21 | { 22 | /** Evaluate Wildcard 23 | * 24 | * Checks a given string against value to find wildcard pattern matches. 25 | * 26 | * @param[in] strWildcard The wildcard statement we are checking against. 27 | * @param[in] strValue The value we are checking wildcard against. 28 | * 29 | * @return true if wildcard pattern was found in value. 30 | * 31 | **/ 32 | bool EvaluateWildcard(const std::string& strWildcard, const std::string& strValue); 33 | 34 | 35 | /** EvaluateResults 36 | * 37 | * Determines if an results JSON object should be included in a list based on given clause. 38 | * 39 | * @param[in] jClause The clause to check filter for. 40 | * @param[out] jCheck The JSON object we are checking for. 41 | * 42 | * @return true if the object should be included in the results. 43 | * 44 | **/ 45 | bool EvaluateResults(const encoding::json& jClause, encoding::json &jCheck); 46 | 47 | 48 | /** EvaluateObject 49 | * 50 | * Determines if an object should be included in a list based on given clause. 51 | * 52 | * @param[in] jClause The clause to check filter for. 53 | * @param[out] rObject The object we are checking for. 54 | * 55 | * @return true if the object should be included in the results. 56 | * 57 | **/ 58 | bool EvaluateObject(const encoding::json& jClause, TAO::Register::Object &rObject); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/TAO/API/include/execute.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | namespace TAO::Operation { class Contract; } 17 | namespace TAO::Register { class Object; } 18 | 19 | namespace TAO::API 20 | { 21 | /** ExecuteContract 22 | * 23 | * Extracts a register pre-state from contract and executes to get the final post-state 24 | * 25 | * @param[in] rContract The contract that we want to execute state for 26 | * 27 | * @return the modified register's post-state 28 | * 29 | **/ 30 | TAO::Register::Object ExecuteContract(const TAO::Operation::Contract& rContract); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/TAO/API/include/global.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace TAO::API 19 | { 20 | /** Initialize 21 | * 22 | * Instantiate global instances of the API. 23 | * 24 | **/ 25 | void Initialize(); 26 | 27 | 28 | /** Shutdown 29 | * 30 | * Delete global instances of the API. 31 | * 32 | **/ 33 | void Shutdown(); 34 | } 35 | -------------------------------------------------------------------------------- /src/TAO/API/include/results.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | 22 | /** ResultsToArray 23 | * 24 | * Convert a given json results queue into a compiled array of only values. 25 | * 26 | * @param[in] jParams The parameters that contain fieldname we are converting for. 27 | * @param[in] jResponse The object we are building array from. 28 | * @param[out] jArray The array we are building. 29 | * 30 | **/ 31 | void ResultsToArray(const encoding::json& jParams, const encoding::json& jResponse, encoding::json &jArray); 32 | 33 | 34 | /** ResultsToArray 35 | * 36 | * Convert a given json results queue into a compiled array of only values. 37 | * 38 | * @param[in] strField The fieldname we are converting for. 39 | * @param[in] jResponse The object we are building array from. 40 | * @param[out] jArray The array we are building. 41 | * 42 | * @return true if converted fields sucessfully. 43 | * 44 | **/ 45 | bool ResultsToArray(const std::string& strField, const encoding::json& jResponse, encoding::json &jArray); 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/TAO/API/operators/array.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | /* Global TAO namespace. */ 20 | namespace TAO::API 21 | { 22 | /* Get the data from a digital asset */ 23 | encoding::json Operators::Array(const encoding::json& jParams, const encoding::json& jResult) 24 | { 25 | /* Check if already in array form. */ 26 | if(jResult.is_array() && !jResult.empty() && jResult.back().is_primitive()) 27 | return jResult; 28 | 29 | /* Build our array object. */ 30 | encoding::json jRet = encoding::json::array(); 31 | for(const auto& jItem : jResult) 32 | ResultsToArray(jParams, jItem, jRet); 33 | 34 | return jRet; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/TAO/API/operators/count.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | /* Global TAO namespace. */ 20 | namespace TAO::API 21 | { 22 | /* Get the data from a digital asset */ 23 | encoding::json Operators::Count(const encoding::json& jParams, const encoding::json& jResult) 24 | { 25 | /* Build our array object. */ 26 | const encoding::json jRet = 27 | Operators::Array(jParams, jResult); 28 | 29 | return { {"count", jRet.size() }}; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/TAO/API/operators/floor.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | /* Global TAO namespace. */ 20 | namespace TAO::API 21 | { 22 | /* Get the data from a digital asset */ 23 | encoding::json Operators::Floor(const encoding::json& jParams, const encoding::json& jResult) 24 | { 25 | /* Build our array object. */ 26 | encoding::json jList = 27 | Operators::Array(jParams, jResult); 28 | 29 | /* Loop through our values to adjust to whole numbers. */ 30 | for(auto& jItem : jList) 31 | { 32 | /* Handle for floats. */ 33 | if(!jItem.is_number_float()) 34 | throw Exception(-123, "[", jItem.type_name(), "] unsupported for operator [floor]"); 35 | 36 | /* Adjust our values by triming at the integer's whole value. */ 37 | jItem = int64_t(jItem.get()); 38 | } 39 | 40 | return jList; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/commands/network.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** Network 22 | * 23 | * Network API Class. 24 | * Manages the function pointers for all Network commands. 25 | * 26 | **/ 27 | class Network : public Derived 28 | { 29 | public: 30 | 31 | /** Default Constructor. **/ 32 | Network() 33 | : Derived() 34 | { 35 | } 36 | 37 | 38 | /** Initialize. 39 | * 40 | * Sets the function pointers for this API. 41 | * 42 | **/ 43 | void Initialize() final; 44 | 45 | 46 | /** Name 47 | * 48 | * Returns the name of this API. 49 | * 50 | **/ 51 | static std::string Name() 52 | { 53 | return "network"; 54 | } 55 | 56 | 57 | /** List 58 | * 59 | * Lists network specific data related to nodes and node count 60 | * 61 | * @param[in] jParams The parameters from the API call. 62 | * @param[in] fHelp Trigger for help data. 63 | * 64 | * @return The return object in JSON. 65 | * 66 | **/ 67 | encoding::json List(const encoding::json& jParams, const bool fHelp); 68 | 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /src/TAO/API/types/commands/supply.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** Supply 22 | * 23 | * Supply API Class. 24 | * Manages the function pointers for all Supply commands. 25 | * 26 | **/ 27 | class Supply : public Derived 28 | { 29 | public: 30 | 31 | /** Default Constructor. **/ 32 | Supply() 33 | : Derived() 34 | { 35 | } 36 | 37 | 38 | /** Initialize. 39 | * 40 | * Sets the function pointers for this API. 41 | * 42 | **/ 43 | void Initialize() final; 44 | 45 | 46 | /** Name 47 | * 48 | * Returns the name of this API. 49 | * 50 | **/ 51 | static std::string Name() 52 | { 53 | return "supply"; 54 | } 55 | 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /src/TAO/API/types/commands/tokens.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** Assets 22 | * 23 | * Assets API Class. 24 | * Manages the function pointers for all Asset commands. 25 | * 26 | **/ 27 | class Tokens : public Derived 28 | { 29 | public: 30 | 31 | /** Default Constructor. **/ 32 | Tokens() 33 | : Derived() 34 | { 35 | Initialize(); 36 | } 37 | 38 | 39 | /** Initialize. 40 | * 41 | * Sets the function pointers for this API. 42 | * 43 | **/ 44 | void Initialize() override final; 45 | 46 | 47 | /** Name 48 | * 49 | * Returns the name of this API. 50 | * 51 | **/ 52 | static std::string Name() 53 | { 54 | return "tokens"; 55 | } 56 | 57 | 58 | /** ListTokenAccounts 59 | * 60 | * Lists all accounts that have been created for a particular token 61 | * 62 | * @param[in] jParams The parameters from the API call. 63 | * @param[in] fHelp Trigger for help data. 64 | * 65 | * @return The return object in JSON. 66 | * 67 | **/ 68 | encoding::json ListTokenAccounts(const encoding::json& jParams, const bool fHelp); 69 | 70 | }; 71 | } 72 | -------------------------------------------------------------------------------- /src/TAO/API/types/contracts/exchange.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #include 16 | 17 | #include 18 | 19 | /* Forward declarations. */ 20 | namespace TAO::Operation { class Contract; } 21 | 22 | /* Global TAO namespace. */ 23 | namespace TAO::API 24 | { 25 | /** Contracts::Exchange 26 | * 27 | * This creates a limited order that can be executed and exchanged. 28 | * 29 | **/ 30 | namespace Contracts::Exchange 31 | { 32 | 33 | /** Token 34 | * 35 | * An exchange contract that exchanges two tokens for one another. 36 | * 37 | **/ 38 | extern const std::vector> Token; 39 | 40 | 41 | /** Asset 42 | * 43 | * An exchange contract that exchanges a tokens for an asset. 44 | * 45 | **/ 46 | extern const std::vector Asset; 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/TAO/API/types/contracts/expiring.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #include 16 | 17 | #include 18 | 19 | /* Forward declarations. */ 20 | namespace TAO::Operation { class Contract; } 21 | 22 | /* Global TAO namespace. */ 23 | namespace TAO::API 24 | { 25 | /** Contracts::Expiring 26 | * 27 | * This contract allows the recipient a window of time to claim the contract, after which the recipient will no longer 28 | * be able to claim the funds, and they will return back to the sender. 29 | * 30 | **/ 31 | namespace Contracts::Expiring 32 | { 33 | 34 | /** Receiver 35 | * 36 | * An expiring contract that expires the receiver's ability to claim after a given time period. 37 | * 38 | **/ 39 | extern const std::vector> Receiver; 40 | 41 | 42 | /** Sender 43 | * 44 | * An expiring contract that expires the senders's ability to claim after a given time period. 45 | * 46 | **/ 47 | extern const std::vector Sender; 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/TAO/API/types/exception.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | #include 18 | 19 | /* Global TAO namespace. */ 20 | namespace TAO::API 21 | { 22 | /** Exception 23 | * 24 | * Encapsulates an exception that can be converted into a valid JSON error object 25 | * 26 | **/ 27 | class Exception : public encoding::detail::exception 28 | { 29 | public: 30 | 31 | /** Default Constructor **/ 32 | Exception(const int32_t nCode, const std::string& strMessage) 33 | : encoding::detail::exception(nCode, strMessage.c_str()) 34 | { 35 | } 36 | 37 | 38 | /** Variadic template constructor for building error strings. **/ 39 | template 40 | Exception(const int32_t nCode, Args&&... args) 41 | : encoding::detail::exception(nCode, debug::safe_printstr(args...).c_str()) 42 | { 43 | } 44 | 45 | 46 | /** ToJSON 47 | * 48 | * Converts this exception into a json object conforming to the JSON-RPC specification. 49 | * 50 | * @return the json object containing the exception code and message. 51 | * 52 | **/ 53 | encoding::json ToJSON() const 54 | { 55 | /* Include our global errors if applicable. */ 56 | std::string strMessage = std::string(what()); 57 | if(!debug::strLastError.empty()) 58 | strMessage += ". " + debug::GetLastError(); 59 | 60 | return { {"code", id }, {"message", strMessage} }; //no need to make another copy, so emplace our return value 61 | } 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/array.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Array 30 | * 31 | * Computes values into a single item array 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Array(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/count.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Count 30 | * 31 | * Gets the total size of the returned data-set 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Count(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/floor.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Round 30 | * 31 | * Rounds a float value into integer without decimals for using with other operators that may not need precision. 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Floor(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/initialize.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | class Operator; 22 | 23 | /** @namespace Operators 24 | * 25 | * Namespace to hold all available operators for use in commands routes. 26 | * 27 | **/ 28 | namespace Operators 29 | { 30 | 31 | /** Track what operators are currently supported by initialize. **/ 32 | extern const std::map mapSupported; 33 | 34 | 35 | /** Initialize 36 | * 37 | * Initialize a set of operators using a set series of string arguments in CSV format. 38 | * 39 | * @param[out] mapOperators The operators map to pass back to the host API command-set. 40 | * @param[in] strOperators List of operators that will be supported by this command. 41 | * 42 | **/ 43 | void Initialize(std::map &mapOperators, const std::string& strOperators = ""); 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/lookup.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Lookup 30 | * 31 | * Resolve a list of register addresses to their register components. 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Lookup(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/max.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Max 30 | * 31 | * Get's the largest value from an array container. 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Max(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/mean.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Mean 30 | * 31 | * Computes mean or average values into a single item array 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Mean(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/min.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Array 30 | * 31 | * Computes values into a single item array 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Min(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/mode.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Mode 30 | * 31 | * Get's the most occuring value in the sequence. Supports bi-modal, tri-modal, and multi-modal. 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Mode(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/API/types/operators/sum.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::API 20 | { 21 | /** @namespace Operators 22 | * 23 | * Namespace to hold all available operators for use in commands routes. 24 | * 25 | **/ 26 | namespace Operators 27 | { 28 | 29 | /** Sum 30 | * 31 | * Computes values list by addition. 32 | * 33 | * @param[in] jParams The input parameters to the command. 34 | * @param[in] jResult The list of objects to operate on. 35 | * 36 | * @return the json result of the operations. 37 | * 38 | **/ 39 | encoding::json Sum(const encoding::json& jParams, const encoding::json& jResult); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/TAO/Ledger/difficulty.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To The Voice of The People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | /* Global TAO namespace. */ 24 | namespace TAO::Ledger 25 | { 26 | /* Determines the Decimal of nBits per Channel for a decent "Frame of Reference". */ 27 | double GetDifficulty(uint32_t nBits, int32_t nChannel) 28 | { 29 | /* Prime Channel is just Decimal Held in Integer 30 | Multiplied and Divided by Significant Digits. */ 31 | if(nChannel == 1) 32 | return nBits / 10000000.0; 33 | 34 | /* Check for divide by zero. */ 35 | if(nBits == 0) 36 | return 0.0; 37 | 38 | /* Get the Proportion of the Bits First. */ 39 | double dDiff = (double)0x0000ffff / (double)(nBits & 0x00ffffff); 40 | 41 | /* Calculate where on Compact Scale Difficulty is. */ 42 | uint32_t nShift = nBits >> 24; 43 | 44 | /* Shift down if Position on Compact Scale is above 124. */ 45 | while(nShift > 124) 46 | { 47 | dDiff = dDiff / 256.0; 48 | --nShift; 49 | } 50 | 51 | /* Shift up if Position on Compact Scale is below 124. */ 52 | while(nShift < 124) 53 | { 54 | dDiff = dDiff * 256.0; 55 | ++nShift; 56 | } 57 | 58 | /* Offset the number by 64 to give larger starting reference. */ 59 | const uint64_t nFixed = 60 | ((dDiff * ((nChannel == 2) ? 64 : 1024 * 1024 * 256)) * 1000000); //this will give us 6 figures of precision 61 | 62 | return nFixed / 1000000.0; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/TAO/Ledger/genesis.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | /* Global TAO namespace. */ 20 | namespace TAO 21 | { 22 | 23 | /* Ledger Layer namespace. */ 24 | namespace Ledger 25 | { 26 | 27 | /* Default constructor. */ 28 | Genesis::Genesis() 29 | : uint256_t(0) 30 | { 31 | } 32 | 33 | 34 | /* Copy Constructor */ 35 | Genesis::Genesis(const uint256_t& value, bool fSet) 36 | : uint256_t(value) 37 | { 38 | if(fSet) 39 | SetType(GENESIS::UserType()); 40 | } 41 | 42 | 43 | /* Move Constructor */ 44 | Genesis::Genesis(uint256_t&& value) noexcept 45 | : uint256_t(std::move(value)) 46 | { 47 | } 48 | 49 | 50 | /* Copy Assignment operator. */ 51 | Genesis& Genesis::operator=(const uint256_t& value) 52 | { 53 | for(uint8_t i = 0; i < WIDTH; ++i) 54 | pn[i] = value.pn[i]; 55 | 56 | return *this; 57 | } 58 | 59 | 60 | /* Move Assignment operator. */ 61 | Genesis& Genesis::operator=(uint256_t&& value) noexcept 62 | { 63 | for(uint8_t i = 0; i < WIDTH; ++i) 64 | pn[i] = std::move(value.pn[i]); 65 | 66 | return *this; 67 | } 68 | 69 | 70 | /* Check if genesis has a valid indicator byte.*/ 71 | bool Genesis::IsValid() const 72 | { 73 | return GetType() == TAO::Ledger::GENESIS::UserType(); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/TAO/Ledger/include/difficulty.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To The Voice of The People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_LEDGER_INCLUDE_DIFFICULTY_H 16 | #define NEXUS_TAO_LEDGER_INCLUDE_DIFFICULTY_H 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO 20 | { 21 | 22 | /* Ledger Layer namespace. */ 23 | namespace Ledger 24 | { 25 | 26 | /** GetDifficulty 27 | * 28 | * Determines the Decimal of nBits per Channel for a decent "Frame of Reference". 29 | * Has no functionality in Network Operation. 30 | * 31 | * @param[in] nBits The bits to convert to double 32 | * @param[in] nChannel The channel to get difficulty for. 33 | * 34 | * @return the difficulty value. 35 | * 36 | **/ 37 | double GetDifficulty(uint32_t nBits, int nChannel); 38 | 39 | } 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/TAO/Ledger/include/dispatch.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To The Voice of The People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | /* Global TAO namespace. */ 27 | namespace TAO::Ledger 28 | { 29 | /** @class 30 | * 31 | * This class is responsible for dispatching events triggered by a new block. 32 | * These events could be best chain pointers, transactions, contracts, or other relevant data. 33 | * 34 | **/ 35 | class Dispatch : public Singleton 36 | { 37 | /** Queue to handle dispatch requests. **/ 38 | util::atomic::lock_unique_ptr> DISPATCH_QUEUE; 39 | 40 | 41 | /** Thread for running dispatch. **/ 42 | std::thread DISPATCH_THREAD; 43 | 44 | 45 | /** Condition variable to wake up the relay thread. **/ 46 | std::condition_variable CONDITION; 47 | 48 | 49 | public: 50 | 51 | /** Default Constructor. **/ 52 | Dispatch(); 53 | 54 | 55 | /** Default Destructor. **/ 56 | ~Dispatch(); 57 | 58 | 59 | /** PushRelay 60 | * 61 | * Dispatch a new block hash to relay thread. 62 | * 63 | * @param[in] hashBlock The block hash to dispatch. 64 | * 65 | **/ 66 | void PushRelay(const uint1024_t& hashBlock); 67 | 68 | 69 | /** Relay Thread 70 | * 71 | * Handle relays of all events for LLP when processing block. 72 | * 73 | **/ 74 | void Relay(); 75 | }; 76 | } 77 | -------------------------------------------------------------------------------- /src/TAO/Ledger/include/genesis_block.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_LEDGER_INCLUDE_GENESIS_H 16 | #define NEXUS_TAO_LEDGER_INCLUDE_GENESIS_H 17 | 18 | #include 19 | 20 | /* Global TAO namespace. */ 21 | namespace TAO 22 | { 23 | 24 | /* Ledger Layer namespace. */ 25 | namespace Ledger 26 | { 27 | 28 | /** LegacyGenesis 29 | * 30 | * Creates the legacy genesis block. 31 | * 32 | **/ 33 | const BlockState LegacyGenesis(); 34 | 35 | 36 | /** HybridGenesis 37 | * 38 | * Creates the hybrid network genesis block. 39 | * 40 | **/ 41 | const BlockState HybridGenesis(); 42 | 43 | 44 | /** TritiumGenesis 45 | * 46 | * Creates the tritium genesis block which is the first Tritium block mined. 47 | * 48 | **/ 49 | const BlockState TritiumGenesis(); 50 | } 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/TAO/Operation/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/src/TAO/Operation/.gitkeep -------------------------------------------------------------------------------- /src/TAO/Operation/include/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/src/TAO/Operation/include/.gitkeep -------------------------------------------------------------------------------- /src/TAO/Operation/include/coinbase.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_OPERATION_INCLUDE_COINBASE_H 16 | #define NEXUS_TAO_OPERATION_INCLUDE_COINBASE_H 17 | 18 | #include 19 | 20 | /* Global TAO namespace. */ 21 | namespace TAO 22 | { 23 | 24 | 25 | /* Operation Layer namespace. */ 26 | namespace Operation 27 | { 28 | 29 | /* Forward declarations. */ 30 | class Contract; 31 | 32 | 33 | /** Append 34 | * 35 | * Namespace to contain main functions for OP::APPEND 36 | * 37 | **/ 38 | namespace Coinbase 39 | { 40 | 41 | /** Commit 42 | * 43 | * Commit the final state to disk. 44 | * 45 | * @param[in] state The state to commit. 46 | * @param[in] hashAddress The register address to commit. 47 | * @param[in] hashTx The transaction that is calling coinbase 48 | * @param[in] nFlags Flags to the LLD instance. 49 | * 50 | * @return true if successful. 51 | * 52 | **/ 53 | bool Commit(const uint256_t& hashAddress, const uint512_t& hashTx, const uint8_t nFlags); 54 | 55 | 56 | /** Verify 57 | * 58 | * Verify append validation rules and caller. 59 | * 60 | * @param[in] contract The contract to verify. 61 | * 62 | * @return true if successful. 63 | * 64 | **/ 65 | bool Verify(const Contract& contract); 66 | } 67 | } 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/TAO/Operation/include/constants.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_OPERATION_INCLUDE_CONSTANTS_H 16 | #define NEXUS_TAO_OPERATION_INCLUDE_CONSTANTS_H 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO 20 | { 21 | 22 | /* Register Layer namespace. */ 23 | namespace Operation 24 | { 25 | 26 | /** The 'free' limit for conditions. **/ 27 | const uint64_t CONDITION_LIMIT_FREE = 4096; 28 | 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/TAO/Operation/include/cost.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_OPERATION_INCLUDE_COST_H 16 | #define NEXUS_TAO_OPERATION_INCLUDE_COST_H 17 | 18 | #include 19 | 20 | /* Global TAO namespace. */ 21 | namespace TAO 22 | { 23 | /* Operation Layer namespace. */ 24 | namespace Operation 25 | { 26 | 27 | /* Forward declarations. */ 28 | class Contract; 29 | 30 | 31 | /** Cost 32 | * 33 | * Run the contract for costs only. 34 | * 35 | * @param[in] contract The contract to get costs for. 36 | * @param[out] nCost The total cost for this contract. 37 | * 38 | **/ 39 | void Cost(const Contract& contract, uint64_t &nCost); 40 | 41 | 42 | /** TxCost 43 | * 44 | * Calculates the transaction cost for including this contract in a transaction. This method gives us the ability to 45 | * modulate the transaction cost depending on the contract type, for example to have no costs for credit or claim contracts. 46 | * 47 | * @param[in] contract The contract to get the transaction cost for. 48 | * @param[out] nCost The transaction cost for this contract. 49 | * 50 | **/ 51 | void TxCost(const Contract& contract, uint64_t &nCost); 52 | 53 | } 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/TAO/Operation/include/execute.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO::Operation 20 | { 21 | 22 | /* Forward declarations. */ 23 | class Contract; 24 | 25 | 26 | /** Execute 27 | * 28 | * Executes a given contract based on given flags 29 | * 30 | * @param[in] contract The contract to execute 31 | * @param[in] nFlags The flags to execute with. 32 | * 33 | * @return True if operations executed successfully, false otherwise. 34 | * 35 | **/ 36 | bool Execute(const Contract& contract, const uint8_t nFlags); 37 | 38 | 39 | /** Execute 40 | * 41 | * Executes a given contract and calculates its cost 42 | * 43 | * @param[in] contract The contract to execute 44 | * @param[in] nFlags The flags to execute with. 45 | * @param[out] nCost The calculated cost to execute this contract 46 | * 47 | * @return True if operations executed successfully, false otherwise. 48 | * 49 | **/ 50 | bool Execute(const Contract& contract, const uint8_t nFlags, uint64_t &nCost); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/TAO/Register/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/src/TAO/Register/.gitkeep -------------------------------------------------------------------------------- /src/TAO/Register/include/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/src/TAO/Register/include/.gitkeep -------------------------------------------------------------------------------- /src/TAO/Register/include/build.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_REGISTER_INCLUDE_BUILD_H 16 | #define NEXUS_TAO_REGISTER_INCLUDE_BUILD_H 17 | 18 | #include 19 | 20 | #include 21 | 22 | /* Global TAO namespace. */ 23 | namespace TAO 24 | { 25 | /* Operation layer. */ 26 | namespace Operation 27 | { 28 | /* Forward declarations. */ 29 | class Contract; 30 | } 31 | 32 | 33 | /* Register Layer namespace. */ 34 | namespace Register 35 | { 36 | /* Forward declarations. */ 37 | class State; 38 | 39 | 40 | /** Build 41 | * 42 | * Build the pre-states and post-state checksums for a contract. 43 | * 44 | * @param[out] contract The contract to calculate for 45 | * @param[out] mapStates The temporary states if pre-states rely on previous contracts. 46 | * @param[in] nFlags The flags to define block, memory, or conflict tree 47 | * 48 | * @return true if verified correctly, false otherwise. 49 | * 50 | **/ 51 | bool Build(TAO::Operation::Contract& contract, std::map& mapStates, const uint8_t nFlags = TAO::Ledger::FLAGS::MEMPOOL); 52 | 53 | } 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/TAO/Register/include/names.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_REGISTER_INCLUDE_UTILS_H 16 | #define NEXUS_TAO_REGISTER_INCLUDE_UTILS_H 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | 25 | /* Global TAO namespace. */ 26 | namespace TAO 27 | { 28 | 29 | /* Register Layer namespace. */ 30 | namespace Register 31 | { 32 | 33 | /** GetNameRegister 34 | * 35 | * Retrieve the name register for a namespace/name combination. 36 | * 37 | * @param[in] hashNamespace 38 | * @param[in] strName 39 | * @param[out] nameRegister 40 | * 41 | * @return true if register retrieved successfully 42 | * 43 | **/ 44 | bool GetNameRegister(const uint256_t& hashNamespace, const std::string& strName, Object& nameRegister); 45 | 46 | 47 | /** GetNamespaceRegister 48 | * 49 | * Retrieve the namespace register by namespace name. 50 | * 51 | * @param[in] strName 52 | * @param[out] nameRegister 53 | * 54 | * @return true if register retrieved successfully 55 | * 56 | **/ 57 | bool GetNamespaceRegister(const std::string& strNamespace, Object& namespaceRegister); 58 | 59 | 60 | } 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/TAO/Register/include/rollback.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_REGISTER_INCLUDE_ROLLBACK_H 16 | #define NEXUS_TAO_REGISTER_INCLUDE_ROLLBACK_H 17 | 18 | /* Global TAO namespace. */ 19 | namespace TAO 20 | { 21 | 22 | /* Register layer. */ 23 | namespace Operation 24 | { 25 | /* Forward declarations. */ 26 | class Contract; 27 | } 28 | 29 | /* Register Layer namespace. */ 30 | namespace Register 31 | { 32 | 33 | /** Rollback 34 | * 35 | * Rollback the current network state to register pre-states. 36 | * 37 | * @param[in] contract The contract to rollback to pre-states 38 | * @param[in] nFlags Ledger level flags to determine if memory or disk 39 | * 40 | * @return True if verified correctly, false otherwise. 41 | * 42 | **/ 43 | bool Rollback(const TAO::Operation::Contract& contract, const uint8_t nFlags = TAO::Ledger::FLAGS::BLOCK); 44 | } 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/TAO/Register/include/verify.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_REGISTER_INCLUDE_VERIFY_H 16 | #define NEXUS_TAO_REGISTER_INCLUDE_VERIFY_H 17 | 18 | #include 19 | 20 | #include 21 | 22 | /* Global TAO namespace. */ 23 | namespace TAO 24 | { 25 | 26 | /* Register layer. */ 27 | namespace Operation 28 | { 29 | /* Forward declarations. */ 30 | class Contract; 31 | } 32 | 33 | /* Register Layer namespace. */ 34 | namespace Register 35 | { 36 | class State; 37 | 38 | /** Verify 39 | * 40 | * Verify the pre-states of a register to current network state. 41 | * 42 | * @param[in] contract The contract to verify. 43 | * @param[out] mapStates The temporary states if pre-states rely on previous contracts. 44 | * @param[in] nFlags The flags to verify for. 45 | * 46 | * @return true if verified correctly, false otherwise. 47 | * 48 | **/ 49 | bool Verify(const TAO::Operation::Contract& contract, 50 | std::map& mapStates, const uint8_t nFlags = TAO::Ledger::FLAGS::BLOCK); 51 | 52 | } 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/TAO/Register/types/exception.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "If only you knew the magnificence of the 3, 6, and 9, then you 11 | would have a key to the universe" - Nikola Tesla 12 | 13 | ____________________________________________________________________________________________*/ 14 | 15 | #pragma once 16 | 17 | 18 | #include 19 | 20 | namespace TAO 21 | { 22 | 23 | namespace Register 24 | { 25 | /** BaseVmException 26 | * 27 | * Specialzed Exception so that we can capture exceptions originating from the BaseVM class 28 | * 29 | **/ 30 | class BaseVMException : public debug::exception 31 | { 32 | public: 33 | 34 | /** Constructor 35 | * 36 | * @param[in] args The variadic template for initialization. 37 | * 38 | **/ 39 | template 40 | BaseVMException(Args&&... args) : debug::exception(args...){} 41 | 42 | }; 43 | 44 | 45 | /** MalformedException 46 | * 47 | * Used to describe malformed conditions 48 | * 49 | **/ 50 | class MalformedException : public TAO::Register::BaseVMException 51 | { 52 | public: 53 | 54 | /** Constructor 55 | * 56 | * @param[in] args The variadic template for initialization. 57 | * 58 | **/ 59 | template 60 | MalformedException(Args&&... args) : BaseVMException(args...){} 61 | 62 | }; 63 | 64 | } /* End Register Namespace */ 65 | 66 | } /* End TAO Namespace */ -------------------------------------------------------------------------------- /src/TAO/Register/types/value.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_TAO_REGISTER_INCLUDE_VALUE_H 16 | #define NEXUS_TAO_REGISTER_INCLUDE_VALUE_H 17 | 18 | #include 19 | #include 20 | 21 | namespace TAO 22 | { 23 | 24 | namespace Register 25 | { 26 | 27 | /** Value 28 | * 29 | * An object that keeps track of a values positions in the register based VM. 30 | * 31 | **/ 32 | class Value 33 | { 34 | public: 35 | 36 | /** The memory starting value. **/ 37 | uint32_t nBegin; 38 | 39 | 40 | /** The memory ending value. **/ 41 | uint32_t nEnd; 42 | 43 | 44 | /** The bytes allocated in this register value. **/ 45 | uint16_t nBytes; 46 | 47 | 48 | /** Default constructor. **/ 49 | Value() 50 | : nBegin(0) 51 | , nEnd(0) 52 | { 53 | } 54 | 55 | 56 | /** Size (in 64-bit chunks) of value. **/ 57 | uint32_t size() const 58 | { 59 | return nEnd - nBegin; 60 | } 61 | 62 | 63 | /** Flag to check for null value. **/ 64 | bool null() const 65 | { 66 | return nBegin == 0 && nEnd == 0; 67 | } 68 | }; 69 | } 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/Util/include/daemon.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_UTIL_INCLUDE_DAEMON_H 16 | #define NEXUS_UTIL_INCLUDE_DAEMON_H 17 | 18 | #if !defined(WIN32) && !defined(QT_GUI) && !defined(NO_DAEMON) 19 | #include 20 | #include 21 | #endif 22 | 23 | 24 | /** Daemonize 25 | * 26 | * Daemonize by forking the parent process 27 | * 28 | **/ 29 | void Daemonize() 30 | { 31 | #if !defined(WIN32) && !defined(QT_GUI) && !defined(NO_DAEMON) 32 | 33 | 34 | pid_t pid = fork(); 35 | if(pid < 0) 36 | { 37 | debug::error(FUNCTION, "fork() returned ", pid, " errno ", errno); 38 | exit(EXIT_FAILURE); 39 | } 40 | if(pid > 0) 41 | { 42 | /* generate a pid file so that we can keep track of the forked process */ 43 | filesystem::CreatePidFile(filesystem::GetPidFile(), pid); 44 | 45 | /* Success: Let the parent terminate */ 46 | exit(EXIT_SUCCESS); 47 | } 48 | 49 | pid_t sid = setsid(); 50 | if(sid < 0) 51 | { 52 | debug::error(FUNCTION, "setsid() returned ", sid, " errno %d", errno); 53 | exit(EXIT_FAILURE); 54 | } 55 | 56 | debug::log(0, "Nexus server starting"); 57 | 58 | /* Set new file permissions */ 59 | umask(077); 60 | 61 | /* close stdin, stderr, stdout so that the tty no longer receives output */ 62 | if(int fdnull = open("/dev/null", O_RDWR)) 63 | { 64 | dup2 (fdnull, STDIN_FILENO); 65 | dup2 (fdnull, STDOUT_FILENO); 66 | dup2 (fdnull, STDERR_FILENO); 67 | close(fdnull); 68 | } 69 | else 70 | { 71 | debug::error(FUNCTION, "Failed to open /dev/null"); 72 | exit(EXIT_FAILURE); 73 | } 74 | #endif 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/Util/include/mutex.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_UTIL_INCLUDE_MUTEX_H 16 | #define NEXUS_UTIL_INCLUDE_MUTEX_H 17 | 18 | #include 19 | 20 | /* Macro preprocessor definitions for debug purposes. */ 21 | #define LOCK(mut) std::unique_lock lk(mut) 22 | #define LOCK2(mut) std::unique_lock lk2(mut) 23 | 24 | /* Variadic macro to support multiple locks in same macro. */ 25 | #define CRITICAL(...) std::scoped_lock __LOCK(__VA_ARGS__) 26 | #define RECURSIVE(...) std::scoped_lock __LOCK(__VA_ARGS__) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/Util/include/signals.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_UTIL_INCLUDE_SIGNALS_H 16 | #define NEXUS_UTIL_INCLUDE_SIGNALS_H 17 | 18 | 19 | #include 20 | 21 | 22 | extern std::condition_variable SHUTDOWN; 23 | 24 | /** Shutdown 25 | * 26 | * Shutdown the system and all its subsystems. 27 | * 28 | **/ 29 | void Shutdown(); 30 | 31 | 32 | /** HandleSIGTERM 33 | * 34 | * Catch Signal Handler function 35 | * 36 | * @param[in] signum the signal number 37 | * 38 | **/ 39 | void HandleSIGTERM(int signum); 40 | 41 | 42 | /** SetupSignals 43 | * 44 | * Setup the signal handlers. 45 | * 46 | **/ 47 | void SetupSignals(); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/Util/include/sorting.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | #ifndef NEXUS_UTIL_INCLUDE_SORTING_H 16 | #define NEXUS_UTIL_INCLUDE_SORTING_H 17 | 18 | #include 19 | #include 20 | 21 | 22 | /** alignup 23 | * 24 | * Align by increasing pointer, must have extra space at end of buffer 25 | * 26 | * @param[in] p Pointer to the buffer to align. 27 | * 28 | * @return Pointer to the aligned buffer 29 | * 30 | **/ 31 | template 32 | T* alignup(T* p) 33 | { 34 | union 35 | { 36 | T* ptr; 37 | size_t n; 38 | } u; 39 | u.ptr = p; 40 | u.n = (u.n + (nBytes-1)) & ~(nBytes-1); 41 | return u.ptr; 42 | } 43 | 44 | 45 | /** flip_map 46 | * 47 | * Create a sorted Multimap for rich lists. 48 | * 49 | * @param[in] src The source map to sort. 50 | * 51 | * @return Sorted multimap containing rich lists. 52 | * 53 | **/ 54 | template 55 | std::multimap flip_map(std::map & src) 56 | { 57 | std::multimap dst; 58 | for(typename std::map::const_iterator it = src.begin(); it != src.end(); ++it) 59 | dst.insert(std::pair(it -> second, it -> first)); 60 | 61 | return dst; 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/Util/memory.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | #include 14 | 15 | namespace memory 16 | { 17 | 18 | /** Compares two byte arrays and determines their signed equivalence byte for 19 | * byte. 20 | **/ 21 | int32_t compare(const uint8_t *a, const uint8_t *b, const uint64_t size) 22 | { 23 | for(uint64_t i = 0; i < size; ++i) 24 | { 25 | const uint8_t &ai = a[i]; 26 | const uint8_t &bi = b[i]; 27 | 28 | if(ai != bi) 29 | return ai - bi; 30 | } 31 | return 0; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Util/signals.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | std::condition_variable SHUTDOWN; 20 | 21 | /** Shutdown the system and all its subsystems. **/ 22 | void Shutdown() 23 | { 24 | config::fShutdown.store(true); 25 | SHUTDOWN.notify_all(); 26 | } 27 | 28 | 29 | /** Catch Signal Handler function **/ 30 | void HandleSIGTERM(int signum) 31 | { 32 | #ifndef WIN32 33 | if(signum != SIGPIPE) 34 | Shutdown(); 35 | #else 36 | if(signum != SIGINT) //catch this signal so Windoze can't terminate our process 37 | Shutdown(); 38 | #endif 39 | } 40 | 41 | 42 | /** Setup the signal handlers.**/ 43 | void SetupSignals() 44 | { 45 | /* Handle all the signals with signal handler method. */ 46 | #ifndef WIN32 47 | // Clean shutdown on SIGTERM 48 | struct sigaction sa; 49 | sa.sa_handler = HandleSIGTERM; 50 | sigemptyset(&sa.sa_mask); 51 | sa.sa_flags = 0; 52 | 53 | //catch all signals to flag fShutdown for all threads 54 | sigaction(SIGABRT, &sa, nullptr); 55 | sigaction(SIGILL, &sa, nullptr); 56 | sigaction(SIGINT, &sa, nullptr); 57 | sigaction(SIGTERM, &sa, nullptr); 58 | sigaction(SIGPIPE, &sa, nullptr); 59 | 60 | #else 61 | //catch all signals to flag fShutdown for all threads 62 | signal(SIGABRT, HandleSIGTERM); 63 | signal(SIGILL, HandleSIGTERM); 64 | signal(SIGINT, HandleSIGTERM); 65 | signal(SIGTERM, HandleSIGTERM); 66 | 67 | #ifdef SIGBREAK 68 | signal(SIGBREAK, HandleSIGTERM); 69 | #endif 70 | #endif 71 | } 72 | -------------------------------------------------------------------------------- /src/Util/templates/singleton.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | #include 19 | 20 | /** @class 21 | * 22 | * This class is a base class for any object that wants to use a singleton access pattern. 23 | * 24 | **/ 25 | template 26 | class Singleton 27 | { 28 | protected: 29 | 30 | /** Static instance pointer. **/ 31 | static std::atomic INSTANCE; 32 | 33 | public: 34 | 35 | /** Default Constructor. **/ 36 | Singleton() {} 37 | 38 | 39 | /** Default Destructor. **/ 40 | ~Singleton(){} 41 | 42 | 43 | /** Singleton instance. **/ 44 | static Type& Instance() 45 | { 46 | /* Check if instance needs to be initialized. */ 47 | if(Type::INSTANCE.load() == nullptr) 48 | throw debug::exception(FUNCTION, "instance not initialized"); 49 | 50 | return *INSTANCE.load(); 51 | } 52 | 53 | 54 | /** Singleton initialize instance. **/ 55 | static void Initialize() 56 | { 57 | /* Check if instance needs to be initialized. */ 58 | if(Type::INSTANCE.load() == nullptr) 59 | Type::INSTANCE.store(new Type()); 60 | } 61 | 62 | 63 | /** Singleton shutdown instance. **/ 64 | static void Shutdown() 65 | { 66 | /* Check if instance needs to be initialized. */ 67 | if(Type::INSTANCE.load() != nullptr) 68 | { 69 | /* Cleanup our pointers. */ 70 | delete Type::INSTANCE.load(); 71 | 72 | Type::INSTANCE.store(nullptr); 73 | } 74 | } 75 | }; 76 | 77 | /* Initialize our static instance. */ 78 | template 79 | std::atomic Singleton::INSTANCE; 80 | -------------------------------------------------------------------------------- /src/Util/templates/typename.h: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace util::types 19 | { 20 | /* Output the string names using type overloading to help with templates. */ 21 | inline std::string name(uint8_t n) { return "uint8_t"; } 22 | inline std::string name(uint16_t n) { return "uint16_t"; } 23 | inline std::string name(uint32_t n) { return "uint32_t"; } 24 | inline std::string name(uint64_t n) { return "uint64_t"; } 25 | inline std::string name(uint256_t n) { return "uint256_t"; } 26 | inline std::string name(uint512_t n) { return "uint512_t"; } 27 | inline std::string name(uint1024_t n) { return "uint1024_t"; } 28 | 29 | inline std::string name(int8_t n) { return "int8_t"; } 30 | inline std::string name(int16_t n) { return "int16_t"; } 31 | inline std::string name(int32_t n) { return "int32_t"; } 32 | inline std::string name(int64_t n) { return "int64_t"; } 33 | 34 | inline std::string name(float n) { return "float"; } 35 | inline std::string name(double n) { return "double"; } 36 | } 37 | -------------------------------------------------------------------------------- /tests/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/LLL-TAO/12832e245ba751d489122cab988cb6b7832922b7/tests/.gitkeep -------------------------------------------------------------------------------- /tests/bench/LLD/binary_key.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | 14 | TEST_CASE( "Binary Key LRU Benchmarks", "[LLD]") 15 | { 16 | debug::log(0, "===== Begin Binary Key LRU Benchmarks ====="); 17 | 18 | //benchmarks 19 | LLD::KeyLRU* cache = new LLD::KeyLRU(); 20 | uint256_t hash = LLC::GetRand256(); 21 | { 22 | runtime::timer timer; 23 | timer.Start(); 24 | 25 | for(int i = 0; i < 1000000; i++) 26 | { 27 | DataStream ssKey(SER_LLD, LLD::DATABASE_VERSION); 28 | ssKey << std::make_pair(std::string("data"), hash + i); 29 | 30 | cache->Put(ssKey.Bytes()); 31 | } 32 | 33 | uint64_t nTime = timer.ElapsedMicroseconds(); 34 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Put::", ANSI_COLOR_RESET, 1000000.0 / nTime, " million records / second"); 35 | } 36 | 37 | 38 | { 39 | runtime::timer timer; 40 | timer.Start(); 41 | 42 | for(int i = 0; i < 1000000; i++) 43 | { 44 | DataStream ssKey(SER_LLD, LLD::DATABASE_VERSION); 45 | ssKey << std::make_pair(std::string("data"), hash + i); 46 | 47 | cache->Has(ssKey.Bytes()); 48 | } 49 | 50 | uint64_t nTime = timer.ElapsedMicroseconds(); 51 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Has::", ANSI_COLOR_RESET, 1000000.0 / nTime, " million records / second"); 52 | } 53 | 54 | 55 | debug::log(0, "===== End Binary Key LRU Benchmarks =====\n"); 56 | } 57 | -------------------------------------------------------------------------------- /tests/bench/LLD/binary_lru.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | 14 | TEST_CASE( "Binary LRU Benchmarks", "[LLD]") 15 | { 16 | debug::log(0, "===== Begin Binary LRU Benchmarks ====="); 17 | 18 | //benchmarks 19 | LLD::BinaryLRU* cache = new LLD::BinaryLRU(); 20 | uint256_t hash = LLC::GetRand256(); 21 | { 22 | runtime::timer timer; 23 | timer.Start(); 24 | 25 | for(int i = 0; i < 1000000; i++) 26 | { 27 | DataStream ssKey(SER_LLD, LLD::DATABASE_VERSION); 28 | ssKey << std::make_pair(std::string("data"), hash + i); 29 | 30 | DataStream ssData(SER_LLD, LLD::DATABASE_VERSION); 31 | ssData << uint1024_t(4934943); 32 | 33 | cache->Put(ssKey.Bytes(), ssData.Bytes()); 34 | } 35 | 36 | uint64_t nTime = timer.ElapsedMicroseconds(); 37 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Put::", ANSI_COLOR_RESET, 1000000.0 / nTime, " million records / second"); 38 | } 39 | 40 | 41 | { 42 | runtime::timer timer; 43 | timer.Start(); 44 | 45 | for(int i = 0; i < 1000000; i++) 46 | { 47 | DataStream ssKey(SER_LLD, LLD::DATABASE_VERSION); 48 | ssKey << std::make_pair(std::string("data"), hash + i); 49 | 50 | std::vector vBytes; 51 | 52 | cache->Get(ssKey.Bytes(), vBytes); 53 | } 54 | 55 | uint64_t nTime = timer.ElapsedMicroseconds(); 56 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Get::", ANSI_COLOR_RESET, 1000000.0 / nTime, " million records / second"); 57 | } 58 | 59 | 60 | debug::log(0, "===== End Binary LRU Benchmarks =====\n"); 61 | } 62 | -------------------------------------------------------------------------------- /tests/bench/LLD/ledger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | 14 | TEST_CASE( "LLD Benchamrks", "[LLD]") 15 | { 16 | debug::log(0, "===== Begin Ledger Random Read / Write Benchmarks ====="); 17 | 18 | //benchmarks 19 | uint256_t hash = LLC::GetRand256(); 20 | { 21 | runtime::timer timer; 22 | timer.Start(); 23 | 24 | TAO::Ledger::BlockState state; 25 | for(int i = 0; i < 5000; i++) 26 | { 27 | LLD::Ledger->WriteBlock(uint1024_t(i), state); 28 | } 29 | 30 | uint64_t nTime = timer.ElapsedMicroseconds(); 31 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Put::", ANSI_COLOR_RESET, "5k records in ", nTime, " microseconds (", (5000000000) / nTime, ") per/s"); 32 | } 33 | 34 | 35 | { 36 | runtime::timer timer; 37 | timer.Start(); 38 | 39 | TAO::Ledger::BlockState state; 40 | for(int i = 0; i < 5000; i++) 41 | { 42 | LLD::Ledger->ReadBlock(uint1024_t(i), state); 43 | } 44 | 45 | uint64_t nTime = timer.ElapsedMicroseconds(); 46 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Get::", ANSI_COLOR_RESET, "5k records in ", nTime, " microseconds (", (5000000000) / nTime, ") per/s"); 47 | } 48 | 49 | 50 | debug::log(0, "===== End Ledger Random Read / Write Benchmarks =====\n"); 51 | 52 | 53 | debug::log(0, "===== Begin Ledger Sequential Read Benchmarks ====="); 54 | 55 | 56 | { 57 | runtime::timer timer; 58 | timer.Start(); 59 | 60 | std::vector vStates; 61 | LLD::Ledger->BatchRead("block", vStates, 5000); 62 | 63 | uint64_t nTime = timer.ElapsedMicroseconds(); 64 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Get::", ANSI_COLOR_RESET, vStates.size(), " records in ", nTime, " microseconds (", (vStates.size() * 1000000) / nTime, ") per/s"); 65 | } 66 | 67 | 68 | debug::log(0, "===== End Ledger Sequential Read Benchmarks =====\n"); 69 | } 70 | -------------------------------------------------------------------------------- /tests/bench/LLD/register.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | 14 | TEST_CASE( "LLD Benchamrks", "[LLD]") 15 | { 16 | debug::log(0, "===== Begin Register Random Read / Write Benchmarks ====="); 17 | 18 | //benchmarks 19 | uint256_t hash = LLC::GetRand256(); 20 | { 21 | runtime::timer timer; 22 | timer.Start(); 23 | 24 | TAO::Ledger::BlockState state; 25 | for(int i = 0; i < 100000; i++) 26 | LLD::Ledger->WriteBlock(uint1024_t(i), state); 27 | 28 | uint64_t nTime = timer.ElapsedMilliseconds(); 29 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Put::", ANSI_COLOR_RESET, "10k records in ", nTime, "ms (", (100000000) / nTime, ") per/s"); 30 | } 31 | 32 | 33 | { 34 | runtime::timer timer; 35 | timer.Start(); 36 | 37 | TAO::Ledger::BlockState state; 38 | for(int i = 0; i < 100000; i++) 39 | LLD::Ledger->ReadBlock(uint1024_t(i), state); 40 | 41 | uint64_t nTime = timer.ElapsedMilliseconds(); 42 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Get::", ANSI_COLOR_RESET, "10k records in ", nTime, "ms (", (100000000) / nTime, ") per/s"); 43 | } 44 | 45 | 46 | debug::log(0, "===== End Ledger Random Read / Write Benchmarks =====\n"); 47 | } 48 | -------------------------------------------------------------------------------- /tests/bench/LLD/template_lru.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | 14 | TEST_CASE( "Template LRU Benchmarks", "[LLD]") 15 | { 16 | debug::log(0, "===== Begin Template LRU Benchmarks ====="); 17 | 18 | //benchmarks 19 | LLD::TemplateLRU* cache = new LLD::TemplateLRU(1024); 20 | 21 | uint256_t hash = LLC::GetRand256(); 22 | { 23 | runtime::timer timer; 24 | timer.Start(); 25 | 26 | for(int i = 0; i < 1000000; i++) 27 | { 28 | cache->Put(hash + i, std::string("data")); 29 | } 30 | 31 | uint64_t nTime = timer.ElapsedMicroseconds(); 32 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Put::", ANSI_COLOR_RESET, 1000000.0 / nTime, " million records / second"); 33 | } 34 | 35 | 36 | { 37 | runtime::timer timer; 38 | timer.Start(); 39 | 40 | for(int i = 0; i < 1000000; i++) 41 | { 42 | std::string str; 43 | cache->Get(hash + i, str); 44 | } 45 | 46 | uint64_t nTime = timer.ElapsedMicroseconds(); 47 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Get::", ANSI_COLOR_RESET, 1000000.0 / nTime, " million records / second"); 48 | } 49 | 50 | 51 | debug::log(0, "===== End Template LRU Benchmarks =====\n"); 52 | } 53 | -------------------------------------------------------------------------------- /tests/bench/TAO/Ledger/sigchain.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | TEST_CASE( "Signature Chain Benchmarks", "[ledger]") 8 | { 9 | 10 | debug::log(0, "===== Begin Signature Chain Benchmarks ====="); 11 | 12 | runtime::timer bench; 13 | bench.Reset(); 14 | TAO::Ledger::Credentials user = TAO::Ledger::Credentials("user", "password"); 15 | 16 | //time output 17 | uint64_t nTime = bench.ElapsedMilliseconds(); 18 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Genesis::", ANSI_COLOR_RESET, "Created in ", nTime, " ms"); 19 | 20 | user.Genesis(); 21 | 22 | bench.Reset(); 23 | user.Generate(0, "pin"); 24 | 25 | //time output 26 | nTime = bench.ElapsedMilliseconds(); 27 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "Generate::", ANSI_COLOR_RESET, "Created in ", nTime, " ms"); 28 | 29 | debug::log(0, "===== End Signature Chain Benchmarks =====\n"); 30 | } 31 | -------------------------------------------------------------------------------- /tests/bench/TAO/Operation/create.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | 14 | 15 | 16 | TEST_CASE( "OP::CREATE Benchmarks", "[operation]") 17 | { 18 | using namespace TAO::Operation; 19 | 20 | debug::log(0, "===== Begin OP::CREATE Benchmarks ====="); 21 | 22 | { 23 | std::vector vData(32, 0xff); 24 | 25 | std::vector vTx; 26 | for(int i = 0; i < 10000; ++i) 27 | { 28 | TAO::Ledger::Transaction tx; 29 | tx.hashGenesis = LLC::GetRand256(); 30 | tx[0] << uint8_t(OP::CREATE) << LLC::GetRand256() << uint8_t(TAO::Register::REGISTER::READONLY) << vData; 31 | 32 | REQUIRE(tx.Build()); 33 | 34 | vTx.push_back(tx); 35 | } 36 | 37 | 38 | //Benchmark of 10,000 executions 39 | runtime::timer bench; 40 | bench.Reset(); 41 | { 42 | LLD::TxnBegin(); 43 | for(int i = 0; i < vTx.size(); ++i) 44 | { 45 | REQUIRE(vTx[i].Connect(TAO::Ledger::FLAGS::MEMPOOL)); 46 | } 47 | LLD::TxnCommit(); 48 | } 49 | 50 | //time output 51 | uint64_t nTime = bench.ElapsedMilliseconds(); 52 | debug::log(0, ANSI_COLOR_BRIGHT_CYAN, "OP::CREATE", ANSI_COLOR_RESET, " Processed ", 10000000.0 / nTime, " ops / second"); 53 | } 54 | 55 | debug::log(0, "===== End OP::CREATE Benchmarks =====\n"); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /tests/bench/main.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | TEST_CASE("Arguments Tests", "[args]") 23 | { 24 | config::fTestNet = true; 25 | config::mapArgs["-testnet"] = "92349234"; 26 | 27 | REQUIRE(config::fTestNet.load() == true); 28 | REQUIRE(config::GetArg("-testnet", 0) == 92349234); 29 | 30 | //get the data directory 31 | std::string strPath = config::GetDataDir(); 32 | 33 | //test the filesystem remove and also clear from previous unit tests 34 | if(filesystem::exists(strPath)) 35 | { 36 | REQUIRE(filesystem::remove_directories(strPath)); 37 | REQUIRE_FALSE(filesystem::exists(strPath)); 38 | } 39 | 40 | //create LLD instances 41 | LLD::Contract = new LLD::ContractDB(LLD::FLAGS::CREATE | LLD::FLAGS::FORCE); 42 | LLD::Register = new LLD::RegisterDB(LLD::FLAGS::CREATE | LLD::FLAGS::FORCE); 43 | LLD::Local = new LLD::LocalDB(LLD::FLAGS::CREATE | LLD::FLAGS::FORCE); 44 | LLD::Ledger = new LLD::LedgerDB( 45 | LLD::FLAGS::CREATE | LLD::FLAGS::WRITE, 46 | 256 * 256 * 16, 47 | 4 * 1024 * 1024); 48 | 49 | LLD::Trust = new LLD::TrustDB(LLD::FLAGS::CREATE | LLD::FLAGS::FORCE); 50 | LLD::Legacy = new LLD::LegacyDB(LLD::FLAGS::CREATE | LLD::FLAGS::FORCE); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /tests/smoke/api/api_call.sh: -------------------------------------------------------------------------------- 1 | echo "========"$1"========" 2 | ../../../nexus $* 3 | echo " " 4 | -------------------------------------------------------------------------------- /tests/smoke/api/finance.sh: -------------------------------------------------------------------------------- 1 | ./api_call.sh users/login/user/bob password=bob pin=1234 2 | 3 | #Create a new NXS account called savings for Bob (note PIN is required) 4 | ./api_call.sh finance/create/account name=savings pin=1234 5 | 6 | ./api_call.sh users/logout/user/bob password=bob pin=1234 7 | 8 | ./api_call.sh users/login/user/jack password=jack pin=1234 9 | 10 | #Create a new NXS account called savings for Jack (note PIN is required) 11 | ./api_call.sh finance/create/account name=savings pin=1234 12 | 13 | #Send (debit) 10 NXS from your default account to savings 14 | ./api_call.sh finance/debit/account/default amount=10 name_to=savings pin=1234 15 | 16 | #If you do NOT have the events processor running and configured to process debits, then this is how you create a credit to add the 17 | #funds from the debit transaction to your account. 18 | #the txid is the transaction ID of the debit transaction (available from notifications) 19 | ./api_call.sh finance/credit/account txid=ca2741d25a5f00f59ffe20f1d34cac71a2dedb547e83ed20a9d59c3812527c7356f7a5662bb0305dd2a4fc36b1596583d1922fdc615a25e69a8c36596370c3cd pin=1234 20 | 21 | #Send (debit) 10 NXS from your savings to bob's savings account 22 | ./api_call.sh finance/debit/account/savings amount=10 name_to=bob:savings pin=1234 23 | 24 | #Send (debit) 10 NXS from your savings to someone's account when they only provided the address not the name 25 | ./api_call.sh finance/debit/account/savings amount=10 address_to=a73b0598e1aabf97398fd02563f7074acd5292d493aaed2697f4e2037519bc20 pin=1234 26 | 27 | #List your NXS accounts 28 | ./api_call.sh finance/list/accounts 29 | 30 | #List a NXS account by name 31 | ./api_call.sh finance/get/account/default 32 | 33 | #Get a particular field (the balance in this case) from the account info 34 | ./api_call.sh finance/get/account/default/balance 35 | 36 | ./api_call.sh users/logout/user username=jack password=jack pin=1234 37 | -------------------------------------------------------------------------------- /tests/smoke/api/ledger.sh: -------------------------------------------------------------------------------- 1 | # Get block hash from height 2 | ./api_call.sh ledger/get/blockhash height=2 3 | 4 | #Get block data from height 5 | ./api_call.sh ledger/get/block height=2 6 | 7 | #Get block data from block hash 8 | ./api_call.sh ledger/get/block hash=ca9f6d89d3ab2f071686cb368682409386b5ba2d9bdc6dfffa64f84cf2016bf1df0538749f8ead32319460f28495dd887b824678336c7de1cca7c8764390c02276eb128eec7787418a2a689a432314a636d1925a43d1e6d5092ca02117cc18e6f73a44a2af3d5080d1386091f0260d77d397f381f4a525d8ffcf8be524a6ac75 9 | 10 | #List 100 blocks starting at height 1 11 | ./api_call.sh ledger/list/blocks height=1 limit=100 12 | 13 | #List the second page of 10 blocks starting at height 1 (blocks 21-30) 14 | ./api_call.sh ledger/list/blocks height=1 limit=10 page=2 15 | 16 | #Get transaction data by hash 17 | ./api_call.sh ledger/get/transaction hash=32104b0faac8c15bc5d7645f356e138297e7e6d7f8eadc3e8263d85adb30f42ec0880ab10e15a7ea2ff223f6a23e9f97a00bf2c4d393e658dec2b287bc0794d6 18 | 19 | #Get raw transaction binary data by hash 20 | ./api_call.sh ledger/get/transaction format=raw hash=32104b0faac8c15bc5d7645f356e138297e7e6d7f8eadc3e8263d85adb30f42ec0880ab10e15a7ea2ff223f6a23e9f97a00bf2c4d393e658dec2b287bc0794d6 21 | -------------------------------------------------------------------------------- /tests/smoke/api/supply.sh: -------------------------------------------------------------------------------- 1 | #Login 2 | ./api_call.sh users/login/user/jack password=jack pin=1234 3 | 4 | #Create a supply item with simple data 5 | ./api_call.sh supply/create/item name=item1 data=123456789 pin=1234 6 | 7 | #Retrieve an item by name 8 | ./api_call.sh supply/get/item/item1 9 | 10 | #Retrieve an item by address 11 | ./api_call.sh supply/get/item/ee0ec5255644f730a9574b6813b6de2e7a892253c039cac77cd9af0ffcac10b8 12 | 13 | #Update the item data 14 | ./api_call.sh supply/update/item/item1 data=987654321 pin=1234 15 | 16 | #View an item history 17 | ./api_call.sh supply/list/item/history/item1 18 | 19 | #Transfer an item to another user 20 | ./api_call.sh supply/transfer/item/item1 username=jack pin=1234 21 | 22 | #Claim an item transferred to you 23 | ./api_call.sh supply/claim/item txid=430a91929c003f577f8d3a8f6388287d5353df2c3aef4149d33b9de0564808abd12d2a14c4c056968e73bc1276f93bfbfff7d6e4eabbae801b9d76c5a1f65015 pin=1234 24 | 25 | #Logout 26 | ./api_call.sh users/logout/user/jack password=jack pin=1234 27 | -------------------------------------------------------------------------------- /tests/smoke/api/system.sh: -------------------------------------------------------------------------------- 1 | #Get system info 2 | ./api_call.sh system/get/info 3 | 4 | #Get peers 5 | ./api_call.sh system/list/peers 6 | -------------------------------------------------------------------------------- /tests/smoke/api/test.sh: -------------------------------------------------------------------------------- 1 | echo "====================================USERS=======================================" 2 | ./users.sh 3 | 4 | 5 | echo "====================================TOKENS======================================" 6 | ./tokens.sh 7 | 8 | 9 | echo "====================================ASSETS======================================" 10 | ./assets.sh 11 | 12 | 13 | echo "====================================SUPPLY======================================" 14 | ./supply.sh 15 | 16 | 17 | echo "====================================SYSTEM======================================" 18 | ./system.sh 19 | 20 | 21 | echo "====================================LEDGER======================================" 22 | ./ledger.sh 23 | 24 | 25 | #echo "====================================FINANCE=====================================" 26 | #./finance.sh 27 | -------------------------------------------------------------------------------- /tests/smoke/api/users.sh: -------------------------------------------------------------------------------- 1 | 2 | #Create 3 | ./api_call.sh users/create/user/paul password=paul pin=1234 4 | 5 | ./api_call.sh users/create/user/jack password=jack pin=1234 6 | 7 | ./api_call.sh users/create/user username=bob password=bob pin=1234 8 | 9 | #Login 10 | ./api_call.sh users/login/user/paul password=paul pin=1234 11 | 12 | #Unlock 13 | ./api_call.sh users/unlock/user/paul password=paul pin=1234 14 | 15 | #Lock 16 | ./api_call.sh users/lock/user/paul password=paul pin=1234 17 | 18 | #Logout 19 | ./api_call.sh users/logout/user/paul password=paul pin=1234 20 | 21 | #Login 22 | ./api_call.sh users/login/user/jack password=jack pin=1234 23 | 24 | #List your accounts (note that account names are only returned for the logged in user) 25 | ./api_call.sh users/list/accounts/jack 26 | 27 | #List someone elses accounts when you know their username 28 | ./api_call.sh users/list/accounts/paul 29 | 30 | #list someone elses account when you only know their genesis 31 | ./api_call.sh users/list/accounts/1ff463e036cbde3595fbe2de9dff15721a89e99ef3e2e9bfa7ce48ed825e9ec2 32 | 33 | #List your tokens 34 | ./api_call.sh users/list/tokens/jack 35 | 36 | #List your assets 37 | ./api_call.sh users/list/assets/jack 38 | 39 | #List your notifications (transactions you need to credit/claim) 40 | ./api_call.sh users/list/notifications/jack 41 | 42 | #Logout 43 | ./api_call.sh users/logout/user/jack password=jack pin=1234 44 | -------------------------------------------------------------------------------- /tests/smoke/examples/nexus.conf.publictestnet: -------------------------------------------------------------------------------- 1 | testnet=1 2 | unified=1 3 | listen=1 4 | stake=1 5 | server=1 6 | mining=1 7 | debug=1 8 | verbose=4 9 | rpcuser=therpcuser 10 | rpcpassword=ptCHANGEME89uhij4903i4ij 11 | rpcallowip=127.0.0.1 12 | daemon=1 13 | -------------------------------------------------------------------------------- /tests/smoke/mainnet-setup-for-debugger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Note, this does not clear the data dir - assumes you want to keep existing data for main net. 4 | 5 | NEXUS_TEST_MAIN=1 NEXUS_TEST_SETUP_ONLY=1 NEXUS_TEST_NO_DAEMON=1 ./run-start-nexus-test.sh 6 | -------------------------------------------------------------------------------- /tests/smoke/public-testnet-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Note, this does not clear the data dir - assumes you want to keep existing data for public test net. 4 | 5 | NEXUS_TEST_PUBLIC=1 NEXUS_TEST_SETUP_ONLY=0 NEXUS_TEST_NO_DAEMON=0 ./run-start-nexus-test.sh 6 | -------------------------------------------------------------------------------- /tests/smoke/setup-for-debugger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Quick script to setup nexus for step through debugging. 4 | 5 | NEXUS_TEST_CLEAR=1 NEXUS_TEST_SETUP_ONLY=1 NEXUS_TEST_NO_DAEMON=1 ./run-start-nexus-test.sh 6 | -------------------------------------------------------------------------------- /tests/smoke/setup-for-debugger2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Quick script to setup nexus for step through debugging. 4 | 5 | NEXUS_TEST_NODE_NUM=2 NEXUS_TEST_CLEAR=1 NEXUS_TEST_SETUP_ONLY=1 NEXUS_TEST_NO_DAEMON=1 ./run-start-nexus-test.sh 6 | -------------------------------------------------------------------------------- /tests/smoke/setup-two-local-test-nodes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Quick script to setup nexus for step through debugging. 4 | 5 | NEXUS_TEST_CLEAR=1 NEXUS_TEST_SETUP_ONLY=1 NEXUS_TEST_NO_DAEMON=1 ./run-start-nexus-test.sh 6 | 7 | NEXUS_TEST_NODE_NUM=2 NEXUS_TEST_CLEAR=1 NEXUS_TEST_SETUP_ONLY=1 NEXUS_TEST_NO_DAEMON=1 ./run-start-nexus-test.sh 8 | -------------------------------------------------------------------------------- /tests/smoke/start-local-testnet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -vex 4 | 5 | echo "starting local regression test nodes" 6 | 7 | cd /home/dev/nexustest 8 | 9 | cd testnet1 10 | 11 | ./run-test-nexus.sh & 12 | 13 | cd ../testnet2 14 | 15 | ./run-test-nexus.sh & 16 | 17 | cd $HOME/code/Nexus/qa/smoke 18 | 19 | ./startminerfortest.sh & 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /tests/smoke/startminerfortest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "starting miner for tests" 4 | 5 | ${HOME}/code/PrimeSoloMiner/miner localhost 8325 2 6 | -------------------------------------------------------------------------------- /tests/unit/LLP/trust_address.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | 18 | TEST_CASE( "LLP::TrustAddress", "[trust_address]") 19 | { 20 | LLP::TrustAddress a1, a2; 21 | 22 | a1.SetIP(std::string("192.168.0.1")); 23 | a1.SetPort(9325); 24 | 25 | a1.nConnected = 2; 26 | a1.nDropped = 1; 27 | a1.nFailed = 1; 28 | a1.nFails = 0; 29 | 30 | 31 | a2.SetIP(std::string("192.168.0.2")); 32 | a2.SetPort(8325); 33 | 34 | /* Testing Logical Not */ 35 | REQUIRE(a1 != a2); 36 | 37 | a1 = a2; 38 | 39 | /* Testing assignment and relational equivalance */ 40 | REQUIRE(a1 == a2); 41 | } 42 | -------------------------------------------------------------------------------- /tests/unit/TAO/Ledger/transaction.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | 16 | #include 17 | 18 | //test greater than operator 19 | TEST_CASE( "Transaction::operator>", "[ledger]" ) 20 | { 21 | TAO::Ledger::Transaction tx1, tx2; 22 | 23 | tx1.nSequence = 1; 24 | tx2.nSequence = 2; 25 | 26 | REQUIRE_FALSE(tx1 > tx2); 27 | REQUIRE(tx2 > tx1); 28 | } 29 | 30 | 31 | //test less than operator 32 | TEST_CASE( "Transaction::operator<", "[ledger]" ) 33 | { 34 | TAO::Ledger::Transaction tx1, tx2; 35 | 36 | tx1.nSequence = 1; 37 | tx2.nSequence = 2; 38 | 39 | REQUIRE(tx1 < tx2); 40 | REQUIRE_FALSE(tx2 < tx1); 41 | } 42 | -------------------------------------------------------------------------------- /tests/unit/Util/hex.cpp: -------------------------------------------------------------------------------- 1 | /*__________________________________________________________________________________________ 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014]++ 4 | 5 | (c) Copyright The Nexus Developers 2014 - 2025 6 | 7 | Distributed under the MIT software license, see the accompanying 8 | file COPYING or http://www.opensource.org/licenses/mit-license.php. 9 | 10 | "ad vocem populi" - To the Voice of the People 11 | 12 | ____________________________________________________________________________________________*/ 13 | 14 | #include 15 | #include 16 | 17 | TEST_CASE("Util hex tests", "[hex]") 18 | { 19 | std::string isAllHex = "0123456789ABCDEF"; 20 | std::string isNotAllHex = "!@#$%^&*()this is not all hex, but hey at least i tried"; 21 | 22 | /* Test the IsHex boolean function. */ 23 | REQUIRE(IsHex(isAllHex) == true); 24 | REQUIRE(IsHex(isNotAllHex) == false); 25 | 26 | 27 | 28 | } 29 | --------------------------------------------------------------------------------