├── .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 15 | 16 | namespace json_spirit 17 | { 18 | template< class Obj_t, class Map_t > 19 | void obj_to_map( const Obj_t& obj, Map_t& mp_obj ) 20 | { 21 | mp_obj.clear(); 22 | 23 | for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i ) 24 | { 25 | mp_obj[ i->name_ ] = i->value_; 26 | } 27 | } 28 | 29 | template< class Obj_t, class Map_t > 30 | void map_to_obj( const Map_t& mp_obj, Obj_t& obj ) 31 | { 32 | obj.clear(); 33 | 34 | for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i ) 35 | { 36 | obj.push_back( typename Obj_t::value_type( i->first, i->second ) ); 37 | } 38 | } 39 | 40 | typedef std::map< std::string, Value > Mapped_obj; 41 | 42 | #ifndef BOOST_NO_STD_WSTRING 43 | typedef std::map< std::wstring, wValue > wMapped_obj; 44 | #endif 45 | 46 | template< class Object_type, class String_type > 47 | const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name ) 48 | { 49 | for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i ) 50 | { 51 | if( i->name_ == name ) 52 | { 53 | return i->value_; 54 | } 55 | } 56 | 57 | return Object_type::value_type::Value_type::null; 58 | } 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/json/json_spirit_value.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 John W Wilkinson 2 | 3 | This source code can be used for any purpose as long as 4 | this comment is retained. */ 5 | 6 | // json spirit version 2.00 7 | 8 | #include "json_spirit_value.h" 9 | -------------------------------------------------------------------------------- /src/json/json_spirit_writer.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_writer.h" 7 | #include "json_spirit_writer_template.h" 8 | 9 | void json_spirit::write( const Value& value, std::ostream& os ) 10 | { 11 | write_stream( value, os, false ); 12 | } 13 | 14 | void json_spirit::write_formatted( const Value& value, std::ostream& os ) 15 | { 16 | write_stream( value, os, true ); 17 | } 18 | 19 | std::string json_spirit::write( const Value& value ) 20 | { 21 | return write_string( value, false ); 22 | } 23 | 24 | std::string json_spirit::write_formatted( const Value& value ) 25 | { 26 | return write_string( value, true ); 27 | } 28 | 29 | #ifndef BOOST_NO_STD_WSTRING 30 | 31 | void json_spirit::write( const wValue& value, std::wostream& os ) 32 | { 33 | write_stream( value, os, false ); 34 | } 35 | 36 | void json_spirit::write_formatted( const wValue& value, std::wostream& os ) 37 | { 38 | write_stream( value, os, true ); 39 | } 40 | 41 | std::wstring json_spirit::write( const wValue& value ) 42 | { 43 | return write_string( value, false ); 44 | } 45 | 46 | std::wstring json_spirit::write_formatted( const wValue& value ) 47 | { 48 | return write_string( value, true ); 49 | } 50 | 51 | #endif 52 | 53 | void json_spirit::write( const mValue& value, std::ostream& os ) 54 | { 55 | write_stream( value, os, false ); 56 | } 57 | 58 | void json_spirit::write_formatted( const mValue& value, std::ostream& os ) 59 | { 60 | write_stream( value, os, true ); 61 | } 62 | 63 | std::string json_spirit::write( const mValue& value ) 64 | { 65 | return write_string( value, false ); 66 | } 67 | 68 | std::string json_spirit::write_formatted( const mValue& value ) 69 | { 70 | return write_string( value, true ); 71 | } 72 | 73 | #ifndef BOOST_NO_STD_WSTRING 74 | 75 | void json_spirit::write( const wmValue& value, std::wostream& os ) 76 | { 77 | write_stream( value, os, false ); 78 | } 79 | 80 | void json_spirit::write_formatted( const wmValue& value, std::wostream& os ) 81 | { 82 | write_stream( value, os, true ); 83 | } 84 | 85 | std::wstring json_spirit::write( const wmValue& value ) 86 | { 87 | return write_string( value, false ); 88 | } 89 | 90 | std::wstring json_spirit::write_formatted( const wmValue& value ) 91 | { 92 | return write_string( value, true ); 93 | } 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /src/json/json_spirit_writer.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT_WRITER 2 | #define JSON_SPIRIT_WRITER 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 15 | 16 | namespace json_spirit 17 | { 18 | // functions to convert JSON Values to text, 19 | // the "formatted" versions add whitespace to format the output nicely 20 | 21 | void write ( const Value& value, std::ostream& os ); 22 | void write_formatted( const Value& value, std::ostream& os ); 23 | std::string write ( const Value& value ); 24 | std::string write_formatted( const Value& value ); 25 | 26 | #ifndef BOOST_NO_STD_WSTRING 27 | 28 | void write ( const wValue& value, std::wostream& os ); 29 | void write_formatted( const wValue& value, std::wostream& os ); 30 | std::wstring write ( const wValue& value ); 31 | std::wstring write_formatted( const wValue& value ); 32 | 33 | #endif 34 | 35 | void write ( const mValue& value, std::ostream& os ); 36 | void write_formatted( const mValue& value, std::ostream& os ); 37 | std::string write ( const mValue& value ); 38 | std::string write_formatted( const mValue& value ); 39 | 40 | #ifndef BOOST_NO_STD_WSTRING 41 | 42 | void write ( const wmValue& value, std::wostream& os ); 43 | void write_formatted( const wmValue& value, std::wostream& os ); 44 | std::wstring write ( const wmValue& value ); 45 | std::wstring write_formatted( const wmValue& value ); 46 | 47 | #endif 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/main.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_INIT_H 10 | #define NEXUS_INIT_H 11 | 12 | #include "wallet/wallet.h" 13 | 14 | extern Wallet::CWallet* pwalletMain; 15 | 16 | void StartShutdown(); 17 | void Shutdown(void* parg); 18 | bool AppInit(int argc, char* argv[]); 19 | bool AppInit2(int argc, char* argv[]); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/net/rpcserver.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 _NexusRPC_H_ 10 | #define _NexusRPC_H_ 1 11 | 12 | #include 13 | #include 14 | 15 | namespace Wallet { class CReserveKey; } 16 | 17 | #include "../json/json_spirit_reader_template.h" 18 | #include "../json/json_spirit_writer_template.h" 19 | #include "../json/json_spirit_utils.h" 20 | 21 | namespace Net 22 | { 23 | void ThreadRPCServer(void* parg); 24 | int CommandLineRPC(int argc, char *argv[]); 25 | 26 | /** Convert parameter values for RPC call from strings to command-specific JSON objects. */ 27 | json_spirit::Array RPCConvertValues(const std::string &strMethod, const std::vector &strParams); 28 | 29 | typedef json_spirit::Value(*rpcfn_type)(const json_spirit::Array& params, bool fHelp); 30 | 31 | class CRPCCommand 32 | { 33 | public: 34 | std::string name; 35 | rpcfn_type actor; 36 | bool okSafeMode; 37 | }; 38 | 39 | /** 40 | * Nexus RPC command dispatcher. 41 | */ 42 | class CRPCTable 43 | { 44 | private: 45 | std::map mapCommands; 46 | public: 47 | CRPCTable(); 48 | const CRPCCommand* operator[](std::string name) const; 49 | std::string help(std::string name) const; 50 | 51 | /** 52 | * Execute a method. 53 | * @param method Method to execute 54 | * @param params Array of arguments (JSON objects) 55 | * @returns Result of the call. 56 | * @throws an exception (json_spirit::Value) when an error happens. 57 | */ 58 | json_spirit::Value execute(const std::string &method, const json_spirit::Array ¶ms) const; 59 | 60 | /** 61 | * Get RPC command map. 62 | * 63 | */ 64 | std::vector getMapCommandsKeyVector() const; 65 | }; 66 | 67 | extern const CRPCTable tableRPC; 68 | extern Wallet::CReserveKey* pMiningKey; 69 | 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/qt/core/guiconstants.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef GUICONSTANTS_H 10 | #define GUICONSTANTS_H 11 | 12 | /* Milliseconds between model updates */ 13 | static const int MODEL_UPDATE_DELAY = 500; 14 | 15 | /* Maximum passphrase length */ 16 | static const int MAX_PASSPHRASE_SIZE = 1024; 17 | 18 | /* Size of icons in status bar */ 19 | static const int STATUSBAR_ICONSIZE = 16; 20 | 21 | /* Invalid field background style */ 22 | #define STYLE_INVALID "background:#FF8080" 23 | 24 | /* Transaction list -- unconfirmed transaction */ 25 | #define COLOR_UNCONFIRMED QColor(128, 128, 128) 26 | /* Transaction list -- negative amount */ 27 | #define COLOR_NEGATIVE QColor(255, 0, 0) 28 | /* Transaction list -- bare address (without label) */ 29 | #define COLOR_BAREADDRESS QColor(140, 140, 140) 30 | 31 | #endif // GUICONSTANTS_H 32 | -------------------------------------------------------------------------------- /src/qt/core/qtipcserver.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "../util/ui_interface.h" 15 | #include "../util/util.h" 16 | #include "qtipcserver.h" 17 | 18 | using namespace boost::interprocess; 19 | using namespace boost::posix_time; 20 | using namespace boost; 21 | using namespace std; 22 | 23 | void ipcShutdown() 24 | { 25 | message_queue::remove(NEXUS_URI_QUEUE_NAME); 26 | } 27 | 28 | void ipcThread(void* parg) 29 | { 30 | 31 | } 32 | 33 | void ipcInit() 34 | { 35 | #ifdef MAC_OSX 36 | // TODO: implement Nexus: URI handling the Mac Way 37 | return; 38 | #endif 39 | #ifdef WIN32 40 | // TODO: THOROUGHLY test boost::interprocess fix, 41 | // and make sure there are no Windows argument-handling exploitable 42 | // problems. 43 | return; 44 | #endif 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/qt/core/qtipcserver.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #define NEXUS_URI_QUEUE_NAME "NexusURI" 10 | 11 | void ipcInit(); 12 | void ipcShutdown(); 13 | -------------------------------------------------------------------------------- /src/qt/core/rpcconsole.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef RPCCONSOLE_H 10 | #define RPCCONSOLE_H 11 | #include 12 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 13 | #include 14 | #else 15 | #include 16 | #endif 17 | 18 | namespace Ui { 19 | class RPCConsole; 20 | } 21 | class ClientModel; 22 | 23 | /** Local Nexus RPC console. */ 24 | class RPCConsole: public QDialog 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit RPCConsole(QWidget *parent = 0); 30 | ~RPCConsole(); 31 | 32 | void setClientModel(ClientModel *model); 33 | 34 | enum MessageClass { 35 | MC_ERROR, 36 | MC_DEBUG, 37 | CMD_REQUEST, 38 | CMD_REPLY, 39 | CMD_ERROR 40 | }; 41 | 42 | protected: 43 | virtual bool eventFilter(QObject* obj, QEvent *event); 44 | 45 | private slots: 46 | void on_lineEdit_returnPressed(); 47 | 48 | void on_tabWidget_currentChanged(int index); 49 | 50 | public slots: 51 | void clear(); 52 | void message(int category, const QString &message, bool html = false); 53 | 54 | /** Set number of connections shown in the UI */ 55 | void setNumConnections(int count); 56 | 57 | /** Set number of blocks shown in the UI */ 58 | void setNumBlocks(int count); 59 | 60 | /** Set the Coin Supply Information. **/ 61 | void SetCoinSupply(unsigned int nSupply, unsigned int nIdealSupply); 62 | 63 | /** Set the Information Associated with the Prime Channel. **/ 64 | void SetPrimeInfo(double nDiff, unsigned int nReserves, unsigned int nHeight, double nRewards); 65 | 66 | /** Set the Information Associated with the Hashing Channel. **/ 67 | void SetHashInfo(double nDiff, unsigned int nReserves, unsigned int nHeight, double nRewards); 68 | 69 | 70 | /** Go forward or back in history */ 71 | void browseHistory(int offset); 72 | 73 | /** Scroll console view to end */ 74 | void scrollToEnd(); 75 | signals: 76 | // For RPC command executor 77 | void stopExecutor(); 78 | void cmdRequest(const QString &command); 79 | 80 | private: 81 | Ui::RPCConsole *ui; 82 | ClientModel *clientModel; 83 | QStringList history; 84 | int historyPtr; 85 | 86 | void startExecutor(); 87 | }; 88 | 89 | #endif // RPCCONSOLE_H 90 | -------------------------------------------------------------------------------- /src/qt/core/units.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef NexusUNITS_H 10 | #define NexusUNITS_H 11 | 12 | #include 13 | #include 14 | 15 | /** Nexus unit definitions. Encapsulates parsing and formatting 16 | and serves as list model for dropdown selection boxes. 17 | */ 18 | class NexusUnits: public QAbstractListModel 19 | { 20 | public: 21 | explicit NexusUnits(QObject *parent); 22 | 23 | /** Nexus units. 24 | @note Source: https://en.Nexus.it/wiki/Units . Please add only sensible ones 25 | */ 26 | enum Unit 27 | { 28 | Nexus, 29 | mNexus, 30 | uNexus 31 | }; 32 | 33 | //! @name Static API 34 | //! Unit conversion and formatting 35 | ///@{ 36 | 37 | //! Get list of units, for dropdown box 38 | static QList availableUnits(); 39 | //! Is unit ID valid? 40 | static bool valid(int unit); 41 | //! Short name 42 | static QString name(int unit); 43 | //! Longer description 44 | static QString description(int unit); 45 | //! Number of Satoshis (1e-8) per unit 46 | static qint64 factor(int unit); 47 | //! Number of amount digits (to represent max number of coins) 48 | static int amountDigits(int unit); 49 | //! Number of decimals left 50 | static int decimals(int unit); 51 | //! Format as string 52 | static QString format(int unit, qint64 amount, bool plussign=false); 53 | //! Format as string (with unit) 54 | static QString formatWithUnit(int unit, qint64 amount, bool plussign=false); 55 | //! Parse string to coin amount 56 | static bool parse(int unit, const QString &value, qint64 *val_out); 57 | ///@} 58 | 59 | //! @name AbstractListModel implementation 60 | //! List model for unit dropdown selection box. 61 | ///@{ 62 | enum RoleIndex { 63 | /** Unit identifier */ 64 | UnitRole = Qt::UserRole 65 | }; 66 | int rowCount(const QModelIndex &parent) const; 67 | QVariant data(const QModelIndex &index, int role) const; 68 | ///@} 69 | private: 70 | QList unitlist; 71 | }; 72 | typedef NexusUnits::Unit NexusUnit; 73 | 74 | #endif // NexusUNITS_H 75 | -------------------------------------------------------------------------------- /src/qt/dialogs/aboutdialog.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "aboutdialog.h" 10 | #include "ui_aboutdialog.h" 11 | #include "../models/clientmodel.h" 12 | 13 | #include "../../core/version.h" 14 | 15 | AboutDialog::AboutDialog(QWidget *parent) : 16 | QDialog(parent), 17 | ui(new Ui::AboutDialog) 18 | { 19 | ui->setupUi(this); 20 | setStyleSheet("selection-background-color: #084B8A; background-color: #F7F7F7"); 21 | } 22 | 23 | void AboutDialog::setModel(ClientModel *model) 24 | { 25 | if(model) 26 | { 27 | ui->versionLabel->setText(model->formatFullVersion()); 28 | } 29 | } 30 | 31 | AboutDialog::~AboutDialog() 32 | { 33 | delete ui; 34 | } 35 | 36 | void AboutDialog::on_buttonBox_accepted() 37 | { 38 | close(); 39 | } 40 | -------------------------------------------------------------------------------- /src/qt/dialogs/aboutdialog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef ABOUTDIALOG_H 10 | #define ABOUTDIALOG_H 11 | #include 12 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 13 | #include 14 | #else 15 | #include 16 | #endif 17 | 18 | namespace Ui { class AboutDialog; } 19 | class ClientModel; 20 | 21 | /** "About" dialog box */ 22 | class AboutDialog : public QDialog 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit AboutDialog(QWidget *parent = 0); 28 | ~AboutDialog(); 29 | 30 | void setModel(ClientModel *model); 31 | private: 32 | Ui::AboutDialog *ui; 33 | 34 | private slots: 35 | void on_buttonBox_accepted(); 36 | }; 37 | 38 | #endif // ABOUTDIALOG_H 39 | -------------------------------------------------------------------------------- /src/qt/dialogs/askpassphrasedialog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef ASKPASSPHRASEDIALOG_H 10 | #define ASKPASSPHRASEDIALOG_H 11 | #include 12 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 13 | #include 14 | #else 15 | #include 16 | #endif 17 | 18 | namespace Ui { 19 | class AskPassphraseDialog; 20 | } 21 | 22 | class WalletModel; 23 | 24 | /** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase. 25 | */ 26 | class AskPassphraseDialog : public QDialog 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | enum Mode { 32 | Encrypt, /**< Ask passphrase twice and encrypt */ 33 | Unlock, /**< Ask passphrase and unlock */ 34 | UnlockOrMint, /**< Ask passphrase and unlock or mint only unlock */ 35 | ChangePass, /**< Ask old passphrase + new passphrase twice */ 36 | Decrypt /**< Ask passphrase and decrypt wallet */ 37 | }; 38 | 39 | explicit AskPassphraseDialog(Mode mode, QWidget *parent = 0); 40 | ~AskPassphraseDialog(); 41 | 42 | void accept(); 43 | 44 | void setModel(WalletModel *model); 45 | 46 | private: 47 | Ui::AskPassphraseDialog *ui; 48 | Mode mode; 49 | WalletModel *model; 50 | bool fCapsLock; 51 | 52 | private slots: 53 | void textChanged(); 54 | bool event(QEvent *event); 55 | bool eventFilter(QObject *, QEvent *event); 56 | }; 57 | 58 | #endif // ASKPASSPHRASEDIALOG_H 59 | -------------------------------------------------------------------------------- /src/qt/dialogs/editaddressdialog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef EDITADDRESSDIALOG_H 10 | #define EDITADDRESSDIALOG_H 11 | #include 12 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 13 | #include 14 | #else 15 | #include 16 | #endif 17 | 18 | QT_BEGIN_NAMESPACE 19 | class QDataWidgetMapper; 20 | QT_END_NAMESPACE 21 | 22 | namespace Ui { 23 | class EditAddressDialog; 24 | } 25 | class AddressTableModel; 26 | 27 | /** Dialog for editing an address and associated information. 28 | */ 29 | class EditAddressDialog : public QDialog 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | enum Mode { 35 | NewReceivingAddress, 36 | NewSendingAddress, 37 | EditReceivingAddress, 38 | EditSendingAddress 39 | }; 40 | 41 | explicit EditAddressDialog(Mode mode, QWidget *parent = 0); 42 | ~EditAddressDialog(); 43 | 44 | void setModel(AddressTableModel *model); 45 | void loadRow(int row); 46 | 47 | void accept(); 48 | 49 | QString getAddress() const; 50 | void setAddress(const QString &address); 51 | private: 52 | bool saveCurrentRow(); 53 | 54 | Ui::EditAddressDialog *ui; 55 | QDataWidgetMapper *mapper; 56 | Mode mode; 57 | AddressTableModel *model; 58 | 59 | QString address; 60 | }; 61 | 62 | #endif // EDITADDRESSDIALOG_H 63 | -------------------------------------------------------------------------------- /src/qt/dialogs/optionsdialog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef OPTIONSDIALOG_H 10 | #define OPTIONSDIALOG_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | QT_BEGIN_NAMESPACE 20 | class QStackedWidget; 21 | class QListWidget; 22 | class QListWidgetItem; 23 | class QPushButton; 24 | QT_END_NAMESPACE 25 | class OptionsModel; 26 | class MainOptionsPage; 27 | class DisplayOptionsPage; 28 | class MonitoredDataMapper; 29 | 30 | /** Preferences dialog. */ 31 | class OptionsDialog : public QDialog 32 | { 33 | Q_OBJECT 34 | public: 35 | explicit OptionsDialog(QWidget *parent=0); 36 | 37 | void setModel(OptionsModel *model); 38 | 39 | signals: 40 | 41 | public slots: 42 | /** Change the current page to \a index. */ 43 | void changePage(int index); 44 | 45 | private slots: 46 | void okClicked(); 47 | void cancelClicked(); 48 | void applyClicked(); 49 | void enableApply(); 50 | void disableApply(); 51 | 52 | private: 53 | QListWidget *contents_widget; 54 | QStackedWidget *pages_widget; 55 | OptionsModel *model; 56 | MonitoredDataMapper *mapper; 57 | QPushButton *apply_button; 58 | 59 | // Pages 60 | MainOptionsPage *main_page; 61 | DisplayOptionsPage *display_page; 62 | 63 | void setupMainPage(); 64 | }; 65 | 66 | #endif // OPTIONSDIALOG_H 67 | -------------------------------------------------------------------------------- /src/qt/dialogs/qrcodedialog.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "qrcodedialog.h" 10 | #include "ui_qrcodedialog.h" 11 | #include "../util/guiutil.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #define EXPORT_IMAGE_SIZE 256 20 | 21 | QRCodeDialog::QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent) : 22 | QDialog(parent), ui(new Ui::QRCodeDialog), address(addr) 23 | { 24 | ui->setupUi(this); 25 | setWindowTitle(QString("%1").arg(address)); 26 | setAttribute(Qt::WA_DeleteOnClose); 27 | 28 | ui->chkReqPayment->setVisible(enableReq); 29 | ui->lnReqAmount->setVisible(enableReq); 30 | ui->lblAmount->setVisible(enableReq); 31 | ui->lblNexus->setVisible(enableReq); 32 | 33 | ui->lnLabel->setText(label); 34 | 35 | genCode(); 36 | } 37 | 38 | QRCodeDialog::~QRCodeDialog() 39 | { 40 | delete ui; 41 | } 42 | 43 | void QRCodeDialog::genCode() 44 | { 45 | QString uri = getURI(); 46 | 47 | if (uri != "") 48 | { 49 | ui->lblQRCode->setText(""); 50 | 51 | QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1); 52 | if (!code) 53 | { 54 | ui->lblQRCode->setText(tr("Error encoding URI into QR Code.")); 55 | return; 56 | } 57 | myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); 58 | myImage.fill(0xffffff); 59 | unsigned char *p = code->data; 60 | for (int y = 0; y < code->width; y++) 61 | { 62 | for (int x = 0; x < code->width; x++) 63 | { 64 | myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff)); 65 | p++; 66 | } 67 | } 68 | QRcode_free(code); 69 | ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300)); 70 | } 71 | else 72 | ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce the text for label / message.")); 73 | } 74 | 75 | QString QRCodeDialog::getURI() 76 | { 77 | QString ret = QString("Nexus:%1").arg(address); 78 | 79 | int paramCount = 0; 80 | if (ui->chkReqPayment->isChecked() && !ui->lnReqAmount->text().isEmpty()) 81 | { 82 | bool ok = false; 83 | ui->lnReqAmount->text().toDouble(&ok); 84 | if (ok) 85 | { 86 | ret += QString("?amount=%1").arg(ui->lnReqAmount->text()); 87 | paramCount++; 88 | } 89 | } 90 | 91 | if (!ui->lnLabel->text().isEmpty()) 92 | { 93 | QString lbl(QUrl::toPercentEncoding(ui->lnLabel->text())); 94 | ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl); 95 | paramCount++; 96 | } 97 | 98 | if (!ui->lnMessage->text().isEmpty()) 99 | { 100 | QString msg(QUrl::toPercentEncoding(ui->lnMessage->text())); 101 | ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg); 102 | paramCount++; 103 | } 104 | 105 | // limit URI length to 255 chars, to prevent a DoS against the QR-Code dialog 106 | if (ret.length() < 256) 107 | return ret; 108 | else 109 | return QString(""); 110 | } 111 | 112 | void QRCodeDialog::on_lnReqAmount_textChanged(const QString &arg1) 113 | { 114 | genCode(); 115 | } 116 | 117 | void QRCodeDialog::on_lnLabel_textChanged(const QString &arg1) 118 | { 119 | genCode(); 120 | } 121 | 122 | void QRCodeDialog::on_lnMessage_textChanged(const QString &arg1) 123 | { 124 | genCode(); 125 | } 126 | 127 | void QRCodeDialog::on_btnSaveAs_clicked() 128 | { 129 | QString fn = GUIUtil::getSaveFileName(this, tr("Save Image..."), QString(), tr("PNG Images (*.png)")); 130 | if (!fn.isEmpty()) 131 | myImage.scaled(EXPORT_IMAGE_SIZE, EXPORT_IMAGE_SIZE).save(fn); 132 | } 133 | 134 | void QRCodeDialog::on_chkReqPayment_toggled(bool) 135 | { 136 | genCode(); 137 | } 138 | -------------------------------------------------------------------------------- /src/qt/dialogs/qrcodedialog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef QRCODEDIALOG_H 10 | #define QRCODEDIALOG_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | #include 19 | 20 | namespace Ui { 21 | class QRCodeDialog; 22 | } 23 | 24 | class QRCodeDialog : public QDialog 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent = 0); 30 | ~QRCodeDialog(); 31 | 32 | private slots: 33 | void on_lnReqAmount_textChanged(const QString &arg1); 34 | void on_lnLabel_textChanged(const QString &arg1); 35 | void on_lnMessage_textChanged(const QString &arg1); 36 | void on_btnSaveAs_clicked(); 37 | 38 | void on_chkReqPayment_toggled(bool checked); 39 | 40 | private: 41 | Ui::QRCodeDialog *ui; 42 | QImage myImage; 43 | 44 | QString getURI(); 45 | QString address; 46 | 47 | void genCode(); 48 | }; 49 | 50 | #endif // QRCODEDIALOG_H 51 | -------------------------------------------------------------------------------- /src/qt/dialogs/sendcoinsdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef SENDCOINSDIALOG_H 2 | #define SENDCOINSDIALOG_H 3 | 4 | #include 5 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 6 | #include 7 | #else 8 | #include 9 | #endif 10 | 11 | namespace Ui { 12 | class SendCoinsDialog; 13 | } 14 | class WalletModel; 15 | class SendCoinsEntry; 16 | class SendCoinsRecipient; 17 | 18 | QT_BEGIN_NAMESPACE 19 | class QUrl; 20 | QT_END_NAMESPACE 21 | 22 | /** Dialog for sending Nexus */ 23 | class SendCoinsDialog : public QDialog 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit SendCoinsDialog(QWidget *parent = 0); 29 | ~SendCoinsDialog(); 30 | 31 | void setModel(WalletModel *model); 32 | 33 | /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue http://bugreports.qt.nokia.com/browse/QTBUG-10907). 34 | */ 35 | QWidget *setupTabChain(QWidget *prev); 36 | 37 | void pasteEntry(const SendCoinsRecipient &rv); 38 | void handleURI(const QString &uri); 39 | 40 | public slots: 41 | void clear(); 42 | void reject(); 43 | void accept(); 44 | SendCoinsEntry *addEntry(); 45 | void updateRemoveEnabled(); 46 | void setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance); 47 | 48 | private: 49 | Ui::SendCoinsDialog *ui; 50 | WalletModel *model; 51 | bool fNewRecipientAllowed; 52 | 53 | private slots: 54 | void on_sendButton_clicked(); 55 | 56 | void removeEntry(SendCoinsEntry* entry); 57 | }; 58 | 59 | #endif // SENDCOINSDIALOG_H 60 | -------------------------------------------------------------------------------- /src/qt/dialogs/transactiondescdialog.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "transactiondescdialog.h" 10 | #include "ui_transactiondescdialog.h" 11 | 12 | #include "../models/transactiontablemodel.h" 13 | 14 | #include 15 | 16 | TransactionDescDialog::TransactionDescDialog(const QModelIndex &idx, QWidget *parent) : 17 | QDialog(parent), 18 | ui(new Ui::TransactionDescDialog) 19 | { 20 | ui->setupUi(this); 21 | QString desc = idx.data(TransactionTableModel::LongDescriptionRole).toString(); 22 | ui->detailText->setHtml(desc); 23 | 24 | setStyleSheet("selection-background-color: #084B8A; background-color: #F7F7F7"); 25 | } 26 | 27 | TransactionDescDialog::~TransactionDescDialog() 28 | { 29 | delete ui; 30 | } 31 | -------------------------------------------------------------------------------- /src/qt/dialogs/transactiondescdialog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef TRANSACTIONDESCDIALOG_H 10 | #define TRANSACTIONDESCDIALOG_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | namespace Ui { 20 | class TransactionDescDialog; 21 | } 22 | QT_BEGIN_NAMESPACE 23 | class QModelIndex; 24 | QT_END_NAMESPACE 25 | 26 | /** Dialog showing transaction details. */ 27 | class TransactionDescDialog : public QDialog 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit TransactionDescDialog(const QModelIndex &idx, QWidget *parent = 0); 33 | ~TransactionDescDialog(); 34 | 35 | private: 36 | Ui::TransactionDescDialog *ui; 37 | }; 38 | 39 | #endif // TRANSACTIONDESCDIALOG_H 40 | -------------------------------------------------------------------------------- /src/qt/forms/editaddressdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EditAddressDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 457 10 | 126 11 | 12 | 13 | 14 | Edit Address 15 | 16 | 17 | 18 | 19 | 20 | QFormLayout::AllNonFixedFieldsGrow 21 | 22 | 23 | 24 | 25 | &Label 26 | 27 | 28 | labelEdit 29 | 30 | 31 | 32 | 33 | 34 | 35 | The label associated with this address book entry 36 | 37 | 38 | 39 | 40 | 41 | 42 | &Address 43 | 44 | 45 | addressEdit 46 | 47 | 48 | 49 | 50 | 51 | 52 | The address associated with this address book entry. This can only be modified for sending addresses. 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | Qt::Horizontal 62 | 63 | 64 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | buttonBox 74 | accepted() 75 | EditAddressDialog 76 | accept() 77 | 78 | 79 | 248 80 | 254 81 | 82 | 83 | 157 84 | 274 85 | 86 | 87 | 88 | 89 | buttonBox 90 | rejected() 91 | EditAddressDialog 92 | reject() 93 | 94 | 95 | 316 96 | 260 97 | 98 | 99 | 286 100 | 274 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/qt/forms/transactiondescdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | TransactionDescDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Transaction details 15 | 16 | 17 | 18 | 19 | 20 | This pane shows a detailed description of the transaction 21 | 22 | 23 | true 24 | 25 | 26 | 27 | 28 | 29 | 30 | Qt::Horizontal 31 | 32 | 33 | QDialogButtonBox::Close 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | buttonBox 43 | accepted() 44 | TransactionDescDialog 45 | accept() 46 | 47 | 48 | 248 49 | 254 50 | 51 | 52 | 157 53 | 274 54 | 55 | 56 | 57 | 58 | buttonBox 59 | rejected() 60 | TransactionDescDialog 61 | reject() 62 | 63 | 64 | 316 65 | 260 66 | 67 | 68 | 286 69 | 274 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/qt/models/addresstablemodel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef ADDRESSTABLEMODEL_H 10 | #define ADDRESSTABLEMODEL_H 11 | 12 | #include 13 | #include 14 | 15 | class AddressTablePriv; 16 | namespace Wallet { class CWallet; } 17 | class WalletModel; 18 | 19 | /** 20 | Qt model of the address book in the core. This allows views to access and modify the address book. 21 | */ 22 | class AddressTableModel : public QAbstractTableModel 23 | { 24 | Q_OBJECT 25 | public: 26 | explicit AddressTableModel(Wallet::CWallet *wallet, WalletModel *parent = 0); 27 | ~AddressTableModel(); 28 | 29 | enum ColumnIndex { 30 | Label = 0, /**< User specified label */ 31 | Address = 1 /**< Nexus address */ 32 | }; 33 | 34 | enum RoleIndex { 35 | TypeRole = Qt::UserRole /**< Type of address (#Send or #Receive) */ 36 | }; 37 | 38 | /** Return status of edit/insert operation */ 39 | enum EditStatus { 40 | OK, 41 | INVALID_ADDRESS, /**< Unparseable address */ 42 | DUPLICATE_ADDRESS, /**< Address already in address book */ 43 | WALLET_UNLOCK_FAILURE, /**< Wallet could not be unlocked to create new receiving address */ 44 | KEY_GENERATION_FAILURE /**< Generating a new public key for a receiving address failed */ 45 | }; 46 | 47 | static const QString Send; /**< Specifies send address */ 48 | static const QString Receive; /**< Specifies receive address */ 49 | 50 | /** @name Methods overridden from QAbstractTableModel 51 | @{*/ 52 | int rowCount(const QModelIndex &parent) const; 53 | int columnCount(const QModelIndex &parent) const; 54 | QVariant data(const QModelIndex &index, int role) const; 55 | bool setData(const QModelIndex & index, const QVariant & value, int role); 56 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 57 | QModelIndex index(int row, int column, const QModelIndex & parent) const; 58 | bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); 59 | Qt::ItemFlags flags(const QModelIndex & index) const; 60 | /*@}*/ 61 | 62 | /* Add an address to the model. 63 | Returns the added address on success, and an empty string otherwise. 64 | */ 65 | QString addRow(const QString &type, const QString &label, const QString &address); 66 | 67 | /* Look up label for address in address book, if not found return empty string. 68 | */ 69 | QString labelForAddress(const QString &address) const; 70 | 71 | /* Look up row index of an address in the model. 72 | Return -1 if not found. 73 | */ 74 | int lookupAddress(const QString &address) const; 75 | 76 | EditStatus getEditStatus() const { return editStatus; } 77 | 78 | private: 79 | WalletModel *walletModel; 80 | Wallet::CWallet *wallet; 81 | AddressTablePriv *priv; 82 | QStringList columns; 83 | EditStatus editStatus; 84 | 85 | signals: 86 | void defaultAddressChanged(const QString &address); 87 | 88 | public slots: 89 | /* Update address list from core. Invalidates any indices. 90 | */ 91 | void update(); 92 | }; 93 | 94 | #endif // ADDRESSTABLEMODEL_H 95 | -------------------------------------------------------------------------------- /src/qt/models/clientmodel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef CLIENTMODEL_H 10 | #define CLIENTMODEL_H 11 | 12 | #include 13 | 14 | class OptionsModel; 15 | class AddressTableModel; 16 | class TransactionTableModel; 17 | class CWallet; 18 | 19 | QT_BEGIN_NAMESPACE 20 | class QDateTime; 21 | QT_END_NAMESPACE 22 | 23 | /** Model for Nexus network client. */ 24 | class ClientModel : public QObject 25 | { 26 | Q_OBJECT 27 | public: 28 | explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0); 29 | 30 | OptionsModel *getOptionsModel(); 31 | 32 | int getNumConnections() const; 33 | int getNumBlocks() const; 34 | int getNumBlocksAtStartup(); 35 | 36 | QDateTime getLastBlockDate() const; 37 | 38 | //! Return true if client connected to testnet 39 | bool isTestNet() const; 40 | 41 | 42 | //! Return true if core is doing initial block download 43 | bool inInitialBlockDownload() const; 44 | 45 | double getTrustWeight() const; 46 | double getBlockWeight() const; 47 | double getInterestRate() const; 48 | 49 | //! Return true if in 72hr wait period for staking 50 | bool getIsWaitPeriod() const; 51 | 52 | /** Return the Total Coin supply from the Block Chain. **/ 53 | unsigned int GetCoinSupply() const; 54 | unsigned int GetIdealSupply() const; 55 | 56 | double GetPrimeDifficulty() const; 57 | double GetHashDifficulty() const; 58 | 59 | unsigned int GetPrimeReserves() const; 60 | unsigned int GetHashReserves() const; 61 | 62 | double GetPrimeReward() const; 63 | double GetHashReward() const; 64 | 65 | unsigned int GetPrimeHeight() const; 66 | unsigned int GetHashHeight() const; 67 | 68 | //! Return conservative estimate of total number of blocks, or 0 if unknown 69 | int getNumBlocksOfPeers() const; 70 | 71 | 72 | //! Return warnings to be displayed in status bar 73 | QString getStatusBarWarnings() const; 74 | 75 | QString formatFullVersion() const; 76 | QString formatBuildDate() const; 77 | QString clientName() const; 78 | 79 | private: 80 | OptionsModel *optionsModel; 81 | 82 | int cachedNumConnections; 83 | int cachedNumBlocks; 84 | QString cachedStatusBar; 85 | 86 | int numBlocksAtStartup; 87 | 88 | signals: 89 | void numConnectionsChanged(int count); 90 | void numBlocksChanged(int count); 91 | 92 | //! Asynchronous error notification 93 | void error(const QString &title, const QString &message, bool modal); 94 | 95 | public slots: 96 | 97 | private slots: 98 | void update(); 99 | }; 100 | 101 | #endif // CLIENTMODEL_H 102 | -------------------------------------------------------------------------------- /src/qt/models/optionsmodel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef OPTIONSMODEL_H 10 | #define OPTIONSMODEL_H 11 | 12 | #include 13 | 14 | /** Interface from QT to configuration data structure for Nexus client. 15 | To QT, the options are presented as a list with the different options 16 | laid out vertically. 17 | This can be changed to a tree once the settings become sufficiently 18 | complex. 19 | */ 20 | class OptionsModel : public QAbstractListModel 21 | { 22 | Q_OBJECT 23 | public: 24 | explicit OptionsModel(QObject *parent = 0); 25 | 26 | enum OptionID { 27 | StartAtStartup, // bool 28 | MinimizeToTray, // bool 29 | MapPortUPnP, // bool 30 | MinimizeOnClose, // bool 31 | ConnectSOCKS4, // bool 32 | ProxyIP, // QString 33 | ProxyPort, // QString 34 | Fee, // qint64 35 | DisplayUnit, // NexusUnits::Unit 36 | DisplayAddresses, // bool 37 | DetachDatabases, // bool 38 | OptionIDRowCount, 39 | }; 40 | 41 | void Init(); 42 | 43 | /* Migrate settings from wallet.dat after app initialization */ 44 | bool Upgrade(); /* returns true if settings upgraded */ 45 | 46 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 47 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; 48 | bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); 49 | 50 | /* Explicit getters */ 51 | qint64 getTransactionFee(); 52 | bool getMinimizeToTray(); 53 | bool getMinimizeOnClose(); 54 | int getDisplayUnit(); 55 | bool getDisplayAddresses(); 56 | private: 57 | int nDisplayUnit; 58 | bool bDisplayAddresses; 59 | bool fMinimizeToTray; 60 | bool fMinimizeOnClose; 61 | signals: 62 | void displayUnitChanged(int unit); 63 | 64 | public slots: 65 | 66 | }; 67 | 68 | #endif // OPTIONSMODEL_H 69 | -------------------------------------------------------------------------------- /src/qt/models/transactiontablemodel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef TRANSACTIONTABLEMODEL_H 10 | #define TRANSACTIONTABLEMODEL_H 11 | 12 | #include 13 | #include 14 | 15 | namespace Wallet { class CWallet; } 16 | 17 | class TransactionTablePriv; 18 | class TransactionRecord; 19 | class WalletModel; 20 | 21 | /** UI model for the transaction table of a wallet. 22 | */ 23 | class TransactionTableModel : public QAbstractTableModel 24 | { 25 | Q_OBJECT 26 | public: 27 | explicit TransactionTableModel(Wallet::CWallet* wallet, WalletModel *parent = 0); 28 | ~TransactionTableModel(); 29 | 30 | enum ColumnIndex { 31 | Status = 0, 32 | Date = 1, 33 | Type = 2, 34 | ToAddress = 3, 35 | Amount = 4 36 | }; 37 | 38 | /** Roles to get specific information from a transaction row. 39 | These are independent of column. 40 | */ 41 | enum RoleIndex { 42 | /** Type of transaction */ 43 | TypeRole = Qt::UserRole, 44 | /** Date and time this transaction was created */ 45 | DateRole, 46 | /** Long description (HTML format) */ 47 | LongDescriptionRole, 48 | /** Address of transaction */ 49 | AddressRole, 50 | /** Label of address related to transaction */ 51 | LabelRole, 52 | /** Net amount of transaction */ 53 | AmountRole, 54 | /** Unique identifier */ 55 | TxIDRole, 56 | /** Is transaction confirmed? */ 57 | ConfirmedRole, 58 | /** Formatted amount, without brackets when unconfirmed */ 59 | FormattedAmountRole 60 | }; 61 | 62 | int rowCount(const QModelIndex &parent) const; 63 | int columnCount(const QModelIndex &parent) const; 64 | QVariant data(const QModelIndex &index, int role) const; 65 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 66 | QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; 67 | private: 68 | Wallet::CWallet* wallet; 69 | WalletModel *walletModel; 70 | QStringList columns; 71 | TransactionTablePriv *priv; 72 | 73 | QString lookupAddress(const std::string &address, bool tooltip) const; 74 | QVariant addressColor(const TransactionRecord *wtx) const; 75 | QString formatTxStatus(const TransactionRecord *wtx) const; 76 | QString formatTxDate(const TransactionRecord *wtx) const; 77 | QString formatTxType(const TransactionRecord *wtx) const; 78 | QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const; 79 | QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const; 80 | QString formatTooltip(const TransactionRecord *rec) const; 81 | QVariant txStatusDecoration(const TransactionRecord *wtx) const; 82 | QVariant txAddressDecoration(const TransactionRecord *wtx) const; 83 | 84 | private slots: 85 | void update(); 86 | 87 | friend class TransactionTablePriv; 88 | }; 89 | 90 | #endif 91 | 92 | -------------------------------------------------------------------------------- /src/qt/pages/addressbookpage.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef ADDRESSBOOKPAGE_H 10 | #define ADDRESSBOOKPAGE_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | namespace Ui { 20 | class AddressBookPage; 21 | } 22 | class AddressTableModel; 23 | 24 | QT_BEGIN_NAMESPACE 25 | class QTableView; 26 | class QItemSelection; 27 | class QSortFilterProxyModel; 28 | class QMenu; 29 | QT_END_NAMESPACE 30 | 31 | /** Widget that shows a list of sending or receiving addresses. 32 | */ 33 | class AddressBookPage : public QDialog 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | enum Tabs { 39 | SendingTab = 0, 40 | ReceivingTab = 1 41 | }; 42 | 43 | enum Mode { 44 | ForSending, /**< Open address book to pick address for sending */ 45 | ForEditing /**< Open address book for editing */ 46 | }; 47 | 48 | explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent = 0); 49 | ~AddressBookPage(); 50 | 51 | void setModel(AddressTableModel *model); 52 | const QString &getReturnValue() const { return returnValue; } 53 | 54 | public slots: 55 | void done(int retval); 56 | void exportClicked(); 57 | 58 | private: 59 | Ui::AddressBookPage *ui; 60 | AddressTableModel *model; 61 | Mode mode; 62 | Tabs tab; 63 | QString returnValue; 64 | QSortFilterProxyModel *proxyModel; 65 | QMenu *contextMenu; 66 | QAction *deleteAction; 67 | 68 | private slots: 69 | void on_deleteButton_clicked(); 70 | void on_newAddressButton_clicked(); 71 | /** Copy address of currently selected address entry to clipboard */ 72 | void on_copyToClipboard_clicked(); 73 | void on_signMessage_clicked(); 74 | void selectionChanged(); 75 | void on_showQRCode_clicked(); 76 | /** Spawn contextual menu (right mouse menu) for address book entry */ 77 | void contextualMenu(const QPoint &point); 78 | 79 | /** Copy label of currently selected address entry to clipboard */ 80 | void onCopyLabelAction(); 81 | /** Edit currently selected address entry */ 82 | void onEditAction(); 83 | }; 84 | 85 | #endif // ADDRESSBOOKDIALOG_H 86 | -------------------------------------------------------------------------------- /src/qt/pages/messagepage.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef MESSAGEPAGE_H 10 | #define MESSAGEPAGE_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | namespace Ui { 20 | class MessagePage; 21 | } 22 | class WalletModel; 23 | 24 | QT_BEGIN_NAMESPACE 25 | QT_END_NAMESPACE 26 | 27 | class MessagePage : public QDialog 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | explicit MessagePage(QWidget *parent = 0); 33 | ~MessagePage(); 34 | 35 | void setModel(WalletModel *model); 36 | 37 | void setAddress(QString); 38 | 39 | private: 40 | Ui::MessagePage *ui; 41 | WalletModel *model; 42 | 43 | private slots: 44 | void on_pasteButton_clicked(); 45 | void on_addressBookButton_clicked(); 46 | 47 | void on_signMessage_clicked(); 48 | void on_verifyMessage_clicked(); 49 | void on_copyToClipboard_clicked(); 50 | }; 51 | 52 | #endif // MESSAGEPAGE_H 53 | -------------------------------------------------------------------------------- /src/qt/pages/overviewpage.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef OVERVIEWPAGE_H 10 | #define OVERVIEWPAGE_H 11 | #include 12 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 13 | #include 14 | #else 15 | #include 16 | #endif 17 | 18 | QT_BEGIN_NAMESPACE 19 | class QModelIndex; 20 | QT_END_NAMESPACE 21 | 22 | namespace Ui { 23 | class OverviewPage; 24 | } 25 | class WalletModel; 26 | class TxViewDelegate; 27 | 28 | /** Overview ("home") page widget */ 29 | class OverviewPage : public QWidget 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | explicit OverviewPage(QWidget *parent = 0); 35 | ~OverviewPage(); 36 | 37 | void setModel(WalletModel *model); 38 | 39 | public slots: 40 | void setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance = 0); 41 | void setNumTransactions(int count); 42 | 43 | signals: 44 | void transactionClicked(const QModelIndex &index); 45 | 46 | private: 47 | Ui::OverviewPage *ui; 48 | WalletModel *model; 49 | qint64 currentBalance; 50 | qint64 currentStake; 51 | qint64 currentUnconfirmedBalance; 52 | qint64 currentImmatureBalance; 53 | 54 | TxViewDelegate *txdelegate; 55 | 56 | private slots: 57 | void displayUnitChanged(); 58 | }; 59 | 60 | #endif // OVERVIEWPAGE_H 61 | -------------------------------------------------------------------------------- /src/qt/res/icons/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/add.png -------------------------------------------------------------------------------- /src/qt/res/icons/address-book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/address-book.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/clock1.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/clock2.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/clock3.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/clock4.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/clock5.png -------------------------------------------------------------------------------- /src/qt/res/icons/configure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/configure.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect0_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/connect0_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect1_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/connect1_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect2_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/connect2_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect3_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/connect3_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect4_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/connect4_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/edit.png -------------------------------------------------------------------------------- /src/qt/res/icons/editcopy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/editcopy.png -------------------------------------------------------------------------------- /src/qt/res/icons/editpaste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/editpaste.png -------------------------------------------------------------------------------- /src/qt/res/icons/export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/export.png -------------------------------------------------------------------------------- /src/qt/res/icons/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/filesave.png -------------------------------------------------------------------------------- /src/qt/res/icons/history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/history.png -------------------------------------------------------------------------------- /src/qt/res/icons/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/key.png -------------------------------------------------------------------------------- /src/qt/res/icons/lock_closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/lock_closed.png -------------------------------------------------------------------------------- /src/qt/res/icons/lock_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/lock_open.png -------------------------------------------------------------------------------- /src/qt/res/icons/nexus.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/nexus.icns -------------------------------------------------------------------------------- /src/qt/res/icons/nexus.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/nexus.ico -------------------------------------------------------------------------------- /src/qt/res/icons/nexus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/nexus.png -------------------------------------------------------------------------------- /src/qt/res/icons/nexus_testnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/nexus_testnet.png -------------------------------------------------------------------------------- /src/qt/res/icons/notsynced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/notsynced.png -------------------------------------------------------------------------------- /src/qt/res/icons/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/overview.png -------------------------------------------------------------------------------- /src/qt/res/icons/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/quit.png -------------------------------------------------------------------------------- /src/qt/res/icons/receive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/receive.png -------------------------------------------------------------------------------- /src/qt/res/icons/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/remove.png -------------------------------------------------------------------------------- /src/qt/res/icons/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/send.png -------------------------------------------------------------------------------- /src/qt/res/icons/synced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/synced.png -------------------------------------------------------------------------------- /src/qt/res/icons/toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/toolbar.png -------------------------------------------------------------------------------- /src/qt/res/icons/toolbar_testnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/toolbar_testnet.png -------------------------------------------------------------------------------- /src/qt/res/icons/transaction0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/transaction0.png -------------------------------------------------------------------------------- /src/qt/res/icons/transaction2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/transaction2.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_inout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/tx_inout.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/tx_input.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_mined.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/tx_mined.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/icons/tx_output.png -------------------------------------------------------------------------------- /src/qt/res/images/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/images/about.png -------------------------------------------------------------------------------- /src/qt/res/images/qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/images/qrcode.png -------------------------------------------------------------------------------- /src/qt/res/images/splash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/images/splash.jpg -------------------------------------------------------------------------------- /src/qt/res/movies/update_spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nexusoft/Legacy/6ebcce338d958807ae33934d3056249f924d894f/src/qt/res/movies/update_spinner.gif -------------------------------------------------------------------------------- /src/qt/res/nexus-qt.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "icons/nexus.ico" 2 | -------------------------------------------------------------------------------- /src/qt/util/addressvalidator.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "../util/addressvalidator.h" 10 | 11 | 12 | NexusAddressValidator::NexusAddressValidator(QObject *parent) : 13 | QValidator(parent) 14 | { 15 | } 16 | 17 | QValidator::State NexusAddressValidator::validate(QString &input, int &pos) const 18 | { 19 | // Correction 20 | for(int idx=0; idx= '0' && ch<='9') || 60 | (ch >= 'a' && ch<='z') || 61 | (ch >= 'A' && ch<='Z')) && 62 | ch != 'l' && ch != 'I' && ch != '0' && ch != 'O') 63 | { 64 | // Alphanumeric and not a 'forbidden' character 65 | } 66 | else 67 | { 68 | state = QValidator::Invalid; 69 | } 70 | } 71 | 72 | // Empty address is "intermediate" input 73 | if(input.isEmpty()) 74 | { 75 | state = QValidator::Intermediate; 76 | } 77 | 78 | return state; 79 | } 80 | -------------------------------------------------------------------------------- /src/qt/util/addressvalidator.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef NexusADDRESSVALIDATOR_H 10 | #define NexusADDRESSVALIDATOR_H 11 | 12 | #include 13 | 14 | /** Base48 entry widget validator. 15 | Corrects near-miss characters and refuses characters that are no part of base48. 16 | */ 17 | class NexusAddressValidator : public QValidator 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit NexusAddressValidator(QObject *parent = 0); 22 | 23 | State validate(QString &input, int &pos) const; 24 | 25 | static const int MaxAddressLength = 52; 26 | signals: 27 | 28 | public slots: 29 | 30 | }; 31 | 32 | #endif // NexusADDRESSVALIDATOR_H 33 | -------------------------------------------------------------------------------- /src/qt/util/amountfield.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef NexusFIELD_H 10 | #define NexusFIELD_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | QT_BEGIN_NAMESPACE 20 | class QDoubleSpinBox; 21 | class QValueComboBox; 22 | QT_END_NAMESPACE 23 | 24 | /** Widget for entering Nexus amounts. 25 | */ 26 | class NexusAmountField: public QWidget 27 | { 28 | Q_OBJECT 29 | Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true) 30 | public: 31 | explicit NexusAmountField(QWidget *parent = 0); 32 | 33 | qint64 value(bool *valid=0) const; 34 | void setValue(qint64 value); 35 | 36 | /** Mark current value as invalid in UI. */ 37 | void setValid(bool valid); 38 | /** Perform input validation, mark field as invalid if entered value is not valid. */ 39 | bool validate(); 40 | 41 | /** Change unit used to display amount. */ 42 | void setDisplayUnit(int unit); 43 | 44 | /** Make field empty and ready for new input. */ 45 | void clear(); 46 | 47 | /** Qt messes up the tab chain by default in some cases (issue http://bugreports.qt.nokia.com/browse/QTBUG-10907), 48 | in these cases we have to set it up manually. 49 | */ 50 | QWidget *setupTabChain(QWidget *prev); 51 | 52 | signals: 53 | void textChanged(); 54 | 55 | protected: 56 | /** Intercept focus-in event and ',' keypresses */ 57 | bool eventFilter(QObject *object, QEvent *event); 58 | 59 | private: 60 | QDoubleSpinBox *amount; 61 | QValueComboBox *unit; 62 | int currentUnit; 63 | 64 | void setText(const QString &text); 65 | QString text() const; 66 | 67 | private slots: 68 | void unitChanged(int idx); 69 | 70 | }; 71 | 72 | 73 | #endif // NexusFIELD_H 74 | -------------------------------------------------------------------------------- /src/qt/util/csvmodelwriter.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "csvmodelwriter.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | CSVModelWriter::CSVModelWriter(const QString &filename, QObject *parent) : 16 | QObject(parent), 17 | filename(filename), model(0) 18 | { 19 | } 20 | 21 | void CSVModelWriter::setModel(const QAbstractItemModel *model) 22 | { 23 | this->model = model; 24 | } 25 | 26 | void CSVModelWriter::addColumn(const QString &title, int column, int role) 27 | { 28 | Column col; 29 | col.title = title; 30 | col.column = column; 31 | col.role = role; 32 | 33 | columns.append(col); 34 | } 35 | 36 | static void writeValue(QTextStream &f, const QString &value) 37 | { 38 | QString escaped = value; 39 | escaped.replace('"', "\"\""); 40 | f << "\"" << escaped << "\""; 41 | } 42 | 43 | static void writeSep(QTextStream &f) 44 | { 45 | f << ","; 46 | } 47 | 48 | static void writeNewline(QTextStream &f) 49 | { 50 | f << "\n"; 51 | } 52 | 53 | bool CSVModelWriter::write() 54 | { 55 | QFile file(filename); 56 | if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) 57 | return false; 58 | QTextStream out(&file); 59 | 60 | int numRows = 0; 61 | if(model) 62 | { 63 | numRows = model->rowCount(); 64 | } 65 | 66 | // Header row 67 | for(int i=0; iindex(j, columns[i].column).data(columns[i].role); 87 | writeValue(out, data.toString()); 88 | } 89 | writeNewline(out); 90 | } 91 | 92 | file.close(); 93 | 94 | return file.error() == QFile::NoError; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /src/qt/util/csvmodelwriter.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef CSVMODELWRITER_H 10 | #define CSVMODELWRITER_H 11 | 12 | #include 13 | #include 14 | 15 | QT_BEGIN_NAMESPACE 16 | class QAbstractItemModel; 17 | QT_END_NAMESPACE 18 | 19 | /** Export a Qt table model to a CSV file. This is useful for analyzing or post-processing the data in 20 | a spreadsheet. 21 | */ 22 | class CSVModelWriter : public QObject 23 | { 24 | Q_OBJECT 25 | public: 26 | explicit CSVModelWriter(const QString &filename, QObject *parent = 0); 27 | 28 | void setModel(const QAbstractItemModel *model); 29 | void addColumn(const QString &title, int column, int role=Qt::EditRole); 30 | 31 | /** Perform export of the model to CSV. 32 | @returns true on success, false otherwise 33 | */ 34 | bool write(); 35 | 36 | private: 37 | QString filename; 38 | const QAbstractItemModel *model; 39 | 40 | struct Column 41 | { 42 | QString title; 43 | int column; 44 | int role; 45 | }; 46 | QList columns; 47 | 48 | signals: 49 | 50 | public slots: 51 | 52 | }; 53 | 54 | #endif // CSVMODELWRITER_H 55 | -------------------------------------------------------------------------------- /src/qt/util/guiutil.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef GUIUTIL_H 10 | #define GUIUTIL_H 11 | 12 | #include 13 | 14 | QT_BEGIN_NAMESPACE 15 | class QFont; 16 | class QLineEdit; 17 | class QWidget; 18 | class QDateTime; 19 | class QUrl; 20 | class QAbstractItemView; 21 | QT_END_NAMESPACE 22 | class SendCoinsRecipient; 23 | 24 | /** Utility functions used by the Nexus Qt UI. 25 | */ 26 | namespace GUIUtil 27 | { 28 | // Create human-readable string from date 29 | QString dateTimeStr(const QDateTime &datetime); 30 | QString dateTimeStr(qint64 nTime); 31 | 32 | // Render Nexus addresses in monospace font 33 | QFont NexusAddressFont(); 34 | 35 | // Set up widgets for address and amounts 36 | void setupAddressWidget(QLineEdit *widget, QWidget *parent); 37 | void setupAmountWidget(QLineEdit *widget, QWidget *parent); 38 | 39 | // Parse "Nexus:" URI into recipient object, return true on succesful parsing 40 | // See Nexus URI definition discussion here: https://Nexustalk.org/index.php?topic=33490.0 41 | bool parseNexusURI(const QUrl &uri, SendCoinsRecipient *out); 42 | bool parseNexusURI(QString uri, SendCoinsRecipient *out); 43 | 44 | // HTML escaping for rich text controls 45 | QString HtmlEscape(const QString& str, bool fMultiLine=false); 46 | QString HtmlEscape(const std::string& str, bool fMultiLine=false); 47 | 48 | /** Copy a field of the currently selected entry of a view to the clipboard. Does nothing if nothing 49 | is selected. 50 | @param[in] column Data column to extract from the model 51 | @param[in] role Data role to extract from the model 52 | @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress 53 | */ 54 | void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole); 55 | 56 | /** Get save file name, mimics QFileDialog::getSaveFileName, except that it appends a default suffix 57 | when no suffix is provided by the user. 58 | 59 | @param[in] parent Parent window (or 0) 60 | @param[in] caption Window caption (or empty, for default) 61 | @param[in] dir Starting directory (or empty, to default to documents directory) 62 | @param[in] filter Filter specification such as "Comma Separated Files (*.csv)" 63 | @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0). 64 | Can be useful when choosing the save file format based on suffix. 65 | */ 66 | QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(), 67 | const QString &dir=QString(), const QString &filter=QString(), 68 | QString *selectedSuffixOut=0); 69 | 70 | /** Get connection type to call object slot in GUI thread with invokeMethod. The call will be blocking. 71 | 72 | @returns If called from the GUI thread, return a Qt::DirectConnection. 73 | If called from another thread, return a Qt::BlockingQueuedConnection. 74 | */ 75 | Qt::ConnectionType blockingGUIThreadConnection(); 76 | 77 | // Determine whether a widget is hidden behind other windows 78 | bool isObscured(QWidget *w); 79 | 80 | } // namespace GUIUtil 81 | 82 | #endif // GUIUTIL_H 83 | -------------------------------------------------------------------------------- /src/qt/util/macdockiconhandler.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef MACDOCKICONHANDLER_H 10 | #define MACDOCKICONHANDLER_H 11 | 12 | #include 13 | #include 14 | 15 | QT_BEGIN_NAMESPACE 16 | class QIcon; 17 | class QMenu; 18 | class QWidget; 19 | QT_END_NAMESPACE 20 | 21 | /** Macintosh-specific dock icon handler. 22 | */ 23 | class MacDockIconHandler : public QObject 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | ~MacDockIconHandler(); 29 | 30 | QMenu *dockMenu(); 31 | void setIcon(const QIcon &icon); 32 | void setMainWindow(QMainWindow *window); 33 | static MacDockIconHandler *instance(); 34 | static void cleanup(); 35 | void handleDockIconClickEvent(); 36 | 37 | Q_SIGNALS: 38 | void dockIconClicked(); 39 | 40 | private: 41 | MacDockIconHandler(); 42 | 43 | QWidget *m_dummyWidget; 44 | QMenu *m_dockMenu; 45 | QMainWindow *mainWindow; 46 | }; 47 | 48 | #endif // MACDOCKICONCLICKHANDLER_H 49 | -------------------------------------------------------------------------------- /src/qt/util/macdockiconhandler.mm: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Nexus Core developers 2 | // Distributed under the MIT software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "macdockiconhandler.h" 6 | 7 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 8 | #include 9 | #else 10 | #include 11 | #endif 12 | #include 13 | #include 14 | #include 15 | 16 | #undef slots 17 | #include 18 | #include 19 | #include 20 | 21 | #if QT_VERSION < 0x050000 22 | extern void qt_mac_set_dock_menu(QMenu *); 23 | #endif 24 | 25 | static MacDockIconHandler *s_instance = NULL; 26 | 27 | bool dockClickHandler(id self,SEL _cmd,...) { 28 | Q_UNUSED(self) 29 | Q_UNUSED(_cmd) 30 | 31 | s_instance->handleDockIconClickEvent(); 32 | 33 | // Return NO (false) to suppress the default OS X actions 34 | return false; 35 | } 36 | 37 | void setupDockClickHandler() { 38 | Class cls = objc_getClass("NSApplication"); 39 | id appInst = objc_msgSend((id)cls, sel_registerName("sharedApplication")); 40 | 41 | if (appInst != NULL) { 42 | id delegate = objc_msgSend(appInst, sel_registerName("delegate")); 43 | Class delClass = (Class)objc_msgSend(delegate, sel_registerName("class")); 44 | SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:"); 45 | if (class_getInstanceMethod(delClass, shouldHandle)) 46 | class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:"); 47 | else 48 | class_addMethod(delClass, shouldHandle, (IMP)dockClickHandler,"B@:"); 49 | } 50 | } 51 | 52 | 53 | MacDockIconHandler::MacDockIconHandler() : QObject() 54 | { 55 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 56 | 57 | setupDockClickHandler(); 58 | this->m_dummyWidget = new QWidget(); 59 | this->m_dockMenu = new QMenu(this->m_dummyWidget); 60 | this->setMainWindow(NULL); 61 | #if QT_VERSION < 0x050000 62 | qt_mac_set_dock_menu(this->m_dockMenu); 63 | #elif QT_VERSION >= 0x050200 64 | this->m_dockMenu->setAsDockMenu(); 65 | #endif 66 | [pool release]; 67 | } 68 | 69 | void MacDockIconHandler::setMainWindow(QMainWindow *window) { 70 | this->mainWindow = window; 71 | } 72 | 73 | MacDockIconHandler::~MacDockIconHandler() 74 | { 75 | delete this->m_dummyWidget; 76 | this->setMainWindow(NULL); 77 | } 78 | 79 | QMenu *MacDockIconHandler::dockMenu() 80 | { 81 | return this->m_dockMenu; 82 | } 83 | 84 | void MacDockIconHandler::setIcon(const QIcon &icon) 85 | { 86 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 87 | NSImage *image = nil; 88 | if (icon.isNull()) 89 | image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; 90 | else { 91 | // generate NSImage from QIcon and use this as dock icon. 92 | QSize size = icon.actualSize(QSize(128, 128)); 93 | QPixmap pixmap = icon.pixmap(size); 94 | 95 | // Write image into a R/W buffer from raw pixmap, then save the image. 96 | QBuffer notificationBuffer; 97 | if (!pixmap.isNull() && notificationBuffer.open(QIODevice::ReadWrite)) { 98 | QImageWriter writer(¬ificationBuffer, "PNG"); 99 | if (writer.write(pixmap.toImage())) { 100 | NSData* macImgData = [NSData dataWithBytes:notificationBuffer.buffer().data() 101 | length:notificationBuffer.buffer().size()]; 102 | image = [[NSImage alloc] initWithData:macImgData]; 103 | } 104 | } 105 | 106 | if(!image) { 107 | // if testnet image could not be created, load std. app icon 108 | image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; 109 | } 110 | } 111 | 112 | [NSApp setApplicationIconImage:image]; 113 | [image release]; 114 | [pool release]; 115 | } 116 | 117 | MacDockIconHandler *MacDockIconHandler::instance() 118 | { 119 | if (!s_instance) 120 | s_instance = new MacDockIconHandler(); 121 | return s_instance; 122 | } 123 | 124 | void MacDockIconHandler::cleanup() 125 | { 126 | delete s_instance; 127 | } 128 | 129 | void MacDockIconHandler::handleDockIconClickEvent() 130 | { 131 | if (this->mainWindow) 132 | { 133 | this->mainWindow->activateWindow(); 134 | this->mainWindow->show(); 135 | } 136 | 137 | Q_EMIT this->dockIconClicked(); 138 | } -------------------------------------------------------------------------------- /src/qt/util/monitoreddatamapper.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "monitoreddatamapper.h" 10 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 11 | #include 12 | #else 13 | #include 14 | #endif 15 | 16 | 17 | #include 18 | #include 19 | 20 | MonitoredDataMapper::MonitoredDataMapper(QObject *parent) : 21 | QDataWidgetMapper(parent) 22 | { 23 | } 24 | 25 | 26 | void MonitoredDataMapper::addMapping(QWidget *widget, int section) 27 | { 28 | QDataWidgetMapper::addMapping(widget, section); 29 | addChangeMonitor(widget); 30 | } 31 | 32 | void MonitoredDataMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName) 33 | { 34 | QDataWidgetMapper::addMapping(widget, section, propertyName); 35 | addChangeMonitor(widget); 36 | } 37 | 38 | void MonitoredDataMapper::addChangeMonitor(QWidget *widget) 39 | { 40 | // Watch user property of widget for changes, and connect 41 | // the signal to our viewModified signal. 42 | QMetaProperty prop = widget->metaObject()->userProperty(); 43 | int signal = prop.notifySignalIndex(); 44 | int method = this->metaObject()->indexOfMethod("viewModified()"); 45 | if(signal != -1 && method != -1) 46 | { 47 | QMetaObject::connect(widget, signal, this, method); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/qt/util/monitoreddatamapper.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef MONITOREDDATAMAPPER_H 10 | #define MONITOREDDATAMAPPER_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | QT_BEGIN_NAMESPACE 20 | class QWidget; 21 | QT_END_NAMESPACE 22 | 23 | /** Data to Widget mapper that watches for edits and notifies listeners when a field is edited. 24 | This can be used, for example, to enable a commit/apply button in a configuration dialog. 25 | */ 26 | class MonitoredDataMapper : public QDataWidgetMapper 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit MonitoredDataMapper(QObject *parent=0); 31 | 32 | void addMapping(QWidget *widget, int section); 33 | void addMapping(QWidget *widget, int section, const QByteArray &propertyName); 34 | private: 35 | void addChangeMonitor(QWidget *widget); 36 | 37 | signals: 38 | void viewModified(); 39 | 40 | }; 41 | 42 | 43 | 44 | #endif // MONITOREDDATAMAPPER_H 45 | -------------------------------------------------------------------------------- /src/qt/util/notificator.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef NOTIFICATOR_H 10 | #define NOTIFICATOR_H 11 | 12 | #include 13 | #include 14 | 15 | QT_BEGIN_NAMESPACE 16 | class QSystemTrayIcon; 17 | #ifdef USE_DBUS 18 | class QDBusInterface; 19 | #endif 20 | QT_END_NAMESPACE 21 | 22 | /** Cross-platform desktop notification client. */ 23 | class Notificator: public QObject 24 | { 25 | Q_OBJECT 26 | public: 27 | /** Create a new notificator. 28 | @note Ownership of trayIcon is not transferred to this object. 29 | */ 30 | Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0); 31 | ~Notificator(); 32 | 33 | // Message class 34 | enum Class 35 | { 36 | Information, /**< Informational message */ 37 | Warning, /**< Notify user of potential problem */ 38 | Critical /**< An error occured */ 39 | }; 40 | 41 | public slots: 42 | 43 | /** Show notification message. 44 | @param[in] cls general message class 45 | @param[in] title title shown with message 46 | @param[in] text message content 47 | @param[in] icon optional icon to show with message 48 | @param[in] millisTimeout notification timeout in milliseconds (defaults to 10 seconds) 49 | @note Platform implementations are free to ignore any of the provided fields except for \a text. 50 | */ 51 | void notify(Class cls, const QString &title, const QString &text, 52 | const QIcon &icon = QIcon(), int millisTimeout = 10000); 53 | 54 | private: 55 | QWidget *parent; 56 | enum Mode { 57 | None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */ 58 | Freedesktop, /**< Use DBus org.freedesktop.Notifications */ 59 | QSystemTray, /**< Use QSystemTray::showMessage */ 60 | Growl12, /**< Use the Growl 1.2 notification system (Mac only) */ 61 | Growl13 /**< Use the Growl 1.3 notification system (Mac only) */ 62 | }; 63 | QString programName; 64 | Mode mode; 65 | QSystemTrayIcon *trayIcon; 66 | #ifdef USE_DBUS 67 | QDBusInterface *interface; 68 | 69 | void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); 70 | #endif 71 | void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); 72 | #ifdef Q_WS_MAC 73 | void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon); 74 | #endif 75 | }; 76 | 77 | #endif // NOTIFICATOR_H 78 | -------------------------------------------------------------------------------- /src/qt/util/qvalidatedlineedit.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "qvalidatedlineedit.h" 10 | 11 | #include "../core/guiconstants.h" 12 | 13 | QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) : 14 | QLineEdit(parent), valid(true) 15 | { 16 | connect(this, SIGNAL(textChanged(QString)), this, SLOT(markValid())); 17 | } 18 | 19 | void QValidatedLineEdit::setValid(bool valid) 20 | { 21 | if(valid == this->valid) 22 | { 23 | return; 24 | } 25 | 26 | if(valid) 27 | { 28 | setStyleSheet(""); 29 | } 30 | else 31 | { 32 | setStyleSheet(STYLE_INVALID); 33 | } 34 | this->valid = valid; 35 | } 36 | 37 | void QValidatedLineEdit::focusInEvent(QFocusEvent *evt) 38 | { 39 | // Clear invalid flag on focus 40 | setValid(true); 41 | QLineEdit::focusInEvent(evt); 42 | } 43 | 44 | void QValidatedLineEdit::markValid() 45 | { 46 | setValid(true); 47 | } 48 | 49 | void QValidatedLineEdit::clear() 50 | { 51 | setValid(true); 52 | QLineEdit::clear(); 53 | } 54 | -------------------------------------------------------------------------------- /src/qt/util/qvalidatedlineedit.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef QVALIDATEDLINEEDIT_H 10 | #define QVALIDATEDLINEEDIT_H 11 | 12 | #include 13 | 14 | /** Line edit that can be marked as "invalid" to show input validation feedback. When marked as invalid, 15 | it will get a red background until it is focused. 16 | */ 17 | class QValidatedLineEdit : public QLineEdit 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit QValidatedLineEdit(QWidget *parent = 0); 22 | void clear(); 23 | 24 | protected: 25 | void focusInEvent(QFocusEvent *evt); 26 | 27 | private: 28 | bool valid; 29 | 30 | public slots: 31 | void setValid(bool valid); 32 | 33 | private slots: 34 | void markValid(); 35 | }; 36 | 37 | #endif // QVALIDATEDLINEEDIT_H 38 | -------------------------------------------------------------------------------- /src/qt/util/qvaluecombobox.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "qvaluecombobox.h" 10 | 11 | QValueComboBox::QValueComboBox(QWidget *parent) : 12 | QComboBox(parent), role(Qt::UserRole) 13 | { 14 | connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); 15 | } 16 | 17 | int QValueComboBox::value() const 18 | { 19 | return itemData(currentIndex(), role).toInt(); 20 | } 21 | 22 | void QValueComboBox::setValue(int value) 23 | { 24 | setCurrentIndex(findData(value, role)); 25 | } 26 | 27 | void QValueComboBox::setRole(int role) 28 | { 29 | this->role = role; 30 | } 31 | 32 | void QValueComboBox::handleSelectionChanged(int idx) 33 | { 34 | emit valueChanged(); 35 | } 36 | -------------------------------------------------------------------------------- /src/qt/util/qvaluecombobox.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef QVALUECOMBOBOX_H 10 | #define QVALUECOMBOBOX_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | /* QComboBox that can be used with QDataWidgetMapper to select ordinal values from a model. */ 20 | class QValueComboBox : public QComboBox 21 | { 22 | Q_OBJECT 23 | Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true) 24 | public: 25 | explicit QValueComboBox(QWidget *parent = 0); 26 | 27 | int value() const; 28 | void setValue(int value); 29 | 30 | /** Specify model role to use as ordinal value */ 31 | void setRole(int role); 32 | 33 | signals: 34 | void valueChanged(); 35 | 36 | public slots: 37 | 38 | private: 39 | int role; 40 | 41 | private slots: 42 | void handleSelectionChanged(int idx); 43 | }; 44 | 45 | #endif // QVALUECOMBOBOX_H 46 | -------------------------------------------------------------------------------- /src/qt/wallet/sendcoinsentry.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef SENDCOINSENTRY_H 10 | #define SENDCOINSENTRY_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | namespace Ui { 20 | class SendCoinsEntry; 21 | } 22 | class WalletModel; 23 | class SendCoinsRecipient; 24 | 25 | /** A single entry in the dialog for sending Nexus. */ 26 | class SendCoinsEntry : public QFrame 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | explicit SendCoinsEntry(QWidget *parent = 0); 32 | ~SendCoinsEntry(); 33 | 34 | void setModel(WalletModel *model); 35 | bool validate(); 36 | SendCoinsRecipient getValue(); 37 | 38 | /** Return whether the entry is still empty and unedited */ 39 | bool isClear(); 40 | 41 | void setValue(const SendCoinsRecipient &value); 42 | 43 | /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue http://bugreports.qt.nokia.com/browse/QTBUG-10907). 44 | */ 45 | QWidget *setupTabChain(QWidget *prev); 46 | 47 | void setFocus(); 48 | 49 | public slots: 50 | void setRemoveEnabled(bool enabled); 51 | void clear(); 52 | 53 | signals: 54 | void removeEntry(SendCoinsEntry *entry); 55 | 56 | private slots: 57 | void on_deleteButton_clicked(); 58 | void on_payTo_textChanged(const QString &address); 59 | void on_addressBookButton_clicked(); 60 | void on_pasteButton_clicked(); 61 | 62 | private: 63 | Ui::SendCoinsEntry *ui; 64 | WalletModel *model; 65 | }; 66 | 67 | #endif // SENDCOINSENTRY_H 68 | -------------------------------------------------------------------------------- /src/qt/wallet/transactiondesc.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef TRANSACTIONDESC_H 10 | #define TRANSACTIONDESC_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace Wallet 17 | { 18 | class CWallet; 19 | class CWalletTx; 20 | } 21 | 22 | /** Provide a human-readable extended HTML description of a transaction. 23 | */ 24 | class TransactionDesc: public QObject 25 | { 26 | Q_OBJECT 27 | public: 28 | static QString toHTML(Wallet::CWallet *wallet, Wallet::CWalletTx &wtx); 29 | private: 30 | TransactionDesc() {} 31 | 32 | static QString FormatTxStatus(const Wallet::CWalletTx& wtx); 33 | }; 34 | 35 | #endif // TRANSACTIONDESC_H 36 | -------------------------------------------------------------------------------- /src/qt/wallet/transactionfilterproxy.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #include "transactionfilterproxy.h" 10 | #include "../models/transactiontablemodel.h" 11 | 12 | #include 13 | 14 | #include 15 | 16 | // Earliest date that can be represented (far in the past) 17 | const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0); 18 | // Last date that can be represented (far in the future) 19 | const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF); 20 | 21 | TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : 22 | QSortFilterProxyModel(parent), 23 | dateFrom(MIN_DATE), 24 | dateTo(MAX_DATE), 25 | addrPrefix(), 26 | typeFilter(ALL_TYPES), 27 | minAmount(0), 28 | limitRows(-1) 29 | { 30 | } 31 | 32 | bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const 33 | { 34 | QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); 35 | 36 | int type = index.data(TransactionTableModel::TypeRole).toInt(); 37 | QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); 38 | QString address = index.data(TransactionTableModel::AddressRole).toString(); 39 | QString label = index.data(TransactionTableModel::LabelRole).toString(); 40 | qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); 41 | 42 | if(!(TYPE(type) & typeFilter)) 43 | return false; 44 | if(datetime < dateFrom || datetime > dateTo) 45 | return false; 46 | if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) 47 | return false; 48 | if(amount < minAmount) 49 | return false; 50 | 51 | return true; 52 | } 53 | 54 | void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to) 55 | { 56 | this->dateFrom = from; 57 | this->dateTo = to; 58 | invalidateFilter(); 59 | } 60 | 61 | void TransactionFilterProxy::setAddressPrefix(const QString &addrPrefix) 62 | { 63 | this->addrPrefix = addrPrefix; 64 | invalidateFilter(); 65 | } 66 | 67 | void TransactionFilterProxy::setTypeFilter(quint32 modes) 68 | { 69 | this->typeFilter = modes; 70 | invalidateFilter(); 71 | } 72 | 73 | void TransactionFilterProxy::setMinAmount(qint64 minimum) 74 | { 75 | this->minAmount = minimum; 76 | invalidateFilter(); 77 | } 78 | 79 | void TransactionFilterProxy::setLimit(int limit) 80 | { 81 | this->limitRows = limit; 82 | } 83 | 84 | int TransactionFilterProxy::rowCount(const QModelIndex &parent) const 85 | { 86 | if(limitRows != -1) 87 | { 88 | return std::min(QSortFilterProxyModel::rowCount(parent), limitRows); 89 | } 90 | else 91 | { 92 | return QSortFilterProxyModel::rowCount(parent); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/qt/wallet/transactionfilterproxy.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef TRANSACTIONFILTERPROXY_H 10 | #define TRANSACTIONFILTERPROXY_H 11 | 12 | #include 13 | #include 14 | 15 | /** Filter the transaction list according to pre-specified rules. */ 16 | class TransactionFilterProxy : public QSortFilterProxyModel 17 | { 18 | Q_OBJECT 19 | public: 20 | explicit TransactionFilterProxy(QObject *parent = 0); 21 | 22 | /** Earliest date that can be represented (far in the past) */ 23 | static const QDateTime MIN_DATE; 24 | /** Last date that can be represented (far in the future) */ 25 | static const QDateTime MAX_DATE; 26 | /** Type filter bit field (all types) */ 27 | static const quint32 ALL_TYPES = 0xFFFFFFFF; 28 | 29 | static quint32 TYPE(int type) { return 1< 15 | 16 | namespace Wallet 17 | { 18 | class CWallet; 19 | class CWalletTx; 20 | } 21 | 22 | /** UI model for transaction status. The transaction status is the part of a transaction that will change over time. 23 | */ 24 | class TransactionStatus 25 | { 26 | public: 27 | TransactionStatus(): 28 | confirmed(false), sortKey(""), maturity(Mature), 29 | matures_in(0), status(Offline), depth(0), open_for(0), cur_num_blocks(-1) 30 | { } 31 | 32 | enum Maturity 33 | { 34 | Immature, 35 | Mature, 36 | MaturesWarning, /**< Transaction will likely not mature because no nodes have confirmed */ 37 | NotAccepted 38 | }; 39 | 40 | enum Status { 41 | OpenUntilDate, 42 | OpenUntilBlock, 43 | Offline, 44 | Unconfirmed, 45 | HaveConfirmations 46 | }; 47 | 48 | bool confirmed; 49 | std::string sortKey; 50 | 51 | /** @name Generated (mined) transactions 52 | @{*/ 53 | Maturity maturity; 54 | int matures_in; 55 | /**@}*/ 56 | 57 | /** @name Reported status 58 | @{*/ 59 | Status status; 60 | int64 depth; 61 | int64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number of blocks */ 62 | /**@}*/ 63 | 64 | /** Current number of blocks (to know whether cached status is still valid) */ 65 | int cur_num_blocks; 66 | }; 67 | 68 | /** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has 69 | multiple outputs. 70 | */ 71 | class TransactionRecord 72 | { 73 | public: 74 | enum Type 75 | { 76 | Other, 77 | Generated, 78 | SendToAddress, 79 | SendToOther, 80 | RecvWithAddress, 81 | RecvFromOther, 82 | SendToSelf, 83 | StakeGenesis, 84 | StakeTrust 85 | }; 86 | 87 | /** Number of confirmation needed for transaction */ 88 | static const int NumConfirmations = 3; 89 | 90 | TransactionRecord(): 91 | hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0) 92 | { 93 | } 94 | 95 | TransactionRecord(uint512 hash, int64 time): 96 | hash(hash), time(time), type(Other), address(""), debit(0), 97 | credit(0), idx(0) 98 | { 99 | } 100 | 101 | TransactionRecord(uint512 hash, int64 time, 102 | Type type, const std::string &address, 103 | int64 debit, int64 credit): 104 | hash(hash), time(time), type(type), address(address), debit(debit), credit(credit), 105 | idx(0) 106 | { 107 | } 108 | 109 | /** Decompose Wallet::CWallet transaction to model transaction records. 110 | */ 111 | static bool showTransaction(const Wallet::CWalletTx &wtx); 112 | static QList decomposeTransaction(const Wallet::CWallet *wallet, const Wallet::CWalletTx &wtx); 113 | 114 | /** @name Immutable transaction attributes 115 | @{*/ 116 | uint512 hash; 117 | int64 time; 118 | Type type; 119 | std::string address; 120 | int64 debit; 121 | int64 credit; 122 | /**@}*/ 123 | 124 | /** Subtransaction index, for sort key */ 125 | int idx; 126 | 127 | /** Status: can change with block chain update */ 128 | TransactionStatus status; 129 | 130 | /** Return the unique identifier for this transaction (part) */ 131 | std::string getTxID(); 132 | 133 | /** Update status from core wallet tx. 134 | */ 135 | void updateStatus(const Wallet::CWalletTx &wtx); 136 | 137 | /** Return whether a status update is needed. 138 | */ 139 | bool statusUpdateNeeded(); 140 | }; 141 | 142 | #endif // TRANSACTIONRECORD_H 143 | -------------------------------------------------------------------------------- /src/qt/wallet/transactionview.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | 3 | Hash(BEGIN(Satoshi[2010]), END(W.J.[2012])) == Videlicet[2014] ++ 4 | 5 | [Learn and Create] Viz. http://www.opensource.org/licenses/mit-license.php 6 | 7 | *******************************************************************************************/ 8 | 9 | #ifndef TRANSACTIONVIEW_H 10 | #define TRANSACTIONVIEW_H 11 | 12 | #include 13 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | class WalletModel; 20 | class TransactionFilterProxy; 21 | 22 | QT_BEGIN_NAMESPACE 23 | class QTableView; 24 | class QComboBox; 25 | class QLineEdit; 26 | class QModelIndex; 27 | class QMenu; 28 | class QFrame; 29 | class QDateTimeEdit; 30 | QT_END_NAMESPACE 31 | 32 | /** Widget showing the transaction list for a wallet, including a filter row. 33 | Using the filter row, the user can view or export a subset of the transactions. 34 | */ 35 | class TransactionView : public QWidget 36 | { 37 | Q_OBJECT 38 | public: 39 | explicit TransactionView(QWidget *parent = 0); 40 | 41 | void setModel(WalletModel *model); 42 | 43 | // Date ranges for filter 44 | enum DateEnum 45 | { 46 | All, 47 | Today, 48 | ThisWeek, 49 | ThisMonth, 50 | LastMonth, 51 | ThisYear, 52 | Range 53 | }; 54 | 55 | private: 56 | WalletModel *model; 57 | TransactionFilterProxy *transactionProxyModel; 58 | QTableView *transactionView; 59 | 60 | QComboBox *dateWidget; 61 | QComboBox *typeWidget; 62 | QLineEdit *addressWidget; 63 | QLineEdit *amountWidget; 64 | 65 | QMenu *contextMenu; 66 | 67 | QFrame *dateRangeWidget; 68 | QDateTimeEdit *dateFrom; 69 | QDateTimeEdit *dateTo; 70 | 71 | QWidget *createDateRangeWidget(); 72 | 73 | private slots: 74 | void contextualMenu(const QPoint &); 75 | void dateRangeChanged(); 76 | void showDetails(); 77 | void copyAddress(); 78 | void editLabel(); 79 | void copyLabel(); 80 | void copyAmount(); 81 | 82 | signals: 83 | void doubleClicked(const QModelIndex&); 84 | 85 | public slots: 86 | void chooseDate(int idx); 87 | void chooseType(int idx); 88 | void changedPrefix(const QString &prefix); 89 | void changedAmount(const QString &amount); 90 | void exportClicked(); 91 | 92 | }; 93 | 94 | #endif // TRANSACTIONVIEW_H 95 | -------------------------------------------------------------------------------- /src/util/compat.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_COMPAT_H 10 | #define _NEXUS_COMPAT_H 1 11 | 12 | #ifdef WIN32 13 | #define _WIN32_WINNT 0x0501 14 | #define WIN32_LEAN_AND_MEAN 1 15 | #ifndef NOMINMAX 16 | #define NOMINMAX 17 | #endif 18 | #include 19 | #include 20 | #include 21 | #else 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #endif 31 | 32 | #ifndef ___WSA_SOCKET_TYPES_H 33 | typedef u_int SOCKET; 34 | #endif 35 | #ifdef WIN32 36 | #define MSG_NOSIGNAL 0 37 | #define MSG_DONTWAIT 0 38 | typedef int socklen_t; 39 | #else 40 | #include "errno.h" 41 | #define WSAGetLastError() errno 42 | #define WSAEINVAL EINVAL 43 | #define WSAEALREADY EALREADY 44 | #define WSAEWOULDBLOCK EWOULDBLOCK 45 | #define WSAEMSGSIZE EMSGSIZE 46 | #define WSAEINTR EINTR 47 | #define WSAEINPROGRESS EINPROGRESS 48 | #define WSAEADDRINUSE EADDRINUSE 49 | #define WSAENOTSOCK EBADF 50 | #define INVALID_SOCKET (SOCKET)(~0) 51 | #define SOCKET_ERROR -1 52 | #endif 53 | 54 | inline int myclosesocket(SOCKET& hSocket) 55 | { 56 | if (hSocket == INVALID_SOCKET) 57 | return WSAENOTSOCK; 58 | #ifdef WIN32 59 | int ret = closesocket(hSocket); 60 | #else 61 | int ret = close(hSocket); 62 | #endif 63 | hSocket = INVALID_SOCKET; 64 | return ret; 65 | } 66 | #define closesocket(s) myclosesocket(s) 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/util/mruset.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_MRUSET_H 10 | #define NEXUS_MRUSET_H 11 | 12 | #include 13 | #include 14 | 15 | /** STL-like set container that only keeps the most recent N elements. */ 16 | template class mruset 17 | { 18 | public: 19 | typedef T key_type; 20 | typedef T value_type; 21 | typedef typename std::set::iterator iterator; 22 | typedef typename std::set::const_iterator const_iterator; 23 | typedef typename std::set::size_type size_type; 24 | 25 | protected: 26 | std::set set; 27 | std::deque queue; 28 | size_type nMaxSize; 29 | 30 | public: 31 | mruset(size_type nMaxSizeIn = 0) { nMaxSize = nMaxSizeIn; } 32 | iterator begin() const { return set.begin(); } 33 | iterator end() const { return set.end(); } 34 | size_type size() const { return set.size(); } 35 | bool empty() const { return set.empty(); } 36 | iterator find(const key_type& k) const { return set.find(k); } 37 | size_type count(const key_type& k) const { return set.count(k); } 38 | bool inline friend operator==(const mruset& a, const mruset& b) { return a.set == b.set; } 39 | bool inline friend operator==(const mruset& a, const std::set& b) { return a.set == b; } 40 | bool inline friend operator<(const mruset& a, const mruset& b) { return a.set < b.set; } 41 | std::pair insert(const key_type& x) 42 | { 43 | std::pair ret = set.insert(x); 44 | if (ret.second) 45 | { 46 | if (nMaxSize && queue.size() == nMaxSize) 47 | { 48 | set.erase(queue.front()); 49 | queue.pop_front(); 50 | } 51 | queue.push_back(x); 52 | } 53 | return ret; 54 | } 55 | size_type max_size() const { return nMaxSize; } 56 | size_type max_size(size_type s) 57 | { 58 | if (s) 59 | while (queue.size() >= s) 60 | { 61 | set.erase(queue.front()); 62 | queue.pop_front(); 63 | } 64 | nMaxSize = s; 65 | return nMaxSize; 66 | } 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/util/noui.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 "../util/ui_interface.h" 10 | 11 | #include 12 | #include "../core/core.h" 13 | #include "../main.h" 14 | 15 | int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style) 16 | { 17 | printf("%s: %s\n", caption.c_str(), message.c_str()); 18 | fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str()); 19 | return 4; 20 | } 21 | 22 | bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption) 23 | { 24 | return true; 25 | } 26 | 27 | void MainFrameRepaint() 28 | { 29 | } 30 | 31 | void AddressBookRepaint() 32 | { 33 | } 34 | 35 | void InitMessage(const std::string &message) 36 | { 37 | } 38 | 39 | std::string _(const char* psz) 40 | { 41 | return psz; 42 | } 43 | 44 | void QueueShutdown() 45 | { 46 | // Without UI, Shutdown can simply be started in a new thread 47 | CreateThread(Shutdown, NULL); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/util/strlcpy.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 1998 Todd C. Miller 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef NEXUS_STRLCPY_H 18 | #define NEXUS_STRLCPY_H 19 | 20 | #include 21 | #include 22 | 23 | /* 24 | * Copy src to string dst of size siz. At most siz-1 characters 25 | * will be copied. Always NUL terminates (unless siz == 0). 26 | * Returns strlen(src); if retval >= siz, truncation occurred. 27 | */ 28 | inline size_t strlcpy(char *dst, const char *src, size_t siz) 29 | { 30 | char *d = dst; 31 | const char *s = src; 32 | size_t n = siz; 33 | 34 | /* Copy as many bytes as will fit */ 35 | if (n != 0) 36 | { 37 | while (--n != 0) 38 | { 39 | if ((*d++ = *s++) == '\0') 40 | break; 41 | } 42 | } 43 | 44 | /* Not enough room in dst, add NUL and traverse rest of src */ 45 | if (n == 0) 46 | { 47 | if (siz != 0) 48 | *d = '\0'; /* NUL-terminate dst */ 49 | while (*s++) 50 | ; 51 | } 52 | 53 | return(s - src - 1); /* count does not include NUL */ 54 | } 55 | 56 | /* 57 | * Appends src to string dst of size siz (unlike strncat, siz is the 58 | * full size of dst, not space left). At most siz-1 characters 59 | * will be copied. Always NUL terminates (unless siz <= strlen(dst)). 60 | * Returns strlen(src) + MIN(siz, strlen(initial dst)). 61 | * If retval >= siz, truncation occurred. 62 | */ 63 | inline size_t strlcat(char *dst, const char *src, size_t siz) 64 | { 65 | char *d = dst; 66 | const char *s = src; 67 | size_t n = siz; 68 | size_t dlen; 69 | 70 | /* Find the end of dst and adjust bytes left but don't go past end */ 71 | while (n-- != 0 && *d != '\0') 72 | d++; 73 | dlen = d - dst; 74 | n = siz - dlen; 75 | 76 | if (n == 0) 77 | return(dlen + strlen(s)); 78 | while (*s != '\0') 79 | { 80 | if (n != 1) 81 | { 82 | *d++ = *s; 83 | n--; 84 | } 85 | s++; 86 | } 87 | *d = '\0'; 88 | 89 | return(dlen + (s - src)); /* count does not include NUL */ 90 | } 91 | #endif 92 | -------------------------------------------------------------------------------- /src/util/ui_interface.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_UI_INTERFACE_H 10 | #define NEXUS_UI_INTERFACE_H 11 | 12 | #include 13 | #include "util.h" // for int64 14 | 15 | #define wxYES 0x00000002 16 | #define wxOK 0x00000004 17 | #define wxNO 0x00000008 18 | #define wxYES_NO (wxYES|wxNO) 19 | #define wxCANCEL 0x00000010 20 | #define wxAPPLY 0x00000020 21 | #define wxCLOSE 0x00000040 22 | #define wxOK_DEFAULT 0x00000000 23 | #define wxYES_DEFAULT 0x00000000 24 | #define wxNO_DEFAULT 0x00000080 25 | #define wxCANCEL_DEFAULT 0x80000000 26 | #define wxICON_EXCLAMATION 0x00000100 27 | #define wxICON_HAND 0x00000200 28 | #define wxICON_WARNING wxICON_EXCLAMATION 29 | #define wxICON_ERROR wxICON_HAND 30 | #define wxICON_QUESTION 0x00000400 31 | #define wxICON_INFORMATION 0x00000800 32 | #define wxICON_STOP wxICON_HAND 33 | #define wxICON_ASTERISK wxICON_INFORMATION 34 | #define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800) 35 | #define wxFORWARD 0x00001000 36 | #define wxBACKWARD 0x00002000 37 | #define wxRESET 0x00004000 38 | #define wxHELP 0x00008000 39 | #define wxMORE 0x00010000 40 | #define wxSETUP 0x00020000 41 | // Force blocking, modal message box dialog (not just notification) 42 | #define wxMODAL 0x00040000 43 | 44 | /* These UI communication functions are implemented in start_qt.cpp (for ui) and noui.cpp (no ui) */ 45 | 46 | extern int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK); 47 | extern bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption); 48 | extern void ThreadSafeHandleURI(const std::string& strURI); 49 | extern void MainFrameRepaint(); 50 | extern void AddressBookRepaint(); 51 | extern void QueueShutdown(); 52 | extern void InitMessage(const std::string &message); 53 | extern std::string _(const char* psz); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/wallet/crypter.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 __CRYPTER_H__ 10 | #define __CRYPTER_H__ 11 | 12 | #include "../util/allocators.h" /* for SecureString */ 13 | #include "key.h" 14 | #include "../util/serialize.h" 15 | 16 | namespace Wallet 17 | { 18 | const unsigned int WALLET_CRYPTO_KEY_SIZE = 72; 19 | const unsigned int WALLET_CRYPTO_SALT_SIZE = 18; 20 | 21 | /** 22 | Private key encryption is done based on a CMasterKey, 23 | which holds a salt and random encryption key. 24 | 25 | CMasterKeys are encrypted using AES-256-CBC using a key 26 | derived using derivation method nDerivationMethod 27 | (0 == EVP_sha512()) and derivation iterations nDeriveIterations. 28 | vchOtherDerivationParameters is provided for alternative algorithms 29 | which may require more parameters (such as scrypt). 30 | 31 | Wallet Private Keys are then encrypted using AES-256-CBC 32 | with the SK576 of the public key as the IV, and the 33 | master key's key as the encryption key (see keystore.[ch]). 34 | */ 35 | 36 | /** Master key for wallet encryption */ 37 | class CMasterKey 38 | { 39 | public: 40 | std::vector vchCryptedKey; 41 | std::vector vchSalt; 42 | // 0 = EVP_sha512() 43 | // 1 = scrypt() 44 | unsigned int nDerivationMethod; 45 | unsigned int nDeriveIterations; 46 | // Use this for more parameters to key derivation, 47 | // such as the various parameters to scrypt 48 | std::vector vchOtherDerivationParameters; 49 | 50 | IMPLEMENT_SERIALIZE 51 | ( 52 | READWRITE(vchCryptedKey); 53 | READWRITE(vchSalt); 54 | READWRITE(nDerivationMethod); 55 | READWRITE(nDeriveIterations); 56 | READWRITE(vchOtherDerivationParameters); 57 | ) 58 | CMasterKey() 59 | { 60 | // 25000 rounds is just under 0.1 seconds on a 1.86 GHz Pentium M 61 | // ie slightly lower than the lowest hardware we need bother supporting 62 | nDeriveIterations = 25000; 63 | nDerivationMethod = 0; 64 | vchOtherDerivationParameters = std::vector(0); 65 | } 66 | }; 67 | 68 | typedef std::vector > CKeyingMaterial; 69 | 70 | /** Encryption/decryption context with key information */ 71 | class CCrypter 72 | { 73 | private: 74 | unsigned char chKey[WALLET_CRYPTO_KEY_SIZE]; 75 | unsigned char chIV[WALLET_CRYPTO_KEY_SIZE]; 76 | bool fKeySet; 77 | 78 | public: 79 | bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod); 80 | bool Encrypt(const CKeyingMaterial& vchPlaintext, std::vector &vchCiphertext); 81 | bool Decrypt(const std::vector& vchCiphertext, CKeyingMaterial& vchPlaintext); 82 | bool SetKey(const CKeyingMaterial& chNewKey, const std::vector& chNewIV); 83 | 84 | void CleanKey() 85 | { 86 | memset(&chKey, 0, sizeof chKey); 87 | memset(&chIV, 0, sizeof chIV); 88 | munlock(&chKey, sizeof chKey); 89 | munlock(&chIV, sizeof chIV); 90 | fKeySet = false; 91 | } 92 | 93 | CCrypter() 94 | { 95 | fKeySet = false; 96 | } 97 | 98 | ~CCrypter() 99 | { 100 | CleanKey(); 101 | } 102 | }; 103 | 104 | bool EncryptSecret(CKeyingMaterial& vMasterKey, const CSecret &vchPlaintext, const uint576& nIV, std::vector &vchCiphertext); 105 | bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector &vchCiphertext, const uint576& nIV, CSecret &vchPlaintext); 106 | 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /src/wallet/key.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_KEY_H 10 | #define NEXUS_KEY_H 11 | 12 | #include 13 | #include 14 | 15 | #include "../util/allocators.h" 16 | #include "../hash/uint1024.h" 17 | 18 | #include // for EC_KEY definition 19 | 20 | namespace Wallet 21 | { 22 | class key_error : public std::runtime_error 23 | { 24 | public: 25 | explicit key_error(const std::string& str) : std::runtime_error(str) {} 26 | }; 27 | 28 | 29 | // secure_allocator is defined in serialize.h 30 | // CPrivKey is a serialized private key, with all parameters included (279 bytes) 31 | typedef std::vector > CPrivKey; 32 | // CSecret is a serialization of just the secret parameter (32 bytes) 33 | typedef std::vector > CSecret; 34 | 35 | /** An encapsulated OpenSSL Elliptic Curve key (public and/or private) */ 36 | class CKey 37 | { 38 | protected: 39 | EC_KEY* pkey; 40 | bool fSet; 41 | bool fCompressedPubKey; 42 | 43 | void SetCompressedPubKey(); 44 | 45 | public: 46 | 47 | void Reset(); 48 | 49 | CKey(); 50 | CKey(const CKey& b); 51 | 52 | CKey& operator=(const CKey& b); 53 | 54 | ~CKey(); 55 | 56 | bool IsNull() const; 57 | bool IsCompressed() const; 58 | 59 | void MakeNewKey(bool fCompressed); 60 | bool SetPrivKey(const CPrivKey& vchPrivKey); 61 | bool SetSecret(const CSecret& vchSecret, bool fCompressed = false); 62 | CSecret GetSecret(bool &fCompressed) const; 63 | CPrivKey GetPrivKey() const; 64 | bool SetPubKey(const std::vector& vchPubKey); 65 | std::vector GetPubKey() const; 66 | 67 | bool SignCompact(uint256 hash, std::vector& vchSig); 68 | bool SetCompactSignature(uint256 hash, const std::vector& vchSig); 69 | 70 | bool Sign(uint1024 hash, std::vector& vchSig, int nBits); 71 | bool Verify(uint1024 hash, const std::vector& vchSig, int nBits); 72 | bool IsValid(); 73 | }; 74 | } 75 | #endif 76 | --------------------------------------------------------------------------------