├── .gitignore
├── COPYING.MD
├── Dockerfile.test
├── LICENSE
├── README.md
├── build
└── .gitkeep
├── create_dmg.sh
├── doc
├── README.md
├── bootstrap-linux-LLD.MD
├── build-centos
├── build-debian.MD
├── build-osx.MD
└── build-win.MD
├── makefile.cli
├── nexus-qt.pro
├── qa
└── smoke
│ ├── README.md
│ ├── examples
│ └── nexus.conf.publictestnet
│ ├── mainnet-setup-for-debugger.sh
│ ├── makefile.unix.test
│ ├── public-testnet-setup.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
├── release
├── macdeploy
│ ├── LICENSE
│ ├── background.png
│ ├── fancy.plist
│ ├── macdeployqtplus
│ └── notes.txt
└── qt_translations.py
├── src
├── LLD
│ ├── index.cpp
│ ├── index.h
│ ├── journal.h
│ ├── key.h
│ ├── keychain.cpp
│ ├── keychain.h
│ ├── sector.h
│ ├── transaction.h
│ ├── trustkeys.cpp
│ └── trustkeys.h
├── LLP
│ ├── client.h
│ ├── coreserver.h
│ ├── debug.h
│ ├── miningserver.h
│ ├── server.h
│ └── types.h
├── core
│ ├── block.cpp
│ ├── checkpoints.cpp
│ ├── core.h
│ ├── debug.cpp
│ ├── difficulty.cpp
│ ├── dispatch.cpp
│ ├── global.cpp
│ ├── kernel.cpp
│ ├── message.cpp
│ ├── mining.cpp
│ ├── prime.cpp
│ ├── release.cpp
│ ├── transaction.cpp
│ ├── unifiedtime.cpp
│ ├── unifiedtime.h
│ ├── version.cpp
│ └── version.h
├── hash
│ ├── Keccak-compact64.c
│ ├── KeccakDuplex.c
│ ├── KeccakDuplex.h
│ ├── KeccakF-1600-interface.h
│ ├── KeccakHash.c
│ ├── KeccakHash.h
│ ├── KeccakSponge.c
│ ├── KeccakSponge.h
│ ├── brg_endian.h
│ ├── brg_types.h
│ ├── crypto_hash.h
│ ├── skein.cpp
│ ├── skein.h
│ ├── skein_block.cpp
│ ├── skein_iv.h
│ ├── skein_port.h
│ ├── templates.h
│ └── uint1024.h
├── json
│ ├── LICENSE.txt
│ ├── json_spirit.h
│ ├── json_spirit_error_position.h
│ ├── json_spirit_reader.cpp
│ ├── json_spirit_reader.h
│ ├── json_spirit_reader_template.h
│ ├── json_spirit_stream_reader.h
│ ├── json_spirit_utils.h
│ ├── json_spirit_value.cpp
│ ├── json_spirit_value.h
│ ├── json_spirit_writer.cpp
│ ├── json_spirit_writer.h
│ └── json_spirit_writer_template.h
├── main.cpp
├── main.h
├── net
│ ├── addrman.cpp
│ ├── addrman.h
│ ├── net.cpp
│ ├── net.h
│ ├── netbase.cpp
│ ├── netbase.h
│ ├── protocol.cpp
│ ├── protocol.h
│ ├── rpcdump.cpp
│ ├── rpcserver.cpp
│ └── rpcserver.h
├── qt
│ ├── core
│ │ ├── gui.cpp
│ │ ├── gui.h
│ │ ├── guiconstants.h
│ │ ├── qtipcserver.cpp
│ │ ├── qtipcserver.h
│ │ ├── rpcconsole.cpp
│ │ ├── rpcconsole.h
│ │ ├── strings.cpp
│ │ ├── units.cpp
│ │ └── units.h
│ ├── dialogs
│ │ ├── aboutdialog.cpp
│ │ ├── aboutdialog.h
│ │ ├── askpassphrasedialog.cpp
│ │ ├── askpassphrasedialog.h
│ │ ├── editaddressdialog.cpp
│ │ ├── editaddressdialog.h
│ │ ├── optionsdialog.cpp
│ │ ├── optionsdialog.h
│ │ ├── qrcodedialog.cpp
│ │ ├── qrcodedialog.h
│ │ ├── sendcoinsdialog.cpp
│ │ ├── sendcoinsdialog.h
│ │ ├── transactiondescdialog.cpp
│ │ └── transactiondescdialog.h
│ ├── forms
│ │ ├── aboutdialog.ui
│ │ ├── addressbookpage.ui
│ │ ├── askpassphrasedialog.ui
│ │ ├── editaddressdialog.ui
│ │ ├── messagepage.ui
│ │ ├── overviewpage.ui
│ │ ├── qrcodedialog.ui
│ │ ├── rpcconsole.ui
│ │ ├── sendcoinsdialog.ui
│ │ ├── sendcoinsentry.ui
│ │ └── transactiondescdialog.ui
│ ├── locale
│ │ ├── nexus_ca_ES.ts
│ │ ├── nexus_cs.ts
│ │ ├── nexus_da.ts
│ │ ├── nexus_de.ts
│ │ ├── nexus_en.ts
│ │ ├── nexus_es.ts
│ │ ├── nexus_es_CL.ts
│ │ ├── nexus_et.ts
│ │ ├── nexus_eu_ES.ts
│ │ ├── nexus_fa.ts
│ │ ├── nexus_fa_IR.ts
│ │ ├── nexus_fi.ts
│ │ ├── nexus_fr_CA.ts
│ │ ├── nexus_fr_FR.ts
│ │ ├── nexus_he.ts
│ │ ├── nexus_hr.ts
│ │ ├── nexus_hu.ts
│ │ ├── nexus_it.ts
│ │ ├── nexus_lt.ts
│ │ ├── nexus_nb.ts
│ │ ├── nexus_nl.ts
│ │ ├── nexus_pl.ts
│ │ ├── nexus_pt_BR.ts
│ │ ├── nexus_ro_RO.ts
│ │ ├── nexus_ru.ts
│ │ ├── nexus_sk.ts
│ │ ├── nexus_sr.ts
│ │ ├── nexus_sv.ts
│ │ ├── nexus_tr.ts
│ │ ├── nexus_uk.ts
│ │ ├── nexus_zh_CN.ts
│ │ └── nexus_zh_TW.ts
│ ├── main-qt.cpp
│ ├── models
│ │ ├── addresstablemodel.cpp
│ │ ├── addresstablemodel.h
│ │ ├── clientmodel.cpp
│ │ ├── clientmodel.h
│ │ ├── optionsmodel.cpp
│ │ ├── optionsmodel.h
│ │ ├── transactiontablemodel.cpp
│ │ ├── transactiontablemodel.h
│ │ ├── walletmodel.cpp
│ │ └── walletmodel.h
│ ├── nexus.qrc
│ ├── pages
│ │ ├── addressbookpage.cpp
│ │ ├── addressbookpage.h
│ │ ├── messagepage.cpp
│ │ ├── messagepage.h
│ │ ├── overviewpage.cpp
│ │ └── overviewpage.h
│ ├── res
│ │ ├── icons
│ │ │ ├── add.png
│ │ │ ├── address-book.png
│ │ │ ├── clock1.png
│ │ │ ├── clock2.png
│ │ │ ├── clock3.png
│ │ │ ├── clock4.png
│ │ │ ├── clock5.png
│ │ │ ├── configure.png
│ │ │ ├── connect0_16.png
│ │ │ ├── connect1_16.png
│ │ │ ├── connect2_16.png
│ │ │ ├── connect3_16.png
│ │ │ ├── connect4_16.png
│ │ │ ├── edit.png
│ │ │ ├── editcopy.png
│ │ │ ├── editpaste.png
│ │ │ ├── export.png
│ │ │ ├── filesave.png
│ │ │ ├── history.png
│ │ │ ├── key.png
│ │ │ ├── lock_closed.png
│ │ │ ├── lock_open.png
│ │ │ ├── nexus.icns
│ │ │ ├── nexus.ico
│ │ │ ├── nexus.png
│ │ │ ├── nexus_testnet.png
│ │ │ ├── notsynced.png
│ │ │ ├── overview.png
│ │ │ ├── quit.png
│ │ │ ├── receive.png
│ │ │ ├── remove.png
│ │ │ ├── send.png
│ │ │ ├── synced.png
│ │ │ ├── toolbar.png
│ │ │ ├── toolbar_testnet.png
│ │ │ ├── transaction0.png
│ │ │ ├── transaction2.png
│ │ │ ├── tx_inout.png
│ │ │ ├── tx_input.png
│ │ │ ├── tx_mined.png
│ │ │ └── tx_output.png
│ │ ├── images
│ │ │ ├── about.png
│ │ │ ├── qrcode.png
│ │ │ └── splash.jpg
│ │ ├── movies
│ │ │ └── update_spinner.gif
│ │ ├── nexus-qt.rc
│ │ └── src
│ │ │ ├── bitcoin.svg
│ │ │ ├── clock1.svg
│ │ │ ├── clock2.svg
│ │ │ ├── clock3.svg
│ │ │ ├── clock4.svg
│ │ │ ├── clock5.svg
│ │ │ ├── clock_green.svg
│ │ │ ├── inout.svg
│ │ │ └── questionmark.svg
│ ├── util
│ │ ├── addressvalidator.cpp
│ │ ├── addressvalidator.h
│ │ ├── amountfield.cpp
│ │ ├── amountfield.h
│ │ ├── csvmodelwriter.cpp
│ │ ├── csvmodelwriter.h
│ │ ├── guiutil.cpp
│ │ ├── guiutil.h
│ │ ├── macdockiconhandler.h
│ │ ├── macdockiconhandler.mm
│ │ ├── monitoreddatamapper.cpp
│ │ ├── monitoreddatamapper.h
│ │ ├── notificator.cpp
│ │ ├── notificator.h
│ │ ├── qvalidatedlineedit.cpp
│ │ ├── qvalidatedlineedit.h
│ │ ├── qvaluecombobox.cpp
│ │ └── qvaluecombobox.h
│ └── wallet
│ │ ├── sendcoinsentry.cpp
│ │ ├── sendcoinsentry.h
│ │ ├── transactiondesc.cpp
│ │ ├── transactiondesc.h
│ │ ├── transactionfilterproxy.cpp
│ │ ├── transactionfilterproxy.h
│ │ ├── transactionrecord.cpp
│ │ ├── transactionrecord.h
│ │ ├── transactionview.cpp
│ │ └── transactionview.h
├── util
│ ├── allocators.h
│ ├── bignum.h
│ ├── compat.h
│ ├── mruset.h
│ ├── noui.cpp
│ ├── serialize.h
│ ├── strlcpy.h
│ ├── ui_interface.h
│ ├── util.cpp
│ └── util.h
└── wallet
│ ├── base58.h
│ ├── crypter.cpp
│ ├── crypter.h
│ ├── db.cpp
│ ├── db.h
│ ├── key.cpp
│ ├── key.h
│ ├── keystore.cpp
│ ├── keystore.h
│ ├── script.cpp
│ ├── script.h
│ ├── wallet.cpp
│ ├── wallet.h
│ ├── walletdb.cpp
│ └── walletdb.h
└── win_build.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | *.DS_Store
2 | *.o
3 | *.P
4 | *.bat
5 | *.exe
6 | *.Debug
7 | *.Release
8 | *.kate-swp
9 | *.db
10 | *.app
11 | *.dmg
12 | build/moc/
13 | build/ui/
14 | build/obj/
15 | dist/
16 | *.vscode
17 | *.qm
18 | Makefile
19 | Makefile.Debug
20 | Makefile.Release
21 | nexus
22 | qrc_nexus.cpp
23 |
--------------------------------------------------------------------------------
/COPYING.MD:
--------------------------------------------------------------------------------
1 | (c) Copyright Nexus Developers 2014 - 2017
2 |
3 | Some of the code in this software was written by Satoshi Nakamoto, and some
4 | was written by the Bitcoin Core Developers over the years of 2008 - 2012.
5 | Most of the code has been written by Videlicet and the Nexus Core Developers
6 | over the years of 2014 to 2017 with aim to provide backwards compatibility
7 | to upgrades in the Bitcoin protocol proving stability and security of new
8 | architectures to create opportunities for other currencies to enhance their
9 | technology. It is asked in light of this for those that wish to copy and learn
10 | from this source code to examine it carefully and learn thoroughly rather than
11 | doing a copy/paste. Add to the technology as we have added to the technology of
12 | Bitcoin and Crypto Currencies, and share it in effort to provide cooperation in
13 | technology that has the potential to reinvent the world as we know it.
14 |
15 |
16 | The MIT License (MIT)
17 |
18 | Permission is hereby granted, free of charge, to any person obtaining a copy
19 | of this software and associated documentation files (the "Software"), to deal
20 | in the Software without restriction, including without limitation the rights
21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 | copies of the Software, and to permit persons to whom the Software is
23 | furnished to do so, subject to the following conditions:
24 |
25 | The above copyright notice and this permission notice shall be included in
26 | all copies or substantial portions of the Software.
27 |
28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 | THE SOFTWARE.
35 |
--------------------------------------------------------------------------------
/Dockerfile.test:
--------------------------------------------------------------------------------
1 | FROM debian:latest
2 |
3 | ENV HOME /home/dev
4 |
5 | WORKDIR /home/dev/code/Nexus
6 |
7 | VOLUME /home/dev/.Nexus
8 |
9 | RUN apt-get update && apt-get -y --no-install-recommends install \
10 | build-essential \
11 | ca-certificates \
12 | git \
13 | libboost-all-dev \
14 | libdb-dev \
15 | libdb++-dev \
16 | libgmp3-dev \
17 | libminiupnpc-dev \
18 | libqrencode-dev \
19 | libqt4-dev \
20 | libssl-dev \
21 | psmisc \
22 | qt4-default \
23 | qt4-qmake \
24 | screen \
25 | vim \
26 | && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
27 |
28 | COPY . /home/dev/code/Nexus
29 |
30 | RUN cp makefile.unix Makefile && USE_LLD=1 make -j$(nproc) && rm -f Makefile
31 |
32 | RUN qmake nexus-qt.pro "RELEASE=1" "USE_UPNP=-" "USE_LLD=1" && make -j$(nproc)
33 |
34 | RUN cd qa/smoke && /bin/bash setup-two-local-test-nodes.sh
35 |
36 | RUN cd /home/dev/code && git clone https://github.com/Nexusoft/PrimeSoloMiner.git && cd PrimeSoloMiner && ln -s makefile.unix Makefile && make -j$(nproc)
37 |
38 | CMD /bin/bash qa/smoke/start-local-testnet.sh
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2014 - 2018 The Nexus Embassy
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 Core - 0.2.5.5
2 | =====================================
3 |
4 | nex·usˈneksəs' : a connection or series of connections linking two or more things.
5 |
6 | http://nexusearth.com
7 |
8 |
9 | What is Nexus?
10 | --------------
11 |
12 | Nexus is a framework of tools that can be used to create most of the applications on
13 | the internet as we know it today. The core implementation is of a digital currency
14 | that rides on the backbones of the network and provides a stable storage and transmission
15 | of value from party to party.
16 |
17 | Nexus is a connection between two or more things, with this following code being a set of
18 | tools to facilitate this connection between individuals.
19 |
20 | Why Nexus?
21 | ----------
22 |
23 | Nexus provides the ability to improve the technology in digital currencies in the form of
24 | continued development of new architecture, organizations, financial contracts, and even
25 | distributed consensus and voting with the proper checks and balances. When the entire
26 | framework is complete, it will provide value to many other currencies besides nexus, and
27 | be capable of allowing the world to form structured systems together that can operate
28 | independent of one another, and be connected through the distributed network. This will
29 | create greater opportunity for those that have limited access to such things.
30 |
31 | Development
32 | -----------
33 |
34 | Anyone is free to work on the source, `master` branch is regularly build and tested, but do
35 | not consider it completely stable until full releases. Please submit pull requests at your
36 | discretion if you would like to contribute to the core codebase. A contributing schematic
37 | will be provided soon on our standard for development.
38 |
39 |
40 | License
41 | -------
42 |
43 | Nexus is released under the terms of the MIT license. See [COPYING](COPYING.MD) for more
44 | information or see https://opensource.org/licenses/MIT.
45 |
46 |
47 | Contact
48 | -------
49 |
50 | Contact colin@nexus.io or join the public slack to get introduced to the community and help get in contact with
51 | other developers.
52 |
--------------------------------------------------------------------------------
/build/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/build/.gitkeep
--------------------------------------------------------------------------------
/create_dmg.sh:
--------------------------------------------------------------------------------
1 |
2 | brew install python@2
3 | pip2 install appscript
4 |
5 | clear
6 | echo ' '
7 | echo 'Building nexus-qt dmg file...'
8 | echo '(Do not close or move windows until after this script says it finished.)'
9 |
10 | echo 'export PATH="/usr/local/opt/python/libexec/bin:$PATH"' >> ~/.bash_profile
11 | source ~/.bash_profile
12 | python release/macdeploy/macdeployqtplus nexus-qt.app -dmg -fancy release/macdeploy/fancy.plist
13 |
14 | echo ' '
15 | echo 'Finished Building nexus-qt dmg file'
16 | echo ' '
17 | echo 'File can be found by opening Finder, clicking Go, then Home on'
18 | echo 'the menu bar. Then open the Nexus folder and you should see'
19 | echo 'a file called nexus-qt.dmg. Double click it and drag in the window'
20 | echo 'that appears to the Applications folder and you are finished.'
21 | echo ' '
22 |
--------------------------------------------------------------------------------
/doc/README.md:
--------------------------------------------------------------------------------
1 | # Building Nexus Wallet #
2 |
3 | ##### Please follow the instructions for your OS provided in this folder #####
4 |
5 | ### Compiling options for Nexus-Qt (GUI) ###
6 |
7 | (All options are specified when running qmake)
8 |
9 | * VERBOSE=[0(DEFAULT)|1|2]
10 | This allows for compiler output to show friendly text, verbose text, or all warnings
11 | * [32BIT | 64BIT(DEFAULT)]=1
12 | This allows you to select what architecture you want to compile for. You must have appropriate dependencies that match the architecture as well.
13 | * DEBUG=1
14 | Build Debug version of wallet
15 | * RELEASE=1 (DEFAULT)
16 | Build Release version of wallet
17 | * DEBUG_AND_RELEASE=1 (Same as settings DEBUG=1 and RELEASE=1)
18 | Build both Debug and Release versions of the wallet
19 | * USE_QRCODE=[0(DEFAULT)|1]
20 | Build with ability to generate QRCodes
21 | * NO_UPNP=[0(DEFAULT)|1]
22 | Set to 1 to disable UPNP.
23 | * ORACLE=[0(DEFAULT)|1]
24 | Set to 1 to build wallet with Oracle Database (BDB) instead of LLD
25 | * USE_DBUS=[0(DEFAULT)|1]
26 | Set to 1 to enable Freedesktop notification support.
27 | * MESSAGE_TAB=[0(DEFAULT)|1]
28 | Set to 1 to enable the messaging tab.
29 | * NEXUS_NEED_QT_PLUGINS=[0(DEFAULT)|1]
30 | Set to 1 to include international plugins and accessibility support.
31 |
32 | ### Custom Dependent Directory options for Nexus-Qt (GUI) ###
33 |
34 | (All custom paths are specified when running qmake)
35 |
36 | * BOOST_LIB_SUFFIX=
37 | * BOOST_LIB_PATH=
38 | * BOOST_INCLUDE_PATH=
39 | * OPENSSL_LIB_PATH=
40 | * OPENSSL_INCLUDE_PATH=
41 | * BDB_LIB_PATH=
42 | * BDB_LIB_SUFFIX=
43 | * BDB_INCLUDE_PATH=
44 | * MINIUPNPC_LIB_PATH=
45 | * MINIUPNPC_INCLUDE_PATH=
46 | * QRENCODE_LIB_PATH=
47 | * QRENCODE_INCLUDE_PATH=
48 |
49 | ### Extra build targets for Nexus-Qt (GUI) ###
50 |
51 | (All targets are specified when running make)
52 |
53 | * clean
54 | This will clean all compiled objects that have been created during the make process. Use this if something interrupts building and you're having issues.
55 | * distclean
56 | This will remove all files created during the make process as well as those generated by qmake. This is intended only for preparing the folder for distribution.
57 |
58 | ### Compiling options for Nexus (CLI) ###
59 |
60 | (All options are specified when running make -f makefile.cli)
61 |
62 | * VERBOSE=[0(DEFAULT)|1]
63 | This allows for compiler output to show friendly text or verbose text.
64 | * ENABLE_WARNINGS=[0(DEFAULT)|1]
65 | Set to 1 to display ALL compiler warnings.
66 | * [32BIT | 64BIT(DEFAULT)]=1
67 | This allows you to select what architecture you want to compile for. You must have appropriate dependencies that match the architecture as well.
68 | * NO_UPNP=[0(DEFAULT)|1]
69 | Set to 1 to disable UPNP.
70 | * ORACLE=[0(DEFAULT)|1]
71 | Set to 1 to build wallet with Oracle Database (BDB) instead of LLD
72 |
73 | ### Custom Dependent Directory options for Nexus (CLI) ###
74 |
75 | (All custom paths are specified when running make -f makefile.cli)
76 |
77 | * BOOST_LIB_SUFFIX=
78 | * BOOST_LIB_PATH=
79 | * BOOST_INCLUDE_PATH=
80 | * OPENSSL_LIB_PATH=
81 | * OPENSSL_INCLUDE_PATH=
82 | * BDB_LIB_PATH=
83 | * BDB_LIB_SUFFIX=
84 | * BDB_INCLUDE_PATH=
85 | * MINIUPNPC_LIB_PATH=
86 | * MINIUPNPC_INCLUDE_PATH=
87 |
88 | ### Extra build targets for Nexus-Qt (CLI) ###
89 |
90 | (All targets are specified when running make -f makefile.cli)
91 |
92 | * clean
93 | This will clean all compiled objects that have been created during the make process. Use this if something interrupts building and you're having issues.
--------------------------------------------------------------------------------
/doc/bootstrap-linux-LLD.MD:
--------------------------------------------------------------------------------
1 | ## What is a Bootstrap?
2 | A bootstrap is a copy of the blockchain database. This particular copy is for
3 | the LLD (Lower Level Database) that was programmed and designed specifically
4 | for nexus and other template database systesm. This tutorial will help you
5 | learn how to copy in your bootstrap from your linux server / desktop to have a
6 | faster syncing time.
7 |
8 | ## Steps to Complete
9 | First ensure you have unzip installed
10 |
11 | su
12 | apt-get install unzip
13 | exit
14 |
15 | Go back to your home folder
16 |
17 | cd ~
18 |
19 | Nexus download a bootstrap from this URL
20 |
21 | wget https://nexusearth.com/bootstrap/LLD-Database/recent.zip
22 | unzip recent.zip
23 |
24 | Now proceed to boot up the LLD node as normal.
25 |
--------------------------------------------------------------------------------
/doc/build-centos:
--------------------------------------------------------------------------------
1 | ## Dependencies
2 |
3 | | Library | Purpose | Description |
4 | | ------------ | ----------------- | --------------------------------- |
5 | | libssl | SSL Support | Secure communications |
6 | | libdb4.8 | Berkeley DB | Blockchain & wallet storage |
7 | | libboost | Boost | C++ Library |
8 | | miniupnpc | UPnP Support | Optional firewall-jumping support |
9 | | libqrencode | QRCode generation | Optional QRCode generation |
10 |
11 | ## Compile Options
12 |
13 | **miniupnpc** may be used for UPnP port mapping. Set USE_UPNP to control this.
14 |
15 | **libqrencode** may be used for QRCode image generation. Set USE_QRCODE to control this.
16 |
17 | | Option | Description |
18 | | ------------ | ----------- |
19 | | USE_UPNP=0 | (the default) UPnP support turned off by default at runtime |
20 | | USE_UPNP=1 | UPnP support turned on by default at runtime |
21 | | USE_QRCODE=0 | (the default) No QRCode support - libqrcode not required |
22 | | USE_QRCODE=1 | QRCode support enabled |
23 |
24 | ## Dependency Build Instructions: Ubuntu & Debian
25 |
26 | 1. First ensure you have build essentials installed:
27 |
28 | sudo apt-get install build-essential
29 |
30 | 2. Install Boost:
31 |
32 | sudo apt-get install libboost-all-dev
33 |
34 | 3. Install Berklee DB:
35 |
36 | sudo apt-get install libdb-dev libdb++-dev
37 |
38 | 4. Install Open SSL:
39 |
40 | sudo apt-get install libssl1.0-dev
41 |
42 | * If this fails to install because your linux system still supports 0.X
43 | versions of openssl use this command:
44 |
45 | sudo apt-get install libssl-dev
46 |
47 | 5. Install Mini UPNP:
48 |
49 | sudo apt-get install libminiupnpc-dev
50 |
51 | 6. Install QrenCode:
52 |
53 | sudo apt-get install libqrencode-dev
54 |
55 | 7. For the Qt, install QT Framework:
56 |
57 | sudo apt-get install qt4-qmake libqt4-dev
58 |
59 | * If you get a failed to build because "-lz" was not found this is due to the
60 | fact that your linux operating system is trying to use a 64 bit version of
61 | zlib. You can solve this by installing the 32 bit version here:
62 |
63 | sudo apt-get install lib32z1-dev
64 |
65 | ## Build Instructions (Daemon): Ubuntu & Debian
66 |
67 | cd ~
68 | git clone https://github.com/Nexusoft/Nexus.git Nexus
69 | cd Nexus
70 | make -f makefile.cli
71 |
72 | To execute:
73 |
74 | ./nexus
75 |
76 | ## Build Instructions (Qt): Ubuntu & Debian
77 |
78 | cd ~
79 | git clone https://github.com/Nexusoft/Nexus.git Nexus
80 | cd Nexus
81 | qmake nexus-qt.pro "RELEASE=1" "USE_UPNP=1"
82 | make
83 |
84 | To execute:
85 |
86 | ./nexus-qt
87 |
88 |
89 |
--------------------------------------------------------------------------------
/doc/build-debian.MD:
--------------------------------------------------------------------------------
1 | ## Dependency Build Instructions: Ubuntu & Debian
2 |
3 | 1. First ensure you have build essentials installed:
4 |
5 | sudo apt-get install git build-essential libboost-all-dev libssl-dev libdb-dev libdb++-dev libminiupnpc-dev libqrencode-dev lib32z1-dev qt5-default qttools5-dev*
6 |
7 | ## Build Instructions (Daemon): Ubuntu & Debian
8 |
9 | cd ~
10 | git clone --depth 1 https://github.com/Nexusoft/Nexus
11 | cd Nexus
12 | make -f makefile.cli
13 |
14 | To execute:
15 |
16 | ./nexus
17 |
18 | ## Build Instructions (Qt): Ubuntu & Debian
19 |
20 | cd ~
21 | git clone --depth 1 https://github.com/Nexusoft/Nexus
22 | cd Nexus
23 | qmake
24 | make
25 |
26 | To execute:
27 |
28 | ./nexus-qt
29 |
30 |
31 |
--------------------------------------------------------------------------------
/doc/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 boost git qrencode miniupnpc openssl qt
18 | * echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile
19 | * source ~/.bash_profile
20 |
21 | ### Compiling Wallet ###
22 |
23 | Choose which version you want to use below and follow the instructions for it.
24 | Almost all standard users will want to build the Nexus-Qt (GUI) version.
25 |
26 | ##### To Build the Nexus-Qt version (GUI) #####
27 |
28 | With the prerequisite software installed, do the following:
29 |
30 | * git clone --depth 1 https://github.com/Nexusoft/Nexus.git
31 | * cd Nexus
32 | * qmake
33 | * make
34 |
35 | (If you wish to build Oracle DB version, use "qmake ORACLE=1" instead)
36 |
37 | To deploy this *.app file (Create a dmg), do the following:
38 |
39 | * chmod +x create_dmg.sh
40 | * ./create_dmg.sh
41 |
42 | After this step, you should find Nexus-Qt.dmg in your working directory.
43 |
44 | ### To build the command line version (CLI) #####
45 |
46 | Make sure you are in your home directory, or the directory you would like the source code to be.
47 |
48 | * git clone --depth 1 https://github.com/Nexusoft/Nexus.git
49 | * cd Nexus
50 | * make -f makefile.cli
51 |
--------------------------------------------------------------------------------
/doc/build-win.MD:
--------------------------------------------------------------------------------
1 | REQUIREMENTS - 64bit CPU and OS
2 | At least 6GB free Hard drive space
3 | Stable internet connection
4 |
5 | If you have already completed Part 1: Compiling the Dependencies, please skip to Part 2: Compiling the Nexus Wallet.
6 |
7 | #### Part 1: Compiling the Dependencies ####
8 |
9 | ##### Getting Prerequisites #####
10 |
11 | Download and install MSYS2 with default settings.
12 |
13 | http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20161025.exe
14 |
15 | When it is finished, ensure "Run MSYS2 64bit now" is checked and press Finish.
16 | In the MSYS command prompt that opens, enter:
17 |
18 | * pacman -Syyu
19 |
20 | If you receive any messages saying things are in conflict, press y then enter until it asks "Proceed with installation?", then press y and enter one more time.
21 |
22 | When it is done, it will give you 2 warnings. Close the window with the X in the top right corner. After a few seconds it will warn you that processes are running. Click OK. Then keep clicking the X until it says "Terminal is not responding". Then, click "Close the Program" and wait for it to close.
23 |
24 | After it closes, launch MinGW64 by clicking the Windows Start icon and going to "MSYS2 64bit" and selecting "MSYS2 MingGW 64-Bit". When the MingGW64 window appears, enter:
25 |
26 | * pacman -Syyu
27 |
28 | When prompted to proceed with installation, press y then enter. After it finishes upgrading, enter:
29 |
30 | * pacman -S base-devel mingw-w64-x86_64-toolchain compression git python pv
31 |
32 | Each time it says Enter a Selection, just press enter. When it says "Proceed with installation?" press y, then enter.
33 | This will take some time depending upon your computers hardware and your internet speed. Please be patient until it finishes.
34 |
35 | ##### Download Nexus Source and Dependency Script #####
36 |
37 | In the already open MinGW64 window, enter:
38 |
39 | * cd /c/
40 | * git clone --depth 1 https://github.com/Nexusoft/Nexus
41 |
42 | This will download the Nexus source code to C:\Nexus
43 |
44 | ##### Compiling Dependencies #####
45 |
46 | Run win_build.sh to download and compile dependencies by entering:
47 |
48 | * /c/Nexus/win_build.sh install
49 |
50 | Wait for process to complete. This can take a VERY long time (hours) depending on your computer and internet connection.
51 | Please be patient while it completes the building process. This only needs to be successfully completed once.
52 | After it completes successfully you will only need to follow the steps in Part 2: Compiling the Nexus Wallet.
53 |
54 | #### Part 2: Compiling the Nexus Wallet ####
55 |
56 | If you just followed Part 1, skip to Building Nexus-Qt (GUI) or Building Nexus (CLI) below, depending on which you want.
57 | If you're UPDATING your existing version do this first, then continue following Building Nexus-Qt (GUI) or Building Nexus (CLI) instructions, depending on which you want.
58 |
59 | ##### Getting New Copy of Nexus Wallet Source #####
60 |
61 | To update your source code, launch MinGW64 by clicking the Windows Start icon and going to "MSYS2 64bit" and selecting "MSYS2 MingGW 64-Bit". When the MingGW64 window appears, enter:
62 |
63 | * cd /c/
64 | * mv --backup=numbered -T ./Nexus ./Nexus.bak
65 | * git clone --depth 1 https://github.com/Nexusoft/Nexus
66 |
67 | ##### -OR- #####
68 |
69 | If you have win_build.sh, you can enter:
70 |
71 | * /c/Nexus/win_build.sh update
72 |
73 | ##### Building Nexus-Qt (GUI) #####
74 | In the MinGW64 window, enter:
75 |
76 | * cd /c/Nexus
77 | * qmake
78 | * make
79 |
80 | This will create Nexus-Qt.exe in the releases folder.
81 |
82 | ##### Building Nexus (CLI) #####
83 | In the MinGW64 window, enter:
84 |
85 | * cd /c/Nexus
86 | * make -f makefile.cli
87 |
88 | This will create Nexus.exe in the releases folder.
89 |
90 |
--------------------------------------------------------------------------------
/qa/smoke/README.md:
--------------------------------------------------------------------------------
1 | # Public Testnet Info
2 |
3 | To run a node against the public testnet, you should build nexus from
4 | scratch using this version of the codebase.
5 |
6 | Then, you can use the script named
7 |
8 | public-testnet-setup.sh
9 |
10 | It will output information on where it puts the config files and how to run it.
11 |
12 | Alternatively, you can place the file called
13 |
14 | examples/nexus.conf.publictestnet
15 |
16 | in your ~/.Nexus/ directory.
17 |
18 | If you choose to do this be careful not to run any other instances of nexus on this computer.
19 |
20 | # Docker
21 |
22 | You can run a test environment using Docker.
23 |
24 | Change into the directory containing Dockerfile.test - this is currently the root directory of this project (two levels down from this readme).
25 |
26 | To build:
27 |
28 | ```Bash
29 | docker build -t nexus-test-build -f Dockerfile.test .
30 | ```
31 |
32 | To run:
33 |
34 | ```Bash
35 | docker run -it nexus-test-build bash
36 | ```
37 |
38 | From inside, run this command to start two nexus daemons and the prime solo miner:
39 |
40 | ```Bash
41 | /bin/bash /home/dev/code/Nexus/qa/smoke/start-local-testnet.sh
42 | ```
43 |
44 | # Local Nexus smoke testing info.
45 |
46 | The other scripts in this directory are designed help you smoke test nexus locally.
47 |
48 | ## Prereq: Install the CPU mining code
49 |
50 | In order to be able to produce blocks, you need to install the CPU miner code.
51 | This is easy if you're on ubuntu.
52 | Grab this script and run it
53 |
54 | https://github.com/physicsdude/nexusscripts/blob/master/install-cpu-miner-on-ubuntu.sh
55 |
56 | Then, when you're ready to mine blocks on your mini-chain, use the script below.
57 |
58 | ## setup-two-local-test-nodes.sh
59 |
60 | This will set up a fresh local test net with 2 nodes that communicate with each other.
61 | Look in ~/nexustest after you run this.
62 |
63 | ## run-start-nexus-test.sh
64 |
65 | This script will set up a test data directory and start nexus in test modes for you.
66 | It can also be used to set up an environment suitable for step through debugging.
67 | Check out the source for more info.
68 |
69 | ## makefile.unix.test
70 |
71 | If you want to step-through debug, it's useful to compile with no optimizations.
72 | Otherwise some variables get 'optimized out'.
73 | This file is identical to makefile.unix with the setting -O0.
74 | It's mostly for reference and if it gets out of date just grab the standard makefile.unix
75 | and change -O2 to -O0
76 |
77 | ## setup-for-debugger.sh
78 |
79 | Simple script to set up a nexus environment for step through debugging.
80 |
81 | ## Notes
82 |
83 | The testnet, regtest, and istimeseed options are all important for successfully running a local testnet.
84 | Either use or copy the configs used in run-start-nexus-test.sh.
85 |
86 | # THE TRUTH IS OUT THERE
87 |
--------------------------------------------------------------------------------
/qa/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 |
--------------------------------------------------------------------------------
/qa/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 |
--------------------------------------------------------------------------------
/qa/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 |
--------------------------------------------------------------------------------
/qa/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 |
--------------------------------------------------------------------------------
/qa/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 |
--------------------------------------------------------------------------------
/qa/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 |
--------------------------------------------------------------------------------
/qa/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 |
--------------------------------------------------------------------------------
/qa/smoke/startminerfortest.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "starting miner for tests"
4 |
5 | ${HOME}/code/PrimeSoloMiner/miner localhost 8325 2
6 |
--------------------------------------------------------------------------------
/release/macdeploy/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/release/macdeploy/background.png
--------------------------------------------------------------------------------
/release/macdeploy/fancy.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | window_bounds
6 |
7 | 300
8 | 300
9 | 800
10 | 620
11 |
12 | background_picture
13 | background.png
14 | icon_size
15 | 96
16 | applications_symlink
17 |
18 | items_position
19 |
20 | Applications
21 |
22 | 370
23 | 155
24 |
25 | Nexus-Qt.app
26 |
27 | 128
28 | 155
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/release/macdeploy/notes.txt:
--------------------------------------------------------------------------------
1 |
2 | macdeployqtplus works best on OS X Lion, for Snow Leopard you'd need to install
3 | Python 2.7 and make it your default Python installation.
4 |
5 | You will need the appscript package for the fancy disk image creation to work.
6 | Install it by invoking "sudo easy_install appscript".
7 |
8 | Ths script should be invoked in the target directory like this:
9 | $source_dir/contrib/macdeploy/macdeployqtplus Nexus-Qt.app -add-qt-tr da,de,es,hu,ru,uk,zh_CN,zh_TW -dmg -fancy $source_dir/contrib/macdeploy/fancy.plist -verbose 2
10 |
11 | During the process, the disk image window will pop up briefly where the fancy
12 | settings are applied. This is normal, please do not interfere.
13 |
14 | You can also set up Qt Creator for invoking the script. For this, go to the
15 | "Projects" tab on the left side, switch to "Run Settings" above and add a
16 | deploy configuration. Next add a deploy step choosing "Custom Process Step".
17 | Fill in the following.
18 |
19 | Enable custom process step: [x]
20 | Command: %{sourceDir}/contrib/macdeploy/macdeployqtplus
21 | Working directory: %{buildDir}
22 | Command arguments: Nexus-Qt.app -add-qt-tr da,de,es,hu,ru,uk,zh_CN,zh_TW -dmg -fancy %{sourceDir}/contrib/macdeploy/fancy.plist -verbose 2
23 |
24 | After that you can start the deployment process through the menu with
25 | Build -> Deploy Project "bitcoin-qt"
26 |
27 |
--------------------------------------------------------------------------------
/release/qt_translations.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # Helpful little script that spits out a comma-separated list of
4 | # language codes for Qt icons that should be included
5 | # in binary bitcoin distributions
6 |
7 | import glob
8 | import os
9 | import re
10 | import sys
11 |
12 | if len(sys.argv) != 3:
13 | sys.exit("Usage: %s $QTDIR/translations $NEXUSDIR/src/qt/locale"%sys.argv[0])
14 |
15 | d1 = sys.argv[1]
16 | d2 = sys.argv[2]
17 |
18 | l1 = set([ re.search(r'qt_(.*).qm', f).group(1) for f in glob.glob(os.path.join(d1, 'qt_*.qm')) ])
19 | l2 = set([ re.search(r'nexus_(.*).qm', f).group(1) for f in glob.glob(os.path.join(d2, 'nexus_*.qm')) ])
20 |
21 | print ",".join(sorted(l1.intersection(l2)))
22 |
23 |
--------------------------------------------------------------------------------
/src/LLD/index.h:
--------------------------------------------------------------------------------
1 | #ifndef LOWER_LEVEL_LIBRARY_LLD_INDEX
2 | #define LOWER_LEVEL_LIBRARY_LLD_INDEX
3 |
4 | #include "sector.h"
5 | #include "../core/core.h"
6 | #include "../wallet/db.h"
7 |
8 | /** Lower Level Database Name Space. **/
9 | namespace LLD
10 | {
11 | #ifdef USE_LLD
12 | extern uint1024 hashCorruptedNext;
13 |
14 | class CIndexDB : public SectorDatabase
15 | {
16 | public:
17 | /** The Database Constructor. To determine file location and the Bytes per Record. **/
18 | CIndexDB(const char* pszMode="r+") : SectorDatabase("blkindex", "blkindex", pszMode) {}
19 |
20 | bool ReadTxIndex(uint512 hash, Core::CTxIndex& txindex);
21 | bool UpdateTxIndex(uint512 hash, const Core::CTxIndex& txindex);
22 | bool AddTxIndex(const Core::CTransaction& tx, const Core::CDiskTxPos& pos, int nHeight);
23 | bool EraseTxIndex(const Core::CTransaction& tx);
24 | bool ContainsTx(uint512 hash);
25 | bool ReadDiskTx(uint512 hash, Core::CTransaction& tx, Core::CTxIndex& txindex);
26 | bool ReadDiskTx(uint512 hash, Core::CTransaction& tx);
27 | bool ReadDiskTx(Core::COutPoint outpoint, Core::CTransaction& tx, Core::CTxIndex& txindex);
28 | bool ReadDiskTx(Core::COutPoint outpoint, Core::CTransaction& tx);
29 |
30 | bool WriteTrustKey(uint576 hashTrustKey, Core::CTrustKey cTrustKey);
31 | bool ReadTrustKey(uint576 hashTrustKey, Core::CTrustKey& cTrustKey);
32 | bool HasTrustKey(uint576 hashTrustKey);
33 | bool GetTrustKeys(std::vector& vTrustKeys);
34 | bool EraseTrustKey(uint576 hashTrustKey);
35 |
36 | bool Bootstrapped();
37 | bool Bootstrap();
38 |
39 | bool WriteBlockIndex(const Core::CDiskBlockIndex& blockindex);
40 | bool ReadBlockIndex(const uint1024 hashBlock, Core::CBlockIndex* pindexNew);
41 | bool ReadHashBestChain(uint1024& hashBestChain);
42 | bool WriteHashBestChain(uint1024 hashBestChain);
43 | bool LoadBlockIndex();
44 |
45 | bool WriteTrustKey(uint512 hashTrustKey, Core::CTrustKey cTrustKey);
46 | bool ReadTrustKey(uint512 hashTrustKey, Core::CTrustKey& cTrustKey);
47 | bool AddTrustBlock(uint512 hashTrustKey, uint1024 hashTrustBlock);
48 | bool RemoveTrustBlock(uint1024 hashTrustBlock);
49 | };
50 | #else
51 | class CIndexDB : public Wallet::CDB
52 | {
53 | public:
54 | CIndexDB(const char* pszMode="r+") : Wallet::CDB("blkindex.dat", pszMode) { }
55 |
56 | bool ReadTxIndex(uint512 hash, Core::CTxIndex& txindex);
57 | bool UpdateTxIndex(uint512 hash, const Core::CTxIndex& txindex);
58 | bool AddTxIndex(const Core::CTransaction& tx, const Core::CDiskTxPos& pos, int nHeight);
59 | bool EraseTxIndex(const Core::CTransaction& tx);
60 | bool ContainsTx(uint512 hash);
61 | bool ReadDiskTx(uint512 hash, Core::CTransaction& tx, Core::CTxIndex& txindex);
62 | bool ReadDiskTx(uint512 hash, Core::CTransaction& tx);
63 | bool ReadDiskTx(Core::COutPoint outpoint, Core::CTransaction& tx, Core::CTxIndex& txindex);
64 | bool ReadDiskTx(Core::COutPoint outpoint, Core::CTransaction& tx);
65 | bool WriteBlockIndex(const Core::CDiskBlockIndex& blockindex);
66 | bool ReadBlockIndex(const uint1024 hashBlock, Core::CBlockIndex* pindexNew);
67 | bool ReadHashBestChain(uint1024& hashBestChain);
68 | bool WriteHashBestChain(uint1024 hashBestChain);
69 | bool LoadBlockIndex();
70 |
71 | bool WriteTrustKey(uint512 hashTrustKey, Core::CTrustKey cTrustKey);
72 | bool ReadTrustKey(uint512 hashTrustKey, Core::CTrustKey& cTrustKey);
73 | bool AddTrustBlock(uint512 hashTrustKey, uint1024 hashTrustBlock);
74 | bool RemoveTrustBlock(uint1024 hashTrustBlock);
75 | };
76 | #endif
77 | }
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/src/LLD/journal.h:
--------------------------------------------------------------------------------
1 | #ifndef LOWER_LEVEL_LIBRARY_LLD_JOURNAL
2 | #define LOWER_LEVEL_LIBRARY_LLD_JOURNAL
3 |
4 | #include "sector.h"
5 | #include "core.h"
6 |
7 | /** Lower Level Database Name Space. **/
8 | namespace LLD
9 | {
10 | /* Journal Database keeps in non-volatile memory the transaction record for rollback.
11 | * This will be triggered if the checksums don't match with sector data and the keychain
12 | * TODO: Figure out the best Key system to correlate a transaction to the data in the journal
13 | * This should be seen by the sector as well, which means that the keychain should keep a list
14 | * of the keys that were changed.
15 | */
16 | class CJournalDB : public SectorDatabase
17 | {
18 | public:
19 | /** The Database Constructor. To determine file location and the Bytes per Record. **/
20 | CJournalDB(const char* pszMode="r+", std::string strID) : SectorDatabase(strID, strID, pszMode) {}
21 |
22 | /* TODO: Delete the Journal Database if it is deconstructed.
23 | * This should only happen when the database commits the transaction */
24 | ~CJournalDB()
25 | {
26 |
27 | }
28 |
29 | bool AddTransaction(uint512 hash, Core::CTxIndex& txindex);
30 | bool RemoveTransaction(uint512 hash, const Core::CTxIndex& txindex);
31 | };
32 | }
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/src/LLD/keychain.cpp:
--------------------------------------------------------------------------------
1 | #include "key.h"
2 |
3 | /** Lower Level Database Name Space. **/
4 | namespace LLD
5 | {
6 | /** Handle the Registry of Shared Keychain Pointer Objects. **/
7 | std::map mapKeychainRegistry;
8 |
9 | /** Handle the Key Registry. **/
10 | boost::mutex REGISTRY_MUTEX;
11 |
12 | /** Handle the Registrying of Keychains for LLD Sectors. **/
13 | void RegisterKeychain(std::string strRegistryName, std::string strBaseName)
14 | {
15 | MUTEX_LOCK(REGISTRY_MUTEX);
16 |
17 | /** Create the New Keychain Database. **/
18 | KeyDatabase* SectorKeys = new KeyDatabase(GetDataDir().string() + "/keychain/", strBaseName);
19 | SectorKeys->Initialize();
20 |
21 | /** Log the new Keychain into the Memeory Map. **/
22 | mapKeychainRegistry[strRegistryName] = SectorKeys;
23 |
24 | /** Debug Output for Keychain Database Initialization. **/
25 | printf("[KEYCHAIN] Registered Keychain For Database %s\n", strRegistryName.c_str());
26 | }
27 |
28 | /** Return the Keychain Pointer Object. **/
29 | KeyDatabase* GetKeychain(std::string strRegistryName) {
30 | if(!mapKeychainRegistry.count(strRegistryName))
31 | return NULL;
32 |
33 | return mapKeychainRegistry[strRegistryName];
34 | }
35 |
36 | /** TODO:: Break Keychain Registry into another Database that stores the Keychain Registry and States on Disk.
37 | This can then be used to remove all memory requirements of the Database if so Desired. **/
38 | }
39 |
--------------------------------------------------------------------------------
/src/LLD/keychain.h:
--------------------------------------------------------------------------------
1 | #ifndef LOWER_LEVEL_LIBRARY_LLD_KEYCHAIN
2 | #define LOWER_LEVEL_LIBRARY_LLD_KEYCHAIN
3 |
4 | #include "key.h"
5 |
6 | /** Lower Level Database Name Space. **/
7 | namespace LLD
8 | {
9 | /** Handle the Registry of Shared Keychain Pointer Objects. **/
10 | extern std::map mapKeychainRegistry;
11 |
12 | /** Handle the Key Registry. **/
13 | extern boost::mutex REGISTRY_MUTEX;
14 |
15 | /** Handle the Registrying of Keychains for LLD Sectors. **/
16 | void RegisterKeychain(std::string strRegistryName, std::string strBaseName);
17 |
18 | /** Return the Keychain Pointer Object. **/
19 | KeyDatabase* GetKeychain(std::string strRegistryName);
20 | }
21 |
22 | #endif
--------------------------------------------------------------------------------
/src/LLD/trustkeys.cpp:
--------------------------------------------------------------------------------
1 | #include "trustkeys.h"
2 | #include "../core/core.h"
3 |
4 | /** Lower Level Database Name Space. **/
5 | namespace LLD
6 | {
7 | using namespace std;
8 |
9 | bool CTrustDB::WriteMyKey(Core::CTrustKey cTrustKey)
10 | {
11 | return Write(string("mytrustkey"), cTrustKey);
12 | }
13 |
14 | bool CTrustDB::ReadMyKey(Core::CTrustKey& cTrustKey)
15 | {
16 | return Read(string("mytrustkey"), cTrustKey);
17 | }
18 |
19 | bool CTrustDB::EraseMyKey()
20 | {
21 | return Erase(string("mytrustkey"));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/LLD/trustkeys.h:
--------------------------------------------------------------------------------
1 | #ifndef LOWER_LEVEL_LIBRARY_LLD_TRUSTKEYS
2 | #define LOWER_LEVEL_LIBRARY_LLD_TRUSTKEYS
3 |
4 | #include "sector.h"
5 | #include "../core/core.h"
6 | #include "../wallet/db.h"
7 |
8 | /** Lower Level Database Name Space. **/
9 | namespace LLD
10 | {
11 | class CTrustDB : public SectorDatabase
12 | {
13 | public:
14 | /** The Database Constructor. To determine file location and the Bytes per Record. **/
15 | CTrustDB(const char* pszMode="r+") : SectorDatabase("trust", "trust", pszMode) {}
16 |
17 | bool WriteMyKey(Core::CTrustKey cTrustKey);
18 | bool ReadMyKey(Core::CTrustKey& cTrustKey);
19 | bool EraseMyKey();
20 | };
21 | }
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/LLP/client.h:
--------------------------------------------------------------------------------
1 | #ifndef NEXUS_LLP_CLIENT_H
2 | #define NEXUS_LLP_CLIENT_H
3 |
4 | #include "types.h"
5 |
6 | namespace LLP
7 | {
8 | class Outbound : public Connection
9 | {
10 | Service_t IO_SERVICE;
11 |
12 | public:
13 | std::string IP, PORT;
14 |
15 | /** Outgoing Client Connection Constructor **/
16 | Outbound(std::string ip, std::string port) : IP(ip), PORT(port) { }
17 |
18 | bool Connect()
19 | {
20 | try
21 | {
22 | using boost::asio::ip::tcp;
23 |
24 | tcp::resolver RESOLVER(IO_SERVICE);
25 | tcp::resolver::query QUERY (tcp::v4(), IP.c_str(), PORT.c_str());
26 | tcp::resolver::iterator ADDRESS = RESOLVER.resolve(QUERY);
27 |
28 | SOCKET = Socket_t(new tcp::socket(IO_SERVICE));
29 | SOCKET -> connect(*ADDRESS, ERROR_HANDLE);
30 |
31 | if(ERROR_HANDLE)
32 | return false;
33 |
34 | CONNECTED = true;
35 | TIMER.Start();
36 |
37 | printf("***** Connected to %s:%s...\n", IP.c_str(), PORT.c_str());
38 |
39 | return true;
40 | }
41 | catch(...){ Disconnect(); }
42 |
43 | return false;
44 | }
45 |
46 | };
47 |
48 | class CoreOutbound : public Outbound
49 | {
50 | public:
51 | CoreOutbound(std::string ip, std::string port) : Outbound(ip, port){}
52 |
53 | enum
54 | {
55 | /** DATA PACKETS **/
56 | TIME_DATA = 0,
57 | ADDRESS_DATA = 1,
58 | TIME_OFFSET = 2,
59 |
60 | /** DATA REQUESTS **/
61 | GET_OFFSET = 64,
62 |
63 |
64 | /** REQUEST PACKETS **/
65 | GET_TIME = 129,
66 | GET_ADDRESS = 130,
67 |
68 |
69 | /** GENERIC **/
70 | PING = 253,
71 | CLOSE = 254
72 | };
73 |
74 | inline Packet NewPacket() { return this->INCOMING; }
75 |
76 | inline Packet GetPacket(unsigned char HEADER)
77 | {
78 | Packet PACKET;
79 | PACKET.HEADER = HEADER;
80 | return PACKET;
81 | }
82 |
83 | inline void GetOffset(unsigned int nTimestamp)
84 | {
85 | Packet REQUEST = GetPacket(GET_OFFSET);
86 | REQUEST.LENGTH = 4;
87 | REQUEST.DATA = uint2bytes(nTimestamp);
88 |
89 | this->WritePacket(REQUEST);
90 | }
91 |
92 | inline void GetTime()
93 | {
94 | Packet REQUEST = GetPacket(GET_TIME);
95 | this->WritePacket(REQUEST);
96 | }
97 |
98 | void Close()
99 | {
100 | Packet RESPONSE = GetPacket(CLOSE);
101 | this->WritePacket(RESPONSE);
102 | this->Disconnect();
103 | }
104 |
105 | inline void GetAddress()
106 | {
107 | Packet REQUEST = GetPacket(GET_ADDRESS);
108 | this->WritePacket(REQUEST);
109 | }
110 | };
111 |
112 | }
113 |
114 |
115 |
116 | #endif
--------------------------------------------------------------------------------
/src/LLP/debug.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/LLP/debug.h
--------------------------------------------------------------------------------
/src/core/checkpoints.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 |
3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014] ++
4 |
5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php
6 |
7 | *******************************************************************************************/
8 |
9 | #include // for 'map_list_of()'
10 | #include
11 |
12 | #include "core.h"
13 | #include "../hash/uint1024.h"
14 | #include "../wallet/db.h"
15 |
16 | namespace Core
17 | {
18 | /** Hardened Checkpoints. **/
19 | uint1024 hashCheckpoint = 0;
20 |
21 | unsigned int nCheckHeight = 0;
22 | unsigned int CHECKPOINT_TIMESPAN = 10;
23 |
24 |
25 | /** Check Checkpoint Timespan. **/
26 | bool IsNewTimespan(CBlockIndex* pindex)
27 | {
28 | if(!pindex->pprev)
29 | return true;
30 |
31 | int nFirstMinutes = floor((pindex->GetBlockTime() - mapBlockIndex[pindex->PendingCheckpoint.second]->GetBlockTime()) / 60.0);
32 | int nLastMinutes = floor((pindex->pprev->GetBlockTime() - mapBlockIndex[pindex->PendingCheckpoint.second]->GetBlockTime()) / 60.0);
33 |
34 | return (nFirstMinutes != nLastMinutes && nFirstMinutes >= CHECKPOINT_TIMESPAN);
35 | }
36 |
37 |
38 | /** Checks whether given block index is a descendant of last hardened checkpoint. **/
39 | bool IsDescendant(CBlockIndex* pindex)
40 | {
41 | if(hashCheckpoint == 0)
42 | return true;
43 |
44 | /* Ensure that the block is made after last hardened Checkpoint. */
45 | if(!pindex->pprev)
46 | return true;
47 |
48 | /* Check The Block Hash */
49 | while(pindex->pprev)
50 | {
51 | if(pindex->GetBlockHash() == hashCheckpoint)
52 | return true;
53 |
54 | if(pindex->nHeight < nCheckHeight)
55 | return error("IsDescendant() : New Timespan found with no checkpoint = %s height = %u", hashCheckpoint.ToString().substr(0, 20).c_str(), nCheckHeight);
56 |
57 | pindex = pindex->pprev;
58 | }
59 |
60 | return false;
61 | }
62 |
63 |
64 | /** Hardens the Pending Checkpoint on the Blockchain, determined by a new block creating a new Timespan.
65 | The blockchain from genesis to new hardened checkpoint will then be fixed into place. **/
66 | bool HardenCheckpoint(CBlockIndex* pcheckpoint, bool fInit)
67 | {
68 | /* Only Harden New Checkpoint if it Fits new Timestamp. */
69 | if(!IsNewTimespan(pcheckpoint->pprev))
70 | return false;
71 |
72 | /* Only Harden a New Checkpoint if it isn't already hardened. */
73 | if(hashCheckpoint == pcheckpoint->pprev->PendingCheckpoint.second)
74 | return true;
75 |
76 | /* Update the Checkpoints into Memory. */
77 | hashCheckpoint = pcheckpoint->pprev->PendingCheckpoint.second;
78 | nCheckHeight = pcheckpoint->pprev->PendingCheckpoint.first;
79 |
80 | /* Dump the Checkpoint if not Initializing. */
81 | if(!fInit)
82 | printf("===== Hardened Checkpoint %s Height = %u\n",
83 | pcheckpoint->pprev->PendingCheckpoint.second.ToString().substr(0, 20).c_str(),
84 | pcheckpoint->pprev->PendingCheckpoint.first);
85 |
86 | return true;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/core/debug.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | //Old testing setup. Commenting out all for now as no longer needed.
3 | //Will remove in later patch.
4 |
5 | #include "../LLP/client.h"
6 |
7 | namespace LLP
8 | {
9 |
10 | //Hard - coded Address and Port of Debug Server.
11 | static const std::string DEBUG_IP = "208.94.247.42";
12 | static const std::string DEBUG_PORT = "9965";
13 |
14 | //Class to Wrap LLP for Interpreting Debug LLP
15 | class DebugClient : public Outbound
16 | {
17 | public:
18 | DebugClient() : Outbound(DEBUG_IP, DEBUG_PORT){ }
19 |
20 | enum
21 | {
22 | DEBUG_DATA = 0,
23 | GENERIC_DATA = 1,
24 |
25 | PING = 254,
26 | CLOSE = 255
27 | };
28 |
29 | //Create a new Packet to Send.
30 | inline Packet GetPacket(unsigned char HEADER)
31 | {
32 | Packet PACKET;
33 | PACKET.HEADER = HEADER;
34 | return PACKET;
35 | }
36 |
37 | //Ping the Debug Server.
38 | inline void Ping()
39 | {
40 | Packet PACKET = GetPacket(PING);
41 | this->WritePacket(PACKET);
42 | }
43 |
44 | //Send Data to Debug Server.
45 | inline void SendData(std::string strDebugData, bool fGeneric = false)
46 | {
47 | Packet PACKET = GetPacket((fGeneric ? GENERIC_DATA : DEBUG_DATA));
48 | PACKET.DATA = string2bytes(strDebugData);
49 | PACKET.LENGTH = PACKET.DATA.size();
50 |
51 | this->WritePacket(PACKET);
52 | }
53 | };
54 | }
55 |
56 | //Thread to handle Debugging Server Reporting.
57 | void DebugThread(void* parg)
58 | {
59 | LLP::DebugClient* CLIENT = new LLP::DebugClient();
60 |
61 | //Clear the Debug Data from Core Initialization.
62 | DEBUGGING_MUTEX.lock();
63 | DEBUGGING_OUTPUT.clear();
64 | DEBUGGING_MUTEX.unlock();
65 |
66 | printf("[DEBUG] Debugging Thread Started.\n");
67 | while(true)
68 | {
69 | try
70 | {
71 | //Run this thread slowly.
72 | Sleep(1000);
73 |
74 | if(!CLIENT->Connected() || CLIENT->Errors())
75 | {
76 |
77 | //Try and Reconnect every 10 Seconds if Failed.
78 | if(!CLIENT->Connect())
79 | {
80 | Sleep(10000);
81 |
82 | continue;
83 | }
84 |
85 | printf("[DEBUG] Connection Established to Debugging Server.\n");
86 | }
87 |
88 | if(CLIENT->Timeout(15))
89 | CLIENT->Ping();
90 |
91 | if(DEBUGGING_OUTPUT.empty())
92 | continue;
93 |
94 |
95 | //Send the Data in the Queue to Debug Server
96 | DEBUGGING_MUTEX.lock();
97 | for(int nIndex = 0; nIndex < DEBUGGING_OUTPUT.size(); nIndex++ )
98 | CLIENT->SendData(DEBUGGING_OUTPUT[nIndex].second, DEBUGGING_OUTPUT[nIndex].first);
99 |
100 | DEBUGGING_OUTPUT.clear();
101 | DEBUGGING_MUTEX.unlock();
102 | }
103 | catch(std::exception& e){}
104 | }
105 | } **/
106 |
--------------------------------------------------------------------------------
/src/core/dispatch.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 |
3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014] ++
4 |
5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php
6 |
7 | *******************************************************************************************/
8 |
9 | #include "../main.h"
10 |
11 | namespace Core
12 | {
13 | /** Dispatching Functions: To Dispatch to Registered Wallets **/
14 | void RegisterWallet(Wallet::CWallet* pwalletIn)
15 | {
16 | {
17 | LOCK(cs_setpwalletRegistered);
18 | setpwalletRegistered.insert(pwalletIn);
19 | }
20 | }
21 |
22 | void UnregisterWallet(Wallet::CWallet* pwalletIn)
23 | {
24 | {
25 | LOCK(cs_setpwalletRegistered);
26 | setpwalletRegistered.erase(pwalletIn);
27 | }
28 | }
29 |
30 | /** Check whether the transaction is from us **/
31 | bool IsFromMe(CTransaction& tx)
32 | {
33 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
34 | if (pwallet->IsFromMe(tx))
35 | return true;
36 | return false;
37 | }
38 |
39 | /** Get the transaction from the Wallet **/
40 | bool GetTransaction(const uint512& hashTx, Wallet::CWalletTx& wtx)
41 | {
42 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
43 | if (pwallet->GetTransaction(hashTx,wtx))
44 | return true;
45 | return false;
46 | }
47 |
48 | /** Removes given transaction from the wallet **/
49 | void EraseFromWallets(uint512 hash)
50 | {
51 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
52 | pwallet->EraseFromWallet(hash);
53 | }
54 |
55 | /** Make sure all wallets know about the given transaction, in the given block **/
56 | void SyncWithWallets(const CTransaction& tx, const CBlock* pblock, bool fUpdate, bool fConnect)
57 | {
58 | if (!fConnect)
59 | {
60 | /** Wallets need to refund inputs when disconnecting coinstake **/
61 | if (tx.IsCoinStake())
62 | {
63 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
64 | if (pwallet->IsFromMe(tx))
65 | pwallet->DisableTransaction(tx);
66 | }
67 | return;
68 | }
69 |
70 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
71 | pwallet->AddToWalletIfInvolvingMe(tx, pblock, fUpdate);
72 | }
73 |
74 | /** Notify wallets about a new best chain **/
75 | void SetBestChain(const CBlockLocator& loc)
76 | {
77 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
78 | pwallet->SetBestChain(loc);
79 | }
80 |
81 | /** Notify wallets about an updated transaction **/
82 | void UpdatedTransaction(const uint512& hashTx)
83 | {
84 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
85 | pwallet->UpdatedTransaction(hashTx);
86 | }
87 |
88 | /** Dump All Wallets **/
89 | void PrintWallets(const CBlock& block)
90 | {
91 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
92 | pwallet->PrintWallet(block);
93 | }
94 |
95 | /** Notify wallets about an incoming inventory (for request counts) **/
96 | void Inventory(const uint1024& hash)
97 | {
98 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
99 | pwallet->Inventory(hash);
100 | }
101 |
102 | /** Ask wallets to resend their transactions **/
103 | void ResendWalletTransactions()
104 | {
105 | BOOST_FOREACH(Wallet::CWallet* pwallet, setpwalletRegistered)
106 | pwallet->ResendWalletTransactions();
107 | }
108 | }
109 |
110 |
--------------------------------------------------------------------------------
/src/core/prime.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 |
3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014] ++
4 |
5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php
6 |
7 | *******************************************************************************************/
8 |
9 | #include "core.h"
10 |
11 | using namespace std;
12 |
13 | namespace Core
14 | {
15 |
16 | /** Convert Double to unsigned int Representative. Used for encoding / decoding prime difficulty from nBits. **/
17 | unsigned int SetBits(double nDiff)
18 | {
19 | unsigned int nBits = 10000000;
20 | nBits *= nDiff;
21 |
22 | return nBits;
23 | }
24 |
25 | /** Determines the difficulty of the Given Prime Number.
26 | Difficulty is represented as so V.X
27 | V is the whole number, or Cluster Size, X is a proportion
28 | of Fermat Remainder from last Composite Number [0 - 1] **/
29 | double GetPrimeDifficulty(const CBigNum& prime, int checks)
30 | {
31 | if(!PrimeCheck(prime, checks))
32 | return 0.0; ///difficulty of a composite number
33 |
34 | CBigNum lastPrime = prime;
35 | CBigNum next = prime + 2;
36 | unsigned int clusterSize = 1;
37 |
38 | ///largest prime gap in cluster can be + 12
39 | ///this was determined by previously found clusters up to 17 primes
40 | for( ; next <= lastPrime + 12; next += 2)
41 | {
42 | if(PrimeCheck(next, checks))
43 | {
44 | lastPrime = next;
45 | ++clusterSize;
46 | }
47 | }
48 |
49 | ///calculate the rarity of cluster from proportion of fermat remainder of last prime + 2
50 | ///keep fractional remainder in bounds of [0, 1]
51 | double fractionalRemainder = 1000000.0 / GetFractionalDifficulty(next);
52 | if(fractionalRemainder > 1.0 || fractionalRemainder < 0.0)
53 | fractionalRemainder = 0.0;
54 |
55 | return (clusterSize + fractionalRemainder);
56 | }
57 |
58 | /** Gets the unsigned int representative of a decimal prime difficulty **/
59 | unsigned int GetPrimeBits(const CBigNum& prime)
60 | {
61 | return SetBits(GetPrimeDifficulty(prime, 1));
62 | }
63 |
64 | /** Breaks the remainder of last composite in Prime Cluster into an integer.
65 | Larger numbers are more rare to find, so a proportion can be determined
66 | to give decimal difficulty between whole number increases. **/
67 | unsigned int GetFractionalDifficulty(const CBigNum& composite)
68 | {
69 | /** Break the remainder of Fermat test to calculate fractional difficulty [Thanks Sunny] **/
70 | return ((composite - FermatTest(composite, 2) << 24) / composite).getuint();
71 | }
72 |
73 | /** Determines if given number is Prime. Accuracy can be determined by "checks".
74 | The default checks the Nexus Network uses is 2 **/
75 | bool PrimeCheck(const CBigNum& test, int checks)
76 | {
77 | /** Check A: Small Prime Divisor Tests */
78 | CBigNum primes[11] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
79 | for(int index = 0; index < 11; index++)
80 | if(test % primes[index] == 0)
81 | return false;
82 |
83 | /** Check B: Miller-Rabin Tests */
84 | bool millerRabin = Miller_Rabin(test, checks);
85 | if(!millerRabin)
86 | return false;
87 |
88 | /** Check C: Fermat Tests */
89 | for(CBigNum n = 2; n < 2 + checks; n++)
90 | if(FermatTest(test, n) != 1)
91 | return false;
92 |
93 | return true;
94 | }
95 |
96 | /** Simple Modular Exponential Equation a^(n - 1) % n == 1 or notated in Modular Arithmetic a^(n - 1) = 1 [mod n].
97 | a = Base or 2... 2 + checks, n is the Prime Test. Used after Miller-Rabin and Divisor tests to verify primality. **/
98 | CBigNum FermatTest(const CBigNum& n, const CBigNum& a)
99 | {
100 | CAutoBN_CTX pctx;
101 | CBigNum e = n - 1;
102 | CBigNum r;
103 | BN_mod_exp(r.getBN(), a.getBN(), e.getBN(), n.getBN(), pctx);
104 |
105 | return r;
106 | }
107 |
108 | /** Miller-Rabin Primality Test from the OpenSSL BN Library. **/
109 | bool Miller_Rabin(const CBigNum& n, int checks)
110 | {
111 | return (BN_is_prime_ex(n.getBN(), checks, nullptr, nullptr) == 1);
112 | }
113 |
114 | }
115 |
116 |
--------------------------------------------------------------------------------
/src/core/unifiedtime.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 |
3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014] ++
4 |
5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php
6 |
7 | *******************************************************************************************/
8 | #ifndef NEXUS_UNIFIED_TIME_H
9 | #define NEXUS_UNIFIED_TIME_H
10 |
11 | #include
12 | #include
13 |
14 | #include "../net/net.h"
15 | #include "../wallet/db.h"
16 |
17 |
18 | /** Carried on from uint1024.h **/
19 | typedef long long int64;
20 |
21 |
22 | /** Unified Time Flags **/
23 | extern bool fTimeUnified;
24 | extern bool fIsTimeSeed;
25 | extern bool fIsSeedNode;
26 |
27 |
28 | /** Offset to be added to your Local Time. This counteracts the effects of changing your clock by will or accident. **/
29 | extern int UNIFIED_LOCAL_OFFSET;
30 |
31 |
32 | /** Offset calculated from average Unified Offset collected over time. **/
33 | extern int UNIFIED_AVERAGE_OFFSET;
34 |
35 |
36 | /** Vector to Contain list of Unified Time Offset from Time Seeds, Seed Nodes, and Peers. **/
37 | extern std::vector UNIFIED_TIME_DATA;
38 |
39 | extern std::vector SEED_NODES;
40 | extern std::vector TRUSTED_NODES;
41 |
42 | extern std::vector DNS_SeedNodes;
43 |
44 | /** Declarations for the DNS Seed Nodes. **/
45 | extern std::vector DNS_SeedNodes_Testnet;
46 |
47 | /** Declarations for the DNS Seed Nodes. **/
48 | extern std::vector DNS_SeedNodes_LISPnet;
49 |
50 |
51 |
52 | /** The Maximum Seconds that a Clock can be Off. This is set to account
53 | for Network Propogation Times **/
54 | extern int MAX_UNIFIED_DRIFT;
55 |
56 |
57 | /** Initializes the Unifed Time System.
58 | A] Checks Database for Offset Average List
59 | B] Gets Periodic Average of 10 Seeds if first Unified Time **/
60 | void InitializeUnifiedTime();
61 |
62 |
63 | /** Gets the Current Unified Time Average. The More Data in Time Average, the less
64 | a pesky node with a manipulated time seed can influence. Keep in mind too that the
65 | Unified Time will only be updated upon your outgoing connection... otherwise anyone flooding
66 | network with false time seed will just be ignored. The average is a moving one, so that iter_swap
67 | will allow clocks that operate under different intervals to always stay synchronized with the network. **/
68 | int GetUnifiedAverage();
69 |
70 |
71 |
72 | /** Unified Time Clock Regulator. Periodically gets Offset from Time Seeds to build a strong Average.
73 | Checks current time against itself, if there is too much drift, your local offset adjusts to Unified Average. **/
74 | void ThreadUnifiedSamples(void* parg);
75 |
76 | std::vector DNS_Lookup(std::vector& DNS_Seed);
77 |
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/src/core/version.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 |
3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014] ++
4 |
5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php
6 |
7 | *******************************************************************************************/
8 |
9 | #include
10 | #include "version.h"
11 |
12 | /** Used for Visual Reference Only **/
13 | const std::string CLIENT_NAME("Nexus");
14 |
15 | /* The version number */
16 | const std::string CLIENT_VERSION("2.5.6");
17 |
18 | /* The interface used Qt, CLI, or Tritium) */
19 | #if defined QT_GUI
20 | const std::string CLIENT_INTERFACE("Qt");
21 | #elif defined TRITIUM_GUI
22 | const std::string CLIENT_INTERFACE("Tritium Beta");
23 | #else
24 | const std::string CLIENT_INTERFACE("CLI");
25 | #endif
26 |
27 | /* The database type used (LevelDB, Berkeley DB, or Lower Level Database) */
28 | #if defined USE_LLD
29 | const std::string CLIENT_DATABASE("[LLD]");
30 | #elif defined USE_LEVELDB
31 | const std::string CLIENT_DATABASE("[LVD]");
32 | #else
33 | const std::string CLIENT_DATABASE("[BDB]");
34 | #endif
35 |
36 | /* The Architecture (32-Bit or 64-Bit) */
37 | #ifdef x64
38 | const std::string BUILD_ARCH = "[x64]";
39 | #else
40 | const std::string BUILD_ARCH = "[x86]";
41 | #endif
42 |
43 | const std::string CLIENT_BUILD(CLIENT_VERSION + " " + CLIENT_INTERFACE + " " + CLIENT_DATABASE + BUILD_ARCH);
44 | const std::string CLIENT_DATE(__DATE__ " " __TIME__);
45 |
46 | /** Used to determine the current features available on the local database */
47 | const int DATABASE_VERSION =
48 | 1000000 * DATABASE_MAJOR
49 | + 10000 * DATABASE_MINOR
50 | + 100 * DATABASE_REVISION
51 | + 1 * DATABASE_BUILD;
52 |
53 | /** Used to determine the features available in the Nexus Network **/
54 | const int PROTOCOL_VERSION =
55 | 1000000 * PROTOCOL_MAJOR
56 | + 10000 * PROTOCOL_MINOR
57 | + 100 * PROTOCOL_REVISION
58 | + 1 * PROTOCOL_BUILD;
59 |
60 | /** Used to Lock-Out Nodes that are running a protocol version that is too old,
61 | Or to allow certain new protocol changes without confusing Old Nodes. **/
62 | const int MIN_PROTO_VERSION = 10000;
63 |
--------------------------------------------------------------------------------
/src/core/version.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 |
3 | Hash(BEGIN(Satoshi[2010]), END(Sunny[2012])) == Videlicet[2014] ++
4 |
5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php
6 |
7 | *******************************************************************************************/
8 |
9 | #ifndef NEXUS_VERSION_H
10 | #define NEXUS_VERSION_H
11 |
12 | #include
13 |
14 | #define DATABASE_MAJOR 0
15 | #define DATABASE_MINOR 1
16 | #define DATABASE_REVISION 1
17 | #define DATABASE_BUILD 0
18 |
19 | #define PROTOCOL_MAJOR 0
20 | #define PROTOCOL_MINOR 1
21 | #define PROTOCOL_REVISION 1
22 | #define PROTOCOL_BUILD 0
23 |
24 | /** Used to determine the current features available on the local database */
25 | extern const int DATABASE_VERSION;
26 |
27 | /** Used to determine the features available in the Nexus Network **/
28 | extern const int PROTOCOL_VERSION;
29 |
30 | /** Used to Lock-Out Nodes that are running a protocol version that is too old,
31 | Or to allow certain new protocol changes without confusing Old Nodes. **/
32 | extern const int MIN_PROTO_VERSION;
33 |
34 | /** These external variables are the display only variables. They are used to track the updates of Nexus independent of Database and Protocol Upgrades. **/
35 | extern const std::string CLIENT_NAME;
36 | extern const std::string CLIENT_BUILD;
37 | extern const std::string CLIENT_DATE;
38 |
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/src/hash/KeccakDuplex.c:
--------------------------------------------------------------------------------
1 | /*
2 | The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
3 | Michaël Peeters and Gilles Van Assche. For more information, feedback or
4 | questions, please refer to our website: http://keccak.noekeon.org/
5 |
6 | Implementation by the designers,
7 | hereby denoted as "the implementer".
8 |
9 | To the extent possible under law, the implementer has waived all copyright
10 | and related or neighboring rights to the source code in this file.
11 | http://creativecommons.org/publicdomain/zero/1.0/
12 | */
13 |
14 | #include
15 | #include "KeccakDuplex.h"
16 | #include "KeccakF-1600-interface.h"
17 | #ifdef KeccakReference
18 | #include "displayIntermediateValues.h"
19 | #endif
20 |
21 | int Keccak_DuplexInitialize(Keccak_DuplexInstance *instance, unsigned int rate, unsigned int capacity)
22 | {
23 | if (rate+capacity != 1600)
24 | return 1;
25 | if ((rate <= 2) || (rate > 1600))
26 | return 1;
27 | KeccakF1600_Initialize();
28 | instance->rate = rate;
29 | KeccakF1600_StateInitialize(instance->state);
30 | return 0;
31 | }
32 |
33 | int Keccak_Duplexing(Keccak_DuplexInstance *instance, const unsigned char *sigmaBegin, unsigned int sigmaBeginByteLen, unsigned char *Z, unsigned int ZByteLen, unsigned char delimitedSigmaEnd)
34 | {
35 | unsigned char delimitedSigmaEnd1[1];
36 | const unsigned int rho_max = instance->rate - 2;
37 |
38 | if (delimitedSigmaEnd == 0)
39 | return 1;
40 | if (sigmaBeginByteLen*8 > rho_max)
41 | return 1;
42 | if (rho_max - sigmaBeginByteLen*8 < 7) {
43 | unsigned int maxBitsInDelimitedSigmaEnd = rho_max - sigmaBeginByteLen*8;
44 | if (delimitedSigmaEnd >= (1 << (maxBitsInDelimitedSigmaEnd+1)))
45 | return 1;
46 | }
47 | if (ZByteLen > (instance->rate+7)/8)
48 | return 1; // The output length must not be greater than the rate (rounded up to a byte)
49 |
50 | if ((sigmaBeginByteLen%KeccakF_laneInBytes) > 0) {
51 | unsigned int offsetBeyondLane = (sigmaBeginByteLen/KeccakF_laneInBytes)*KeccakF_laneInBytes;
52 | unsigned int beyondLaneBytes = sigmaBeginByteLen%KeccakF_laneInBytes;
53 | KeccakF1600_StateXORBytesInLane(instance->state, sigmaBeginByteLen/KeccakF_laneInBytes,
54 | sigmaBegin+offsetBeyondLane, 0, beyondLaneBytes);
55 | }
56 |
57 | #ifdef KeccakReference
58 | {
59 | unsigned char block[KeccakF_width/8];
60 | memcpy(block, sigmaBegin, sigmaBeginByteLen);
61 | block[sigmaBeginByteLen] = delimitedSigmaEnd;
62 | memset(block+sigmaBeginByteLen+1, 0, ((instance->rate+63)/64)*8-sigmaBeginByteLen-1);
63 | block[(instance->rate-1)/8] |= 1 << ((instance->rate-1) % 8);
64 | displayBytes(1, "Block to be absorbed (after padding)", block, (instance->rate+7)/8);
65 | }
66 | #endif
67 |
68 | delimitedSigmaEnd1[0] = delimitedSigmaEnd;
69 | // Last few bits, whose delimiter coincides with first bit of padding
70 | KeccakF1600_StateXORBytesInLane(instance->state, sigmaBeginByteLen/KeccakF_laneInBytes,
71 | delimitedSigmaEnd1, sigmaBeginByteLen%KeccakF_laneInBytes, 1);
72 | // Second bit of padding
73 | KeccakF1600_StateComplementBit(instance->state, instance->rate - 1);
74 | KeccakF1600_StateXORPermuteExtract(instance->state, sigmaBegin, sigmaBeginByteLen/KeccakF_laneInBytes,
75 | Z, ZByteLen/KeccakF_laneInBytes);
76 |
77 | if ((ZByteLen%KeccakF_laneInBytes) > 0) {
78 | unsigned int offsetBeyondLane = (ZByteLen/KeccakF_laneInBytes)*KeccakF_laneInBytes;
79 | unsigned int beyondLaneBytes = ZByteLen%KeccakF_laneInBytes;
80 | KeccakF1600_StateExtractBytesInLane(instance->state, ZByteLen/KeccakF_laneInBytes,
81 | Z+offsetBeyondLane, 0, beyondLaneBytes);
82 | }
83 | if (ZByteLen*8 > instance->rate) {
84 | unsigned char mask = (unsigned char)(1 << (instance->rate % 8)) - 1;
85 | Z[ZByteLen-1] &= mask;
86 | }
87 |
88 | return 0;
89 | }
90 |
--------------------------------------------------------------------------------
/src/hash/KeccakDuplex.h:
--------------------------------------------------------------------------------
1 | /*
2 | The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
3 | Michaël Peeters and Gilles Van Assche. For more information, feedback or
4 | questions, please refer to our website: http://keccak.noekeon.org/
5 |
6 | Implementation by the designers,
7 | hereby denoted as "the implementer".
8 |
9 | To the extent possible under law, the implementer has waived all copyright
10 | and related or neighboring rights to the source code in this file.
11 | http://creativecommons.org/publicdomain/zero/1.0/
12 | */
13 |
14 | #ifndef _KeccakDuplex_h_
15 | #define _KeccakDuplex_h_
16 |
17 | #include "KeccakF-1600-interface.h"
18 |
19 | #ifdef ALIGN
20 | #undef ALIGN
21 | #endif
22 |
23 | #if defined(__GNUC__)
24 | #define ALIGN __attribute__ ((aligned(32)))
25 | #elif defined(_MSC_VER)
26 | #define ALIGN __declspec(align(32))
27 | #else
28 | #define ALIGN
29 | #endif
30 |
31 | /**
32 | * Structure that contains the duplex instance for use with the
33 | * Keccak_Duplex* functions.
34 | * It gathers the state processed by the permutation as well as
35 | * the rate.
36 | */
37 | ALIGN typedef struct Keccak_DuplexInstanceStruct {
38 | /** The state processed by the permutation. */
39 | ALIGN unsigned char state[KeccakF_width/8];
40 | /** The value of the rate in bits.*/
41 | unsigned int rate;
42 | } Keccak_DuplexInstance;
43 |
44 | /**
45 | * Function to initialize a duplex object Duplex[Keccak-f[r+c], pad10*1, r].
46 | * @param duplexInstance Pointer to the duplex instance to be initialized.
47 | * @param rate The value of the rate r.
48 | * @param capacity The value of the capacity c.
49 | * @pre One must have r+c=1600 in this implementation.
50 | * @pre 3 ≤ @a rate ≤ 1600, and otherwise the value of the rate is unrestricted.
51 | * @return Zero if successful, 1 otherwise.
52 | */
53 | int Keccak_DuplexInitialize(Keccak_DuplexInstance *duplexInstance, unsigned int rate, unsigned int capacity);
54 |
55 | /**
56 | * Function to make a duplexing call to the duplex object initialized
57 | * with Keccak_DuplexInitialize().
58 | * @param duplexInstance Pointer to the duplex instance initialized
59 | * by Keccak_DuplexInitialize().
60 | * @param sigmaBegin Pointer to the first part of the input σ given as bytes.
61 | * Trailing bits are given in @a delimitedSigmaEnd.
62 | * @param sigmaBeginByteLen The number of input bytes provided in @a sigmaBegin.
63 | * @param Z Pointer to the buffer where to store the output data Z.
64 | * @param ZByteLen The number of output bytes desired for Z.
65 | * If @a ZByteLen*8 is greater than the rate r,
66 | * the last byte contains only r modulo 8 bits,
67 | * in the least significant bits.
68 | * @param delimitedSigmaEnd Byte containing from 0 to 7 trailing bits that must be
69 | * appended to the input data in @a sigmaBegin.
70 | * These n=|σ| mod 8 bits must be in the least significant bit positions.
71 | * These bits must be delimited with a bit 1 at position n
72 | * (counting from 0=LSB to 7=MSB) and followed by bits 0
73 | * from position n+1 to position 7.
74 | * Some examples:
75 | * - If |σ| is a multiple of 8, then @a delimitedSigmaEnd must be 0x01.
76 | * - If |σ| mod 8 is 1 and the last bit is 1 then @a delimitedSigmaEnd must be 0x03.
77 | * - If |σ| mod 8 is 4 and the last 4 bits are 0,0,0,1 then @a delimitedSigmaEnd must be 0x18.
78 | * - If |σ| mod 8 is 6 and the last 6 bits are 1,1,1,0,0,1 then @a delimitedSigmaEnd must be 0x67.
79 | * .
80 | * @note The input bits σ are the result of the concatenation of the bytes in @a sigmaBegin
81 | * and the bits in @a delimitedSigmaEnd before the delimiter.
82 | * @pre @a delimitedSigmaEnd ≠ 0x00
83 | * @pre @a sigmaBeginByteLen*8+n ≤ (r-2)
84 | * @pre @a ZByteLen ≤ ceil(r/8)
85 | * @return Zero if successful, 1 otherwise.
86 | */
87 | int Keccak_Duplexing(Keccak_DuplexInstance *duplexInstance, const unsigned char *sigmaBegin, unsigned int sigmaBeginByteLen, unsigned char *Z, unsigned int ZByteLen, unsigned char delimitedSigmaEnd);
88 |
89 | #endif
90 |
--------------------------------------------------------------------------------
/src/hash/KeccakHash.c:
--------------------------------------------------------------------------------
1 | /*
2 | The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
3 | Michaël Peeters and Gilles Van Assche. For more information, feedback or
4 | questions, please refer to our website: http://keccak.noekeon.org/
5 |
6 | Implementation by the designers,
7 | hereby denoted as "the implementer".
8 |
9 | To the extent possible under law, the implementer has waived all copyright
10 | and related or neighboring rights to the source code in this file.
11 | http://creativecommons.org/publicdomain/zero/1.0/
12 | */
13 |
14 | #include
15 |
16 | #include "KeccakHash.h"
17 | #include "KeccakF-1600-interface.h"
18 |
19 | /* ---------------------------------------------------------------- */
20 |
21 | HashReturn Keccak_HashInitialize(Keccak_HashInstance *instance, unsigned int rate, unsigned int capacity, unsigned int hashbitlen, unsigned char delimitedSuffix)
22 | {
23 | HashReturn result;
24 |
25 | if (delimitedSuffix == 0)
26 | return FAIL;
27 | result = Keccak_SpongeInitialize(&instance->sponge, rate, capacity);
28 | if (result != SUCCESS)
29 | return result;
30 | instance->fixedOutputLength = hashbitlen;
31 | instance->delimitedSuffix = delimitedSuffix;
32 | return SUCCESS;
33 | }
34 |
35 | /* ---------------------------------------------------------------- */
36 |
37 | HashReturn Keccak_HashUpdate(Keccak_HashInstance *instance, const BitSequence *data, DataLength databitlen)
38 | {
39 | if ((databitlen % 8) == 0)
40 | return Keccak_SpongeAbsorb(&instance->sponge, data, databitlen/8);
41 | else {
42 | HashReturn ret = Keccak_SpongeAbsorb(&instance->sponge, data, databitlen/8);
43 | if (ret == SUCCESS) {
44 | // The last partial byte is assumed to be aligned on the least significant bits
45 | unsigned char lastByte = data[databitlen/8];
46 | // Concatenate the last few bits provided here with those of the suffix
47 | unsigned short delimitedLastBytes = (unsigned short)lastByte | ((unsigned short)instance->delimitedSuffix << (databitlen % 8));
48 | if ((delimitedLastBytes & 0xFF00) == 0x0000) {
49 | instance->delimitedSuffix = delimitedLastBytes & 0xFF;
50 | }
51 | else {
52 | unsigned char oneByte[1];
53 | oneByte[0] = delimitedLastBytes & 0xFF;
54 | ret = Keccak_SpongeAbsorb(&instance->sponge, oneByte, 1);
55 | instance->delimitedSuffix = (delimitedLastBytes >> 8) & 0xFF;
56 | }
57 | }
58 | return ret;
59 | }
60 | }
61 |
62 | /* ---------------------------------------------------------------- */
63 |
64 | HashReturn Keccak_HashFinal(Keccak_HashInstance *instance, BitSequence *hashval)
65 | {
66 | HashReturn ret = Keccak_SpongeAbsorbLastFewBits(&instance->sponge, instance->delimitedSuffix);
67 | if (ret == SUCCESS)
68 | return Keccak_SpongeSqueeze(&instance->sponge, hashval, instance->fixedOutputLength/8);
69 | else
70 | return ret;
71 | }
72 |
73 | /* ---------------------------------------------------------------- */
74 |
75 | HashReturn Keccak_HashSqueeze(Keccak_HashInstance *instance, BitSequence *data, DataLength databitlen)
76 | {
77 | if ((databitlen % 8) != 0)
78 | return FAIL;
79 | return Keccak_SpongeSqueeze(&instance->sponge, data, databitlen/8);
80 | }
81 |
--------------------------------------------------------------------------------
/src/hash/crypto_hash.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/hash/crypto_hash.h
--------------------------------------------------------------------------------
/src/json/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2007 - 2009 John W. Wilkinson
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without
8 | restriction, including without limitation the rights to use,
9 | copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the
11 | Software is furnished to do so, subject to the following
12 | conditions:
13 |
14 | The above copyright notice and this permission notice shall be
15 | included in all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | OTHER DEALINGS IN THE SOFTWARE.
25 |
--------------------------------------------------------------------------------
/src/json/json_spirit.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_SPIRIT
2 | #define JSON_SPIRIT
3 |
4 | // Copyright John W. Wilkinson 2007 - 2009.
5 | // Distributed under the MIT License, see accompanying file LICENSE.txt
6 |
7 | // json spirit version 4.03
8 |
9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 | # pragma once
11 | #endif
12 |
13 | #include "json_spirit_value.h"
14 | #include "json_spirit_reader.h"
15 | #include "json_spirit_writer.h"
16 | #include "json_spirit_utils.h"
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/src/json/json_spirit_error_position.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_SPIRIT_ERROR_POSITION
2 | #define JSON_SPIRIT_ERROR_POSITION
3 |
4 | // Copyright John W. Wilkinson 2007 - 2009.
5 | // Distributed under the MIT License, see accompanying file LICENSE.txt
6 |
7 | // json spirit version 4.03
8 |
9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 | # pragma once
11 | #endif
12 |
13 | #include
14 |
15 | namespace json_spirit
16 | {
17 | // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error.
18 | // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read"
19 | // functions that return a bool.
20 | //
21 | struct Error_position
22 | {
23 | Error_position();
24 | Error_position( unsigned int line, unsigned int column, const std::string& reason );
25 | bool operator==( const Error_position& lhs ) const;
26 | unsigned int line_;
27 | unsigned int column_;
28 | std::string reason_;
29 | };
30 |
31 | inline Error_position::Error_position()
32 | : line_( 0 )
33 | , column_( 0 )
34 | {
35 | }
36 |
37 | inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason )
38 | : line_( line )
39 | , column_( column )
40 | , reason_( reason )
41 | {
42 | }
43 |
44 | inline bool Error_position::operator==( const Error_position& lhs ) const
45 | {
46 | if( this == &lhs ) return true;
47 |
48 | return ( reason_ == lhs.reason_ ) &&
49 | ( line_ == lhs.line_ ) &&
50 | ( column_ == lhs.column_ );
51 | }
52 | }
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/json/json_spirit_reader.cpp:
--------------------------------------------------------------------------------
1 | // Copyright John W. Wilkinson 2007 - 2009.
2 | // Distributed under the MIT License, see accompanying file LICENSE.txt
3 |
4 | // json spirit version 4.03
5 |
6 | #include "json_spirit_reader.h"
7 | #include "json_spirit_reader_template.h"
8 |
9 | using namespace json_spirit;
10 |
11 | bool json_spirit::read( const std::string& s, Value& value )
12 | {
13 | return read_string( s, value );
14 | }
15 |
16 | void json_spirit::read_or_throw( const std::string& s, Value& value )
17 | {
18 | read_string_or_throw( s, value );
19 | }
20 |
21 | bool json_spirit::read( std::istream& is, Value& value )
22 | {
23 | return read_stream( is, value );
24 | }
25 |
26 | void json_spirit::read_or_throw( std::istream& is, Value& value )
27 | {
28 | read_stream_or_throw( is, value );
29 | }
30 |
31 | bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
32 | {
33 | return read_range( begin, end, value );
34 | }
35 |
36 | void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
37 | {
38 | begin = read_range_or_throw( begin, end, value );
39 | }
40 |
41 | #ifndef BOOST_NO_STD_WSTRING
42 |
43 | bool json_spirit::read( const std::wstring& s, wValue& value )
44 | {
45 | return read_string( s, value );
46 | }
47 |
48 | void json_spirit::read_or_throw( const std::wstring& s, wValue& value )
49 | {
50 | read_string_or_throw( s, value );
51 | }
52 |
53 | bool json_spirit::read( std::wistream& is, wValue& value )
54 | {
55 | return read_stream( is, value );
56 | }
57 |
58 | void json_spirit::read_or_throw( std::wistream& is, wValue& value )
59 | {
60 | read_stream_or_throw( is, value );
61 | }
62 |
63 | bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
64 | {
65 | return read_range( begin, end, value );
66 | }
67 |
68 | void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
69 | {
70 | begin = read_range_or_throw( begin, end, value );
71 | }
72 |
73 | #endif
74 |
75 | bool json_spirit::read( const std::string& s, mValue& value )
76 | {
77 | return read_string( s, value );
78 | }
79 |
80 | void json_spirit::read_or_throw( const std::string& s, mValue& value )
81 | {
82 | read_string_or_throw( s, value );
83 | }
84 |
85 | bool json_spirit::read( std::istream& is, mValue& value )
86 | {
87 | return read_stream( is, value );
88 | }
89 |
90 | void json_spirit::read_or_throw( std::istream& is, mValue& value )
91 | {
92 | read_stream_or_throw( is, value );
93 | }
94 |
95 | bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
96 | {
97 | return read_range( begin, end, value );
98 | }
99 |
100 | void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
101 | {
102 | begin = read_range_or_throw( begin, end, value );
103 | }
104 |
105 | #ifndef BOOST_NO_STD_WSTRING
106 |
107 | bool json_spirit::read( const std::wstring& s, wmValue& value )
108 | {
109 | return read_string( s, value );
110 | }
111 |
112 | void json_spirit::read_or_throw( const std::wstring& s, wmValue& value )
113 | {
114 | read_string_or_throw( s, value );
115 | }
116 |
117 | bool json_spirit::read( std::wistream& is, wmValue& value )
118 | {
119 | return read_stream( is, value );
120 | }
121 |
122 | void json_spirit::read_or_throw( std::wistream& is, wmValue& value )
123 | {
124 | read_stream_or_throw( is, value );
125 | }
126 |
127 | bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
128 | {
129 | return read_range( begin, end, value );
130 | }
131 |
132 | void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
133 | {
134 | begin = read_range_or_throw( begin, end, value );
135 | }
136 |
137 | #endif
138 |
--------------------------------------------------------------------------------
/src/json/json_spirit_reader.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_SPIRIT_READER
2 | #define JSON_SPIRIT_READER
3 |
4 | // Copyright John W. Wilkinson 2007 - 2009.
5 | // Distributed under the MIT License, see accompanying file LICENSE.txt
6 |
7 | // json spirit version 4.03
8 |
9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 | # pragma once
11 | #endif
12 |
13 | #include "json_spirit_value.h"
14 | #include "json_spirit_error_position.h"
15 | #include
16 |
17 | namespace json_spirit
18 | {
19 | // functions to reads a JSON values
20 |
21 | bool read( const std::string& s, Value& value );
22 | bool read( std::istream& is, Value& value );
23 | bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
24 |
25 | void read_or_throw( const std::string& s, Value& value );
26 | void read_or_throw( std::istream& is, Value& value );
27 | void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
28 |
29 | #ifndef BOOST_NO_STD_WSTRING
30 |
31 | bool read( const std::wstring& s, wValue& value );
32 | bool read( std::wistream& is, wValue& value );
33 | bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
34 |
35 | void read_or_throw( const std::wstring& s, wValue& value );
36 | void read_or_throw( std::wistream& is, wValue& value );
37 | void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
38 |
39 | #endif
40 |
41 | bool read( const std::string& s, mValue& value );
42 | bool read( std::istream& is, mValue& value );
43 | bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
44 |
45 | void read_or_throw( const std::string& s, mValue& value );
46 | void read_or_throw( std::istream& is, mValue& value );
47 | void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
48 |
49 | #ifndef BOOST_NO_STD_WSTRING
50 |
51 | bool read( const std::wstring& s, wmValue& value );
52 | bool read( std::wistream& is, wmValue& value );
53 | bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
54 |
55 | void read_or_throw( const std::wstring& s, wmValue& value );
56 | void read_or_throw( std::wistream& is, wmValue& value );
57 | void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
58 |
59 | #endif
60 | }
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/src/json/json_spirit_stream_reader.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_SPIRIT_READ_STREAM
2 | #define JSON_SPIRIT_READ_STREAM
3 |
4 | // Copyright John W. Wilkinson 2007 - 2009.
5 | // Distributed under the MIT License, see accompanying file LICENSE.txt
6 |
7 | // json spirit version 4.03
8 |
9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 | # pragma once
11 | #endif
12 |
13 | #include "json_spirit_reader_template.h"
14 |
15 | namespace json_spirit
16 | {
17 | // these classes allows you to read multiple top level contiguous values from a stream,
18 | // the normal stream read functions have a bug that prevent multiple top level values
19 | // from being read unless they are separated by spaces
20 |
21 | template< class Istream_type, class Value_type >
22 | class Stream_reader
23 | {
24 | public:
25 |
26 | Stream_reader( Istream_type& is )
27 | : iters_( is )
28 | {
29 | }
30 |
31 | bool read_next( Value_type& value )
32 | {
33 | return read_range( iters_.begin_, iters_.end_, value );
34 | }
35 |
36 | private:
37 |
38 | typedef Multi_pass_iters< Istream_type > Mp_iters;
39 |
40 | Mp_iters iters_;
41 | };
42 |
43 | template< class Istream_type, class Value_type >
44 | class Stream_reader_thrower
45 | {
46 | public:
47 |
48 | Stream_reader_thrower( Istream_type& is )
49 | : iters_( is )
50 | , posn_begin_( iters_.begin_, iters_.end_ )
51 | , posn_end_( iters_.end_, iters_.end_ )
52 | {
53 | }
54 |
55 | void read_next( Value_type& value )
56 | {
57 | posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value );
58 | }
59 |
60 | private:
61 |
62 | typedef Multi_pass_iters< Istream_type > Mp_iters;
63 | typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t;
64 |
65 | Mp_iters iters_;
66 | Posn_iter_t posn_begin_, posn_end_;
67 | };
68 | }
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/json/json_spirit_utils.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_SPIRIT_UTILS
2 | #define JSON_SPIRIT_UTILS
3 |
4 | // Copyright John W. Wilkinson 2007 - 2009.
5 | // Distributed under the MIT License, see accompanying file LICENSE.txt
6 |
7 | // json spirit version 4.03
8 |
9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 | # pragma once
11 | #endif
12 |
13 | #include "json_spirit_value.h"
14 | #include