├── .gitignore ├── COPYING ├── DESIGN-namecoin.md ├── DEVELOPMENT-PROCESS.md ├── FAQ.md ├── README.md ├── TODO-namecoin ├── changelog.md ├── client ├── DNS │ ├── Base.py │ ├── Class.py │ ├── Lib.py │ ├── Opcode.py │ ├── Status.py │ ├── Type.py │ ├── __init__.py │ └── lazy.py ├── README.md ├── doc │ └── README.sockspy ├── jsonrpc │ ├── __init__.py │ ├── _tests │ │ ├── __init__.py │ │ ├── test_cgiwrapper.py │ │ ├── test_json.py │ │ ├── test_modpywrapper.py │ │ ├── test_proxy.py │ │ └── test_serviceHandler.py │ ├── cgiwrapper.py │ ├── json.py │ ├── modpywrapper.py │ ├── proxy.py │ └── serviceHandler.py ├── ncproxy ├── socks.py └── socks5.py ├── contrib ├── .gitignore ├── easywinbuilder │ ├── 1a_environment_mingw.bat │ ├── 1b_environment_qt.bat │ ├── 2a_run_download.bat │ ├── 2b_run_unpack.bat │ ├── 3a_build_boost.bat │ ├── 3b_run_build_dep.bat │ ├── 3c_build_miniupnpc.bat │ ├── 4a_build_daemon.bat │ ├── 4b_build_qt.bat │ ├── 6_gather_dlls.bat │ ├── README.md │ ├── __all_easywinbuilder.bat │ ├── __everything_but_environment_easywinbuilder.bat │ ├── __everything_from_after_unpack_easywinbuilder.bat │ ├── __rebuild_daemon_and_qt.bat │ ├── build_dep.sh │ ├── download.sh │ ├── patch_files.sh │ ├── set_vars.bat │ └── unpack.sh ├── merged-mine-proxy ├── nmcsh └── setup_script.iss ├── doc ├── README ├── README_merged-mining.md ├── README_windows.txt ├── build-osx.txt ├── build-unix.txt ├── coding.txt ├── release-process.txt └── vincent.gpg ├── libs ├── .gitignore └── readme.txt ├── namecoin-qt.pro └── src ├── Makefile ├── Makefile.osx ├── allocators.h ├── auxpow.cpp ├── auxpow.h ├── base58.h ├── bignum.h ├── bitcoinrpc.cpp ├── bitcoinrpc.h ├── crypter.cpp ├── crypter.h ├── cryptopp ├── License.txt ├── Readme.txt ├── config.h ├── cpu.cpp ├── cpu.h ├── cryptlib.h ├── iterhash.h ├── misc.h ├── obj │ └── .gitignore ├── pch.h ├── secblock.h ├── sha.cpp ├── sha.h ├── simple.h ├── smartptr.h └── stdcpp.h ├── db.cpp ├── db.h ├── headers.h ├── hook.h ├── init.cpp ├── init.h ├── irc.cpp ├── irc.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 ├── key.cpp ├── key.h ├── keystore.cpp ├── keystore.h ├── main.cpp ├── main.h ├── makefile.mingw ├── namecoin.cpp ├── namecoin.h ├── net.cpp ├── net.h ├── noui.h ├── obj ├── .gitignore ├── nogui │ └── .gitignore └── test │ └── .gitignore ├── qt ├── aboutdialog.cpp ├── aboutdialog.h ├── addressbookpage.cpp ├── addressbookpage.h ├── addresstablemodel.cpp ├── addresstablemodel.h ├── askpassphrasedialog.cpp ├── askpassphrasedialog.h ├── bitcoin.cpp ├── bitcoin.qrc ├── bitcoinaddressvalidator.cpp ├── bitcoinaddressvalidator.h ├── bitcoinamountfield.cpp ├── bitcoinamountfield.h ├── bitcoingui.cpp ├── bitcoingui.h ├── bitcoinstrings.cpp ├── bitcoinunits.cpp ├── bitcoinunits.h ├── clientmodel.cpp ├── clientmodel.h ├── configurenamedialog.cpp ├── configurenamedialog.h ├── csvmodelwriter.cpp ├── csvmodelwriter.h ├── editaddressdialog.cpp ├── editaddressdialog.h ├── forms │ ├── aboutdialog.ui │ ├── addressbookpage.ui │ ├── askpassphrasedialog.ui │ ├── configurenamedialog.ui │ ├── editaddressdialog.ui │ ├── managenamespage.ui │ ├── optionsdialog.ui │ ├── overviewpage.ui │ ├── qrcodedialog.ui │ ├── rpcconsole.ui │ ├── sendcoinsdialog.ui │ ├── sendcoinsentry.ui │ ├── signverifymessagedialog.ui │ └── transactiondescdialog.ui ├── guiconstants.h ├── guiutil.cpp ├── guiutil.h ├── locale │ ├── .gitignore │ ├── bitcoin_af_ZA.ts │ ├── bitcoin_ar.ts │ ├── bitcoin_bg.ts │ ├── bitcoin_ca_ES.ts │ ├── bitcoin_cs.ts │ ├── bitcoin_da.ts │ ├── bitcoin_de.ts │ ├── bitcoin_el_GR.ts │ ├── bitcoin_en.ts │ ├── bitcoin_es.ts │ ├── bitcoin_es_CL.ts │ ├── bitcoin_et.ts │ ├── bitcoin_eu_ES.ts │ ├── bitcoin_fa.ts │ ├── bitcoin_fa_IR.ts │ ├── bitcoin_fi.ts │ ├── bitcoin_fr.ts │ ├── bitcoin_fr_CA.ts │ ├── bitcoin_gu_IN.ts │ ├── bitcoin_he.ts │ ├── bitcoin_hi_IN.ts │ ├── bitcoin_hr.ts │ ├── bitcoin_hu.ts │ ├── bitcoin_it.ts │ ├── bitcoin_ja.ts │ ├── bitcoin_lt.ts │ ├── bitcoin_nb.ts │ ├── bitcoin_nl.ts │ ├── bitcoin_pl.ts │ ├── bitcoin_pt_BR.ts │ ├── bitcoin_pt_PT.ts │ ├── bitcoin_ro_RO.ts │ ├── bitcoin_ru.ts │ ├── bitcoin_sk.ts │ ├── bitcoin_sr.ts │ ├── bitcoin_sv.ts │ ├── bitcoin_th_TH.ts │ ├── bitcoin_tr.ts │ ├── bitcoin_uk.ts │ ├── bitcoin_zh_CN.ts │ └── bitcoin_zh_TW.ts ├── macdockiconhandler.h ├── macdockiconhandler.mm ├── managenamespage.cpp ├── managenamespage.h ├── monitoreddatamapper.cpp ├── monitoreddatamapper.h ├── nametablemodel.cpp ├── nametablemodel.h ├── netbase.cpp ├── netbase.h ├── notificator.cpp ├── notificator.h ├── optionsdialog.cpp ├── optionsdialog.h ├── optionsmodel.cpp ├── optionsmodel.h ├── overviewpage.cpp ├── overviewpage.h ├── paymentserver.cpp ├── paymentserver.h ├── qrcodedialog.cpp ├── qrcodedialog.h ├── qvalidatedlineedit.cpp ├── qvalidatedlineedit.h ├── qvaluecombobox.cpp ├── qvaluecombobox.h ├── res │ ├── bitcoin-qt.rc │ ├── icons │ │ ├── add.png │ │ ├── address-book.png │ │ ├── bitcoin.icns │ │ ├── bitcoin.ico │ │ ├── bitcoin.png │ │ ├── bitcoin_testnet.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 │ │ ├── debugwindow.png │ │ ├── edit.png │ │ ├── editcopy.png │ │ ├── editpaste.png │ │ ├── export.png │ │ ├── filesave.png │ │ ├── history.png │ │ ├── key.png │ │ ├── lock_closed.png │ │ ├── lock_open.png │ │ ├── notsynced.png │ │ ├── overview.png │ │ ├── qrcode.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_nameop.png │ │ └── tx_output.png │ ├── images │ │ ├── about.png │ │ └── namecoin-logo.png │ ├── movies │ │ └── update_spinner.mng │ └── src │ │ ├── bitcoin.svg │ │ ├── clock1.svg │ │ ├── clock2.svg │ │ ├── clock3.svg │ │ ├── clock4.svg │ │ ├── clock5.svg │ │ ├── clock_green.svg │ │ ├── inout.svg │ │ └── questionmark.svg ├── rpcconsole.cpp ├── rpcconsole.h ├── sendcoinsdialog.cpp ├── sendcoinsdialog.h ├── sendcoinsentry.cpp ├── sendcoinsentry.h ├── signverifymessagedialog.cpp ├── signverifymessagedialog.h ├── test │ ├── test_main.cpp │ ├── uritests.cpp │ └── uritests.h ├── transactiondesc.cpp ├── transactiondesc.h ├── transactiondescdialog.cpp ├── transactiondescdialog.h ├── transactionfilterproxy.cpp ├── transactionfilterproxy.h ├── transactionrecord.cpp ├── transactionrecord.h ├── transactiontablemodel.cpp ├── transactiontablemodel.h ├── transactionview.cpp ├── transactionview.h ├── ui_interface.h ├── walletmodel.cpp └── walletmodel.h ├── runValgrind.sh ├── script.cpp ├── script.h ├── serialize.h ├── strlcpy.h ├── test ├── README ├── test_bitcoin.cpp ├── uint160_tests.cpp └── uint256_tests.cpp ├── ui.h ├── uibase.h ├── uint256.h ├── util.cpp ├── util.h ├── wallet.cpp ├── wallet.h ├── walletdb.cpp └── walletdb.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | *.dll 3 | *.pyc 4 | .*.swp 5 | *.*~* 6 | namecoin-qt 7 | namecoin-qt.exe 8 | src/namecoind 9 | src/namecoind.exe 10 | 11 | # Stuff created by the Qt build system. 12 | qrc_bitcoin.cpp 13 | build 14 | debug 15 | release 16 | /Makefile 17 | *.Debug 18 | *.Release 19 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2015 Bitcoin Developers 2 | Copyright (c) 2009-2015 Namecoin Developers 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /DEVELOPMENT-PROCESS.md: -------------------------------------------------------------------------------- 1 | Namecoin integration/staging tree 2 | 3 | Development process 4 | =================== 5 | 6 | Developers work in their own trees, then submit pull requests when they think their feature or bug fix is ready. 7 | 8 | If it is a simple/trivial/non-controversial change, then one of the namecoin development team members simply pulls it. 9 | 10 | If it is a more complicated or potentially controversial change, then the patch submitter will be asked to start a discussion (if they haven't already) on the development forums. 11 | 12 | The patch will be accepted if there is broad consensus that it is a good thing. Developers should expect to rework and resubmit patches if they don't match the project's coding conventions (see coding.txt) or are controversial. 13 | 14 | The master branch is regularly built and tested (by who? need people willing to be quality assurance testers), and periodically pushed to the subversion repo to become the official, stable, released namecoin. 15 | 16 | 17 | Feature branches are created when there are major new features being worked on by several people. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Namecoin 2 | =================== 3 | 4 | Namecoin is a decentralized key/value registration and transfer system based on Bitcoin technology (a decentralized cryptocurrency). 5 | 6 | It can be used for multiple purposes, for example a secure and censorship resistant replacement for DNS. 7 | 8 | Ownership of a name is based on ownership of a coin, which is in turn based on public key cryptography. The namecoin network reaches consensus every few minutes as to which names have been reserved or updated. 9 | 10 | There is a FAQ.md to answer some general questions. 11 | 12 | See http://namecoin.info or http://dot-bit.org for more information. 13 | 14 | 15 | Technical 16 | ===================== 17 | 18 | The Bitcoin protocol is augmented with namecoin operations, to reserve, register and update names. In addition to DNS like entries, arbitrary name/value pairs are allowed and multiple namespaces will be available. This will include a personal handle namespace mapping handles to public keys and personal address data. 19 | 20 | The protocol differences from bitcoin include: 21 | 22 | * Different blockchain, port, IRC bootstrap and message header 23 | * New transaction types: new, first-update, update 24 | * Validation on the new transaction types 25 | * RPC calls for managing names 26 | * Network fees to slow down the initial rush 27 | 28 | Please read DESIGN-namecoind.md for details. 29 | 30 | 31 | BUILDING 32 | ====================== 33 | 34 | Building is supported on Linux, Windows and Mac. For building on windows you can use the scripts in ./contrib/easywinbuilder. Find build instructions on https://wiki.namecoin.info/index.php?title=Build_Namecoin_From_Source. 35 | 36 | -------------------------------------------------------------------------------- /TODO-namecoin: -------------------------------------------------------------------------------- 1 | * drop transactions that cannot be accepted because of a name conflict 2 | * name_clean additional review 3 | * name_clean on name_update (but that should have happened anyway?) 4 | * tx can linger in memory on other nodes - move conflict check to CheckTransaction? 5 | * other conflicts: update on expired name, firstupdate on expired name_new 6 | * d7cc9e949d invalid number of args 7 | * blockexplorer 8 | * IsMine hook to ensure modified clients don't spend namecoins by mistake as regular coins in case of future changes to IsMine 9 | * listtransactions improved decode 10 | * auto-send firstupdate after 6 blocks with persistent name/rand 11 | * review threading 12 | * sideloading resolver library 13 | * reference DNS server 14 | * cross-mining 15 | 16 | Bugs 17 | 18 | * CWalletTx::GetAmounts nFee is off by 0.01 for name txs because IsMine is false on the name output 19 | * Reports of crashes, bdb was mentioned 20 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | v0.3.80 2 | ====== 3 | * Various stricter checks, some small modifications and cleanup to harmonize 4 | behavior in preparation for the rebase of Namecoin on the latest Bitcoin version. 5 | Changes will take full effect by block height 212500. This is a softfork, miners 6 | must update, regular users should update! (domob) 7 | * fix locale bugs (itoffshore) 8 | 9 | v0.3.76rc1 10 | ======== 11 | * Set default fee per kb to 0.005NMC (phelix) 12 | * Several optimizations to improve handling of large/many network transactions (Domob) 13 | * Only accept finished transactions (phelix) 14 | * Relay transaction size limited to 20kb (consensus/phelix) 15 | * Increased network relay fee MIN_RELAY_TX_FEE to 100000 (RyanC/Indolering/phelix) 16 | * More restrictive filtering of transactions 17 | * Update to OpenSSL1.0.1i (phelix) 18 | * Better drive performance on disk based systems through less fragmentation (Domob) 19 | * "Renew" GUI Button (Domob) 20 | * contrib/easywinbuilder: Qt5/MinGW4.8.2/cleanup (phelix) 21 | * Qt5 compatibility (Canercandan/phelix) 22 | * New command line / .conf file option: -walletpath=customwalletfilename.dat (digital-dreamer) 23 | * "Pay To" in the Qt can be used to send coins also to a name, like "sendtoname" (Domob) 24 | * New RPC block info: height, confirmations, chainwork, nextblockhash. Change: No previousblockhash for block 0 (RyanC) 25 | * The RPC interface now returns an error while initialising, instead of not accepting connections at all (Domob) 26 | 27 | v0.3.75 28 | ======= 29 | * Add difficulty to RPC block output JSON (Domob) 30 | * Bitcoin port: skip signature verification on blocks before last checkpoint (phelix) 31 | * New checkpoint at 182000 32 | * Update to OpenSSL1.0.1h (security fix for SSL http RPC) 33 | * Czech localization (digital-dreamer) 34 | * Windows installer script for Innsetup (phelix) 35 | * Enforce value length of 520 characters in RPC and Qt (Domob) 36 | * New command line argument -dbstats runs a DB file storage statistics analysis and prints it to the debug log. (Domob) 37 | * Atomic handling of TxDB/NameDB operations, DB code cleanup and optimization. (Domob) 38 | * Even smaller blkindex.dat. Not backward compatible. It will take a while for the rewrite on the first start. (Domob) 39 | 40 | v0.3.74-rc1 (never officially released) 41 | ======================================= 42 | * allow for atomic name transactions via rpc commands (Domob) 43 | * new rpc commands: name_pending, getchains (Domob) 44 | * Simplified blkindex.dat for smaller file size and faster startup - not backward compatible ("remove auxpow", Domob) - IT WILL TAKE A WHILE FOR THE REWRITE ON THE FIRST START 45 | * Implement name_update in createrawtransaction (Domob) 46 | * More detailed JSON outputs for decoderawtransaction and getrawtransaction (Domob) 47 | * Async RPC calls (Domob: ported from Huntercoin) 48 | * Add toaddress argument to name_firstupdate (Domob) 49 | * fixed memory leaks (Domob) 50 | * listsinceblock (Olgasanko) 51 | * Several performance optimizations (Domob) 52 | * valgrind script (Domob) 53 | * Small updates and fixes, code cleanup 54 | 55 | v0.3.73-rc1 (never officially released) 56 | ======================================= 57 | * Modified testnet difficulty calculation (Khal) 58 | * GUI: ID-tab (Domob) 59 | * improve name_filter speed (Khal) 60 | * Small updates and fixes 61 | -------------------------------------------------------------------------------- /client/DNS/Class.py: -------------------------------------------------------------------------------- 1 | """ 2 | $Id: Class.py,v 1.6 2002/04/23 12:52:19 anthonybaxter Exp $ 3 | 4 | This file is part of the pydns project. 5 | Homepage: http://pydns.sourceforge.net 6 | 7 | This code is covered by the standard Python License. 8 | 9 | CLASS values (section 3.2.4) 10 | """ 11 | 12 | 13 | IN = 1 # the Internet 14 | CS = 2 # the CSNET class (Obsolete - used only for examples in 15 | # some obsolete RFCs) 16 | CH = 3 # the CHAOS class. When someone shows me python running on 17 | # a Symbolics Lisp machine, I'll look at implementing this. 18 | HS = 4 # Hesiod [Dyer 87] 19 | 20 | # QCLASS values (section 3.2.5) 21 | 22 | ANY = 255 # any class 23 | 24 | 25 | # Construct reverse mapping dictionary 26 | 27 | _names = dir() 28 | classmap = {} 29 | for _name in _names: 30 | if _name[0] != '_': classmap[eval(_name)] = _name 31 | 32 | def classstr(klass): 33 | if classmap.has_key(klass): return classmap[klass] 34 | else: return `klass` 35 | 36 | # 37 | # $Log: Class.py,v $ 38 | # Revision 1.6 2002/04/23 12:52:19 anthonybaxter 39 | # cleanup whitespace. 40 | # 41 | # Revision 1.5 2002/03/19 12:41:33 anthonybaxter 42 | # tabnannied and reindented everything. 4 space indent, no tabs. 43 | # yay. 44 | # 45 | # Revision 1.4 2002/03/19 12:26:13 anthonybaxter 46 | # death to leading tabs. 47 | # 48 | # Revision 1.3 2001/08/09 09:08:55 anthonybaxter 49 | # added identifying header to top of each file 50 | # 51 | # Revision 1.2 2001/07/19 06:57:07 anthony 52 | # cvs keywords added 53 | # 54 | # 55 | -------------------------------------------------------------------------------- /client/DNS/Lib.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/client/DNS/Lib.py -------------------------------------------------------------------------------- /client/DNS/Opcode.py: -------------------------------------------------------------------------------- 1 | """ 2 | $Id: Opcode.py,v 1.6 2002/04/23 10:51:43 anthonybaxter Exp $ 3 | 4 | This file is part of the pydns project. 5 | Homepage: http://pydns.sourceforge.net 6 | 7 | This code is covered by the standard Python License. 8 | 9 | Opcode values in message header. RFC 1035, 1996, 2136. 10 | """ 11 | 12 | 13 | 14 | QUERY = 0 15 | IQUERY = 1 16 | STATUS = 2 17 | NOTIFY = 4 18 | UPDATE = 5 19 | 20 | # Construct reverse mapping dictionary 21 | 22 | _names = dir() 23 | opcodemap = {} 24 | for _name in _names: 25 | if _name[0] != '_': opcodemap[eval(_name)] = _name 26 | 27 | def opcodestr(opcode): 28 | if opcodemap.has_key(opcode): return opcodemap[opcode] 29 | else: return `opcode` 30 | 31 | # 32 | # $Log: Opcode.py,v $ 33 | # Revision 1.6 2002/04/23 10:51:43 anthonybaxter 34 | # Added UPDATE, NOTIFY. 35 | # 36 | # Revision 1.5 2002/03/19 12:41:33 anthonybaxter 37 | # tabnannied and reindented everything. 4 space indent, no tabs. 38 | # yay. 39 | # 40 | # Revision 1.4 2002/03/19 12:26:13 anthonybaxter 41 | # death to leading tabs. 42 | # 43 | # Revision 1.3 2001/08/09 09:08:55 anthonybaxter 44 | # added identifying header to top of each file 45 | # 46 | # Revision 1.2 2001/07/19 06:57:07 anthony 47 | # cvs keywords added 48 | # 49 | # 50 | -------------------------------------------------------------------------------- /client/DNS/Status.py: -------------------------------------------------------------------------------- 1 | """ 2 | $Id: Status.py,v 1.7 2002/04/23 12:52:19 anthonybaxter Exp $ 3 | 4 | This file is part of the pydns project. 5 | Homepage: http://pydns.sourceforge.net 6 | 7 | This code is covered by the standard Python License. 8 | 9 | Status values in message header 10 | """ 11 | 12 | NOERROR = 0 # No Error [RFC 1035] 13 | FORMERR = 1 # Format Error [RFC 1035] 14 | SERVFAIL = 2 # Server Failure [RFC 1035] 15 | NXDOMAIN = 3 # Non-Existent Domain [RFC 1035] 16 | NOTIMP = 4 # Not Implemented [RFC 1035] 17 | REFUSED = 5 # Query Refused [RFC 1035] 18 | YXDOMAIN = 6 # Name Exists when it should not [RFC 2136] 19 | YXRRSET = 7 # RR Set Exists when it should not [RFC 2136] 20 | NXRRSET = 8 # RR Set that should exist does not [RFC 2136] 21 | NOTAUTH = 9 # Server Not Authoritative for zone [RFC 2136] 22 | NOTZONE = 10 # Name not contained in zone [RFC 2136] 23 | BADVERS = 16 # Bad OPT Version [RFC 2671] 24 | BADSIG = 16 # TSIG Signature Failure [RFC 2845] 25 | BADKEY = 17 # Key not recognized [RFC 2845] 26 | BADTIME = 18 # Signature out of time window [RFC 2845] 27 | BADMODE = 19 # Bad TKEY Mode [RFC 2930] 28 | BADNAME = 20 # Duplicate key name [RFC 2930] 29 | BADALG = 21 # Algorithm not supported [RFC 2930] 30 | 31 | # Construct reverse mapping dictionary 32 | 33 | _names = dir() 34 | statusmap = {} 35 | for _name in _names: 36 | if _name[0] != '_': statusmap[eval(_name)] = _name 37 | 38 | def statusstr(status): 39 | if statusmap.has_key(status): return statusmap[status] 40 | else: return `status` 41 | 42 | # 43 | # $Log: Status.py,v $ 44 | # Revision 1.7 2002/04/23 12:52:19 anthonybaxter 45 | # cleanup whitespace. 46 | # 47 | # Revision 1.6 2002/04/23 10:57:57 anthonybaxter 48 | # update to complete the list of response codes. 49 | # 50 | # Revision 1.5 2002/03/19 12:41:33 anthonybaxter 51 | # tabnannied and reindented everything. 4 space indent, no tabs. 52 | # yay. 53 | # 54 | # Revision 1.4 2002/03/19 12:26:13 anthonybaxter 55 | # death to leading tabs. 56 | # 57 | # Revision 1.3 2001/08/09 09:08:55 anthonybaxter 58 | # added identifying header to top of each file 59 | # 60 | # Revision 1.2 2001/07/19 06:57:07 anthony 61 | # cvs keywords added 62 | # 63 | # 64 | -------------------------------------------------------------------------------- /client/DNS/Type.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/client/DNS/Type.py -------------------------------------------------------------------------------- /client/DNS/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # $Id: __init__.py,v 1.8.2.7 2009/06/09 18:05:29 customdesigned Exp $ 3 | # 4 | # This file is part of the pydns project. 5 | # Homepage: http://pydns.sourceforge.net 6 | # 7 | # This code is covered by the standard Python License. 8 | # 9 | 10 | # __init__.py for DNS class. 11 | 12 | __version__ = '2.3.4' 13 | 14 | import Type,Opcode,Status,Class 15 | from Base import DnsRequest, DNSError 16 | from Lib import DnsResult 17 | from Base import * 18 | from Lib import * 19 | Error=DNSError 20 | from lazy import * 21 | Request = DnsRequest 22 | Result = DnsResult 23 | 24 | # 25 | # $Log: __init__.py,v $ 26 | # Revision 1.8.2.7 2009/06/09 18:05:29 customdesigned 27 | # Release 2.3.4 28 | # 29 | # Revision 1.8.2.6 2008/08/01 04:01:25 customdesigned 30 | # Release 2.3.3 31 | # 32 | # Revision 1.8.2.5 2008/07/28 02:11:07 customdesigned 33 | # Bump version. 34 | # 35 | # Revision 1.8.2.4 2008/07/28 00:17:10 customdesigned 36 | # Randomize source ports. 37 | # 38 | # Revision 1.8.2.3 2008/07/24 20:10:55 customdesigned 39 | # Randomize tid in requests, and check in response. 40 | # 41 | # Revision 1.8.2.2 2007/05/22 21:06:52 customdesigned 42 | # utf-8 in __init__.py 43 | # 44 | # Revision 1.8.2.1 2007/05/22 20:39:20 customdesigned 45 | # Release 2.3.1 46 | # 47 | # Revision 1.8 2002/05/06 06:17:49 anthonybaxter 48 | # found that the old README file called itself release 2.2. So make 49 | # this one 2.3... 50 | # 51 | # Revision 1.7 2002/05/06 06:16:15 anthonybaxter 52 | # make some sort of reasonable version string. releasewards ho! 53 | # 54 | # Revision 1.6 2002/03/19 13:05:02 anthonybaxter 55 | # converted to class based exceptions (there goes the python1.4 compatibility :) 56 | # 57 | # removed a quite gross use of 'eval()'. 58 | # 59 | # Revision 1.5 2002/03/19 12:41:33 anthonybaxter 60 | # tabnannied and reindented everything. 4 space indent, no tabs. 61 | # yay. 62 | # 63 | # Revision 1.4 2001/11/26 17:57:51 stroeder 64 | # Added __version__ 65 | # 66 | # Revision 1.3 2001/08/09 09:08:55 anthonybaxter 67 | # added identifying header to top of each file 68 | # 69 | # Revision 1.2 2001/07/19 06:57:07 anthony 70 | # cvs keywords added 71 | # 72 | # 73 | -------------------------------------------------------------------------------- /client/DNS/lazy.py: -------------------------------------------------------------------------------- 1 | # $Id: lazy.py,v 1.5.2.1 2007/05/22 20:23:38 customdesigned Exp $ 2 | # 3 | # This file is part of the pydns project. 4 | # Homepage: http://pydns.sourceforge.net 5 | # 6 | # This code is covered by the standard Python License. 7 | # 8 | 9 | # routines for lazy people. 10 | import Base 11 | import string 12 | 13 | class NoDataError(IndexError): pass 14 | class StatusError(IndexError): pass 15 | 16 | def revlookup(name): 17 | "convenience routine for doing a reverse lookup of an address" 18 | if Base.defaults['server'] == []: Base.DiscoverNameServers() 19 | a = string.split(name, '.') 20 | a.reverse() 21 | b = string.join(a, '.')+'.in-addr.arpa' 22 | # this will only return one of any records returned. 23 | result = Base.DnsRequest(b, qtype = 'ptr').req() 24 | if result.header['status'] != 'NOERROR': 25 | raise StatusError("DNS query status: %s" % result.header['status']) 26 | elif len(result.answers) == 0: 27 | raise NoDataError("No PTR records for %s" % name) 28 | else: 29 | return result.answers[0]['data'] 30 | 31 | def mxlookup(name): 32 | """ 33 | convenience routine for doing an MX lookup of a name. returns a 34 | sorted list of (preference, mail exchanger) records 35 | """ 36 | if Base.defaults['server'] == []: Base.DiscoverNameServers() 37 | a = Base.DnsRequest(name, qtype = 'mx').req().answers 38 | l = map(lambda x:x['data'], a) 39 | l.sort() 40 | return l 41 | 42 | # 43 | # $Log: lazy.py,v $ 44 | # Revision 1.5.2.1 2007/05/22 20:23:38 customdesigned 45 | # Lazy call to DiscoverNameServers 46 | # 47 | # Revision 1.5 2002/05/06 06:14:38 anthonybaxter 48 | # reformat, move import to top of file. 49 | # 50 | # Revision 1.4 2002/03/19 12:41:33 anthonybaxter 51 | # tabnannied and reindented everything. 4 space indent, no tabs. 52 | # yay. 53 | # 54 | # Revision 1.3 2001/08/09 09:08:55 anthonybaxter 55 | # added identifying header to top of each file 56 | # 57 | # Revision 1.2 2001/07/19 06:57:07 anthony 58 | # cvs keywords added 59 | # 60 | # 61 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | ncproxy 2 | ============== 3 | 4 | A SOCKS5 adapter that provides namecoin name resolution. 5 | 6 | This program listens for SOCKS5 connections, resolves .bit DNS names if any 7 | and passes the request to a parent SOCKS5 proxy. It can be used between polipo 8 | and Tor. 9 | 10 | HowTo 11 | ============= 12 | 13 | This assumes namecoin is running on the local machine with the default RPC port, and Tor and polipo are installed. 14 | 15 | Run ncproxy with RPC user and password arguments for namecoin: 16 | 17 | `./ncproxy --user=USER --pass=PASS` 18 | 19 | The ncproxy script listens on port 9055, so configure /etc/polipo/config as follows: 20 | 21 | `socksParentProxy = "localhost:9055"` 22 | 23 | Make sure that there is just one such statement. Then do 24 | 25 | `sudo service polipo restart` 26 | 27 | Check that your browser is already configured to use polipo. For example, Torbutton does this configuration for you. .bit should now resolve correctly since polipo will pass all requests through ncproxy. ncproxy also resolves .b and .n if you prefer the shorthand and the target web site supports it. 28 | -------------------------------------------------------------------------------- /client/jsonrpc/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Copyright (c) 2007 Jan-Klaas Kollhof 4 | 5 | This file is part of jsonrpc. 6 | 7 | jsonrpc is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 2.1 of the License, or 10 | (at your option) any later version. 11 | 12 | This software is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this software; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | """ 21 | 22 | from jsonrpc.json import loads, dumps, JSONEncodeException, JSONDecodeException 23 | from jsonrpc.proxy import ServiceProxy, JSONRPCException 24 | from jsonrpc.serviceHandler import ServiceMethod, ServiceHandler, ServiceMethodNotFound, ServiceException 25 | from jsonrpc.cgiwrapper import handleCGI 26 | from jsonrpc.modpywrapper import handler -------------------------------------------------------------------------------- /client/jsonrpc/_tests/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Copyright (c) 2007 Jan-Klaas Kollhof 4 | 5 | This file is part of jsonrpc. 6 | 7 | jsonrpc is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 2.1 of the License, or 10 | (at your option) any later version. 11 | 12 | This software is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this software; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | """ 21 | -------------------------------------------------------------------------------- /client/jsonrpc/_tests/test_cgiwrapper.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Copyright (c) 2007 Jan-Klaas Kollhof 4 | 5 | This file is part of jsonrpc. 6 | 7 | jsonrpc is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 2.1 of the License, or 10 | (at your option) any later version. 11 | 12 | This software is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this software; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | """ 21 | import unittest 22 | import jsonrpc 23 | from types import * 24 | 25 | class Service(object): 26 | @jsonrpc.ServiceMethod 27 | def echo(self, arg): 28 | return arg 29 | 30 | 31 | class TestCGIWrapper(unittest.TestCase): 32 | 33 | def setUp(self): 34 | pass 35 | 36 | def tearDown(self): 37 | pass 38 | 39 | def test_runCGIHandler(self): 40 | from StringIO import StringIO 41 | 42 | json=u'{"method":"echo","params":["foobar"], "id":""}' 43 | fin=StringIO(json) 44 | fout=StringIO() 45 | 46 | env = {"CONTENT_LENGTH":len(json)} 47 | 48 | jsonrpc.handleCGI(service=Service(), fin=fin, fout=fout, env=env) 49 | 50 | data = StringIO(fout.getvalue()) 51 | data.readline() 52 | data.readline() 53 | data = data.read() 54 | self.assertEquals(jsonrpc.loads(data), {"result":"foobar", "error":None, "id":""}) 55 | 56 | -------------------------------------------------------------------------------- /client/jsonrpc/_tests/test_modpywrapper.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Copyright (c) 2007 Jan-Klaas Kollhof 4 | 5 | This file is part of jsonrpc. 6 | 7 | jsonrpc is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 2.1 of the License, or 10 | (at your option) any later version. 11 | 12 | This software is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this software; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | """ 21 | import unittest 22 | import jsonrpc 23 | from types import * 24 | 25 | class Service(object): 26 | @jsonrpc.ServiceMethod 27 | def echo(self, arg): 28 | return arg 29 | 30 | 31 | class ApacheRequestMockup(object): 32 | 33 | def __init__(self, filename, fin, fout): 34 | self.fin=fin 35 | self.fout = fout 36 | self.filename = filename 37 | 38 | def write(self,data): 39 | self.fout.write(data) 40 | 41 | def flush(self): 42 | pass 43 | 44 | def read(self): 45 | return self.fin.read() 46 | 47 | class ModPyMockup(object): 48 | def __init__(self): 49 | self.apache=ApacheModuleMockup() 50 | 51 | class ApacheModuleMockup(object): 52 | def __getattr__(self, name): 53 | return name 54 | 55 | def import_module(self, moduleName, log=1): 56 | return Service() 57 | 58 | 59 | 60 | class TestModPyWrapper(unittest.TestCase): 61 | 62 | def setUp(self): 63 | import sys 64 | sys.modules['mod_python'] =ModPyMockup() 65 | 66 | def tearDown(self): 67 | pass 68 | 69 | def test_runHandler(self): 70 | from StringIO import StringIO 71 | 72 | json=u'{"method":"echo","params":["foobar"], "id":""}' 73 | fin=StringIO(json) 74 | fout=StringIO() 75 | req = ApacheRequestMockup(__file__ , fin, fout) 76 | 77 | jsonrpc.handler(req) 78 | 79 | data = fout.getvalue() 80 | 81 | self.assertEquals(jsonrpc.loads(data), {"result":"foobar", "error":None, "id":""}) 82 | 83 | def test_ServiceImplementationNotFound(self): 84 | from StringIO import StringIO 85 | 86 | json=u'{"method":"echo","params":["foobar"], "id":""}' 87 | fin=StringIO(json) 88 | fout=StringIO() 89 | req = ApacheRequestMockup("foobar" , fin, fout) 90 | 91 | rslt = jsonrpc.handler(req) 92 | self.assertEquals(rslt, "OK") 93 | data = fout.getvalue() 94 | 95 | self.assertEquals(jsonrpc.loads(data), {u'id': '', u'result': None, u'error': {u'message': '', u'name': u'ServiceImplementaionNotFound'}} ) 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /client/jsonrpc/_tests/test_proxy.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Copyright (c) 2007 Jan-Klaas Kollhof 4 | 5 | This file is part of jsonrpc. 6 | 7 | jsonrpc is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 2.1 of the License, or 10 | (at your option) any later version. 11 | 12 | This software is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this software; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | """ 21 | 22 | import unittest 23 | import jsonrpc 24 | 25 | import urllib 26 | 27 | from StringIO import StringIO 28 | 29 | class TestProxy(unittest.TestCase): 30 | 31 | def urlopen(self, url, data): 32 | self.postdata = data 33 | return StringIO(self.respdata) 34 | 35 | def setUp(self): 36 | self.postdata="" 37 | self.urllib_openurl = urllib.urlopen 38 | urllib.urlopen = self.urlopen 39 | 40 | def tearDown(self): 41 | urllib.urlopen = self.urllib_openurl 42 | 43 | def test_ProvidesProxyMethod(self): 44 | s = jsonrpc.ServiceProxy("http://localhost/") 45 | self.assert_(callable(s.echo)) 46 | 47 | def test_MethodCallCallsService(self): 48 | 49 | s = jsonrpc.ServiceProxy("http://localhost/") 50 | 51 | self.respdata='{"result":"foobar","error":null,"id":""}' 52 | echo = s.echo("foobar") 53 | self.assertEquals(self.postdata, jsonrpc.dumps({"method":"echo", 'params':['foobar'], 'id':'jsonrpc'})) 54 | self.assertEquals(echo, 'foobar') 55 | 56 | self.respdata='{"result":null,"error":"MethodNotFound","id":""}' 57 | try: 58 | s.echo("foobar") 59 | except jsonrpc.JSONRPCException,e: 60 | self.assertEquals(e.error, "MethodNotFound") 61 | -------------------------------------------------------------------------------- /client/jsonrpc/cgiwrapper.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | from jsonrpc import ServiceHandler 3 | 4 | class CGIServiceHandler(ServiceHandler): 5 | def __init__(self, service): 6 | if service == None: 7 | import __main__ as service 8 | 9 | ServiceHandler.__init__(self, service) 10 | 11 | def handleRequest(self, fin=None, fout=None, env=None): 12 | if fin==None: 13 | fin = sys.stdin 14 | if fout==None: 15 | fout = sys.stdout 16 | if env == None: 17 | env = os.environ 18 | 19 | try: 20 | contLen=int(env['CONTENT_LENGTH']) 21 | data = fin.read(contLen) 22 | except Exception, e: 23 | data = "" 24 | 25 | resultData = ServiceHandler.handleRequest(self, data) 26 | 27 | response = "Content-Type: text/plain\n" 28 | response += "Content-Length: %d\n\n" % len(resultData) 29 | response += resultData 30 | 31 | #on windows all \n are converted to \r\n if stdout is a terminal and is not set to binary mode :( 32 | #this will then cause an incorrect Content-length. 33 | #I have only experienced this problem with apache on Win so far. 34 | if sys.platform == "win32": 35 | try: 36 | import msvcrt 37 | msvcrt.setmode(fout.fileno(), os.O_BINARY) 38 | except: 39 | pass 40 | #put out the response 41 | fout.write(response) 42 | fout.flush() 43 | 44 | def handleCGI(service=None, fin=None, fout=None, env=None): 45 | CGIServiceHandler(service).handleRequest(fin, fout, env) -------------------------------------------------------------------------------- /client/jsonrpc/modpywrapper.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | from jsonrpc import ServiceHandler, ServiceException 3 | 4 | 5 | class ServiceImplementaionNotFound(ServiceException): 6 | pass 7 | 8 | 9 | class ModPyServiceHandler(ServiceHandler): 10 | def __init__(self, req): 11 | self.req = req 12 | ServiceHandler.__init__(self, None) 13 | 14 | 15 | def findServiceEndpoint(self, name): 16 | req = self.req 17 | 18 | (modulePath, fileName) = os.path.split(req.filename) 19 | (moduleName, ext) = os.path.splitext(fileName) 20 | 21 | if not os.path.exists(os.path.join(modulePath, moduleName + ".py")): 22 | raise ServiceImplementaionNotFound() 23 | else: 24 | if not modulePath in sys.path: 25 | sys.path.insert(0, modulePath) 26 | 27 | from mod_python import apache 28 | module = apache.import_module(moduleName, log=1) 29 | 30 | if hasattr(module, "service"): 31 | self.service = module.service 32 | elif hasattr(module, "Service"): 33 | self.service = module.Service() 34 | else: 35 | self.service = module 36 | 37 | return ServiceHandler.findServiceEndpoint(self, name) 38 | 39 | 40 | def handleRequest(self, data): 41 | self.req.content_type = "text/plain" 42 | data = self.req.read() 43 | resultData = ServiceHandler.handleRequest(self, data) 44 | self.req.write(resultData) 45 | self.req.flush() 46 | 47 | def handler(req): 48 | from mod_python import apache 49 | ModPyServiceHandler(req).handleRequest(req) 50 | return apache.OK 51 | 52 | 53 | -------------------------------------------------------------------------------- /client/jsonrpc/proxy.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Copyright (c) 2007 Jan-Klaas Kollhof 4 | 5 | This file is part of jsonrpc. 6 | 7 | jsonrpc is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 2.1 of the License, or 10 | (at your option) any later version. 11 | 12 | This software is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with this software; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | """ 21 | 22 | import urllib 23 | from jsonrpc.json import dumps, loads 24 | 25 | class JSONRPCException(Exception): 26 | def __init__(self, rpcError): 27 | Exception.__init__(self) 28 | self.error = rpcError 29 | 30 | class ServiceProxy(object): 31 | def __init__(self, serviceURL, serviceName=None): 32 | self.__serviceURL = serviceURL 33 | self.__serviceName = serviceName 34 | 35 | def __getattr__(self, name): 36 | if self.__serviceName != None: 37 | name = "%s.%s" % (self.__serviceName, name) 38 | return ServiceProxy(self.__serviceURL, name) 39 | 40 | def __call__(self, *args): 41 | postdata = dumps({"method": self.__serviceName, 'params': args, 'id':'jsonrpc'}) 42 | respdata = urllib.urlopen(self.__serviceURL, postdata).read() 43 | resp = loads(respdata) 44 | if resp['error'] != None: 45 | raise JSONRPCException(resp['error']) 46 | else: 47 | return resp['result'] 48 | 49 | 50 | -------------------------------------------------------------------------------- /contrib/.gitignore: -------------------------------------------------------------------------------- 1 | installer 2 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/1a_environment_mingw.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | @echo About to download MinGW/MSYS installer - you need to install it manually. Note: 3 | @echo Install to default directory: %MINGWBASEPATH% 4 | @echo Unselect "... also install support for the graphical user interface." 5 | @echo. 6 | @pause 7 | @start %MINGWDOWNLOADPATH% 8 | @echo. 9 | @echo Once the mingw-get-setup has finished press a key. 10 | @pause 11 | %MINGWPATH%\mingw-get.exe update 12 | %MINGWPATH%\mingw-get.exe install msys-base 13 | @rem %MINGWPATH%\mingw-get install mingw32-make 14 | %MINGWPATH%\mingw-get install msys-wget-bin 15 | %MINGWPATH%\mingw-get install msys-unzip-bin 16 | %MINGWPATH%\mingw-get install msys-perl 17 | 18 | @rem %MINGWPATH%\mingw-get.exe install --reinstall --recursive "gcc=4.6.*" 19 | @rem %MINGWPATH%\mingw-get.exe install --reinstall --recursive "gcc-g++=4.6.*" 20 | @rem %MINGWPATH%\mingw-get.exe install --reinstall --recursive "gcc-bin=4.6.*" 21 | 22 | @rem %MINGWPATH%\mingw-get install --reinstall --recursive libgmp-dll="5.0.1-*" 23 | @rem %MINGWPATH%\mingw-get install --reinstall --recursive mingwrt-dev 24 | @rem %MINGWPATH%\mingw-get.exe install --reinstall --recursive "w32api=3.17-2" 25 | @rem %MINGWPATH%\mingw-get.exe install --reinstall --recursive "w32api-dev=3.17-2" 26 | 27 | @rem There is a problem with MSYS bash and sh that stalls OpenSSL config on some systems. Using rxvt shell as a workaround. 28 | %MINGWPATH%\mingw-get install msys-rxvt 29 | echo. 30 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/1b_environment_qt.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | @echo About to download Qt installer - you need to install it manually: 3 | @echo Use default directory "%QTBASEPATH%". 4 | @echo Activate checkbox: tools - MinGW !!! 5 | @echo. 6 | @pause 7 | @start %QTDOWNLOADPATH% 8 | @set WAITQT=1 9 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/2a_run_download.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | @if not "%WAITMINGW%" == "1" goto continue 3 | @echo Ensure MinGW installer has finished. 4 | @pause 5 | :continue 6 | @bash download.sh 7 | @if not "%RUNALL%"=="1" pause 8 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/2b_run_unpack.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | @bash unpack.sh 3 | @if not "%RUNALL%"=="1" pause -------------------------------------------------------------------------------- /contrib/easywinbuilder/3a_build_boost.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | @echo Building boost... 3 | @cd %ROOTPATH%\%EWBLIBS%\%BOOST% 4 | 5 | @echo bootstrap... 6 | call bootstrap.bat mingw 7 | @echo. 8 | @echo. 9 | @echo building... 10 | b2.exe --build-type=minimal --with-chrono --with-filesystem --with-program_options --with-system --with-thread^ 11 | --layout=versioned -sNO_BZIP2=1 -sNO_ZLIB=1^ 12 | variant=release^ 13 | toolset=gcc^ 14 | link=static^ 15 | threading=multi^ 16 | target-os=windows^ 17 | threadapi=win32^ 18 | cxxflags="%ADDITIONALCCFLAGS%"^ 19 | cflags="%ADDITIONALCCFLAGS%"^ 20 | stage 21 | @cd ..\..\%EWBPATH% 22 | @if not "%RUNALL%"=="1" pause 23 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/3b_run_build_dep.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | @rxvt -e ./build_dep.sh 3 | @if not "%RUNALL%"=="1" pause -------------------------------------------------------------------------------- /contrib/easywinbuilder/3c_build_miniupnpc.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | @bash patch_files.sh 3 | @cd %ROOTPATH%\%EWBLIBS%\ 4 | @echo miniupnp... 5 | @cd %MINIUPNPC%\miniupnpc 6 | @rem mingw32-make is different from normal msys make 7 | mingw32-make -f Makefile.mingw ADDITIONALCCFLAGS="%ADDITIONALCCFLAGS%" 8 | @cd ..\..\..\%EWBPATH% 9 | @if not "%RUNALL%"=="1" pause -------------------------------------------------------------------------------- /contrib/easywinbuilder/4a_build_daemon.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | @bash patch_files.sh 3 | @echo Building Bitcoin daemon... 4 | @rem todo: rewrite this with ^ line wrapping 5 | @set PARAMS=BOOST_SUFFIX=%BOOSTSUFFIX% 6 | @set PARAMS=%PARAMS% INCLUDEPATHS=" 7 | @rem set PARAMS=%PARAMS%-I'../src' 8 | @set PARAMS=%PARAMS% -I'../%EWBLIBS%/%BOOST%' 9 | @set PARAMS=%PARAMS% -I'../%EWBLIBS%/%OPENSSL%/include' 10 | @set PARAMS=%PARAMS% -I'../%EWBLIBS%/%BERKELEYDB%/build_unix' 11 | @set PARAMS=%PARAMS% -I'../%EWBLIBS%/%MINIUPNPC%' 12 | @set PARAMS=%PARAMS%" 13 | @set PARAMS=%PARAMS% LIBPATHS=" 14 | @set PARAMS=%PARAMS%-L'../src/leveldb' 15 | @set PARAMS=%PARAMS% -L'../%EWBLIBS%/%BOOST%/stage/lib' 16 | @set PARAMS=%PARAMS% -L'../%EWBLIBS%/%OPENSSL%' 17 | @set PARAMS=%PARAMS% -L'../%EWBLIBS%/%BERKELEYDB%/build_unix' 18 | @set PARAMS=%PARAMS% -L'../%EWBLIBS%/%MINIUPNPC%'/miniupnpc 19 | @set PARAMS=%PARAMS%" 20 | @set PARAMS=%PARAMS% ADDITIONALCCFLAGS="%ADDITIONALCCFLAGS%" 21 | @set PARAMS=%PARAMS:\=/% 22 | @echo PARAMS: %PARAMS% 23 | 24 | @set PARAMS=%PARAMS% USE_UPNP=1 25 | @rem remove "rem " from the next line to deactivate upnp 26 | @rem set PARAMS=%PARAMS% USE_UPNP=- 27 | 28 | @cd %ROOTPATH%\src 29 | @mingw32-make -f makefile.mingw %PARAMS% 30 | @if errorlevel 1 goto error 31 | @echo. 32 | @echo. 33 | @strip %COINNAME%d.exe 34 | @if errorlevel 1 goto error 35 | @echo !!!!!!! %COINNAME% daemon DONE: Find %COINNAME%d.exe in ./src :) 36 | @echo. 37 | @echo. 38 | @if not "%RUNALL%"=="1" pause 39 | @goto end 40 | 41 | :error 42 | @echo. 43 | @echo. 44 | @echo !!!!!! Error! Build daemon failed. 45 | @pause 46 | :end 47 | @cd ..\%EWBPATH% 48 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/4b_build_qt.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | 3 | @bash patch_files.sh 4 | 5 | @cd %ROOTPATH% 6 | @echo building qt - qmake... 7 | 8 | @set QMPS=BOOST_INCLUDE_PATH=%EWBLIBS%/%BOOST%^ 9 | BOOST_LIB_PATH=%EWBLIBS%/%BOOST%/stage/lib^ 10 | BOOST_LIB_SUFFIX=%BOOSTSUFFIX%^ 11 | OPENSSL_INCLUDE_PATH=%EWBLIBS%/%OPENSSL%/include^ 12 | OPENSSL_LIB_PATH=%EWBLIBS%/%OPENSSL%^ 13 | BDB_INCLUDE_PATH=%EWBLIBS%/%BERKELEYDB%/build_unix^ 14 | BDB_LIB_PATH=%EWBLIBS%/%BERKELEYDB%/build_unix^ 15 | MINIUPNPC_INCLUDE_PATH=%EWBLIBS%/%MINIUPNPC%^ 16 | MINIUPNPC_LIB_PATH=%EWBLIBS%/%MINIUPNPC%/miniupnpc^ 17 | QMAKE_CXXFLAGS="%ADDITIONALCCFLAGS%"^ 18 | QMAKE_CFLAGS="%ADDITIONALCCFLAGS%" 19 | 20 | @%QTPATH%\qmake.exe %QMPS% 21 | @echo. 22 | @echo. 23 | @echo building qt - make... 24 | mingw32-make -f Makefile.Release 25 | @if errorlevel 1 goto continue 26 | @echo !!!!!!! %COINNAME%-qt DONE: Find %COINNAME%-qt.exe in ./release :) 27 | :continue 28 | @echo. 29 | @echo. 30 | @echo. 31 | @echo. 32 | @cd %EWBPATH% 33 | @if not "%RUNALL%"=="1" pause -------------------------------------------------------------------------------- /contrib/easywinbuilder/6_gather_dlls.bat: -------------------------------------------------------------------------------- 1 | @call set_vars.bat 2 | 3 | @set QTPATHF=%QTPATH:/=\% 4 | @set MINGWQTPATHF=%MINGWQTPATH:/=\% 5 | 6 | @echo namecoind DLLs 7 | copy %MINGWQTPATHF%\libgcc_s_dw2-1.dll %ROOTPATH%\src\ 8 | copy "%MINGWQTPATHF%\libstdc++-6.dll" %ROOTPATH%\src\ 9 | 10 | copy %QTPATHF%\libwinpthread-1.dll %ROOTPATH%\src\ 11 | 12 | @echo namecoin-qt DLLs 13 | copy %MINGWQTPATHF%\libgcc_s_dw2-1.dll %ROOTPATH%\release\ 14 | copy "%MINGWQTPATHF%\libstdc++-6.dll" %ROOTPATH%\release\ 15 | 16 | copy %QTPATHF%\Qt5Core.dll %ROOTPATH%\release\ 17 | copy %QTPATHF%\Qt5Gui.dll %ROOTPATH%\release\ 18 | copy %QTPATHF%\Qt5Widgets.dll %ROOTPATH%\release\ 19 | copy %QTPATHF%\Qt5Network.dll %ROOTPATH%\release\ 20 | copy %QTPATHF%\libwinpthread-1.dll %ROOTPATH%\release\ 21 | copy %QTPATHF%\icuin52.dll %ROOTPATH%\release\ 22 | copy %QTPATHF%\icuuc52.dll %ROOTPATH%\release\ 23 | copy %QTPATHF%\icudt52.dll %ROOTPATH%\release\ 24 | 25 | mkdir %ROOTPATH%\release\platforms 26 | copy %QTPATHF%\..\plugins\platforms\qwindows.dll %ROOTPATH%\release\platforms 27 | 28 | @if not "%RUNALL%"=="1" pause 29 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/README.md: -------------------------------------------------------------------------------- 1 | EasyWinBuilder v0.6 Namecoin Edition 2 | ============================ 3 | (c) 2014 phelix / blockchained.com - MIT license 4 | 5 | Download environment software, all dependencies and build Namecoin automatically. To run simply double click __all_easywinbuilder.bat or manually start the batch files in order. Building on Windows really is a pain. Hopefully this saves people some trouble. 6 | 7 | EasyWinBuilder can run on a mint windows system (e.g. a virtual machine) or a normal system. It might overwrite your MinGW or Qt installation, though. Please note the process takes about half an hour or more and will need about 3GB of hard drive space. 8 | 9 | To change directories and dependency versions edit set_vars.bat 10 | 11 | More info here: https://bitcointalk.org/index.php?topic=252931 12 | 13 | 14 | ToDo 15 | ----- 16 | * Automatic environment install (how to bootstrap?) 17 | * Try to speed up building of OpenSSL and Berkeley DB by only building what is necessary 18 | 19 | 20 | Credits 21 | ------- 22 | Based on build instructions by nitrogenetics (https://bitcointalk.org/index.php?topic=149479.0), Matt Corallo and others 23 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/__all_easywinbuilder.bat: -------------------------------------------------------------------------------- 1 | @echo EasyWinBuilder v0.3 2 | @echo. 3 | @set RUNALL=1 4 | @echo. 5 | @call 1a_environment_mingw.bat 6 | @rem if errorlevel 1 goto error 7 | @call 1b_environment_qt.bat 8 | @rem if errorlevel 1 goto error 9 | @echo. 10 | @call __everything_but_environment_easywinbuilder.bat 11 | @goto end 12 | 13 | :error 14 | @echo Fatal error! Errorlevel: %errorlevel% 15 | @pause 16 | 17 | :end 18 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/__everything_but_environment_easywinbuilder.bat: -------------------------------------------------------------------------------- 1 | @set RUNALL=1 2 | @call 2a_run_download.bat 3 | @if errorlevel 1 goto error 4 | @call 2b_run_unpack.bat 5 | @if errorlevel 1 goto error 6 | @call __everything_from_after_unpack_easywinbuilder.bat 7 | @goto end 8 | 9 | :error 10 | @echo Fatal error! Errorlevel: %ERRORLEVEL% 11 | @pause 12 | 13 | :end 14 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/__everything_from_after_unpack_easywinbuilder.bat: -------------------------------------------------------------------------------- 1 | @set RUNALL=1 2 | 3 | @if not "%WAITQT%" == "1" goto continue 4 | @echo Ensure Qt installer has finished. 5 | @pause 6 | :continue 7 | 8 | @call 3a_build_boost.bat 9 | @if errorlevel 1 goto error 10 | @call 3b_run_build_dep.bat 11 | @if errorlevel 1 goto error 12 | @call 3c_build_miniupnpc.bat 13 | @if errorlevel 1 goto error 14 | @call 4a_build_daemon.bat 15 | @if errorlevel 1 goto error 16 | @call 4b_build_qt.bat 17 | @if errorlevel 1 goto error 18 | @rem call 5a_run_hash_daemon.bat 19 | @if errorlevel 1 goto error 20 | @rem call 5b_run_hash_qt.bat 21 | @if errorlevel 1 goto error 22 | @call 6_gather_dlls.bat 23 | @if errorlevel 1 goto error 24 | @echo. 25 | @echo. 26 | @goto end 27 | 28 | :error 29 | @echo Fatal error! Errorlevel: %errorlevel% 30 | 31 | :end 32 | @pause 33 | 34 | 35 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/__rebuild_daemon_and_qt.bat: -------------------------------------------------------------------------------- 1 | @set RUNALL=1 2 | @call 4a_build_daemon.bat 3 | @if errorlevel 1 goto error 4 | @call 4b_build_qt.bat 5 | @if errorlevel 1 goto error 6 | @echo. 7 | @echo. 8 | @goto end 9 | 10 | :error 11 | @echo Fatal error! Errorlevel: %errorlevel% 12 | 13 | :end 14 | @pause 15 | 16 | 17 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/build_dep.sh: -------------------------------------------------------------------------------- 1 | cd $ROOTPATHSH/$EWBLIBS 2 | 3 | echo db... 4 | cd $BERKELEYDB 5 | cd build_unix 6 | ../dist/configure --disable-replication --enable-mingw --enable-cxx \ 7 | CXXFLAGS="${ADDITIONALCCFLAGS}" \ 8 | CFLAGS="${ADDITIONALCCFLAGS}" 9 | if [ ${?} -ne 0 ]; then echo "BerkeleyDB configure failed."; read -n 1 -s; exit 1;fi 10 | #sed -i 's/typedef pthread_t db_threadid_t;/typedef u_int32_t db_threadid_t;/g' db.h # workaround, see https://bitcointalk.org/index.php?topic=45507.0 11 | make 12 | if [ ${?} -ne 0 ]; then echo "BerkeleyDB make failed."; read -n 1 -s; exit 1;fi 13 | cd .. 14 | cd .. 15 | echo 16 | 17 | echo openssl... 18 | cd $OPENSSL 19 | export CC="gcc ${ADDITIONALCCFLAGS}" 20 | ./config 21 | if [ ${?} -ne 0 ]; then echo "OpenSSL config failed."; read -n 1 -s; exit 1;fi 22 | make 23 | if [ ${?} -ne 0 ]; then echo "OpenSSL make failed."; read -n 1 -s; exit 1;fi 24 | cd .. 25 | echo 26 | 27 | cd ../$EWBPATH -------------------------------------------------------------------------------- /contrib/easywinbuilder/download.sh: -------------------------------------------------------------------------------- 1 | set -o errexit 2 | 3 | echo Creating lib directory... 4 | cd $ROOTPATHSH 5 | if [ ! -d $EWBLIBS ]; then 6 | mkdir $EWBLIBS 7 | fi 8 | 9 | # echo Downloading source... 10 | # wget --no-check-certificate -N "https://github.com/phelixbtc/namecoin-qt/archive/easywinbuilder.tar.gz" -O "source.tar.gz" 11 | # echo 12 | 13 | echo Downloading dependencies... 14 | cd libs 15 | wget -N "http://www.openssl.org/source/$OPENSSL.tar.gz" 16 | wget -N "http://download.oracle.com/berkeley-db/$BERKELEYDB.tar.gz" 17 | wget -N "http://downloads.sourceforge.net/project/boost/boost/$BOOSTVERSION/$BOOST.tar.gz" 18 | wget -N "http://miniupnp.tuxfamily.org/files/download.php?file=$MINIUPNPC.tar.gz" 19 | echo 20 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/patch_files.sh: -------------------------------------------------------------------------------- 1 | # sed -i.bak 's/INCLUDEPATHS= \\/INCLUDEPATHS?= \\/g' $ROOTPATHSH/src/makefile.mingw 2 | # sed -i.bak 's/LIBPATHS= \\/LIBPATHS?= \\/g' $ROOTPATHSH/src/makefile.mingw 3 | # sed -i.bak 's/USE_UPNP:=-/USE_UPNP?=-/g' $ROOTPATHSH/src/makefile.mingw 4 | 5 | # sed -i.bak 's,#include ,#include ,g' $ROOTPATHSH/src/net.cpp 6 | # sed -i.bak 's,#include ,#include ,g' $ROOTPATHSH/src/net.cpp 7 | # sed -i.bak 's,#include ,#include ,g' $ROOTPATHSH/src/net.cpp 8 | # sed -i.bak 's,#include ,#include ,g' $ROOTPATHSH/src/net.cpp 9 | 10 | sed -i.bak 's/\$(CC) -enable-stdcall-fixup/\$(CC) -Wl,-enable-stdcall-fixup/g' $ROOTPATHSH/${EWBLIBS}/${MINIUPNPC}/miniupnpc/Makefile.mingw # workaround, see http://stackoverflow.com/questions/13227354/warning-cannot-find-entry-symbol-nable-stdcall-fixup-defaulting 11 | sed -i.bak 's/all: init upnpc-static upnpc-shared testminixml libminiupnpc.a miniupnpc.dll/all: init upnpc-static/g' $ROOTPATHSH/${EWBLIBS}/${MINIUPNPC}/miniupnpc/Makefile.mingw # only need static, rest is not compiling 12 | 13 | # += does not work on windows defined variables 14 | # sed -i.bak 's/CFLAGS=-mthreads/CFLAGS=${ADDITIONALCCFLAGS} -mthreads/g' $ROOTPATHSH/src/makefile.mingw 15 | # sed -i.bak 's/CC = gcc/CC=gcc ${ADDITIONALCCFLAGS} -Wall/g' $ROOTPATHSH/${EWBLIBS}/${MINIUPNPC}/Makefile.mingw 16 | 17 | 18 | # winsock trouble 19 | # sed -i.bak 's/-DWIN32 -D_WINDOWS/-DWIN32 -DWIN32_LEAN_AND_MEAN -D_WINDOWS/g' $ROOTPATHSH/src/makefile.mingw 20 | # sed -i.bak 's/DEFINES += WIN32$/DEFINES += WIN32 WIN32_LEAN_AND_MEAN/g' $ROOTPATHSH/${COINNAME}-qt.pro 21 | 22 | # https://github.com/bitcoin/bitcoin/pull/3121 multi threading fix 23 | # sed -i.bak 's/DEFS=-DWIN32/DEFS=-D_MT -DWIN32/g' $ROOTPATHSH/src/makefile.mingw 24 | # sed -i.bak 's/LIBS += -l kernel32/LIBS += -l mingwthrd -l kernel32/g' $ROOTPATHSH/src/makefile.mingw 25 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/set_vars.bat: -------------------------------------------------------------------------------- 1 | @rem System Path Settings 2 | @set QTBASEPATH=C:/Qt/Qt5.3.0 3 | @set QTPATH=%QTBASEPATH%/5.3/mingw482_32/bin 4 | @set MINGWQTPATH=%QTBASEPATH%/Tools/mingw482_32/bin 5 | @set MINGWBASEPATH=C:/MinGW 6 | @set MINGWPATH=%MINGWBASEPATH%/bin 7 | @set MSYSPATH=%MINGWBASEPATH%/msys/1.0/bin 8 | @set PATH=%QTPATH%;%MINGWQTPATH%;%MINGWPATH%;%MSYSPATH% 9 | 10 | @rem Downloadpaths 11 | @set MINGWDOWNLOADPATH=https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download 12 | @set QTDOWNLOADPATH=http://download.qt-project.org/official_releases/qt/5.3/5.3.0/qt-opensource-windows-x86-mingw482_opengl-5.3.0.exe 13 | 14 | @rem Library Paths 15 | @set OPENSSL=openssl-1.0.1i 16 | @set BERKELEYDB=db-4.8.30.NC 17 | @set BOOST=boost_1_54_0 18 | @set BOOSTVERSION=1.54.0 19 | @rem If you wonder why there is no -s- see: https://github.com/bitcoin/bitcoin/pull/2835#issuecomment-21231694 20 | @set BOOSTSUFFIX=-mgw48-mt-1_54 21 | @set MINIUPNPC=miniupnpc-1.8 22 | 23 | @rem Internal Paths 24 | @set EWBLIBS=libs 25 | @set EWBPATH=contrib/easywinbuilder 26 | @set ROOTPATH=..\.. 27 | @set ROOTPATHSH=%ROOTPATH:\=/% 28 | @set PERL=%MSYSPATH%/perl.exe 29 | 30 | @rem Bootstrap Coin Name 31 | @for /F %%a in ('dir /b %ROOTPATH%\*.pro') do @set COINNAME=%%a 32 | @set COINNAME=%COINNAME:-qt.pro=% 33 | 34 | @rem the following will be set as additional CXXFLAGS and CFLAGS for everything - no ' or ", space is ok 35 | @set ADDITIONALCCFLAGS= -fno-guess-branch-probability -frandom-seed=1984 -Wno-unused-variable -Wno-unused-value -Wno-sign-compare -Wno-strict-aliasing 36 | 37 | @rem Language Settings - always US 38 | @set LANG=en_US.UTF8 39 | @set LC_ALL=en_US.UTF8 40 | 41 | @rem Note: Variables set here can NOT be overwritten in makefiles 42 | -------------------------------------------------------------------------------- /contrib/easywinbuilder/unpack.sh: -------------------------------------------------------------------------------- 1 | set -o errexit 2 | 3 | # echo Unpacking source... 4 | # tar xvfz source.tar.gz 5 | # echo 6 | 7 | cd $ROOTPATHSH 8 | cd $EWBLIBS 9 | 10 | echo Unpacking dependencies... 11 | echo openssl... 12 | tar --atime-preserve -xzvf $OPENSSL.tar.gz > /dev/null 13 | echo berkeleydb... 14 | tar --atime-preserve -xzvf $BERKELEYDB.tar.gz > /dev/null 15 | echo boost... 16 | tar --atime-preserve -xzvf $BOOST.tar.gz > /dev/null 17 | echo miniupnpc... 18 | mkdir $MINIUPNPC 19 | tar -C $MINIUPNPC --atime-preserve -xzvf $MINIUPNPC.tar.gz > /dev/null 20 | mv $MINIUPNPC/$MINIUPNPC $MINIUPNPC/miniupnpc 21 | 22 | echo 23 | 24 | cd .. -------------------------------------------------------------------------------- /contrib/nmcsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # nmcsh - simple namecoind readline wrapper 4 | # 5 | # This provides history (Ctrl-p, Ctrl-n) command completion (TAB on an 6 | # incomplete command), argument help (TAB after a finished command), 7 | # and the other usual readline keys. See 8 | # http://tiswww.case.edu/php/chet/readline/rluserman.html for 9 | # details. 10 | # 11 | # Before running this, make sure namecoind is in your $PATH and the 12 | # dameon is running. 13 | # 14 | # Copyright (c) 2014 Mitchell Perilstein 15 | # Distributed under the MIT/X11 software license, see the accompanying 16 | # file COPYING. 17 | 18 | use strict; 19 | use warnings; 20 | use Term::ReadLine; 21 | 22 | my $NMCD = 'namecoind'; # must be in your $PATH 23 | my $PROMPT = 'nmc> '; 24 | my $PAGER = defined $ENV{PAGER} ? "| $ENV{PAGER}" : ''; 25 | 26 | my $term = Term::ReadLine->new('namecoind wrapper'); 27 | my $OUT = $term->OUT || \*STDOUT; 28 | 29 | # grok the help for command completion strings 30 | my %cmds; 31 | my $r = open NMC, "$NMCD help|" or die $!; 32 | while () { 33 | my ($cmd, @rest) = split; 34 | $cmds{$cmd} = join " ", @rest; 35 | } 36 | close NMC or die $!; 37 | 38 | # complete on partial commands or show help for finished ones 39 | sub my_complete { 40 | my ($text, $line, $start) = @_; 41 | 42 | return grep(/^$text/, keys %cmds) 43 | if $start == 0; 44 | 45 | my $cmd = (split(/\s+/, $line))[0]; 46 | if ($cmd) { 47 | print "($cmd)"; 48 | return "$cmd $cmds{$cmd}"; 49 | } 50 | 51 | return ''; 52 | } 53 | 54 | $readline::rl_completion_function = undef; 55 | $readline::rl_completion_function = "main::my_complete"; 56 | 57 | # main loop: prompt, exec command, show result 58 | while (defined ($_ = $term->readline($PROMPT)) ) { 59 | if ('quit' eq $_ || 'exit' eq $_ || 'q' eq $_) { 60 | print $OUT "bye\n"; 61 | exit; 62 | } 63 | 64 | next unless $_; 65 | 66 | # you could set up a bidirectional child but exec each time is fast 67 | # enough and much simpler 68 | my $res = `$NMCD $_ $PAGER`; 69 | if ($@) { 70 | warn $@; 71 | } 72 | else { 73 | print $OUT "[$res]" unless $@; 74 | } 75 | 76 | $term->addhistory($_) if /\S/; 77 | } 78 | -------------------------------------------------------------------------------- /contrib/setup_script.iss: -------------------------------------------------------------------------------- 1 | ; also in the code 2 | #define version "0.x.xx" 3 | 4 | #define sourceFolder "..\release" 5 | #define progname "Namecoin" 6 | 7 | [Messages] 8 | WelcomeLabel2=%nThis will install [name/ver] on your computer.%n 9 | ClickFinish=ATTENTION: Please note it may take a couple of hours for the initial blockchain download to complete.%n%nClick Finish to exit Setup. 10 | ConfirmUninstall=Are you sure you want to completely remove %1 and all of its components?%n%nThis will leave blockchain data and your wallet.dat file alone. 11 | UninstalledAll=%1 was successfully removed from your computer.%n%nThere might still be blockchain data and your wallet.dat file in %APPDATA%\Namecoin 12 | 13 | [Setup] 14 | AppVerName={#progname} {#version} 15 | AppName={#progname} 16 | DefaultDirName={pf}\{#progname} 17 | DefaultGroupName={#progname} 18 | UninstallDisplayIcon={uninstallexe} 19 | Compression=lzma2/ultra 20 | SolidCompression=yes 21 | OutputDir=.\installer 22 | OutputBaseFilename={#progname}_v{#version}_setup 23 | 24 | [Files] 25 | Source: "{#sourceFolder}\namecoin-qt.exe"; DestDir: "{app}"; Flags: ignoreversion 26 | Source: "{#sourceFolder}\..\src\namecoind.exe"; DestDir: "{app}"; Flags: ignoreversion 27 | Source: "{#sourceFolder}\*.dll"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs 28 | 29 | [Tasks] 30 | Name: desktopicon; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:" 31 | Name: desktopicon\common; Description: "For all users"; GroupDescription: "Additional icons:"; Flags: exclusive 32 | Name: desktopicon\user; Description: "For the current user only"; GroupDescription: "Additional icons:"; Flags: exclusive unchecked 33 | Name: quicklaunchicon; Description: "Create a &Quick Launch icon"; GroupDescription: "Additional icons:"; Flags: unchecked 34 | 35 | [Icons] 36 | Name: "{group}\{#progname}"; Filename: "{app}\namecoin-qt.exe" 37 | Name: "{commondesktop}\Namecoin-Qt"; Filename: "{app}\namecoin-qt.exe"; Tasks: desktopicon\common 38 | Name: "{userdesktop}\Namecoin-Qt"; Filename: "{app}\namecoin-qt.exe"; Tasks: desktopicon\user 39 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Namecoin-Qt"; Filename: "{app}\namecoin-qt.exe"; Tasks: quicklaunchicon 40 | Name: "{group}\uninstall"; Filename: "{uninstallexe}"; 41 | 42 | [Run] 43 | ; info time blockchain download 44 | Filename: "{app}\namecoin-qt.exe"; Description: "Launch application"; Flags: postinstall skipifsilent nowait 45 | 46 | -------------------------------------------------------------------------------- /doc/README: -------------------------------------------------------------------------------- 1 | Bitcoin 0.3.24 BETA 2 | 3 | Copyright (c) 2009-2011 Bitcoin Developers 4 | Distributed under the MIT/X11 software license, see the accompanying 5 | file license.txt or http://www.opensource.org/licenses/mit-license.php. 6 | This product includes software developed by the OpenSSL Project for use in 7 | the OpenSSL Toolkit (http://www.openssl.org/). This product includes 8 | cryptographic software written by Eric Young (eay@cryptsoft.com). 9 | 10 | 11 | Intro 12 | ----- 13 | Bitcoin is a free open source peer-to-peer electronic cash system that is 14 | completely decentralized, without the need for a central server or trusted 15 | parties. Users hold the crypto keys to their own money and transact directly 16 | with each other, with the help of a P2P network to check for double-spending. 17 | 18 | 19 | Setup 20 | ----- 21 | Unpack the files into a directory and run: 22 | bin/32/bitcoin (GUI, 32-bit) 23 | bin/32/bitcoind (headless, 32-bit) 24 | bin/64/bitcoin (GUI, 64-bit) 25 | bin/64/bitcoind (headless, 64-bit) 26 | 27 | See the documentation at the bitcoin wiki: 28 | https://en.bitcoin.it/wiki/Main_Page 29 | 30 | ... for help and more information. 31 | -------------------------------------------------------------------------------- /doc/README_merged-mining.md: -------------------------------------------------------------------------------- 1 | Merged Mining 2 | =================== 3 | 4 | Background 5 | ========== 6 | 7 | Merged mining works by attaching additional information to the auxiliary chain block 8 | to prove that work was done on the parent chain. The class CAuxPow includes: 9 | 10 | * a merkle branch to the root of the auxiliary chain tree (currently empty, only one aux chain is supported) 11 | * an index of this chain in the aux chain list (currently should be zero) 12 | * the coinbase transaction in the parent block that includes the merkle root hash of the auxiliary chains in the coinbase script 13 | * the merkle branch of the coinbase transaction in the parent block 14 | * the parent block header 15 | 16 | When a miner finds a parent block that is under an aux chain target, it submits the aux proof of work to the aux chain. Of course, this required a modification to CBlock::CheckWork in the aux chain to validate. 17 | 18 | The validation proceeds as follows: 19 | 20 | * compute the merkle root of the aux chain tree 21 | * verify that the merkle root is in the parent coinbase 22 | * verify that the parent coinbase tx is properly attached to the merkle tree of the parent block 23 | * verify that the parent block hash is under the aux target 24 | * verify that the aux block is at a fixed slot in the chain merkle tree 25 | 26 | Mining 27 | ====== 28 | 29 | A python script is provided in contrib/merged-mine-proxy that asks the parent chain and aux chain for work. The proxy translates these to a backward compatible work that is understood by existing miners and pool software. 30 | 31 | When a miner submits a solution, the solution is submitted to both chains. If the parent block hash is under the parent target, it is accepted in the usual way. If it is under the aux target, it is accepted as an aux proof of work on that chain. 32 | 33 | To deploy, run the satoshi client for each chain, point the proxy at them, then point the mining software at the proxy. 34 | 35 | Status 36 | ====== 37 | 38 | Currently acceptance of aux proof of work is disabled on the production bitcoin network and is enabled on the testnet. Of course, aux POW will be rejected by unpatched clients. 39 | 40 | To enable a synchronized upgrade to a chain, a starting block number can be configured in GetAuxPowStartBlock(). 41 | 42 | How To Example for Bitcoin / Namecoin 43 | ===================================== 44 | 45 | This example assumes bitcoin RPC port is 8332 and namecoin is at port 8331. 46 | 47 | Compile namecoind and bitcoind with the merged mining patch. Then run: 48 | 49 | `contrib/merged-mine-proxy -w 8330 -p http://pw:un@127.0.0.1:8332/ -x http://pw:un@127.0.0.1:8331/` 50 | 51 | This will have the proxy listen at port 8330. 52 | 53 | Point your miner at 127.0.0.1 port 8330 and start mining. 54 | 55 | -------------------------------------------------------------------------------- /doc/README_windows.txt: -------------------------------------------------------------------------------- 1 | Bitcoin 0.3.24 BETA 2 | 3 | Copyright (c) 2009-2011 Bitcoin Developers 4 | Distributed under the MIT/X11 software license, see the accompanying 5 | file license.txt or http://www.opensource.org/licenses/mit-license.php. 6 | This product includes software developed by the OpenSSL Project for use in 7 | the OpenSSL Toolkit (http://www.openssl.org/). This product includes 8 | cryptographic software written by Eric Young (eay@cryptsoft.com). 9 | 10 | 11 | Intro 12 | ----- 13 | Bitcoin is a free open source peer-to-peer electronic cash system that is 14 | completely decentralized, without the need for a central server or trusted 15 | parties. Users hold the crypto keys to their own money and transact directly 16 | with each other, with the help of a P2P network to check for double-spending. 17 | 18 | 19 | Setup 20 | ----- 21 | Unpack the files into a directory and run bitcoin.exe. 22 | 23 | If you have Microsoft Security Essentials, you need to add bitcoin.exe to its 24 | "Excluded processes" list. Microsoft Security Essentials->Settings tab, 25 | select Excluded processes, press Add, select bitcoin.exe, OK, Save changes. 26 | 27 | The software automatically finds other nodes to connect to. You can 28 | enable Universal Plug and Play using a menu entry or set your firewall 29 | to forward port 8333 (TCP) to your computer so you can receive 30 | incoming connections. Bitcoin work without incoming connections, 31 | but allowing incoming connections helps the Bitcoin network. 32 | 33 | See the bitcoin wiki at: https://en.bitcoin.it/wiki/Main_Page 34 | for more help and information. 35 | -------------------------------------------------------------------------------- /doc/coding.txt: -------------------------------------------------------------------------------- 1 | Please be consistent with the existing coding style. 2 | 3 | Block style: 4 | 5 | bool Function(char* psz, int n) 6 | { 7 | // Comment summarising what this section of code does 8 | for (int i = 0; i < n; i++) 9 | { 10 | // When something fails, return early 11 | if (!Something()) 12 | return false; 13 | ... 14 | } 15 | 16 | // Success return is usually at the end 17 | return true; 18 | } 19 | 20 | - ANSI/Allman block style 21 | - 4 space indenting, no tabs 22 | - No extra spaces inside parenthesis; please don't do ( this ) 23 | - No space after function names, one space after if, for and while 24 | 25 | Variable names begin with the type in lowercase, like nSomeVariable. 26 | Please don't put the first word of the variable name in lowercase like 27 | someVariable. 28 | 29 | Common types: 30 | n integer number: short, unsigned short, int, unsigned int, 31 | int64, uint64, sometimes char if used as a number 32 | d double, float 33 | f flag 34 | hash uint256 35 | p pointer or array, one p for each level of indirection 36 | psz pointer to null terminated string 37 | str string object 38 | v vector or similar list objects 39 | map map or multimap 40 | set set or multiset 41 | bn CBigNum 42 | -------------------------------------------------------------------------------- /doc/release-process.txt: -------------------------------------------------------------------------------- 1 | * update (commit) version in sources 2 | 3 | * update (commit) version in OSX app bundle 4 | 5 | * CFBundleShortVersionString should have value like 0.3.23 6 | * CFBundleVersion should have value like 323 7 | 8 | * tag version in git 9 | 10 | $ git tag -a v0.3.23 11 | 12 | * write release notes. git shortlog helps a lot: 13 | 14 | $ git shortlog --no-merges v0.3.22.. 15 | 16 | * create source-only archive 17 | 18 | $ git archive --format=tar --prefix=bitcoin-0.3.23/ HEAD | \ 19 | gzip -9c > ~/tmp/bitcoin-0.3.23-src.tar.gz 20 | 21 | * perform gitian builds 22 | 23 | * From the bitcoin source dir 24 | $ cd ../gitian-builder 25 | $ ./bin/gbuild --commit bitcoin=v0.3.23 ../bitcoin/contrib/gitian.yml 26 | $ ./bin/gbuild --commit bitcoin=v0.3.23 ../bitcoin/contrib/gitian-win32.yml 27 | 28 | Build output expected: 29 | 1. linux 32-bit and 64-bit binaries + source 30 | 2. windows 32-bit binary + source 31 | 3. windows installer 32 | 33 | * upload source and builds to SF 34 | 35 | * create SHA1SUMS for builds, and PGP-sign it 36 | 37 | * update bitcoin.org version 38 | 39 | * update forum version 40 | 41 | * update wiki 42 | 43 | * update wiki download links 44 | 45 | 46 | -------------------------------------------------------------------------------- /doc/vincent.gpg: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1.4.10 (GNU/Linux) 3 | 4 | mQENBE2qMUsBCACtEgtFHji0PWq7hQCCmVSrfLdmKjiKQlIFdXmHIGWkC4DGmj13 5 | m2zuwdLQO3Ph4Bs7vxymf55Cv/W6OCtxfgOV0oq//uLPjQmLK1l4EXm+6LSYbsUG 6 | lzwrR9t9CfnKG7JHvj5mMlntHw4hPNKAAAginr4KqqluXr4bVPZKVB746Gpjafk3 7 | aibqvqt+9uGnVsWJoKnQm2vbK0qnuhhEvVTyYOcy3+kxcfNJo29b7tyLCL4nxogf 8 | NevzhBjUmd7Ur7EJW32xnKc9aIadyZTRqfM1mb709jLC8TljCP90N5l9q/UGZbIZ 9 | avosR6sWuf398z1/AOGLopxvS/AnL92SVY4pABEBAAG0DlZpbmNlbnQgRHVyaGFt 10 | iQE3BBMBCAAhBQJNqjFLAhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJEJz+ 11 | siqjwOQO2tIH/1NlyQECefZr7U9SaI2MxjXBy9is7gM0rmiPsWH8SG/BG+A+D0W5 12 | Z52miKDJn1kkoU0GQiGTrYIrQBu98heIKKQdftOrtU6f+wU7negLR9yaeoxGI1N7 13 | eeKm9IGy1lnUAFby71A5O+sN+Q822D0tn+6MILkmX7U2pCROH7kXQjorrILXXL60 14 | G0ITseUDbawfjyydBdZbJbvPaBH834FzoS5JfmNoEKKiQO9RQ3xoMcS0V1Mujl/X 15 | EEQvPJUmPZxk3R0WDIIJJr1m2SeuFKEoRWzqUPGLoYK7REUswD+2E19X8eByKuHa 16 | mJ5Q/C/orFRq4Zf5gEywScAva9TuyhFpe+q5AQ0ETaoxSwEIAKHx24c0WiU3N0s1 17 | loZMkpcEpaWz4/0VML6s0Iw+tYnjJjjOMEzyovam73g/yyYuqmgvlyObrP6+kGx+ 18 | R/Gtbm7khaSpjvHYXlriSC4zT45N/Is4lQDwYd5BxeQR+k97SBSVsfU94n4sE3xo 19 | lnfjroi8i4giockeNo1aYYmj5WSfoxAfF6R325SwUMiUjXVxaE/ZfsweOJc2FMlF 20 | zIxiKvjkSYsFz1JfurY+0oVRImiS4LiGPiFVI5xd2I1IQu7T0GGsTnYi2hkaI23b 21 | 7id1jzUJWffCcsJH1NZwahsgzJurbO3ux/V8r7bbfkGGIYgAcJI3N5adk6G47vrp 22 | xPKX/t8AEQEAAYkBHwQYAQgACQUCTaoxSwIbDAAKCRCc/rIqo8DkDnhQB/wL0Dz7 23 | 23UnXRG0V4lQCw17Svhgmuq1NkI3K5KUGq+KCABj2v+zF0svFWiiISbTt1gqCgcx 24 | ARJrlFfnAXJteeNfPAoiKKouYTeHlHcwoBI1YaTW3CioNb2DpOSEXoS/Ks8W/hbW 25 | rbTG+RuKvhnMVIeEu+CO/lC1wISVT8cGEc9P+XTYexMTVB2QiUoxaUjw0Wc/1wHn 26 | AUzH8a1iNZUSgaCPljsI5HWyQEY+REw+rBdEoeJmKi7+N9FeqfVLt8mLThqoh3O7 27 | 3GI1J40k+e9MTQL5d+paPdB5+jbFLh6TU4Pgo0notrwvWUchkNxfvfjCurglj0Zj 28 | zpci3ARTmPQeOTQt 29 | =+Gix 30 | -----END PGP PUBLIC KEY BLOCK----- 31 | -------------------------------------------------------------------------------- /libs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !readme.txt -------------------------------------------------------------------------------- /libs/readme.txt: -------------------------------------------------------------------------------- 1 | Put libraries here, namely: 2 | 3 | boost 4 | OpenSSL 5 | Berkeley DB 6 | MiniUPnPc 7 | 8 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | CXX=g++ 2 | 3 | DEFS=-D_MT -DNOPCH -DFOURWAYSSE2 -DUSE_SSL 4 | 5 | # Detect MinGW 6 | MINGW=$(shell uname -s|grep -i mingw32) 7 | 8 | # Link boost statically 9 | DEFS += -DBOOST_THREAD_USE_LIB 10 | 11 | INCLUDEPATHS= \ 12 | -I../libs/openssl-1.0.1i/include \ 13 | -I../libs/db-4.7.25.NC/build_unix \ 14 | -I../libs/boost_1_50_0 15 | 16 | LIBPATHS= \ 17 | -L../libs/openssl-1.0.1i \ 18 | -L../libs/db-4.7.25.NC/build_unix \ 19 | -L../libs/boost_1_50_0/stage/lib 20 | 21 | LIBBOOST_SUFFIX= 22 | 23 | LIBS= \ 24 | -Wl,-Bstatic \ 25 | -l boost_system$(LIBBOOST_SUFFIX) \ 26 | -l boost_filesystem$(LIBBOOST_SUFFIX) \ 27 | -l boost_program_options$(LIBBOOST_SUFFIX) \ 28 | -l boost_thread$(LIBBOOST_SUFFIX) \ 29 | -l boost_chrono$(LIBBOOST_SUFFIX) \ 30 | -l db_cxx \ 31 | -l ssl \ 32 | -l crypto 33 | 34 | namecoin: USE_UPNP:=1 35 | ifdef USE_UPNP 36 | LIBS += -l miniupnpc 37 | DEFS += -DUSE_UPNP=$(USE_UPNP) 38 | endif 39 | ifneq "$(MINGW)" "" 40 | # MinGW-specific 41 | DEFS += -D__NO_SYSTEM_INCLUDES -D__WXMSW__ 42 | LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32 43 | LIBBOOST_SUFFIX=-mgw46-mt-1_50 44 | else 45 | # Linux-specific 46 | LIBS+= \ 47 | -Wl,-Bdynamic \ 48 | -l gthread-2.0 \ 49 | -l z \ 50 | -l dl \ 51 | -l pthread 52 | endif 53 | 54 | namecoind: USE_UPNP:=0 55 | ifdef USE_UPNP 56 | LIBS += -l miniupnpc 57 | DEFS += -DUSE_UPNP=$(USE_UPNP) 58 | endif 59 | ifneq "$(MINGW)" "" 60 | # MinGW-specific 61 | DEFS += -D__NO_SYSTEM_INCLUDES -D__WXMSW__ 62 | LIBS += -l mingwthrd -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32 63 | else 64 | # Linux-specific 65 | LIBS+= \ 66 | -Wl,-Bdynamic \ 67 | -l gthread-2.0 \ 68 | -l z \ 69 | -l dl \ 70 | -l pthread 71 | endif 72 | 73 | CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEFS) $(INCLUDEPATHS) 74 | HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ 75 | script.h allocators.h db.h walletdb.h crypter.h net.h irc.h keystore.h main.h wallet.h bitcoinrpc.h uibase.h ui.h noui.h init.h auxpow.h 76 | 77 | OBJS= \ 78 | obj/auxpow.o \ 79 | obj/util.o \ 80 | obj/key.o \ 81 | obj/script.o \ 82 | obj/db.o \ 83 | obj/walletdb.o \ 84 | obj/crypter.o \ 85 | obj/net.o \ 86 | obj/irc.o \ 87 | obj/keystore.o \ 88 | obj/main.o \ 89 | obj/wallet.o \ 90 | obj/bitcoinrpc.o \ 91 | obj/init.o \ 92 | cryptopp/obj/sha.o \ 93 | cryptopp/obj/cpu.o 94 | 95 | all: namecoind 96 | 97 | 98 | obj/%.o: %.cpp $(HEADERS) 99 | $(CXX) -c $(CXXFLAGS) -DGUI -o $@ $< 100 | 101 | cryptopp/obj/%.o: cryptopp/%.cpp 102 | $(CXX) -c $(CXXFLAGS) -O3 -o $@ $< 103 | 104 | obj/nogui/%.o: %.cpp $(HEADERS) 105 | $(CXX) -c $(CXXFLAGS) -o $@ $< 106 | 107 | obj/test/%.o: test/%.cpp $(HEADERS) 108 | $(CXX) -c $(CFLAGS) -o $@ $< 109 | 110 | obj/nogui/namecoin.o: namecoin.h 111 | 112 | namecoind: $(OBJS:obj/%=obj/nogui/%) obj/nogui/namecoin.o 113 | $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) 114 | 115 | clean: 116 | -rm -f namecoin namecoind 117 | -rm -f obj/*.o 118 | -rm -f obj/nogui/*.o 119 | -rm -f obj/test/*.o 120 | -rm -f cryptopp/obj/*.o 121 | -rm -f headers.h.gch 122 | -------------------------------------------------------------------------------- /src/Makefile.osx: -------------------------------------------------------------------------------- 1 | CXX=g++ 2 | 3 | DEFS=-D_MT -DNOPCH -DFOURWAYSSE2 -DUSE_SSL -DMAC_OSX=1 -DCRYPTOPP_DISABLE_ASM=1 -DUSE_UPNP=1 4 | 5 | # Detect MinGW 6 | MINGW=$(shell uname -s|grep -i mingw32) 7 | 8 | # Link boost statically 9 | DEFS += -DBOOST_THREAD_USE_LIB 10 | 11 | # TODO: add instructions on how to install specific versions of these via homebrew 12 | INCLUDEPATHS= \ 13 | -I/usr/local/opt/openssl/include \ 14 | -I/usr/local/opt/boost/include \ 15 | -I/usr/local/opt/miniupnpc/include/miniupnpc \ 16 | -I/usr/local/opt/berkeley-db4/include 17 | 18 | LIBPATHS= \ 19 | -L/usr/local/opt/openssl/lib \ 20 | -L/usr/local/opt/boost/lib \ 21 | -L/usr/local/opt/miniupnpc/lib \ 22 | -L/usr/local/opt/miniupnpc/lib \ 23 | -L/usr/local/opt/berkeley-db4/lib \ 24 | -L/usr/local/lib 25 | 26 | LIBBOOST_SUFFIX=-mt 27 | 28 | LIBS= \ 29 | -lboost_system$(LIBBOOST_SUFFIX) \ 30 | -lboost_filesystem$(LIBBOOST_SUFFIX) \ 31 | -lboost_program_options$(LIBBOOST_SUFFIX) \ 32 | -lboost_thread$(LIBBOOST_SUFFIX) \ 33 | -lboost_chrono$(LIBBOOST_SUFFIX) \ 34 | -ldb_cxx -lminiupnpc -lssl -lcrypto \ 35 | -Wl,-dynamic \ 36 | -lz \ 37 | -ldl \ 38 | -lpthread 39 | 40 | # -lgthread-2.0 # doesn't seem necessary? 41 | 42 | CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEFS) $(INCLUDEPATHS) 43 | 44 | HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ 45 | script.h allocators.h db.h walletdb.h crypter.h net.h irc.h keystore.h main.h wallet.h bitcoinrpc.h uibase.h ui.h noui.h init.h auxpow.h 46 | 47 | OBJS= \ 48 | obj/auxpow.o \ 49 | obj/util.o \ 50 | obj/key.o \ 51 | obj/script.o \ 52 | obj/db.o \ 53 | obj/walletdb.o \ 54 | obj/crypter.o \ 55 | obj/net.o \ 56 | obj/irc.o \ 57 | obj/keystore.o \ 58 | obj/main.o \ 59 | obj/wallet.o \ 60 | obj/bitcoinrpc.o \ 61 | obj/init.o \ 62 | cryptopp/obj/sha.o \ 63 | cryptopp/obj/cpu.o 64 | 65 | all: namecoind 66 | 67 | 68 | obj/%.o: %.cpp $(HEADERS) 69 | $(CXX) -c $(CXXFLAGS) -DGUI -o $@ $< 70 | 71 | cryptopp/obj/%.o: cryptopp/%.cpp 72 | $(CXX) -c $(CXXFLAGS) -O3 -o $@ $< 73 | 74 | obj/nogui/%.o: %.cpp $(HEADERS) 75 | $(CXX) -c $(CXXFLAGS) -o $@ $< 76 | 77 | obj/test/%.o: test/%.cpp $(HEADERS) 78 | $(CXX) -c $(CFLAGS) -o $@ $< 79 | 80 | obj/nogui/namecoin.o: namecoin.h 81 | 82 | namecoind: $(OBJS:obj/%=obj/nogui/%) obj/nogui/namecoin.o 83 | $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) 84 | 85 | clean: 86 | -rm -f namecoin namecoind 87 | -rm -f obj/*.o 88 | -rm -f obj/nogui/*.o 89 | -rm -f obj/test/*.o 90 | -rm -f cryptopp/obj/*.o 91 | -rm -f headers.h.gch 92 | -------------------------------------------------------------------------------- /src/auxpow.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file license.txt or http://www.opensource.org/licenses/mit-license.php. 4 | #ifndef BITCOIN_AUXPOW_H 5 | #define BITCOIN_AUXPOW_H 6 | 7 | #include "main.h" 8 | 9 | class CAuxPow : public CMerkleTx 10 | { 11 | public: 12 | CAuxPow(const CTransaction& txIn) : CMerkleTx(txIn) 13 | { 14 | } 15 | 16 | CAuxPow() :CMerkleTx() 17 | { 18 | } 19 | 20 | // Merkle branch with root vchAux 21 | // root must be present inside the coinbase 22 | std::vector vChainMerkleBranch; 23 | // Index of chain in chains merkle tree 24 | int nChainIndex; 25 | CBlock parentBlock; 26 | 27 | IMPLEMENT_SERIALIZE 28 | ( 29 | nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion, ser_action); 30 | nVersion = this->nVersion; 31 | READWRITE(vChainMerkleBranch); 32 | READWRITE(nChainIndex); 33 | 34 | // Always serialize the saved parent block as header so that the size of CAuxPow 35 | // is consistent. 36 | nSerSize += SerReadWrite(s, parentBlock, nType | SER_BLOCKHEADERONLY, nVersion, ser_action); 37 | ) 38 | 39 | bool Check(uint256 hashAuxBlock, int nChainID); 40 | 41 | uint256 GetParentBlockHash() 42 | { 43 | return parentBlock.GetHash(); 44 | } 45 | }; 46 | 47 | template 48 | int ReadWriteAuxPow(Stream& s, const boost::shared_ptr& auxpow, int nType, int nVersion, CSerActionGetSerializeSize ser_action) 49 | { 50 | if (nVersion & BLOCK_VERSION_AUXPOW) 51 | { 52 | return ::GetSerializeSize(*auxpow, nType, nVersion); 53 | } 54 | return 0; 55 | } 56 | 57 | template 58 | int ReadWriteAuxPow(Stream& s, const boost::shared_ptr& auxpow, int nType, int nVersion, CSerActionSerialize ser_action) 59 | { 60 | if (nVersion & BLOCK_VERSION_AUXPOW) 61 | { 62 | return SerReadWrite(s, *auxpow, nType, nVersion, ser_action); 63 | } 64 | return 0; 65 | } 66 | 67 | template 68 | int ReadWriteAuxPow(Stream& s, boost::shared_ptr& auxpow, int nType, int nVersion, CSerActionUnserialize ser_action) 69 | { 70 | if (nVersion & BLOCK_VERSION_AUXPOW) 71 | { 72 | auxpow.reset(new CAuxPow()); 73 | return SerReadWrite(s, *auxpow, nType, nVersion, ser_action); 74 | } 75 | else 76 | { 77 | auxpow.reset(); 78 | return 0; 79 | } 80 | } 81 | 82 | extern void RemoveMergedMiningHeader(std::vector& vchAux); 83 | extern CScript MakeCoinbaseWithAux(unsigned int nBits, unsigned int nExtraNonce, std::vector& vchAux); 84 | #endif 85 | -------------------------------------------------------------------------------- /src/cryptopp/License.txt: -------------------------------------------------------------------------------- 1 | Compilation Copyright (c) 1995-2009 by Wei Dai. All rights reserved. 2 | This copyright applies only to this software distribution package 3 | as a compilation, and does not imply a copyright on any particular 4 | file in the package. 5 | 6 | The following files are copyrighted by their respective original authors, 7 | and their use is subject to additional licenses included in these files. 8 | 9 | mars.cpp - Copyright 1998 Brian Gladman. 10 | 11 | All other files in this compilation are placed in the public domain by 12 | Wei Dai and other contributors. 13 | 14 | I would like to thank the following authors for placing their works into 15 | the public domain: 16 | 17 | Joan Daemen - 3way.cpp 18 | Leonard Janke - cast.cpp, seal.cpp 19 | Steve Reid - cast.cpp 20 | Phil Karn - des.cpp 21 | Andrew M. Kuchling - md2.cpp, md4.cpp 22 | Colin Plumb - md5.cpp 23 | Seal Woods - rc6.cpp 24 | Chris Morgan - rijndael.cpp 25 | Paulo Baretto - rijndael.cpp, skipjack.cpp, square.cpp 26 | Richard De Moliner - safer.cpp 27 | Matthew Skala - twofish.cpp 28 | Kevin Springle - camellia.cpp, shacal2.cpp, ttmac.cpp, whrlpool.cpp, ripemd.cpp 29 | 30 | Permission to use, copy, modify, and distribute this compilation for 31 | any purpose, including commercial applications, is hereby granted 32 | without fee, subject to the following restrictions: 33 | 34 | 1. Any copy or modification of this compilation in any form, except 35 | in object code form as part of an application software, must include 36 | the above copyright notice and this license. 37 | 38 | 2. Users of this software agree that any modification or extension 39 | they provide to Wei Dai will be considered public domain and not 40 | copyrighted unless it includes an explicit copyright notice. 41 | 42 | 3. Wei Dai makes no warranty or representation that the operation of the 43 | software in this compilation will be error-free, and Wei Dai is under no 44 | obligation to provide any services, by way of maintenance, update, or 45 | otherwise. THE SOFTWARE AND ANY DOCUMENTATION ARE PROVIDED "AS IS" 46 | WITHOUT EXPRESS OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO, 47 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 48 | PURPOSE. IN NO EVENT WILL WEI DAI OR ANY OTHER CONTRIBUTOR BE LIABLE FOR 49 | DIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF 50 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 51 | 52 | 4. Users will not use Wei Dai or any other contributor's name in any 53 | publicity or advertising, without prior written consent in each case. 54 | 55 | 5. Export of this software from the United States may require a 56 | specific license from the United States Government. It is the 57 | responsibility of any person or organization contemplating export 58 | to obtain such a license before exporting. 59 | 60 | 6. Certain parts of this software may be protected by patents. It 61 | is the users' responsibility to obtain the appropriate 62 | licenses before using those parts. 63 | 64 | If this compilation is used in object code form in an application 65 | software, acknowledgement of the author is not required but would be 66 | appreciated. The contribution of any useful modifications or extensions 67 | to Wei Dai is not required but would also be appreciated. 68 | -------------------------------------------------------------------------------- /src/cryptopp/iterhash.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTOPP_ITERHASH_H 2 | #define CRYPTOPP_ITERHASH_H 3 | 4 | #include "secblock.h" 5 | 6 | NAMESPACE_BEGIN(CryptoPP) 7 | 8 | // *** trimmed down dependency from iterhash.h *** 9 | template 10 | class CRYPTOPP_NO_VTABLE IteratedHashWithStaticTransform 11 | { 12 | public: 13 | CRYPTOPP_CONSTANT(DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize) 14 | unsigned int DigestSize() const {return DIGESTSIZE;}; 15 | typedef T_HashWordType HashWordType; 16 | CRYPTOPP_CONSTANT(BLOCKSIZE = T_BlockSize) 17 | 18 | protected: 19 | IteratedHashWithStaticTransform() {this->Init();} 20 | void HashEndianCorrectedBlock(const T_HashWordType *data) {T_Transform::Transform(this->m_state, data);} 21 | void Init() {T_Transform::InitState(this->m_state);} 22 | 23 | T_HashWordType* StateBuf() {return this->m_state;} 24 | FixedSizeAlignedSecBlock m_state; 25 | }; 26 | 27 | NAMESPACE_END 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/cryptopp/obj/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/cryptopp/pch.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTOPP_PCH_H 2 | #define CRYPTOPP_PCH_H 3 | 4 | #ifdef CRYPTOPP_GENERATE_X64_MASM 5 | 6 | #include "cpu.h" 7 | 8 | #else 9 | 10 | #include "config.h" 11 | 12 | #ifdef USE_PRECOMPILED_HEADERS 13 | #include "simple.h" 14 | #include "secblock.h" 15 | #include "misc.h" 16 | #include "smartptr.h" 17 | #endif 18 | 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/cryptopp/sha.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTOPP_SHA_H 2 | #define CRYPTOPP_SHA_H 3 | 4 | #include "iterhash.h" 5 | 6 | NAMESPACE_BEGIN(CryptoPP) 7 | 8 | /// SHA-1 9 | class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform 10 | { 11 | public: 12 | static void CRYPTOPP_API InitState(HashWordType *state); 13 | static void CRYPTOPP_API Transform(word32 *digest, const word32 *data); 14 | static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";} 15 | }; 16 | 17 | typedef SHA1 SHA; // for backwards compatibility 18 | 19 | //! implements the SHA-256 standard 20 | class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform 21 | { 22 | public: 23 | #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE) 24 | size_t HashMultipleBlocks(const word32 *input, size_t length); 25 | #endif 26 | static void CRYPTOPP_API InitState(HashWordType *state); 27 | static void CRYPTOPP_API Transform(word32 *digest, const word32 *data); 28 | static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";} 29 | }; 30 | 31 | //! implements the SHA-224 standard 32 | class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform 33 | { 34 | public: 35 | #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE) 36 | size_t HashMultipleBlocks(const word32 *input, size_t length); 37 | #endif 38 | static void CRYPTOPP_API InitState(HashWordType *state); 39 | static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);} 40 | static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";} 41 | }; 42 | 43 | //! implements the SHA-512 standard 44 | class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform 45 | { 46 | public: 47 | static void CRYPTOPP_API InitState(HashWordType *state); 48 | static void CRYPTOPP_API Transform(word64 *digest, const word64 *data); 49 | static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";} 50 | }; 51 | 52 | //! implements the SHA-384 standard 53 | class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform 54 | { 55 | public: 56 | static void CRYPTOPP_API InitState(HashWordType *state); 57 | static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);} 58 | static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";} 59 | }; 60 | 61 | NAMESPACE_END 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/cryptopp/simple.h: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/cryptopp/stdcpp.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTOPP_STDCPP_H 2 | #define CRYPTOPP_STDCPP_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | #ifdef _MSC_VER 14 | #include // CodeWarrior doesn't have memory.h 15 | #include 16 | #include 17 | #include 18 | 19 | // re-disable this 20 | #pragma warning(disable: 4231) 21 | #endif 22 | 23 | #if defined(_MSC_VER) && defined(_CRTAPI1) 24 | #define CRYPTOPP_MSVCRT6 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/headers.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file license.txt or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef BITCOIN_HEADERS_H 6 | #define BITCOIN_HEADERS_H 7 | 8 | #ifdef _MSC_VER 9 | #pragma warning(disable:4786) 10 | #pragma warning(disable:4804) 11 | #pragma warning(disable:4805) 12 | #pragma warning(disable:4717) 13 | #endif 14 | #ifdef _WIN32_WINNT 15 | #undef _WIN32_WINNT 16 | #endif 17 | #define _WIN32_WINNT 0x0501 18 | #ifdef _WIN32_IE 19 | #undef _WIN32_IE 20 | #endif 21 | #define _WIN32_IE 0x0400 22 | #define WIN32_LEAN_AND_MEAN 1 23 | #define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h 24 | #if (defined(__unix__) || defined(unix)) && !defined(USG) 25 | #include // to get BSD define 26 | #endif 27 | #ifdef __WXMAC_OSX__ 28 | #ifndef BSD 29 | #define BSD 1 30 | #endif 31 | #endif 32 | //#ifdef GUI 33 | #if 0 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #endif 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | 63 | #include 64 | 65 | #ifdef __WXMSW__ 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | #else 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include 85 | #include 86 | #include 87 | #endif 88 | #ifdef BSD 89 | #include 90 | #endif 91 | 92 | typedef std::vector vchType; 93 | 94 | #pragma hdrstop 95 | 96 | #include "serialize.h" 97 | #include "uint256.h" 98 | #include "util.h" 99 | #include "bignum.h" 100 | #include "base58.h" 101 | #include "main.h" 102 | #include "hook.h" 103 | #ifdef GUI 104 | #include "uibase.h" 105 | #include "ui.h" 106 | #else 107 | #include "noui.h" 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /src/hook.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010-2011 Vincent Durham 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file license.txt or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef BITCOIN_HOOKS_H 6 | #define BITCOIN_HOOKS_H 7 | 8 | class CHooks 9 | { 10 | public: 11 | virtual bool IsStandard(const CScript& scriptPubKey) = 0; 12 | virtual void AddToWallet(CWalletTx& tx) = 0; 13 | virtual bool CheckTransaction(const CTransaction& tx) = 0; 14 | virtual bool ConnectInputs(DatabaseSet& dbset, 15 | std::map& mapTestPool, 16 | const CTransaction& tx, 17 | std::vector& vTxPrev, 18 | std::vector& vTxindex, 19 | CBlockIndex* pindexBlock, 20 | CDiskTxPos& txPos, 21 | bool fBlock, 22 | bool fMiner) = 0; 23 | virtual bool DisconnectInputs (DatabaseSet& txdb, 24 | const CTransaction& tx, 25 | CBlockIndex* pindexBlock) = 0; 26 | virtual bool ConnectBlock (CBlock& block, DatabaseSet& dbset, 27 | CBlockIndex* pindex) = 0; 28 | virtual bool DisconnectBlock (CBlock& block, DatabaseSet& txdb, 29 | CBlockIndex* pindex) = 0; 30 | virtual bool ExtractAddress(const CScript& script, std::string& address) = 0; 31 | virtual bool GenesisBlock(CBlock& block) = 0; 32 | virtual bool Lockin(int nHeight, uint256 hash) = 0; 33 | virtual int LockinHeight() = 0; 34 | virtual std::string IrcPrefix() = 0; 35 | virtual void MessageStart(char* pchMessageStart) = 0; 36 | virtual bool AcceptToMemoryPool(DatabaseSet& dbset, const CTransaction& tx) = 0; 37 | virtual void RemoveFromMemoryPool(const CTransaction& tx) = 0; 38 | 39 | /* These are for display and wallet management purposes. Not for use to decide 40 | * whether to spend a coin. */ 41 | virtual bool IsMine(const CTransaction& tx) = 0; 42 | virtual bool IsMine(const CTransaction& tx, const CTxOut& txout, bool ignore_name_new = false) = 0; 43 | virtual int GetOurChainID() = 0; 44 | 45 | virtual int GetAuxPowStartBlock() = 0; 46 | virtual int GetFullRetargetStartBlock() = 0; 47 | 48 | virtual std::string GetAlertPubkey1() 49 | { 50 | return "04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284"; 51 | } 52 | 53 | virtual std::string GetAlertPubkey2() { return GetAlertPubkey1(); } 54 | }; 55 | 56 | extern CHooks* InitHook(); 57 | extern std::string GetDefaultDataDirSuffix(); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/init.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file license.txt or http://www.opensource.org/licenses/mit-license.php. 4 | #ifndef BITCOIN_INIT_H 5 | #define BITCOIN_INIT_H 6 | 7 | extern CWallet* pwalletMain; 8 | extern std::string walletPath; 9 | 10 | void StartShutdown(); 11 | void Shutdown(void* parg); 12 | bool AppInit(int argc, char* argv[]); 13 | bool AppInit2(int argc, char* argv[]); 14 | std::string HelpMessage(); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/irc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file license.txt or http://www.opensource.org/licenses/mit-license.php. 4 | #ifndef BITCOIN_IRC_H 5 | #define BITCOIN_IRC_H 6 | 7 | bool RecvLine(SOCKET hSocket, std::string& strLine); 8 | void ThreadIRCSeed(void* parg); 9 | 10 | extern int nGotIRCAddresses; 11 | extern bool fGotExternalIP; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /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.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/keystore.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2011 Satoshi Nakamoto & Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file license.txt or http://www.opensource.org/licenses/mit-license.php. 4 | #ifndef BITCOIN_KEYSTORE_H 5 | #define BITCOIN_KEYSTORE_H 6 | 7 | #include 8 | #include 9 | #include "crypter.h" 10 | 11 | // Currently CPrivKey is just std::vector (with secure_allocator) 12 | typedef std::map, CPrivKey> KeyMap; 13 | typedef std::map, std::vector > CryptedKeyMap; 14 | 15 | class CKeyStore 16 | { 17 | private: 18 | KeyMap mapKeys; 19 | CryptedKeyMap mapCryptedKeys; 20 | 21 | CKeyingMaterial vMasterKey; 22 | 23 | // if fUseCrypto is true, mapKeys must be empty 24 | // if fUseCrypto is false, vMasterKey must be empty 25 | bool fUseCrypto; 26 | 27 | public: 28 | 29 | std::map > mapPubKeys; 30 | 31 | CKeyStore() 32 | : fUseCrypto(false) 33 | { 34 | } 35 | 36 | virtual ~CKeyStore() 37 | { 38 | } 39 | 40 | void DebugPrint() 41 | { 42 | printf("mapKeys.size() = %d\n", mapKeys.size()); 43 | printf("mapCryptedKeys.size() = %d\n", mapCryptedKeys.size()); 44 | } 45 | 46 | mutable CCriticalSection cs_mapKeys; 47 | 48 | virtual bool AddKey(const CKey& key); 49 | virtual bool AddCryptedKey(const std::vector &vchPubKey, const std::vector &vchCryptedSecret); 50 | 51 | virtual bool AddAddress(const uint160& hash160); 52 | 53 | virtual bool HaveKey(const std::vector &vchPubKey) const 54 | { 55 | CRITICAL_BLOCK(cs_mapKeys) 56 | { 57 | if (IsCrypted()) 58 | return (mapCryptedKeys.count(vchPubKey) > 0); 59 | else 60 | return (mapKeys.count(vchPubKey) > 0); 61 | } 62 | } 63 | 64 | virtual bool GetPrivKey(const std::vector &vchPubKey, CPrivKey& keyOut) const; 65 | 66 | std::vector GenerateNewKey(); 67 | 68 | bool IsCrypted() const 69 | { 70 | return fUseCrypto; 71 | } 72 | 73 | bool IsLocked() const 74 | { 75 | if (!IsCrypted()) 76 | return false; 77 | bool result; 78 | CRITICAL_BLOCK(cs_mapKeys) 79 | result = vMasterKey.empty(); 80 | return result; 81 | } 82 | 83 | bool Lock(); 84 | 85 | #ifdef GUI 86 | boost::signals2::signal NotifyStatusChanged; 87 | #endif 88 | 89 | protected: 90 | bool SetCrypted(); 91 | 92 | // will encrypt previously unencrypted keys 93 | bool EncryptKeys(CKeyingMaterial& vMasterKeyIn); 94 | 95 | virtual bool Unlock(const CKeyingMaterial& vMasterKeyIn); 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /src/makefile.mingw: -------------------------------------------------------------------------------- 1 | CXX=g++ 2 | 3 | DEFS=-D_MT -DNOPCH -DFOURWAYSSE2 -DUSE_SSL 4 | 5 | # Detect MinGW 6 | MINGW=$(shell uname -s|grep -i mingw32) 7 | 8 | # Link boost statically 9 | DEFS += -DBOOST_THREAD_USE_LIB 10 | 11 | INCLUDEPATHS?= \ 12 | -I../libs/openssl-1.0.1i/include \ 13 | -I../libs/db-4.7.25.NC/build_unix \ 14 | -I../libs/boost_1_50_0 15 | 16 | LIBPATHS?= \ 17 | -L../libs/openssl-1.0.1i \ 18 | -L../libs/db-4.7.25.NC/build_unix \ 19 | -L../libs/boost_1_50_0/stage/lib 20 | 21 | BOOST_SUFFIX?=-mgw46-mt-s-1_54 22 | LIBS= \ 23 | -Wl,-Bstatic \ 24 | -l boost_system$(BOOST_SUFFIX) \ 25 | -l boost_filesystem$(BOOST_SUFFIX) \ 26 | -l boost_program_options$(BOOST_SUFFIX) \ 27 | -l boost_thread$(BOOST_SUFFIX) \ 28 | -l boost_chrono$(BOOST_SUFFIX) \ 29 | -l db_cxx \ 30 | -l ssl \ 31 | -l crypto 32 | 33 | ifndef USE_UPNP 34 | override USE_UPNP = - 35 | endif 36 | ifneq (${USE_UPNP}, -) 37 | LIBS += -l miniupnpc -l iphlpapi 38 | DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) 39 | endif 40 | 41 | 42 | # todo: change -D__WXMSW__ to WINDOWS 43 | DEFS += -D__WXMSW__ 44 | LIBS += -l mingwthrd -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32 45 | 46 | CFLAGS=${ADDITIONALCCFLAGS} -mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) 47 | HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ 48 | script.h allocators.h db.h walletdb.h crypter.h net.h irc.h keystore.h main.h wallet.h bitcoinrpc.h uibase.h ui.h noui.h init.h auxpow.h 49 | 50 | OBJS= \ 51 | obj/auxpow.o \ 52 | obj/util.o \ 53 | obj/key.o \ 54 | obj/script.o \ 55 | obj/db.o \ 56 | obj/walletdb.o \ 57 | obj/crypter.o \ 58 | obj/net.o \ 59 | obj/irc.o \ 60 | obj/keystore.o \ 61 | obj/main.o \ 62 | obj/wallet.o \ 63 | obj/bitcoinrpc.o \ 64 | obj/init.o \ 65 | cryptopp/obj/sha.o \ 66 | cryptopp/obj/cpu.o 67 | 68 | all: namecoind 69 | 70 | 71 | obj/%.o: %.cpp $(HEADERS) 72 | $(CXX) -c $(CFLAGS) -DGUI -o $@ $< 73 | 74 | cryptopp/obj/%.o: cryptopp/%.cpp 75 | $(CXX) -c $(CFLAGS) -O3 -o $@ $< 76 | 77 | obj/nogui/%.o: %.cpp $(HEADERS) 78 | $(CXX) -c $(CFLAGS) -o $@ $< 79 | 80 | obj/test/%.o: test/%.cpp $(HEADERS) 81 | $(CXX) -c $(CFLAGS) -o $@ $< 82 | 83 | obj/nogui/namecoin.o: namecoin.h 84 | 85 | namecoind: $(OBJS:obj/%=obj/nogui/%) obj/nogui/namecoin.o 86 | $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) 87 | 88 | clean: 89 | -rm -f namecoin namecoind 90 | -rm -f obj/*.o 91 | -rm -f obj/nogui/*.o 92 | -rm -f obj/test/*.o 93 | -rm -f cryptopp/obj/*.o 94 | -rm -f headers.h.gch 95 | -------------------------------------------------------------------------------- /src/namecoin.h: -------------------------------------------------------------------------------- 1 | #ifndef NAMECOIN_H 2 | #define NAMECOIN_H 3 | 4 | #include "json/json_spirit.h" 5 | 6 | static const int NAMECOIN_TX_VERSION = 0x7100; 7 | static const int64 MIN_AMOUNT = CENT; 8 | static const int MAX_NAME_LENGTH = 255; 9 | static const int MAX_VALUE_LENGTH = 1023; 10 | static const int OP_NAME_INVALID = 0x00; 11 | static const int OP_NAME_NEW = 0x01; 12 | static const int OP_NAME_FIRSTUPDATE = 0x02; 13 | static const int OP_NAME_UPDATE = 0x03; 14 | static const int OP_NAME_NOP = 0x04; 15 | static const int MIN_FIRSTUPDATE_DEPTH = 12; 16 | 17 | /* Maximum value length that is allowed by the UIs. Currently, 18 | if the value is set above 520 bytes, it can't ever be updated again 19 | due to limitations in the scripting system. Enforce this 20 | in the UIs. */ 21 | static const int UI_MAX_VALUE_LENGTH = 520; 22 | 23 | class CNameDB; 24 | class CNameIndex; 25 | class CDiskTxPos; 26 | class uint256; 27 | 28 | extern std::map mapMyNames; 29 | extern std::map > mapNamePending; 30 | extern std::set setNewHashes; 31 | 32 | bool doStrictChecks(unsigned nHeight); 33 | 34 | std::string stringFromVch(const std::vector &vch); 35 | std::vector vchFromString(const std::string &str); 36 | int GetTxPosHeight(const CNameIndex& txPos); 37 | int GetTxPosHeight(const CDiskTxPos& txPos); 38 | int GetTxPosHeight2(const CDiskTxPos& txPos, int nHeight); 39 | bool GetTxOfName(CNameDB& dbName, const std::vector &vchName, CTransaction& tx); 40 | int IndexOfNameOutput(const CTransaction& tx); 41 | bool GetValueOfTxPos(const CNameIndex& txPos, std::vector& vchValue, uint256& hash, int& nHeight); 42 | bool GetValueOfTxPos(const CDiskTxPos& txPos, std::vector& vchValue, uint256& hash, int& nHeight); 43 | int GetDisplayExpirationDepth(int nHeight); 44 | bool GetNameOfTx(const CTransaction& tx, std::vector& name); 45 | bool GetValueOfNameTx(const CTransaction& tx, std::vector& value); 46 | bool DecodeNameTx(const CTransaction& tx, int& op, int& nOut, std::vector >& vvch, int nHeight); 47 | bool DecodeNameScript(const CScript& script, int& op, std::vector > &vvch, CScript::const_iterator& pc); 48 | bool DecodeNameScript(const CScript& script, int& op, std::vector > &vvch); 49 | bool GetNameAddress(const CTransaction& tx, std::string& strAddress); 50 | std::string SendMoneyWithInputTx(const CScript& scriptPubKey, int64 nValue, int64 nNetFee, const CWalletTx& wtxIn, CWalletTx& wtxNew, bool fAskFee); 51 | bool CreateTransactionWithInputTx(const std::vector >& vecSend, const CWalletTx& wtxIn, int nTxOut, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet); 52 | int64 GetNetworkFee(int nHeight); 53 | 54 | /* Handle the name operation part of the RPC call createrawtransaction. */ 55 | void AddRawTxNameOperation(CTransaction& tx, const json_spirit::Object& obj); 56 | 57 | #endif // NAMECOIN_H 58 | -------------------------------------------------------------------------------- /src/noui.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 Satoshi Nakamoto 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file license.txt or http://www.opensource.org/licenses/mit-license.php. 4 | #ifndef BITCOIN_NOUI_H 5 | #define BITCOIN_NOUI_H 6 | 7 | #include 8 | #include 9 | #include "wallet.h" 10 | 11 | typedef void wxWindow; 12 | #define wxYES 0x00000002 13 | #define wxOK 0x00000004 14 | #define wxNO 0x00000008 15 | #define wxYES_NO (wxYES|wxNO) 16 | #define wxCANCEL 0x00000010 17 | #define wxAPPLY 0x00000020 18 | #define wxCLOSE 0x00000040 19 | #define wxOK_DEFAULT 0x00000000 20 | #define wxYES_DEFAULT 0x00000000 21 | #define wxNO_DEFAULT 0x00000080 22 | #define wxCANCEL_DEFAULT 0x80000000 23 | #define wxICON_EXCLAMATION 0x00000100 24 | #define wxICON_HAND 0x00000200 25 | #define wxICON_WARNING wxICON_EXCLAMATION 26 | #define wxICON_ERROR wxICON_HAND 27 | #define wxICON_QUESTION 0x00000400 28 | #define wxICON_INFORMATION 0x00000800 29 | #define wxICON_STOP wxICON_HAND 30 | #define wxICON_ASTERISK wxICON_INFORMATION 31 | #define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800) 32 | #define wxFORWARD 0x00001000 33 | #define wxBACKWARD 0x00002000 34 | #define wxRESET 0x00004000 35 | #define wxHELP 0x00008000 36 | #define wxMORE 0x00010000 37 | #define wxSETUP 0x00020000 38 | 39 | inline int MyMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1) 40 | { 41 | printf("%s: %s\n", caption.c_str(), message.c_str()); 42 | fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str()); 43 | return 4; 44 | } 45 | #define wxMessageBox MyMessageBox 46 | 47 | inline int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1) 48 | { 49 | return MyMessageBox(message, caption, style, parent, x, y); 50 | } 51 | 52 | inline bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent) 53 | { 54 | return true; 55 | } 56 | 57 | inline void CalledSetStatusBar(const std::string& strText, int nField) 58 | { 59 | } 60 | 61 | inline void UIThreadCall(boost::function0 fn) 62 | { 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/obj/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/obj/nogui/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/obj/test/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/qt/aboutdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "aboutdialog.h" 2 | #include "ui_aboutdialog.h" 3 | #include "guiconstants.h" 4 | #include "clientmodel.h" 5 | 6 | // Copyright year (2009-this) 7 | // Todo: update this when changing our copyright comments in the source 8 | const int ABOUTDIALOG_COPYRIGHT_YEAR = 2013; 9 | 10 | AboutDialog::AboutDialog(QWidget *parent) : 11 | QDialog(parent, DIALOGWINDOWHINTS), 12 | ui(new Ui::AboutDialog) 13 | { 14 | ui->setupUi(this); 15 | 16 | // Set current copyright year 17 | ui->copyrightLabel->setText(tr("Copyright") + QString(" © ") + tr("2009-%1 The Bitcoin and Namecoin developers").arg(ABOUTDIALOG_COPYRIGHT_YEAR)); 18 | } 19 | 20 | void AboutDialog::setModel(ClientModel *model) 21 | { 22 | if(model) 23 | { 24 | ui->versionLabel->setText(model->formatFullVersion()); 25 | } 26 | } 27 | 28 | AboutDialog::~AboutDialog() 29 | { 30 | delete ui; 31 | } 32 | 33 | void AboutDialog::on_buttonBox_accepted() 34 | { 35 | close(); 36 | } 37 | -------------------------------------------------------------------------------- /src/qt/aboutdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef ABOUTDIALOG_H 2 | #define ABOUTDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class AboutDialog; 8 | } 9 | class ClientModel; 10 | 11 | /** "About" dialog box */ 12 | class AboutDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit AboutDialog(QWidget *parent = 0); 18 | ~AboutDialog(); 19 | 20 | void setModel(ClientModel *model); 21 | 22 | private: 23 | Ui::AboutDialog *ui; 24 | 25 | private slots: 26 | void on_buttonBox_accepted(); 27 | }; 28 | 29 | #endif // ABOUTDIALOG_H 30 | -------------------------------------------------------------------------------- /src/qt/addressbookpage.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDRESSBOOKPAGE_H 2 | #define ADDRESSBOOKPAGE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class AddressBookPage; 8 | } 9 | class AddressTableModel; 10 | class OptionsModel; 11 | 12 | QT_BEGIN_NAMESPACE 13 | class QTableView; 14 | class QItemSelection; 15 | class QSortFilterProxyModel; 16 | class QMenu; 17 | class QModelIndex; 18 | QT_END_NAMESPACE 19 | 20 | /** Widget that shows a list of sending or receiving addresses. 21 | */ 22 | class AddressBookPage : public QDialog 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | enum Tabs { 28 | SendingTab = 0, 29 | ReceivingTab = 1 30 | }; 31 | 32 | enum Mode { 33 | ForSending, /**< Open address book to pick address for sending */ 34 | ForEditing /**< Open address book for editing */ 35 | }; 36 | 37 | explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent = 0); 38 | ~AddressBookPage(); 39 | 40 | void setModel(AddressTableModel *model); 41 | void setOptionsModel(OptionsModel *optionsModel); 42 | const QString &getReturnValue() const { return returnValue; } 43 | 44 | public slots: 45 | void done(int retval); 46 | void exportClicked(); 47 | 48 | private: 49 | Ui::AddressBookPage *ui; 50 | AddressTableModel *model; 51 | OptionsModel *optionsModel; 52 | Mode mode; 53 | Tabs tab; 54 | QString returnValue; 55 | QSortFilterProxyModel *proxyModel; 56 | QMenu *contextMenu; 57 | QAction *deleteAction; // to be able to explicitly disable it 58 | QString newAddressToSelect; 59 | 60 | private slots: 61 | /** Delete currently selected address entry */ 62 | void on_deleteButton_clicked(); 63 | /** Create a new address for receiving coins and / or add a new address book entry */ 64 | void on_newAddressButton_clicked(); 65 | /** Copy address of currently selected address entry to clipboard */ 66 | void on_copyToClipboard_clicked(); 67 | /** Open the sign message tab in the Sign/Verify Message dialog with currently selected address */ 68 | void on_signMessage_clicked(); 69 | /** Open the verify message tab in the Sign/Verify Message dialog with currently selected address */ 70 | void on_verifyMessage_clicked(); 71 | /** Open send coins dialog for currently selected address (no button) */ 72 | void onSendCoins_clicked(); 73 | /** Generate a QR Code from the currently selected address */ 74 | void on_showQRCode_clicked(); 75 | /** Copy label of currently selected address entry to clipboard (no button) */ 76 | void onCopyLabelAction(); 77 | /** Edit currently selected address entry (no button) */ 78 | void onEditAction(); 79 | 80 | /** Set button states based on selected tab and selection */ 81 | void selectionChanged(); 82 | /** Spawn contextual menu (right mouse menu) for address book entry */ 83 | void contextualMenu(const QPoint &point); 84 | /** New entry/entries were added to address table */ 85 | void selectNewAddress(const QModelIndex &parent, int begin, int /*end*/); 86 | 87 | signals: 88 | void signMessage(QString addr); 89 | void verifyMessage(QString addr); 90 | void sendCoins(QString addr); 91 | }; 92 | 93 | #endif // ADDRESSBOOKPAGE_H 94 | -------------------------------------------------------------------------------- /src/qt/addresstablemodel.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDRESSTABLEMODEL_H 2 | #define ADDRESSTABLEMODEL_H 3 | 4 | #include 5 | #include 6 | 7 | class AddressTablePriv; 8 | class CWallet; 9 | class WalletModel; 10 | 11 | /** 12 | Qt model of the address book in the core. This allows views to access and modify the address book. 13 | */ 14 | class AddressTableModel : public QAbstractTableModel 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit AddressTableModel(CWallet *wallet, WalletModel *parent = 0); 20 | ~AddressTableModel(); 21 | 22 | enum ColumnIndex { 23 | Label = 0, /**< User specified label */ 24 | Address = 1 /**< Bitcoin address */ 25 | }; 26 | 27 | enum RoleIndex { 28 | TypeRole = Qt::UserRole /**< Type of address (#Send or #Receive) */ 29 | }; 30 | 31 | /** Return status of edit/insert operation */ 32 | enum EditStatus { 33 | OK, /**< Everything ok */ 34 | NO_CHANGES, /**< No changes were made during edit operation */ 35 | INVALID_ADDRESS, /**< Unparseable address */ 36 | DUPLICATE_ADDRESS, /**< Address already in address book */ 37 | WALLET_UNLOCK_FAILURE, /**< Wallet could not be unlocked to create new receiving address */ 38 | KEY_GENERATION_FAILURE /**< Generating a new public key for a receiving address failed */ 39 | }; 40 | 41 | static const QString Send; /**< Specifies send address */ 42 | static const QString Receive; /**< Specifies receive address */ 43 | 44 | /** @name Methods overridden from QAbstractTableModel 45 | @{*/ 46 | int rowCount(const QModelIndex &parent) const; 47 | int columnCount(const QModelIndex &parent) const; 48 | QVariant data(const QModelIndex &index, int role) const; 49 | bool setData(const QModelIndex &index, const QVariant &value, int role); 50 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 51 | QModelIndex index(int row, int column, const QModelIndex &parent) const; 52 | bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); 53 | Qt::ItemFlags flags(const QModelIndex &index) const; 54 | /*@}*/ 55 | 56 | /* Add an address to the model. 57 | Returns the added address on success, and an empty string otherwise. 58 | */ 59 | QString addRow(const QString &type, const QString &label, const QString &address); 60 | 61 | /* Look up label for address in address book, if not found return empty string. 62 | */ 63 | QString labelForAddress(const QString &address) const; 64 | 65 | /* Look up row index of an address in the model. 66 | Return -1 if not found. 67 | */ 68 | int lookupAddress(const QString &address) const; 69 | 70 | EditStatus getEditStatus() const { return editStatus; } 71 | 72 | private: 73 | WalletModel *walletModel; 74 | CWallet *wallet; 75 | AddressTablePriv *priv; 76 | QStringList columns; 77 | EditStatus editStatus; 78 | 79 | /** Notify listeners that data changed. */ 80 | void emitDataChanged(int index); 81 | 82 | signals: 83 | void defaultAddressChanged(const QString &address); 84 | 85 | public slots: 86 | /* Update address list from core. 87 | */ 88 | void updateEntry(const QString &address, const QString &label, bool isMine, int status); 89 | 90 | friend class AddressTablePriv; 91 | }; 92 | 93 | #endif // ADDRESSTABLEMODEL_H 94 | -------------------------------------------------------------------------------- /src/qt/askpassphrasedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef ASKPASSPHRASEDIALOG_H 2 | #define ASKPASSPHRASEDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class AskPassphraseDialog; 8 | } 9 | class WalletModel; 10 | 11 | /** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase. 12 | */ 13 | class AskPassphraseDialog : public QDialog 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | enum Mode { 19 | Encrypt, /**< Ask passphrase twice and encrypt */ 20 | Unlock, /**< Ask passphrase and unlock */ 21 | ChangePass, /**< Ask old passphrase + new passphrase twice */ 22 | Decrypt /**< Ask passphrase and decrypt wallet */ 23 | }; 24 | 25 | explicit AskPassphraseDialog(Mode mode, QWidget *parent = 0); 26 | ~AskPassphraseDialog(); 27 | 28 | void accept(); 29 | 30 | void setModel(WalletModel *model); 31 | 32 | private: 33 | Ui::AskPassphraseDialog *ui; 34 | Mode mode; 35 | WalletModel *model; 36 | bool fCapsLock; 37 | 38 | private slots: 39 | void textChanged(); 40 | bool event(QEvent *event); 41 | bool eventFilter(QObject *object, QEvent *event); 42 | }; 43 | 44 | #endif // ASKPASSPHRASEDIALOG_H 45 | -------------------------------------------------------------------------------- /src/qt/bitcoinaddressvalidator.cpp: -------------------------------------------------------------------------------- 1 | #include "bitcoinaddressvalidator.h" 2 | 3 | /* Base58 characters are: 4 | "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" 5 | 6 | This is: 7 | - All numbers except for '0' 8 | - All upper-case letters except for 'I' and 'O' 9 | - All lower-case letters except for 'l' 10 | 11 | User friendly Base58 input can map 12 | - 'l' and 'I' to '1' 13 | - '0' and 'O' to 'o' 14 | */ 15 | 16 | BitcoinAddressValidator::BitcoinAddressValidator(QObject *parent, bool fAllowEmpty) : 17 | QValidator(parent), allowEmpty(fAllowEmpty) 18 | { 19 | } 20 | 21 | QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) const 22 | { 23 | // Correction 24 | for(int idx=0; idx= '0' && ch<='9') || 58 | (ch >= 'a' && ch<='z') || 59 | (ch >= 'A' && ch<='Z')) && 60 | ch != 'l' && ch != 'I' && ch != '0' && ch != 'O') 61 | { 62 | // Alphanumeric and not a 'forbidden' character 63 | } 64 | else 65 | { 66 | state = QValidator::Invalid; 67 | } 68 | } 69 | 70 | if (input.isEmpty() && !allowEmpty) 71 | { 72 | // Empty address is "intermediate" input 73 | state = QValidator::Intermediate; 74 | } 75 | 76 | return state; 77 | } 78 | -------------------------------------------------------------------------------- /src/qt/bitcoinaddressvalidator.h: -------------------------------------------------------------------------------- 1 | #ifndef BITCOINADDRESSVALIDATOR_H 2 | #define BITCOINADDRESSVALIDATOR_H 3 | 4 | #include 5 | 6 | /** Base58 entry widget validator. 7 | Corrects near-miss characters and refuses characters that are no part of base58. 8 | */ 9 | class BitcoinAddressValidator : public QValidator 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit BitcoinAddressValidator(QObject *parent = 0, bool fAllowEmpty = false); 15 | 16 | State validate(QString &input, int &pos) const; 17 | 18 | static const int MaxAddressLength = 35; 19 | 20 | private: 21 | bool allowEmpty; 22 | }; 23 | 24 | #endif // BITCOINADDRESSVALIDATOR_H 25 | -------------------------------------------------------------------------------- /src/qt/bitcoinamountfield.h: -------------------------------------------------------------------------------- 1 | #ifndef BITCOINAMOUNTFIELD_H 2 | #define BITCOINAMOUNTFIELD_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | class QDoubleSpinBox; 8 | class QValueComboBox; 9 | QT_END_NAMESPACE 10 | 11 | /** Widget for entering bitcoin amounts. 12 | */ 13 | class BitcoinAmountField: public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true) 18 | 19 | public: 20 | explicit BitcoinAmountField(QWidget *parent = 0); 21 | 22 | qint64 value(bool *valid=0) const; 23 | void setValue(qint64 value); 24 | 25 | /** Mark current value as invalid in UI. */ 26 | void setValid(bool valid); 27 | /** Perform input validation, mark field as invalid if entered value is not valid. */ 28 | bool validate(); 29 | 30 | /** Change unit used to display amount. */ 31 | void setDisplayUnit(int unit); 32 | 33 | /** Make field empty and ready for new input. */ 34 | void clear(); 35 | 36 | /** Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907), 37 | in these cases we have to set it up manually. 38 | */ 39 | QWidget *setupTabChain(QWidget *prev); 40 | 41 | signals: 42 | void textChanged(); 43 | 44 | protected: 45 | /** Intercept focus-in event and ',' key presses */ 46 | bool eventFilter(QObject *object, QEvent *event); 47 | 48 | private: 49 | QDoubleSpinBox *amount; 50 | QValueComboBox *unit; 51 | int currentUnit; 52 | 53 | void setText(const QString &text); 54 | QString text() const; 55 | 56 | private slots: 57 | void unitChanged(int idx); 58 | 59 | }; 60 | 61 | #endif // BITCOINAMOUNTFIELD_H 62 | -------------------------------------------------------------------------------- /src/qt/bitcoinunits.h: -------------------------------------------------------------------------------- 1 | #ifndef BITCOINUNITS_H 2 | #define BITCOINUNITS_H 3 | 4 | #include 5 | #include 6 | 7 | /** Bitcoin unit definitions. Encapsulates parsing and formatting 8 | and serves as list model for drop-down selection boxes. 9 | */ 10 | class BitcoinUnits: public QAbstractListModel 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit BitcoinUnits(QObject *parent); 16 | 17 | /** Bitcoin units. 18 | @note Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones 19 | */ 20 | enum Unit 21 | { 22 | BTC, 23 | mBTC, 24 | uBTC 25 | }; 26 | 27 | //! @name Static API 28 | //! Unit conversion and formatting 29 | ///@{ 30 | 31 | //! Get list of units, for drop-down box 32 | static QList availableUnits(); 33 | //! Is unit ID valid? 34 | static bool valid(int unit); 35 | //! Short name 36 | static QString name(int unit); 37 | //! Longer description 38 | static QString description(int unit); 39 | //! Number of Satoshis (1e-8) per unit 40 | static qint64 factor(int unit); 41 | //! Number of amount digits (to represent max number of coins) 42 | static int amountDigits(int unit); 43 | //! Number of decimals left 44 | static int decimals(int unit); 45 | //! Format as string 46 | static QString format(int unit, qint64 amount, bool plussign=false); 47 | //! Format as string (with unit) 48 | static QString formatWithUnit(int unit, qint64 amount, bool plussign=false); 49 | //! Parse string to coin amount 50 | static bool parse(int unit, const QString &value, qint64 *val_out); 51 | ///@} 52 | 53 | //! @name AbstractListModel implementation 54 | //! List model for unit drop-down selection box. 55 | ///@{ 56 | enum RoleIndex { 57 | /** Unit identifier */ 58 | UnitRole = Qt::UserRole 59 | }; 60 | int rowCount(const QModelIndex &parent) const; 61 | QVariant data(const QModelIndex &index, int role) const; 62 | ///@} 63 | 64 | private: 65 | QList unitlist; 66 | }; 67 | typedef BitcoinUnits::Unit BitcoinUnit; 68 | 69 | #endif // BITCOINUNITS_H 70 | -------------------------------------------------------------------------------- /src/qt/clientmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENTMODEL_H 2 | #define CLIENTMODEL_H 3 | 4 | #include 5 | 6 | class OptionsModel; 7 | class AddressTableModel; 8 | class TransactionTableModel; 9 | class CWallet; 10 | 11 | QT_BEGIN_NAMESPACE 12 | class QDateTime; 13 | class QTimer; 14 | QT_END_NAMESPACE 15 | 16 | enum BlockSource { 17 | BLOCK_SOURCE_NONE, 18 | BLOCK_SOURCE_NETWORK, 19 | BLOCK_SOURCE_DISK, 20 | BLOCK_SOURCE_REINDEX 21 | }; 22 | 23 | /** Model for Bitcoin network client. */ 24 | class ClientModel : public QObject 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0); 30 | ~ClientModel(); 31 | 32 | OptionsModel *getOptionsModel(); 33 | 34 | int getNumConnections() const; 35 | int getNumBlocks() const; 36 | int getNumBlocksAtStartup(); 37 | 38 | double getVerificationProgress() const; 39 | QDateTime getLastBlockDate() const; 40 | 41 | //! Return true if client connected to testnet 42 | bool isTestNet() const; 43 | //! Return true if core is doing initial block download 44 | bool inInitialBlockDownload() const; 45 | //! Return true if core is importing blocks 46 | enum BlockSource getBlockSource() const; 47 | //! Return conservative estimate of total number of blocks, or 0 if unknown 48 | int getNumBlocksOfPeers() const; 49 | //! Return warnings to be displayed in status bar 50 | QString getStatusBarWarnings() const; 51 | 52 | QString formatFullVersion() const; 53 | QString formatBuildDate() const; 54 | bool isReleaseVersion() const; 55 | QString clientName() const; 56 | QString formatClientStartupTime() const; 57 | 58 | private: 59 | OptionsModel *optionsModel; 60 | 61 | int cachedNumBlocks; 62 | int cachedNumBlocksOfPeers; 63 | 64 | int numBlocksAtStartup; 65 | 66 | QTimer *pollTimer; 67 | 68 | void subscribeToCoreSignals(); 69 | void unsubscribeFromCoreSignals(); 70 | 71 | signals: 72 | void numConnectionsChanged(int count); 73 | void numBlocksChanged(int count, int countOfPeers); 74 | void alertsChanged(const QString &warnings); 75 | 76 | //! Asynchronous message notification 77 | void message(const QString &title, const QString &message, unsigned int style); 78 | 79 | public slots: 80 | void updateTimer(); 81 | void updateNumConnections(int numConnections); 82 | void updateAlert(const QString &hash, int status); 83 | }; 84 | 85 | #endif // CLIENTMODEL_H 86 | -------------------------------------------------------------------------------- /src/qt/configurenamedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIGURENAMEDIALOG_H 2 | #define CONFIGURENAMEDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ConfigureNameDialog; 8 | } 9 | 10 | class WalletModel; 11 | 12 | /** Dialog for editing an address and associated information. 13 | */ 14 | class ConfigureNameDialog : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | 20 | explicit ConfigureNameDialog(const QString &name_, const QString &data, const QString &address_, bool firstUpdate_, QWidget *parent = 0); 21 | ~ConfigureNameDialog(); 22 | 23 | void setModel(WalletModel *walletModel); 24 | const QString &getReturnData() const { return returnData; } 25 | 26 | public slots: 27 | void accept(); 28 | void reject(); 29 | void on_addressBookButton_clicked(); 30 | void on_copyButton_clicked(); 31 | void on_pasteButton_clicked(); 32 | void on_nsEdit_textChanged() { if (initialized) SetDNS(); } 33 | void on_nsTranslateEdit_textChanged(const QString &text) { if (initialized) SetDNS(); } 34 | void on_nsFingerprintEdit_textChanged() { if (initialized) SetDNS(); } 35 | void on_ipEdit_textChanged(const QString &text) { if (initialized) SetIP(); } 36 | void on_ipFingerprintEdit_textChanged() { if (initialized) SetIP(); } 37 | void on_idNameEdit_textChanged() { if (initialized) SetID(); } 38 | void on_idEmailEdit_textChanged() { if (initialized) SetID(); } 39 | void on_idBitmessageEdit_textChanged() { if (initialized) SetID(); } 40 | void on_dataEdit_textChanged(const QString &text); 41 | 42 | private: 43 | QString returnData; 44 | Ui::ConfigureNameDialog *ui; 45 | WalletModel *walletModel; 46 | QString name, address; 47 | bool firstUpdate; 48 | bool initialized; 49 | 50 | void SetDNS(); 51 | void SetIP(); 52 | void SetID(); 53 | }; 54 | 55 | #endif // CONFIGURENAMEDIALOG_H 56 | -------------------------------------------------------------------------------- /src/qt/csvmodelwriter.cpp: -------------------------------------------------------------------------------- 1 | #include "csvmodelwriter.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | CSVModelWriter::CSVModelWriter(const QString &filename, QObject *parent) : 8 | QObject(parent), 9 | filename(filename), model(0) 10 | { 11 | } 12 | 13 | void CSVModelWriter::setModel(const QAbstractItemModel *model) 14 | { 15 | this->model = model; 16 | } 17 | 18 | void CSVModelWriter::addColumn(const QString &title, int column, int role) 19 | { 20 | Column col; 21 | col.title = title; 22 | col.column = column; 23 | col.role = role; 24 | 25 | columns.append(col); 26 | } 27 | 28 | static void writeValue(QTextStream &f, const QString &value) 29 | { 30 | QString escaped = value; 31 | escaped.replace('"', "\"\""); 32 | f << "\"" << escaped << "\""; 33 | } 34 | 35 | static void writeSep(QTextStream &f) 36 | { 37 | f << ","; 38 | } 39 | 40 | static void writeNewline(QTextStream &f) 41 | { 42 | f << "\n"; 43 | } 44 | 45 | bool CSVModelWriter::write() 46 | { 47 | QFile file(filename); 48 | if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) 49 | return false; 50 | QTextStream out(&file); 51 | 52 | int numRows = 0; 53 | if(model) 54 | { 55 | numRows = model->rowCount(); 56 | } 57 | 58 | // Header row 59 | for(int i=0; iindex(j, columns[i].column).data(columns[i].role); 79 | writeValue(out, data.toString()); 80 | } 81 | writeNewline(out); 82 | } 83 | 84 | file.close(); 85 | 86 | return file.error() == QFile::NoError; 87 | } 88 | 89 | -------------------------------------------------------------------------------- /src/qt/csvmodelwriter.h: -------------------------------------------------------------------------------- 1 | #ifndef CSVMODELWRITER_H 2 | #define CSVMODELWRITER_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | class QAbstractItemModel; 9 | QT_END_NAMESPACE 10 | 11 | /** Export a Qt table model to a CSV file. This is useful for analyzing or post-processing the data in 12 | a spreadsheet. 13 | */ 14 | class CSVModelWriter : public QObject 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit CSVModelWriter(const QString &filename, QObject *parent = 0); 20 | 21 | void setModel(const QAbstractItemModel *model); 22 | void addColumn(const QString &title, int column, int role=Qt::EditRole); 23 | 24 | /** Perform export of the model to CSV. 25 | @returns true on success, false otherwise 26 | */ 27 | bool write(); 28 | 29 | private: 30 | QString filename; 31 | const QAbstractItemModel *model; 32 | 33 | struct Column 34 | { 35 | QString title; 36 | int column; 37 | int role; 38 | }; 39 | QList columns; 40 | }; 41 | 42 | #endif // CSVMODELWRITER_H 43 | -------------------------------------------------------------------------------- /src/qt/editaddressdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef EDITADDRESSDIALOG_H 2 | #define EDITADDRESSDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class EditAddressDialog; 8 | } 9 | class AddressTableModel; 10 | 11 | QT_BEGIN_NAMESPACE 12 | class QDataWidgetMapper; 13 | QT_END_NAMESPACE 14 | 15 | /** Dialog for editing an address and associated information. 16 | */ 17 | class EditAddressDialog : public QDialog 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | enum Mode { 23 | NewReceivingAddress, 24 | NewSendingAddress, 25 | EditReceivingAddress, 26 | EditSendingAddress 27 | }; 28 | 29 | explicit EditAddressDialog(Mode mode, QWidget *parent = 0); 30 | ~EditAddressDialog(); 31 | 32 | void setModel(AddressTableModel *model); 33 | void loadRow(int row); 34 | 35 | QString getAddress() const; 36 | void setAddress(const QString &address); 37 | 38 | public slots: 39 | void accept(); 40 | 41 | private: 42 | bool saveCurrentRow(); 43 | 44 | Ui::EditAddressDialog *ui; 45 | QDataWidgetMapper *mapper; 46 | Mode mode; 47 | AddressTableModel *model; 48 | 49 | QString address; 50 | }; 51 | 52 | #endif // EDITADDRESSDIALOG_H 53 | -------------------------------------------------------------------------------- /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 | 620 10 | 250 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/guiconstants.h: -------------------------------------------------------------------------------- 1 | #ifndef GUICONSTANTS_H 2 | #define GUICONSTANTS_H 3 | 4 | /* Milliseconds between model updates */ 5 | static const int MODEL_UPDATE_DELAY = 250; 6 | 7 | /* AskPassphraseDialog -- Maximum passphrase length */ 8 | static const int MAX_PASSPHRASE_SIZE = 1024; 9 | 10 | /* BitcoinGUI -- Size of icons in status bar */ 11 | static const int STATUSBAR_ICONSIZE = 16; 12 | 13 | /* Invalid field background style */ 14 | #define STYLE_INVALID "background:#FF8080" 15 | 16 | /* Transaction list -- unconfirmed transaction */ 17 | #define COLOR_UNCONFIRMED QColor(128, 128, 128) 18 | /* Transaction list -- negative amount */ 19 | #define COLOR_NEGATIVE QColor(255, 0, 0) 20 | /* Transaction list -- bare address (without label) */ 21 | #define COLOR_BAREADDRESS QColor(140, 140, 140) 22 | 23 | /* Tooltips longer than this (in characters) are converted into rich text, 24 | so that they can be word-wrapped. 25 | */ 26 | static const int TOOLTIP_WRAP_THRESHOLD = 80; 27 | 28 | /* Maximum allowed URI length */ 29 | static const int MAX_URI_LENGTH = 255; 30 | 31 | /* QRCodeDialog -- size of exported QR Code image */ 32 | #define EXPORT_IMAGE_SIZE 256 33 | 34 | // Dialog Window Flags 35 | #if QT_VERSION < 0x050000 36 | static const Qt::WindowFlags DIALOGWINDOWHINTS = Qt::WindowSystemMenuHint | Qt::WindowTitleHint; 37 | #else 38 | static const Qt::WindowFlags DIALOGWINDOWHINTS = Qt::WindowCloseButtonHint | Qt::WindowTitleHint; 39 | #endif 40 | 41 | 42 | #endif // GUICONSTANTS_H 43 | -------------------------------------------------------------------------------- /src/qt/locale/.gitignore: -------------------------------------------------------------------------------- 1 | *.qm 2 | -------------------------------------------------------------------------------- /src/qt/macdockiconhandler.h: -------------------------------------------------------------------------------- 1 | #ifndef MACDOCKICONHANDLER_H 2 | #define MACDOCKICONHANDLER_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | class QMenu; 8 | class QIcon; 9 | class QWidget; 10 | QT_END_NAMESPACE 11 | 12 | #ifdef __OBJC__ 13 | @class DockIconClickEventHandler; 14 | #else 15 | class DockIconClickEventHandler; 16 | #endif 17 | 18 | /** Macintosh-specific dock icon handler. 19 | */ 20 | class MacDockIconHandler : public QObject 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | ~MacDockIconHandler(); 26 | 27 | QMenu *dockMenu(); 28 | void setIcon(const QIcon &icon); 29 | 30 | static MacDockIconHandler *instance(); 31 | 32 | void handleDockIconClickEvent(); 33 | 34 | signals: 35 | void dockIconClicked(); 36 | 37 | private: 38 | MacDockIconHandler(); 39 | 40 | DockIconClickEventHandler *m_dockIconClickEventHandler; 41 | QWidget *m_dummyWidget; 42 | QMenu *m_dockMenu; 43 | }; 44 | 45 | #endif // MACDOCKICONCLICKHANDLER_H 46 | -------------------------------------------------------------------------------- /src/qt/macdockiconhandler.mm: -------------------------------------------------------------------------------- 1 | #include "macdockiconhandler.h" 2 | 3 | #include 4 | #include 5 | 6 | extern void qt_mac_set_dock_menu(QMenu*); 7 | 8 | #undef slots 9 | #include 10 | 11 | @interface DockIconClickEventHandler : NSObject 12 | { 13 | MacDockIconHandler* dockIconHandler; 14 | } 15 | 16 | @end 17 | 18 | @implementation DockIconClickEventHandler 19 | 20 | - (id)initWithDockIconHandler:(MacDockIconHandler *)aDockIconHandler 21 | { 22 | self = [super init]; 23 | if (self) { 24 | dockIconHandler = aDockIconHandler; 25 | 26 | [[NSAppleEventManager sharedAppleEventManager] 27 | setEventHandler:self 28 | andSelector:@selector(handleDockClickEvent:withReplyEvent:) 29 | forEventClass:kCoreEventClass 30 | andEventID:kAEReopenApplication]; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)handleDockClickEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent 36 | { 37 | Q_UNUSED(event) 38 | Q_UNUSED(replyEvent) 39 | 40 | if (dockIconHandler) 41 | dockIconHandler->handleDockIconClickEvent(); 42 | } 43 | 44 | @end 45 | 46 | MacDockIconHandler::MacDockIconHandler() : QObject() 47 | { 48 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 49 | this->m_dockIconClickEventHandler = [[DockIconClickEventHandler alloc] initWithDockIconHandler:this]; 50 | 51 | this->m_dummyWidget = new QWidget(); 52 | this->m_dockMenu = new QMenu(this->m_dummyWidget); 53 | qt_mac_set_dock_menu(this->m_dockMenu); 54 | [pool release]; 55 | } 56 | 57 | MacDockIconHandler::~MacDockIconHandler() 58 | { 59 | [this->m_dockIconClickEventHandler release]; 60 | delete this->m_dummyWidget; 61 | } 62 | 63 | QMenu *MacDockIconHandler::dockMenu() 64 | { 65 | return this->m_dockMenu; 66 | } 67 | 68 | void MacDockIconHandler::setIcon(const QIcon &icon) 69 | { 70 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 71 | NSImage *image; 72 | if (icon.isNull()) 73 | image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; 74 | else { 75 | QSize size = icon.actualSize(QSize(128, 128)); 76 | QPixmap pixmap = icon.pixmap(size); 77 | CGImageRef cgImage = pixmap.toMacCGImageRef(); 78 | image = [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize]; 79 | CFRelease(cgImage); 80 | } 81 | 82 | [NSApp setApplicationIconImage:image]; 83 | [image release]; 84 | [pool release]; 85 | } 86 | 87 | MacDockIconHandler *MacDockIconHandler::instance() 88 | { 89 | static MacDockIconHandler *s_instance = NULL; 90 | if (!s_instance) 91 | s_instance = new MacDockIconHandler(); 92 | return s_instance; 93 | } 94 | 95 | void MacDockIconHandler::handleDockIconClickEvent() 96 | { 97 | emit this->dockIconClicked(); 98 | } 99 | -------------------------------------------------------------------------------- /src/qt/managenamespage.h: -------------------------------------------------------------------------------- 1 | #ifndef MANAGENAMESPAGE_H 2 | #define MANAGENAMESPAGE_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class ManageNamesPage; 9 | } 10 | class WalletModel; 11 | class NameTableModel; 12 | 13 | QT_BEGIN_NAMESPACE 14 | class QTableView; 15 | class QItemSelection; 16 | class QMenu; 17 | class QModelIndex; 18 | QT_END_NAMESPACE 19 | 20 | class NameFilterProxyModel : public QSortFilterProxyModel 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit NameFilterProxyModel(QObject *parent = 0); 26 | 27 | void setNameSearch(const QString &search); 28 | void setValueSearch(const QString &search); 29 | void setAddressSearch(const QString &search); 30 | 31 | protected: 32 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; 33 | 34 | private: 35 | QString nameSearch, valueSearch, addressSearch; 36 | }; 37 | 38 | /** Page for managing names */ 39 | class ManageNamesPage : public QDialog 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | explicit ManageNamesPage(QWidget *parent = 0); 45 | ~ManageNamesPage(); 46 | 47 | void setModel(WalletModel *walletModel); 48 | 49 | private: 50 | Ui::ManageNamesPage *ui; 51 | NameTableModel *model; 52 | WalletModel *walletModel; 53 | NameFilterProxyModel *proxyModel; 54 | QMenu *contextMenu; 55 | 56 | public slots: 57 | void exportClicked(); 58 | 59 | void changedNameFilter(const QString &filter); 60 | void changedValueFilter(const QString &filter); 61 | void changedAddressFilter(const QString &filter); 62 | 63 | private slots: 64 | void on_submitNameButton_clicked(); 65 | 66 | bool eventFilter(QObject *object, QEvent *event); 67 | void selectionChanged(); 68 | 69 | /** Spawn contextual menu (right mouse menu) for name table entry */ 70 | void contextualMenu(const QPoint &point); 71 | 72 | void onCopyNameAction(); 73 | void onCopyValueAction(); 74 | void onCopyAddressAction(); 75 | void on_configureNameButton_clicked(); 76 | void on_renewNameButton_clicked(); 77 | }; 78 | 79 | #endif // MANAGENAMESPAGE_H 80 | -------------------------------------------------------------------------------- /src/qt/monitoreddatamapper.cpp: -------------------------------------------------------------------------------- 1 | #include "monitoreddatamapper.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | MonitoredDataMapper::MonitoredDataMapper(QObject *parent) : 8 | QDataWidgetMapper(parent) 9 | { 10 | } 11 | 12 | void MonitoredDataMapper::addMapping(QWidget *widget, int section) 13 | { 14 | QDataWidgetMapper::addMapping(widget, section); 15 | addChangeMonitor(widget); 16 | } 17 | 18 | void MonitoredDataMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName) 19 | { 20 | QDataWidgetMapper::addMapping(widget, section, propertyName); 21 | addChangeMonitor(widget); 22 | } 23 | 24 | void MonitoredDataMapper::addChangeMonitor(QWidget *widget) 25 | { 26 | // Watch user property of widget for changes, and connect 27 | // the signal to our viewModified signal. 28 | QMetaProperty prop = widget->metaObject()->userProperty(); 29 | int signal = prop.notifySignalIndex(); 30 | int method = this->metaObject()->indexOfMethod("viewModified()"); 31 | if(signal != -1 && method != -1) 32 | { 33 | QMetaObject::connect(widget, signal, this, method); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/qt/monitoreddatamapper.h: -------------------------------------------------------------------------------- 1 | #ifndef MONITOREDDATAMAPPER_H 2 | #define MONITOREDDATAMAPPER_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | class QWidget; 8 | QT_END_NAMESPACE 9 | 10 | /** Data to Widget mapper that watches for edits and notifies listeners when a field is edited. 11 | This can be used, for example, to enable a commit/apply button in a configuration dialog. 12 | */ 13 | class MonitoredDataMapper : public QDataWidgetMapper 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit MonitoredDataMapper(QObject *parent=0); 19 | 20 | void addMapping(QWidget *widget, int section); 21 | void addMapping(QWidget *widget, int section, const QByteArray &propertyName); 22 | 23 | private: 24 | void addChangeMonitor(QWidget *widget); 25 | 26 | signals: 27 | void viewModified(); 28 | }; 29 | 30 | #endif // MONITOREDDATAMAPPER_H 31 | -------------------------------------------------------------------------------- /src/qt/nametablemodel.h: -------------------------------------------------------------------------------- 1 | #ifndef NAMETABLEMODEL_H 2 | #define NAMETABLEMODEL_H 3 | 4 | #include 5 | #include 6 | 7 | class NameTablePriv; 8 | class CWallet; 9 | class WalletModel; 10 | 11 | /** 12 | Qt model for "Manage Names" page. 13 | */ 14 | class NameTableModel : public QAbstractTableModel 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit NameTableModel(CWallet *wallet, WalletModel *parent = 0); 20 | ~NameTableModel(); 21 | 22 | enum ColumnIndex { 23 | Name = 0, 24 | Value = 1, 25 | Address = 2, 26 | ExpiresIn = 3 27 | }; 28 | 29 | /** @name Methods overridden from QAbstractTableModel 30 | @{*/ 31 | int rowCount(const QModelIndex &parent = QModelIndex()) const; 32 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 33 | QVariant data(const QModelIndex &index, int role) const; 34 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 35 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; 36 | Qt::ItemFlags flags(const QModelIndex &index) const; 37 | /*@}*/ 38 | 39 | private: 40 | WalletModel *walletModel; 41 | CWallet *wallet; 42 | QStringList columns; 43 | NameTablePriv *priv; 44 | int cachedNumBlocks; 45 | 46 | /** Notify listeners that data changed. */ 47 | void emitDataChanged(int index); 48 | 49 | public slots: 50 | void updateEntry(const QString &name, const QString &value, const QString &address, int nHeight, int status, int *outNewRowIndex = NULL); 51 | void updateExpiration(); 52 | void updateTransaction(const QString &hash, int status); 53 | 54 | friend class NameTablePriv; 55 | }; 56 | 57 | struct NameTableEntry 58 | { 59 | QString name; 60 | QString value; 61 | QString address; 62 | int nHeight; 63 | bool transferred; 64 | 65 | static const int NAME_NEW = -1; // Dummy nHeight value for not-yet-created names 66 | static const int NAME_NON_EXISTING = -2; // Dummy nHeight value for unitinialized entries 67 | static const int NAME_UNCONFIRMED = -3; // Dummy nHeight value for unconfirmed name transactions 68 | 69 | bool HeightValid() { return nHeight >= 0; } 70 | static bool CompareHeight(int nOldHeight, int nNewHeight); // Returns true if new height is better 71 | 72 | NameTableEntry() : nHeight(NAME_NON_EXISTING), transferred(false) {} 73 | NameTableEntry(const QString &name, const QString &value, const QString &address, int nHeight, bool transferred = false) : 74 | name(name), value(value), address(address), nHeight(nHeight), transferred(transferred) {} 75 | NameTableEntry(const std::string &name, const std::string &value, const std::string &address, int nHeight, bool transferred = false) : 76 | name(QString::fromStdString(name)), value(QString::fromStdString(value)), address(QString::fromStdString(address)), nHeight(nHeight), transferred(transferred) {} 77 | }; 78 | 79 | #endif // NAMETABLEMODEL_H 80 | -------------------------------------------------------------------------------- /src/qt/notificator.h: -------------------------------------------------------------------------------- 1 | #ifndef NOTIFICATOR_H 2 | #define NOTIFICATOR_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | class QSystemTrayIcon; 9 | #ifdef USE_DBUS 10 | class QDBusInterface; 11 | #endif 12 | QT_END_NAMESPACE 13 | 14 | /** Cross-platform desktop notification client. */ 15 | class Notificator: public QObject 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | /** Create a new notificator. 21 | @note Ownership of trayIcon is not transferred to this object. 22 | */ 23 | Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0); 24 | ~Notificator(); 25 | 26 | // Message class 27 | enum Class 28 | { 29 | Information, /**< Informational message */ 30 | Warning, /**< Notify user of potential problem */ 31 | Critical /**< An error occurred */ 32 | }; 33 | 34 | public slots: 35 | /** Show notification message. 36 | @param[in] cls general message class 37 | @param[in] title title shown with message 38 | @param[in] text message content 39 | @param[in] icon optional icon to show with message 40 | @param[in] millisTimeout notification timeout in milliseconds (defaults to 10 seconds) 41 | @note Platform implementations are free to ignore any of the provided fields except for \a text. 42 | */ 43 | void notify(Class cls, const QString &title, const QString &text, 44 | const QIcon &icon = QIcon(), int millisTimeout = 10000); 45 | 46 | private: 47 | QWidget *parent; 48 | enum Mode { 49 | None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */ 50 | Freedesktop, /**< Use DBus org.freedesktop.Notifications */ 51 | QSystemTray, /**< Use QSystemTray::showMessage */ 52 | Growl12, /**< Use the Growl 1.2 notification system (Mac only) */ 53 | Growl13 /**< Use the Growl 1.3 notification system (Mac only) */ 54 | }; 55 | QString programName; 56 | Mode mode; 57 | QSystemTrayIcon *trayIcon; 58 | #ifdef USE_DBUS 59 | QDBusInterface *interface; 60 | 61 | void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); 62 | #endif 63 | void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); 64 | #ifdef Q_OS_MAC 65 | void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon); 66 | #endif 67 | }; 68 | 69 | #endif // NOTIFICATOR_H 70 | -------------------------------------------------------------------------------- /src/qt/optionsdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef OPTIONSDIALOG_H 2 | #define OPTIONSDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class OptionsDialog; 8 | } 9 | class OptionsModel; 10 | class MonitoredDataMapper; 11 | class QValidatedLineEdit; 12 | 13 | /** Preferences dialog. */ 14 | class OptionsDialog : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit OptionsDialog(QWidget *parent = 0); 20 | ~OptionsDialog(); 21 | 22 | void setModel(OptionsModel *model); 23 | void setMapper(); 24 | 25 | protected: 26 | bool eventFilter(QObject *object, QEvent *event); 27 | 28 | private slots: 29 | /* enable only apply button */ 30 | void enableApplyButton(); 31 | /* disable only apply button */ 32 | void disableApplyButton(); 33 | /* enable apply button and OK button */ 34 | void enableSaveButtons(); 35 | /* disable apply button and OK button */ 36 | void disableSaveButtons(); 37 | /* set apply button and OK button state (enabled / disabled) */ 38 | void setSaveButtonState(bool fState); 39 | void on_resetButton_clicked(); 40 | void on_okButton_clicked(); 41 | void on_cancelButton_clicked(); 42 | void on_applyButton_clicked(); 43 | 44 | void showRestartWarning_Proxy(); 45 | void showRestartWarning_Lang(); 46 | void updateDisplayUnit(); 47 | void handleProxyIpValid(QValidatedLineEdit *object, bool fState); 48 | 49 | signals: 50 | void proxyIpValid(QValidatedLineEdit *object, bool fValid); 51 | 52 | private: 53 | Ui::OptionsDialog *ui; 54 | OptionsModel *model; 55 | MonitoredDataMapper *mapper; 56 | bool fRestartWarningDisplayed_Proxy; 57 | bool fRestartWarningDisplayed_Lang; 58 | bool fProxyIpValid; 59 | }; 60 | 61 | #endif // OPTIONSDIALOG_H 62 | -------------------------------------------------------------------------------- /src/qt/optionsmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef OPTIONSMODEL_H 2 | #define OPTIONSMODEL_H 3 | 4 | #include 5 | 6 | /** Interface from Qt to configuration data structure for Bitcoin client. 7 | To Qt, the options are presented as a list with the different options 8 | laid out vertically. 9 | This can be changed to a tree once the settings become sufficiently 10 | complex. 11 | */ 12 | class OptionsModel : public QAbstractListModel 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit OptionsModel(QObject *parent = 0); 18 | 19 | enum OptionID { 20 | StartAtStartup, // bool 21 | MinimizeToTray, // bool 22 | MapPortUPnP, // bool 23 | MinimizeOnClose, // bool 24 | ProxyUse, // bool 25 | ProxyIP, // QString 26 | ProxyPort, // int 27 | ProxySocksVersion, // int 28 | Fee, // qint64 29 | DisplayUnit, // BitcoinUnits::Unit 30 | DisplayAddresses, // bool 31 | Language, // QString 32 | OptionIDRowCount, 33 | }; 34 | 35 | void Init(); 36 | void Reset(); 37 | 38 | /* Migrate settings from wallet.dat after app initialization */ 39 | bool Upgrade(); /* returns true if settings upgraded */ 40 | 41 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 42 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; 43 | bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); 44 | 45 | /* Explicit getters */ 46 | qint64 getTransactionFee(); 47 | bool getMinimizeToTray() { return fMinimizeToTray; } 48 | bool getMinimizeOnClose() { return fMinimizeOnClose; } 49 | int getDisplayUnit() { return nDisplayUnit; } 50 | bool getDisplayAddresses() { return bDisplayAddresses; } 51 | QString getLanguage() { return language; } 52 | 53 | private: 54 | int nDisplayUnit; 55 | bool bDisplayAddresses; 56 | bool fMinimizeToTray; 57 | bool fMinimizeOnClose; 58 | QString language; 59 | 60 | signals: 61 | void displayUnitChanged(int unit); 62 | }; 63 | 64 | #endif // OPTIONSMODEL_H 65 | -------------------------------------------------------------------------------- /src/qt/overviewpage.h: -------------------------------------------------------------------------------- 1 | #ifndef OVERVIEWPAGE_H 2 | #define OVERVIEWPAGE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class OverviewPage; 8 | } 9 | class ClientModel; 10 | class WalletModel; 11 | class TxViewDelegate; 12 | class TransactionFilterProxy; 13 | 14 | QT_BEGIN_NAMESPACE 15 | class QModelIndex; 16 | QT_END_NAMESPACE 17 | 18 | /** Overview ("home") page widget */ 19 | class OverviewPage : public QWidget 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit OverviewPage(QWidget *parent = 0); 25 | ~OverviewPage(); 26 | 27 | void setClientModel(ClientModel *clientModel); 28 | void setWalletModel(WalletModel *walletModel); 29 | void showOutOfSyncWarning(bool fShow); 30 | 31 | public slots: 32 | void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance); 33 | void setNumTransactions(int count); 34 | 35 | signals: 36 | void transactionClicked(const QModelIndex &index); 37 | 38 | private: 39 | Ui::OverviewPage *ui; 40 | ClientModel *clientModel; 41 | WalletModel *walletModel; 42 | qint64 currentBalance; 43 | qint64 currentUnconfirmedBalance; 44 | qint64 currentImmatureBalance; 45 | 46 | TxViewDelegate *txdelegate; 47 | TransactionFilterProxy *filter; 48 | 49 | private slots: 50 | void updateDisplayUnit(); 51 | void handleTransactionClicked(const QModelIndex &index); 52 | void updateAlerts(const QString &warnings); 53 | }; 54 | 55 | #endif // OVERVIEWPAGE_H 56 | -------------------------------------------------------------------------------- /src/qt/paymentserver.h: -------------------------------------------------------------------------------- 1 | #ifndef PAYMENTSERVER_H 2 | #define PAYMENTSERVER_H 3 | 4 | // 5 | // This class handles payment requests from clicking on 6 | // bitcoin: URIs 7 | // 8 | // This is somewhat tricky, because we have to deal with 9 | // the situation where the user clicks on a link during 10 | // startup/initialization, when the splash-screen is up 11 | // but the main window (and the Send Coins tab) is not. 12 | // 13 | // So, the strategy is: 14 | // 15 | // Create the server, and register the event handler, 16 | // when the application is created. Save any URIs 17 | // received at or during startup in a list. 18 | // 19 | // When startup is finished and the main window is 20 | // show, a signal is sent to slot uiReady(), which 21 | // emits a receivedURL() signal for any payment 22 | // requests that happened during startup. 23 | // 24 | // After startup, receivedURL() happens as usual. 25 | // 26 | // This class has one more feature: a static 27 | // method that finds URIs passed in the command line 28 | // and, if a server is running in another process, 29 | // sends them to the server. 30 | // 31 | #include 32 | #include 33 | 34 | class QApplication; 35 | class QLocalServer; 36 | 37 | class PaymentServer : public QObject 38 | { 39 | Q_OBJECT 40 | private: 41 | bool saveURIs; 42 | QLocalServer* uriServer; 43 | 44 | public: 45 | // Returns true if there were URIs on the command line 46 | // which were successfully sent to an already-running 47 | // process. 48 | static bool ipcSendCommandLine(); 49 | 50 | PaymentServer(QApplication* parent); 51 | 52 | bool eventFilter(QObject *object, QEvent *event); 53 | 54 | signals: 55 | void receivedURI(QString); 56 | 57 | public slots: 58 | // Signal this when the main window's UI is ready 59 | // to display payment requests to the user 60 | void uiReady(); 61 | 62 | private slots: 63 | void handleURIConnection(); 64 | }; 65 | 66 | #endif // PAYMENTSERVER_H 67 | -------------------------------------------------------------------------------- /src/qt/qrcodedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef QRCODEDIALOG_H 2 | #define QRCODEDIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class QRCodeDialog; 9 | } 10 | class OptionsModel; 11 | 12 | class QRCodeDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent = 0); 18 | ~QRCodeDialog(); 19 | 20 | void setModel(OptionsModel *model); 21 | 22 | private slots: 23 | void on_lnReqAmount_textChanged(); 24 | void on_lnLabel_textChanged(); 25 | void on_lnMessage_textChanged(); 26 | void on_btnSaveAs_clicked(); 27 | void on_chkReqPayment_toggled(bool fChecked); 28 | 29 | void updateDisplayUnit(); 30 | 31 | private: 32 | Ui::QRCodeDialog *ui; 33 | OptionsModel *model; 34 | QString address; 35 | QImage myImage; 36 | 37 | void genCode(); 38 | QString getURI(); 39 | }; 40 | 41 | #endif // QRCODEDIALOG_H 42 | -------------------------------------------------------------------------------- /src/qt/qvalidatedlineedit.cpp: -------------------------------------------------------------------------------- 1 | #include "qvalidatedlineedit.h" 2 | 3 | #include "guiconstants.h" 4 | 5 | QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) : 6 | QLineEdit(parent), valid(true) 7 | { 8 | connect(this, SIGNAL(textChanged(QString)), this, SLOT(markValid())); 9 | } 10 | 11 | void QValidatedLineEdit::setValid(bool valid) 12 | { 13 | if(valid == this->valid) 14 | { 15 | return; 16 | } 17 | 18 | if(valid) 19 | { 20 | setStyleSheet(""); 21 | } 22 | else 23 | { 24 | setStyleSheet(STYLE_INVALID); 25 | } 26 | this->valid = valid; 27 | } 28 | 29 | void QValidatedLineEdit::focusInEvent(QFocusEvent *evt) 30 | { 31 | // Clear invalid flag on focus 32 | setValid(true); 33 | QLineEdit::focusInEvent(evt); 34 | } 35 | 36 | void QValidatedLineEdit::markValid() 37 | { 38 | setValid(true); 39 | } 40 | 41 | void QValidatedLineEdit::clear() 42 | { 43 | setValid(true); 44 | QLineEdit::clear(); 45 | } 46 | -------------------------------------------------------------------------------- /src/qt/qvalidatedlineedit.h: -------------------------------------------------------------------------------- 1 | #ifndef QVALIDATEDLINEEDIT_H 2 | #define QVALIDATEDLINEEDIT_H 3 | 4 | #include 5 | 6 | /** Line edit that can be marked as "invalid" to show input validation feedback. When marked as invalid, 7 | it will get a red background until it is focused. 8 | */ 9 | class QValidatedLineEdit : public QLineEdit 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit QValidatedLineEdit(QWidget *parent = 0); 15 | void clear(); 16 | 17 | protected: 18 | void focusInEvent(QFocusEvent *evt); 19 | 20 | private: 21 | bool valid; 22 | 23 | public slots: 24 | void setValid(bool valid); 25 | 26 | private slots: 27 | void markValid(); 28 | }; 29 | 30 | #endif // QVALIDATEDLINEEDIT_H 31 | -------------------------------------------------------------------------------- /src/qt/qvaluecombobox.cpp: -------------------------------------------------------------------------------- 1 | #include "qvaluecombobox.h" 2 | 3 | QValueComboBox::QValueComboBox(QWidget *parent) : 4 | QComboBox(parent), role(Qt::UserRole) 5 | { 6 | connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); 7 | } 8 | 9 | QVariant QValueComboBox::value() const 10 | { 11 | return itemData(currentIndex(), role); 12 | } 13 | 14 | void QValueComboBox::setValue(const QVariant &value) 15 | { 16 | setCurrentIndex(findData(value, role)); 17 | } 18 | 19 | void QValueComboBox::setRole(int role) 20 | { 21 | this->role = role; 22 | } 23 | 24 | void QValueComboBox::handleSelectionChanged(int idx) 25 | { 26 | emit valueChanged(); 27 | } 28 | -------------------------------------------------------------------------------- /src/qt/qvaluecombobox.h: -------------------------------------------------------------------------------- 1 | #ifndef QVALUECOMBOBOX_H 2 | #define QVALUECOMBOBOX_H 3 | 4 | #include 5 | #include 6 | 7 | /* QComboBox that can be used with QDataWidgetMapper to select ordinal values from a model. */ 8 | class QValueComboBox : public QComboBox 9 | { 10 | Q_OBJECT 11 | 12 | Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true) 13 | 14 | public: 15 | explicit QValueComboBox(QWidget *parent = 0); 16 | 17 | QVariant value() const; 18 | void setValue(const QVariant &value); 19 | 20 | /** Specify model role to use as ordinal value (defaults to Qt::UserRole) */ 21 | void setRole(int role); 22 | 23 | signals: 24 | void valueChanged(); 25 | 26 | private: 27 | int role; 28 | 29 | private slots: 30 | void handleSelectionChanged(int idx); 31 | }; 32 | 33 | #endif // QVALUECOMBOBOX_H 34 | -------------------------------------------------------------------------------- /src/qt/res/bitcoin-qt.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "icons/bitcoin.ico" 2 | 3 | #include // needed for VERSIONINFO 4 | 5 | #if 0 6 | #include "../../clientversion.h" // holds the needed client version information 7 | #else 8 | 9 | #define CLIENT_VERSION_MAJOR 0 10 | #define CLIENT_VERSION_MINOR 3 11 | #define CLIENT_VERSION_REVISION 80 12 | #define CLIENT_VERSION_BUILD 0 13 | 14 | // Converts the parameter X to a string after macro replacement on X has been performed. 15 | // Don't merge these into one macro! 16 | #define STRINGIZE(X) DO_STRINGIZE(X) 17 | #define DO_STRINGIZE(X) #X 18 | 19 | #endif 20 | 21 | #define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD 22 | #define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) 23 | #define VER_FILEVERSION VER_PRODUCTVERSION 24 | #define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR 25 | 26 | VS_VERSION_INFO VERSIONINFO 27 | FILEVERSION VER_FILEVERSION 28 | PRODUCTVERSION VER_PRODUCTVERSION 29 | FILEOS VOS_NT_WINDOWS32 30 | FILETYPE VFT_APP 31 | BEGIN 32 | BLOCK "StringFileInfo" 33 | BEGIN 34 | BLOCK "040904E4" // U.S. English - multilingual (hex) 35 | BEGIN 36 | VALUE "CompanyName", "Namecoin" 37 | VALUE "FileDescription", "Namecoin-Qt (OSS GUI client for Namecoin)" 38 | VALUE "FileVersion", VER_FILEVERSION_STR 39 | VALUE "InternalName", "namecoin-qt" 40 | VALUE "LegalCopyright", "2009-2013 The Bitcoin and Namecoin developers" 41 | VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." 42 | VALUE "OriginalFilename", "namecoin-qt.exe" 43 | VALUE "ProductName", "Namecoin-Qt" 44 | VALUE "ProductVersion", VER_PRODUCTVERSION_STR 45 | END 46 | END 47 | 48 | BLOCK "VarFileInfo" 49 | BEGIN 50 | VALUE "Translation", 0x0, 1252 // language neutral - multilingual (decimal) 51 | END 52 | END 53 | -------------------------------------------------------------------------------- /src/qt/res/icons/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/add.png -------------------------------------------------------------------------------- /src/qt/res/icons/address-book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/address-book.png -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/bitcoin.icns -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/bitcoin.ico -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/bitcoin.png -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin_testnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/bitcoin_testnet.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/clock1.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/clock2.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/clock3.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/clock4.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/clock5.png -------------------------------------------------------------------------------- /src/qt/res/icons/configure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/configure.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect0_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/connect0_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect1_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/connect1_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect2_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/connect2_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect3_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/connect3_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect4_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/connect4_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/debugwindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/debugwindow.png -------------------------------------------------------------------------------- /src/qt/res/icons/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/edit.png -------------------------------------------------------------------------------- /src/qt/res/icons/editcopy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/editcopy.png -------------------------------------------------------------------------------- /src/qt/res/icons/editpaste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/editpaste.png -------------------------------------------------------------------------------- /src/qt/res/icons/export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/export.png -------------------------------------------------------------------------------- /src/qt/res/icons/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/filesave.png -------------------------------------------------------------------------------- /src/qt/res/icons/history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/history.png -------------------------------------------------------------------------------- /src/qt/res/icons/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/key.png -------------------------------------------------------------------------------- /src/qt/res/icons/lock_closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/lock_closed.png -------------------------------------------------------------------------------- /src/qt/res/icons/lock_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/lock_open.png -------------------------------------------------------------------------------- /src/qt/res/icons/notsynced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/notsynced.png -------------------------------------------------------------------------------- /src/qt/res/icons/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/overview.png -------------------------------------------------------------------------------- /src/qt/res/icons/qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/qrcode.png -------------------------------------------------------------------------------- /src/qt/res/icons/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/quit.png -------------------------------------------------------------------------------- /src/qt/res/icons/receive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/receive.png -------------------------------------------------------------------------------- /src/qt/res/icons/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/remove.png -------------------------------------------------------------------------------- /src/qt/res/icons/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/send.png -------------------------------------------------------------------------------- /src/qt/res/icons/synced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/synced.png -------------------------------------------------------------------------------- /src/qt/res/icons/toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/toolbar.png -------------------------------------------------------------------------------- /src/qt/res/icons/toolbar_testnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/toolbar_testnet.png -------------------------------------------------------------------------------- /src/qt/res/icons/transaction0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/transaction0.png -------------------------------------------------------------------------------- /src/qt/res/icons/transaction2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/transaction2.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_inout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/tx_inout.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/tx_input.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_mined.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/tx_mined.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_nameop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/tx_nameop.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/icons/tx_output.png -------------------------------------------------------------------------------- /src/qt/res/images/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/images/about.png -------------------------------------------------------------------------------- /src/qt/res/images/namecoin-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/images/namecoin-logo.png -------------------------------------------------------------------------------- /src/qt/res/movies/update_spinner.mng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/namecoin/namecoin-legacy/b043fba28018721b68c90edfc81b9eacb070b47d/src/qt/res/movies/update_spinner.mng -------------------------------------------------------------------------------- /src/qt/rpcconsole.h: -------------------------------------------------------------------------------- 1 | #ifndef RPCCONSOLE_H 2 | #define RPCCONSOLE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class RPCConsole; 8 | } 9 | class ClientModel; 10 | 11 | /** Local Bitcoin RPC console. */ 12 | class RPCConsole: public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit RPCConsole(QWidget *parent = 0); 18 | ~RPCConsole(); 19 | 20 | void setClientModel(ClientModel *model); 21 | 22 | enum MessageClass { 23 | MC_ERROR, 24 | MC_DEBUG, 25 | CMD_REQUEST, 26 | CMD_REPLY, 27 | CMD_ERROR 28 | }; 29 | 30 | protected: 31 | virtual bool eventFilter(QObject* obj, QEvent *event); 32 | 33 | private slots: 34 | void on_lineEdit_returnPressed(); 35 | void on_tabWidget_currentChanged(int index); 36 | /** open the debug.log from the current datadir */ 37 | void on_openDebugLogfileButton_clicked(); 38 | /** display messagebox with program parameters (same as bitcoin-qt --help) */ 39 | void on_showCLOptionsButton_clicked(); 40 | 41 | public slots: 42 | void clear(); 43 | void message(int category, const QString &message, bool html = false); 44 | /** Set number of connections shown in the UI */ 45 | void setNumConnections(int count); 46 | /** Set number of blocks shown in the UI */ 47 | void setNumBlocks(int count, int countOfPeers); 48 | /** Go forward or back in history */ 49 | void browseHistory(int offset); 50 | /** Scroll console view to end */ 51 | void scrollToEnd(); 52 | signals: 53 | // For RPC command executor 54 | void stopExecutor(); 55 | void cmdRequest(const QString &command); 56 | 57 | private: 58 | Ui::RPCConsole *ui; 59 | ClientModel *clientModel; 60 | QStringList history; 61 | int historyPtr; 62 | 63 | void startExecutor(); 64 | }; 65 | 66 | #endif // RPCCONSOLE_H 67 | -------------------------------------------------------------------------------- /src/qt/sendcoinsdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef SENDCOINSDIALOG_H 2 | #define SENDCOINSDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class SendCoinsDialog; 8 | } 9 | class WalletModel; 10 | class SendCoinsEntry; 11 | class SendCoinsRecipient; 12 | 13 | QT_BEGIN_NAMESPACE 14 | class QUrl; 15 | QT_END_NAMESPACE 16 | 17 | /** Dialog for sending bitcoins */ 18 | class SendCoinsDialog : public QDialog 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit SendCoinsDialog(QWidget *parent = 0); 24 | ~SendCoinsDialog(); 25 | 26 | void setModel(WalletModel *model); 27 | 28 | /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). 29 | */ 30 | QWidget *setupTabChain(QWidget *prev); 31 | 32 | void setAddress(const QString &address); 33 | void pasteEntry(const SendCoinsRecipient &rv); 34 | bool handleURI(const QString &uri); 35 | 36 | public slots: 37 | void clear(); 38 | void reject(); 39 | void accept(); 40 | SendCoinsEntry *addEntry(); 41 | void updateRemoveEnabled(); 42 | void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance); 43 | 44 | private: 45 | Ui::SendCoinsDialog *ui; 46 | WalletModel *model; 47 | bool fNewRecipientAllowed; 48 | 49 | private slots: 50 | void on_sendButton_clicked(); 51 | void removeEntry(SendCoinsEntry* entry); 52 | void updateDisplayUnit(); 53 | }; 54 | 55 | #endif // SENDCOINSDIALOG_H 56 | -------------------------------------------------------------------------------- /src/qt/sendcoinsentry.h: -------------------------------------------------------------------------------- 1 | #ifndef SENDCOINSENTRY_H 2 | #define SENDCOINSENTRY_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class SendCoinsEntry; 8 | } 9 | class WalletModel; 10 | class SendCoinsRecipient; 11 | 12 | /** A single entry in the dialog for sending bitcoins. */ 13 | class SendCoinsEntry : public QFrame 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit SendCoinsEntry(QWidget *parent = 0); 19 | ~SendCoinsEntry(); 20 | 21 | void setModel(WalletModel *model); 22 | bool validate(); 23 | SendCoinsRecipient getValue(); 24 | 25 | /** Return whether the entry is still empty and unedited */ 26 | bool isClear(); 27 | 28 | void setValue(const SendCoinsRecipient &value); 29 | void setAddress(const QString &address); 30 | 31 | /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). 32 | */ 33 | QWidget *setupTabChain(QWidget *prev); 34 | 35 | void setFocus(); 36 | 37 | public slots: 38 | void setRemoveEnabled(bool enabled); 39 | void clear(); 40 | 41 | signals: 42 | void removeEntry(SendCoinsEntry *entry); 43 | 44 | private slots: 45 | void on_deleteButton_clicked(); 46 | void on_payTo_textChanged (const QString& value); 47 | void on_addressBookButton_clicked(); 48 | void on_pasteButton_clicked(); 49 | void updateDisplayUnit(); 50 | 51 | private: 52 | Ui::SendCoinsEntry *ui; 53 | WalletModel *model; 54 | }; 55 | 56 | #endif // SENDCOINSENTRY_H 57 | -------------------------------------------------------------------------------- /src/qt/signverifymessagedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGNVERIFYMESSAGEDIALOG_H 2 | #define SIGNVERIFYMESSAGEDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class SignVerifyMessageDialog; 8 | } 9 | class WalletModel; 10 | 11 | class SignVerifyMessageDialog : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit SignVerifyMessageDialog(QWidget *parent = 0); 17 | ~SignVerifyMessageDialog(); 18 | 19 | void setModel(WalletModel *model); 20 | void setAddress_SM(const QString &address); 21 | void setAddress_VM(const QString &address); 22 | 23 | void showTab_SM(bool fShow); 24 | void showTab_VM(bool fShow); 25 | 26 | protected: 27 | bool eventFilter(QObject *object, QEvent *event); 28 | 29 | private: 30 | Ui::SignVerifyMessageDialog *ui; 31 | WalletModel *model; 32 | 33 | private slots: 34 | /* sign message */ 35 | void on_addressBookButton_SM_clicked(); 36 | void on_pasteButton_SM_clicked(); 37 | void on_signMessageButton_SM_clicked(); 38 | void on_copySignatureButton_SM_clicked(); 39 | void on_clearButton_SM_clicked(); 40 | /* verify message */ 41 | void on_addressBookButton_VM_clicked(); 42 | void on_verifyMessageButton_VM_clicked(); 43 | void on_clearButton_VM_clicked(); 44 | }; 45 | 46 | #endif // SIGNVERIFYMESSAGEDIALOG_H 47 | -------------------------------------------------------------------------------- /src/qt/test/test_main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "uritests.h" 5 | 6 | // This is all you need to run all the tests 7 | int main(int argc, char *argv[]) 8 | { 9 | bool fInvalid = false; 10 | 11 | URITests test1; 12 | if (QTest::qExec(&test1) != 0) 13 | fInvalid = true; 14 | 15 | return fInvalid; 16 | } 17 | -------------------------------------------------------------------------------- /src/qt/test/uritests.cpp: -------------------------------------------------------------------------------- 1 | #include "uritests.h" 2 | #include "../guiutil.h" 3 | #include "../walletmodel.h" 4 | 5 | #include 6 | 7 | void URITests::uriTests() 8 | { 9 | SendCoinsRecipient rv; 10 | QUrl uri; 11 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist=")); 12 | QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); 13 | 14 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist=")); 15 | QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); 16 | QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); 17 | QVERIFY(rv.label == QString()); 18 | QVERIFY(rv.amount == 0); 19 | 20 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address")); 21 | QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); 22 | QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); 23 | QVERIFY(rv.label == QString("Wikipedia Example Address")); 24 | QVERIFY(rv.amount == 0); 25 | 26 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001")); 27 | QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); 28 | QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); 29 | QVERIFY(rv.label == QString()); 30 | QVERIFY(rv.amount == 100000); 31 | 32 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001")); 33 | QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); 34 | QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); 35 | QVERIFY(rv.label == QString()); 36 | QVERIFY(rv.amount == 100100000); 37 | 38 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example")); 39 | QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); 40 | QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); 41 | QVERIFY(rv.amount == 10000000000LL); 42 | QVERIFY(rv.label == QString("Wikipedia Example")); 43 | 44 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address")); 45 | QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); 46 | QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); 47 | QVERIFY(rv.label == QString()); 48 | 49 | QVERIFY(GUIUtil::parseBitcoinURI("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv)); 50 | QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); 51 | QVERIFY(rv.label == QString()); 52 | 53 | // We currently don't implement the message parameter (ok, yea, we break spec...) 54 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address")); 55 | QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); 56 | 57 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example")); 58 | QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); 59 | 60 | uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example")); 61 | QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); 62 | } 63 | -------------------------------------------------------------------------------- /src/qt/test/uritests.h: -------------------------------------------------------------------------------- 1 | #ifndef URITESTS_H 2 | #define URITESTS_H 3 | 4 | #include 5 | #include 6 | 7 | class URITests : public QObject 8 | { 9 | Q_OBJECT 10 | 11 | private slots: 12 | void uriTests(); 13 | }; 14 | 15 | #endif // URITESTS_H 16 | -------------------------------------------------------------------------------- /src/qt/transactiondesc.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSACTIONDESC_H 2 | #define TRANSACTIONDESC_H 3 | 4 | #include 5 | #include 6 | 7 | class CWallet; 8 | class CWalletTx; 9 | 10 | /** Provide a human-readable extended HTML description of a transaction. 11 | */ 12 | class TransactionDesc: public QObject 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | static QString toHTML(CWallet *wallet, CWalletTx &wtx); 18 | 19 | private: 20 | TransactionDesc() {} 21 | 22 | static QString FormatTxStatus(const CWalletTx& wtx); 23 | }; 24 | 25 | #endif // TRANSACTIONDESC_H 26 | -------------------------------------------------------------------------------- /src/qt/transactiondescdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "transactiondescdialog.h" 2 | #include "ui_transactiondescdialog.h" 3 | #include "transactiontablemodel.h" 4 | #include "guiconstants.h" 5 | 6 | #include 7 | 8 | TransactionDescDialog::TransactionDescDialog(const QModelIndex &idx, QWidget *parent) : 9 | QDialog(parent, DIALOGWINDOWHINTS), 10 | ui(new Ui::TransactionDescDialog) 11 | { 12 | ui->setupUi(this); 13 | QString desc = idx.data(TransactionTableModel::LongDescriptionRole).toString(); 14 | ui->detailText->setHtml(desc); 15 | } 16 | 17 | TransactionDescDialog::~TransactionDescDialog() 18 | { 19 | delete ui; 20 | } 21 | -------------------------------------------------------------------------------- /src/qt/transactiondescdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSACTIONDESCDIALOG_H 2 | #define TRANSACTIONDESCDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class TransactionDescDialog; 8 | } 9 | 10 | QT_BEGIN_NAMESPACE 11 | class QModelIndex; 12 | QT_END_NAMESPACE 13 | 14 | /** Dialog showing transaction details. */ 15 | class TransactionDescDialog : public QDialog 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit TransactionDescDialog(const QModelIndex &idx, QWidget *parent = 0); 21 | ~TransactionDescDialog(); 22 | 23 | private: 24 | Ui::TransactionDescDialog *ui; 25 | }; 26 | 27 | #endif // TRANSACTIONDESCDIALOG_H 28 | -------------------------------------------------------------------------------- /src/qt/transactionfilterproxy.cpp: -------------------------------------------------------------------------------- 1 | #include "transactionfilterproxy.h" 2 | 3 | #include "transactiontablemodel.h" 4 | 5 | #include 6 | 7 | #include 8 | 9 | // Earliest date that can be represented (far in the past) 10 | const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0); 11 | // Last date that can be represented (far in the future) 12 | const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF); 13 | 14 | TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : 15 | QSortFilterProxyModel(parent), 16 | dateFrom(MIN_DATE), 17 | dateTo(MAX_DATE), 18 | addrPrefix(), 19 | typeFilter(ALL_TYPES), 20 | minAmount(0), 21 | limitRows(-1) 22 | { 23 | } 24 | 25 | bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const 26 | { 27 | QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); 28 | 29 | int type = index.data(TransactionTableModel::TypeRole).toInt(); 30 | QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); 31 | QString address = index.data(TransactionTableModel::AddressRole).toString(); 32 | QString label = index.data(TransactionTableModel::LabelRole).toString(); 33 | qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); 34 | 35 | if(!(TYPE(type) & typeFilter)) 36 | return false; 37 | if(datetime < dateFrom || datetime > dateTo) 38 | return false; 39 | if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) 40 | return false; 41 | if(amount < minAmount) 42 | return false; 43 | 44 | return true; 45 | } 46 | 47 | void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to) 48 | { 49 | this->dateFrom = from; 50 | this->dateTo = to; 51 | invalidateFilter(); 52 | } 53 | 54 | void TransactionFilterProxy::setAddressPrefix(const QString &addrPrefix) 55 | { 56 | this->addrPrefix = addrPrefix; 57 | invalidateFilter(); 58 | } 59 | 60 | void TransactionFilterProxy::setTypeFilter(quint32 modes) 61 | { 62 | this->typeFilter = modes; 63 | invalidateFilter(); 64 | } 65 | 66 | void TransactionFilterProxy::setMinAmount(qint64 minimum) 67 | { 68 | this->minAmount = minimum; 69 | invalidateFilter(); 70 | } 71 | 72 | void TransactionFilterProxy::setLimit(int limit) 73 | { 74 | this->limitRows = limit; 75 | } 76 | 77 | int TransactionFilterProxy::rowCount(const QModelIndex &parent) const 78 | { 79 | if(limitRows != -1) 80 | { 81 | return std::min(QSortFilterProxyModel::rowCount(parent), limitRows); 82 | } 83 | else 84 | { 85 | return QSortFilterProxyModel::rowCount(parent); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/qt/transactionfilterproxy.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSACTIONFILTERPROXY_H 2 | #define TRANSACTIONFILTERPROXY_H 3 | 4 | #include 5 | #include 6 | 7 | /** Filter the transaction list according to pre-specified rules. */ 8 | class TransactionFilterProxy : public QSortFilterProxyModel 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | explicit TransactionFilterProxy(QObject *parent = 0); 14 | 15 | /** Earliest date that can be represented (far in the past) */ 16 | static const QDateTime MIN_DATE; 17 | /** Last date that can be represented (far in the future) */ 18 | static const QDateTime MAX_DATE; 19 | /** Type filter bit field (all types) */ 20 | static const quint32 ALL_TYPES = 0xFFFFFFFF; 21 | 22 | static quint32 TYPE(int type) { return 1< 5 | #include 6 | 7 | class CWallet; 8 | class TransactionTablePriv; 9 | class TransactionRecord; 10 | class WalletModel; 11 | 12 | /** UI model for the transaction table of a wallet. 13 | */ 14 | class TransactionTableModel : public QAbstractTableModel 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0); 20 | ~TransactionTableModel(); 21 | 22 | enum ColumnIndex { 23 | Status = 0, 24 | Date = 1, 25 | Type = 2, 26 | ToAddress = 3, 27 | Amount = 4 28 | }; 29 | 30 | /** Roles to get specific information from a transaction row. 31 | These are independent of column. 32 | */ 33 | enum RoleIndex { 34 | /** Type of transaction */ 35 | TypeRole = Qt::UserRole, 36 | /** Date and time this transaction was created */ 37 | DateRole, 38 | /** Long description (HTML format) */ 39 | LongDescriptionRole, 40 | /** Address of transaction */ 41 | AddressRole, 42 | /** Label of address related to transaction */ 43 | LabelRole, 44 | /** Net amount of transaction */ 45 | AmountRole, 46 | /** Unique identifier */ 47 | TxIDRole, 48 | /** Is transaction confirmed? */ 49 | ConfirmedRole, 50 | /** Formatted amount, without brackets when unconfirmed */ 51 | FormattedAmountRole 52 | }; 53 | 54 | int rowCount(const QModelIndex &parent) const; 55 | int columnCount(const QModelIndex &parent) const; 56 | QVariant data(const QModelIndex &index, int role) const; 57 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 58 | QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; 59 | 60 | private: 61 | CWallet* wallet; 62 | WalletModel *walletModel; 63 | QStringList columns; 64 | TransactionTablePriv *priv; 65 | int cachedNumBlocks; 66 | 67 | QString lookupAddress(const std::string &address, bool tooltip) const; 68 | QVariant addressColor(const TransactionRecord *wtx) const; 69 | QString formatTxStatus(const TransactionRecord *wtx) const; 70 | QString formatTxDate(const TransactionRecord *wtx) const; 71 | QString formatTxType(const TransactionRecord *wtx) const; 72 | QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const; 73 | QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const; 74 | QString formatTooltip(const TransactionRecord *rec) const; 75 | QVariant txStatusDecoration(const TransactionRecord *wtx) const; 76 | QVariant txAddressDecoration(const TransactionRecord *wtx) const; 77 | 78 | public slots: 79 | void updateTransaction(const QString &hash, int status); 80 | void updateConfirmations(); 81 | void updateDisplayUnit(); 82 | 83 | friend class TransactionTablePriv; 84 | }; 85 | 86 | #endif // TRANSACTIONTABLEMODEL_H 87 | -------------------------------------------------------------------------------- /src/qt/transactionview.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSACTIONVIEW_H 2 | #define TRANSACTIONVIEW_H 3 | 4 | #include 5 | 6 | class WalletModel; 7 | class TransactionFilterProxy; 8 | 9 | QT_BEGIN_NAMESPACE 10 | class QTableView; 11 | class QComboBox; 12 | class QLineEdit; 13 | class QModelIndex; 14 | class QMenu; 15 | class QFrame; 16 | class QDateTimeEdit; 17 | QT_END_NAMESPACE 18 | 19 | /** Widget showing the transaction list for a wallet, including a filter row. 20 | Using the filter row, the user can view or export a subset of the transactions. 21 | */ 22 | class TransactionView : public QWidget 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit TransactionView(QWidget *parent = 0); 28 | 29 | void setModel(WalletModel *model); 30 | 31 | // Date ranges for filter 32 | enum DateEnum 33 | { 34 | All, 35 | Today, 36 | ThisWeek, 37 | ThisMonth, 38 | LastMonth, 39 | ThisYear, 40 | Range 41 | }; 42 | 43 | private: 44 | WalletModel *model; 45 | TransactionFilterProxy *transactionProxyModel; 46 | QTableView *transactionView; 47 | 48 | QComboBox *dateWidget; 49 | QComboBox *typeWidget; 50 | QLineEdit *addressWidget; 51 | QLineEdit *amountWidget; 52 | 53 | QMenu *contextMenu; 54 | 55 | QFrame *dateRangeWidget; 56 | QDateTimeEdit *dateFrom; 57 | QDateTimeEdit *dateTo; 58 | 59 | QWidget *createDateRangeWidget(); 60 | 61 | private slots: 62 | void contextualMenu(const QPoint &); 63 | void dateRangeChanged(); 64 | void showDetails(); 65 | void copyAddress(); 66 | void editLabel(); 67 | void copyLabel(); 68 | void copyAmount(); 69 | 70 | signals: 71 | void doubleClicked(const QModelIndex&); 72 | 73 | public slots: 74 | void chooseDate(int idx); 75 | void chooseType(int idx); 76 | void changedPrefix(const QString &prefix); 77 | void changedAmount(const QString &amount); 78 | void exportClicked(); 79 | void focusTransaction(const QModelIndex&); 80 | 81 | }; 82 | 83 | #endif // TRANSACTIONVIEW_H 84 | -------------------------------------------------------------------------------- /src/runValgrind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | valgrind --leak-check=full ./namecoind 2>&1 | tee valgrind.log 4 | -------------------------------------------------------------------------------- /src/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 | #ifndef BITCOIN_STRLCPY_H 17 | #define BITCOIN_STRLCPY_H 18 | /* 19 | * Copy src to string dst of size siz. At most siz-1 characters 20 | * will be copied. Always NUL terminates (unless siz == 0). 21 | * Returns strlen(src); if retval >= siz, truncation occurred. 22 | */ 23 | inline size_t strlcpy(char *dst, const char *src, size_t siz) 24 | { 25 | char *d = dst; 26 | const char *s = src; 27 | size_t n = siz; 28 | 29 | /* Copy as many bytes as will fit */ 30 | if (n != 0) 31 | { 32 | while (--n != 0) 33 | { 34 | if ((*d++ = *s++) == '\0') 35 | break; 36 | } 37 | } 38 | 39 | /* Not enough room in dst, add NUL and traverse rest of src */ 40 | if (n == 0) 41 | { 42 | if (siz != 0) 43 | *d = '\0'; /* NUL-terminate dst */ 44 | while (*s++) 45 | ; 46 | } 47 | 48 | return(s - src - 1); /* count does not include NUL */ 49 | } 50 | 51 | /* 52 | * Appends src to string dst of size siz (unlike strncat, siz is the 53 | * full size of dst, not space left). At most siz-1 characters 54 | * will be copied. Always NUL terminates (unless siz <= strlen(dst)). 55 | * Returns strlen(src) + MIN(siz, strlen(initial dst)). 56 | * If retval >= siz, truncation occurred. 57 | */ 58 | inline size_t strlcat(char *dst, const char *src, size_t siz) 59 | { 60 | char *d = dst; 61 | const char *s = src; 62 | size_t n = siz; 63 | size_t dlen; 64 | 65 | /* Find the end of dst and adjust bytes left but don't go past end */ 66 | while (n-- != 0 && *d != '\0') 67 | d++; 68 | dlen = d - dst; 69 | n = siz - dlen; 70 | 71 | if (n == 0) 72 | return(dlen + strlen(s)); 73 | while (*s != '\0') 74 | { 75 | if (n != 1) 76 | { 77 | *d++ = *s; 78 | n--; 79 | } 80 | s++; 81 | } 82 | *d = '\0'; 83 | 84 | return(dlen + (s - src)); /* count does not include NUL */ 85 | } 86 | #endif 87 | -------------------------------------------------------------------------------- /src/test/README: -------------------------------------------------------------------------------- 1 | The sources in this directory are unit test cases. Boost includes a 2 | unit testing framework, and since bitcoin already uses boost, it makes 3 | sense to simply use this framework rather than require developers to 4 | configure some other framework (we want as few impediments to creating 5 | unit tests as possible). 6 | 7 | The build system is setup to compile an executable called "test_bitcoin" 8 | that runs all of the unit tests. The main source file is called 9 | test_bitcoin.cpp, which simply includes other files that contain the 10 | actual unit tests (outside of a couple required preprocessor 11 | directives). The pattern is to create one test file for each class or 12 | source file for which you want to create unit tests. The file naming 13 | convention is "_tests.cpp" and such files should wrap 14 | their tests in a test suite called "_tests". For an 15 | examples of this pattern, examine uint160_tests.cpp and 16 | uint256_tests.cpp. 17 | 18 | For further reading, I found the following website to be helpful in 19 | explaining how the boost unit test framework works: 20 | 21 | http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/ 22 | -------------------------------------------------------------------------------- /src/test/test_bitcoin.cpp: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_MODULE uint160 2 | #include 3 | 4 | #include "uint160_tests.cpp" 5 | #include "uint256_tests.cpp" 6 | 7 | -------------------------------------------------------------------------------- /src/test/uint160_tests.cpp: -------------------------------------------------------------------------------- 1 | #include "../uint256.h" 2 | 3 | BOOST_AUTO_TEST_SUITE(uint160_tests) 4 | 5 | BOOST_AUTO_TEST_CASE(equality) 6 | { 7 | uint160 num1 = 10; 8 | uint160 num2 = 11; 9 | BOOST_CHECK(num1+1 == num2); 10 | 11 | uint64 num3 = 10; 12 | BOOST_CHECK(num1 == num3); 13 | BOOST_CHECK(num1+num2 == num3+num2); 14 | } 15 | 16 | BOOST_AUTO_TEST_SUITE_END() 17 | -------------------------------------------------------------------------------- /src/test/uint256_tests.cpp: -------------------------------------------------------------------------------- 1 | #include "../uint256.h" 2 | 3 | BOOST_AUTO_TEST_SUITE(uint256_tests) 4 | 5 | BOOST_AUTO_TEST_CASE(equality) 6 | { 7 | uint256 num1 = 10; 8 | uint256 num2 = 11; 9 | BOOST_CHECK(num1+1 == num2); 10 | 11 | uint64 num3 = 10; 12 | BOOST_CHECK(num1 == num3); 13 | BOOST_CHECK(num1+num2 == num3+num2); 14 | } 15 | 16 | BOOST_AUTO_TEST_SUITE_END() 17 | -------------------------------------------------------------------------------- /src/ui.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 Satoshi Nakamoto 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file license.txt or http://www.opensource.org/licenses/mit-license.php. 4 | #ifndef BITCOIN_UI_H 5 | #define BITCOIN_UI_H 6 | 7 | #ifdef GUI 8 | 9 | #include 10 | #include 11 | #include "wallet.h" 12 | #include "qt/ui_interface.h" 13 | 14 | #define wxTheApp true 15 | 16 | typedef void wxWindow; 17 | #define wxYES CClientUIInterface::BTN_YES 18 | #define wxOK CClientUIInterface::BTN_OK 19 | #define wxNO CClientUIInterface::BTN_NO 20 | #define wxYES_NO (wxYES|wxNO) 21 | #define wxCANCEL CClientUIInterface::BTN_CANCEL 22 | #define wxAPPLY CClientUIInterface::BTN_APPLY 23 | #define wxCLOSE CClientUIInterface::BTN_CLOSE 24 | #define wxOK_DEFAULT 0 25 | #define wxYES_DEFAULT 0 26 | #define wxNO_DEFAULT 0 27 | #define wxCANCEL_DEFAULT 0 28 | #define wxICON_EXCLAMATION 0 29 | #define wxICON_HAND CClientUIInterface::MSG_ERROR 30 | #define wxICON_WARNING wxICON_EXCLAMATION 31 | #define wxICON_ERROR wxICON_HAND 32 | #define wxICON_QUESTION 0 33 | #define wxICON_INFORMATION CClientUIInterface::ICON_INFORMATION 34 | #define wxICON_STOP wxICON_HAND 35 | #define wxICON_ASTERISK wxICON_INFORMATION 36 | #define wxICON_MASK CClientUIInterface::ICON_MASK 37 | #define wxFORWARD 0 38 | #define wxBACKWARD 0 39 | #define wxRESET 0 40 | #define wxHELP 0 41 | #define wxMORE 0 42 | #define wxSETUP 0 43 | 44 | inline int MyMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1) 45 | { 46 | return uiInterface.ThreadSafeMessageBox(message, caption, style); 47 | } 48 | 49 | #define wxMessageBox MyMessageBox 50 | 51 | inline void CalledSetStatusBar(const std::string& strText, int nField) 52 | { 53 | } 54 | 55 | inline void UIThreadCall(boost::function0 fn) 56 | { 57 | } 58 | 59 | inline void CreateMainWindow() 60 | { 61 | } 62 | 63 | inline void SetStartOnSystemStartup(bool dummy) 64 | { 65 | } 66 | 67 | #endif 68 | #endif 69 | -------------------------------------------------------------------------------- /src/uibase.h: -------------------------------------------------------------------------------- 1 | // Nothing --------------------------------------------------------------------------------