├── .gitattributes ├── .gitignore ├── COPYING ├── INSTALL ├── Makefile.am ├── README.md ├── autogen.sh ├── configure.ac ├── contrib ├── README.md ├── bitcoin-qt.pro ├── bitcoind.bash-completion ├── bitrpc │ ├── README.md │ └── bitrpc.py ├── debian │ ├── README.md │ ├── bitcoin-qt.desktop │ ├── bitcoin-qt.install │ ├── bitcoin-qt.lintian-overrides │ ├── bitcoin-qt.protocol │ ├── bitcoind.bash-completion │ ├── bitcoind.examples │ ├── bitcoind.install │ ├── bitcoind.lintian-overrides │ ├── bitcoind.manpages │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ ├── examples │ │ └── bitcoin.conf │ ├── gbp.conf │ ├── manpages │ │ ├── bitcoin-qt.1 │ │ ├── bitcoin.conf.5 │ │ └── bitcoind.1 │ ├── patches │ │ ├── README │ │ └── series │ ├── rules │ ├── source │ │ └── format │ └── watch ├── gitian-descriptors │ ├── README.md │ ├── boost-win32.yml │ ├── deps-win32.yml │ ├── gitian-win32.yml │ ├── gitian.yml │ ├── protobuf-win32.yml │ └── qt-win32.yml ├── gitian-downloader │ ├── bluematt-key.pgp │ ├── devrandom-key.pgp │ ├── gavinandresen-key.pgp │ ├── laanwj-key.pgp │ ├── linux-download-config │ ├── luke-jr-key.pgp │ ├── michagogo-key.pgp │ ├── sipa-key.pgp │ ├── tcatm-key.pgp │ ├── win32-download-config │ └── wtogami-key.pgp ├── linearize │ ├── README.md │ ├── example-linearize.cfg │ └── linearize.py ├── macdeploy │ ├── LICENSE │ ├── README.md │ ├── background.png │ ├── background.psd │ ├── fancy.plist │ └── macdeployqtplus ├── pyminer │ ├── README.md │ ├── example-config.cfg │ └── pyminer.py ├── qos │ ├── README.md │ └── tc.sh ├── qt_translations.py ├── seeds │ ├── README.md │ └── makeseeds.py ├── spendfrom │ ├── README.md │ ├── setup.py │ └── spendfrom.py ├── test-patches │ ├── README.md │ └── temp-revert-2.patch ├── testgen │ ├── README.md │ ├── base58.py │ └── gen_base58_test_vectors.py ├── tidy_datadir.sh ├── verifysfbinaries │ ├── README.md │ └── verify.sh └── wallettools │ ├── README.md │ ├── walletchangepass.py │ └── walletunlock.py ├── doc ├── Doxyfile ├── README.md ├── README_windows.txt ├── assets-attribution.md ├── bitcoin_logo_doxygen.png ├── build-msw.md ├── build-osx.md ├── build-unix.md ├── coding.md ├── files.md ├── multiwallet-qt.md ├── release-notes.md ├── release-process.md ├── tor.md ├── translation_process.md └── unit-tests.md ├── pkg.m4 ├── qa └── pull-tester │ ├── build-tests.sh.in │ ├── pull-tester.py │ ├── pull-tester.sh │ └── run-bitcoind-for-test.sh.in ├── share ├── certs │ ├── BitcoinFoundation_Apple_Cert.pem │ ├── BitcoinFoundation_Comodo_Cert.pem │ └── PrivateKeyNotes.md ├── genbuild.sh ├── pixmaps │ ├── addressbook16.bmp │ ├── addressbook16mask.bmp │ ├── addressbook20.bmp │ ├── addressbook20mask.bmp │ ├── bitcoin-bc.ico │ ├── bitcoin.ico │ ├── bitcoin128.png │ ├── bitcoin128.xpm │ ├── bitcoin16.png │ ├── bitcoin16.xpm │ ├── bitcoin256.png │ ├── bitcoin256.xpm │ ├── bitcoin32.png │ ├── bitcoin32.xpm │ ├── bitcoin64.png │ ├── bitcoin64.xpm │ ├── check.ico │ ├── favicon.ico │ ├── nsis-header.bmp │ ├── nsis-wizard.bmp │ ├── send16.bmp │ ├── send16mask.bmp │ ├── send16masknoshadow.bmp │ ├── send20.bmp │ └── send20mask.bmp ├── qt │ ├── Info.plist.in │ ├── clean_mac_info_plist.py │ ├── extract_strings_qt.py │ ├── img │ │ └── reload.xcf │ ├── make_spinner.py │ ├── make_windows_icon.sh │ └── protobuf.pri ├── setup.nsi.in └── ui.rc └── src ├── .gitignore ├── Makefile.am ├── Makefile.include ├── addrman.cpp ├── addrman.h ├── alert.cpp ├── alert.h ├── allocators.cpp ├── allocators.h ├── base58.h ├── bignum.h ├── bitcoin-cli-res.rc ├── bitcoin-cli.cpp ├── bitcoind-res.rc ├── bitcoind.cpp ├── bitcoinrpc.cpp ├── bitcoinrpc.h ├── bloom.cpp ├── bloom.h ├── chainparams.cpp ├── chainparams.h ├── checkpoints.cpp ├── checkpoints.h ├── checkqueue.h ├── clientversion.h ├── coincontrol.h ├── coins.cpp ├── coins.h ├── compat.h ├── core.cpp ├── core.h ├── crypter.cpp ├── crypter.h ├── db.cpp ├── db.h ├── hash.cpp ├── hash.h ├── init.cpp ├── init.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 ├── leveldb ├── .gitignore ├── AUTHORS ├── LICENSE ├── Makefile ├── NEWS ├── README ├── TODO ├── WINDOWS.md ├── build_detect_platform ├── db │ ├── autocompact_test.cc │ ├── builder.cc │ ├── builder.h │ ├── c.cc │ ├── c_test.c │ ├── corruption_test.cc │ ├── db_bench.cc │ ├── db_impl.cc │ ├── db_impl.h │ ├── db_iter.cc │ ├── db_iter.h │ ├── db_test.cc │ ├── dbformat.cc │ ├── dbformat.h │ ├── dbformat_test.cc │ ├── filename.cc │ ├── filename.h │ ├── filename_test.cc │ ├── leveldb_main.cc │ ├── log_format.h │ ├── log_reader.cc │ ├── log_reader.h │ ├── log_test.cc │ ├── log_writer.cc │ ├── log_writer.h │ ├── memtable.cc │ ├── memtable.h │ ├── repair.cc │ ├── skiplist.h │ ├── skiplist_test.cc │ ├── snapshot.h │ ├── table_cache.cc │ ├── table_cache.h │ ├── version_edit.cc │ ├── version_edit.h │ ├── version_edit_test.cc │ ├── version_set.cc │ ├── version_set.h │ ├── version_set_test.cc │ ├── write_batch.cc │ ├── write_batch_internal.h │ └── write_batch_test.cc ├── doc │ ├── bench │ │ ├── db_bench_sqlite3.cc │ │ └── db_bench_tree_db.cc │ ├── benchmark.html │ ├── doc.css │ ├── impl.html │ ├── index.html │ ├── log_format.txt │ └── table_format.txt ├── helpers │ └── memenv │ │ ├── memenv.cc │ │ ├── memenv.h │ │ └── memenv_test.cc ├── include │ └── leveldb │ │ ├── c.h │ │ ├── cache.h │ │ ├── comparator.h │ │ ├── db.h │ │ ├── env.h │ │ ├── filter_policy.h │ │ ├── iterator.h │ │ ├── options.h │ │ ├── slice.h │ │ ├── status.h │ │ ├── table.h │ │ ├── table_builder.h │ │ └── write_batch.h ├── issues │ └── issue178_test.cc ├── port │ ├── README │ ├── atomic_pointer.h │ ├── port.h │ ├── port_example.h │ ├── port_posix.cc │ ├── port_posix.h │ ├── port_win.cc │ ├── port_win.h │ ├── thread_annotations.h │ └── win │ │ └── stdint.h ├── table │ ├── block.cc │ ├── block.h │ ├── block_builder.cc │ ├── block_builder.h │ ├── filter_block.cc │ ├── filter_block.h │ ├── filter_block_test.cc │ ├── format.cc │ ├── format.h │ ├── iterator.cc │ ├── iterator_wrapper.h │ ├── merger.cc │ ├── merger.h │ ├── table.cc │ ├── table_builder.cc │ ├── table_test.cc │ ├── two_level_iterator.cc │ └── two_level_iterator.h └── util │ ├── arena.cc │ ├── arena.h │ ├── arena_test.cc │ ├── bloom.cc │ ├── bloom_test.cc │ ├── cache.cc │ ├── cache_test.cc │ ├── coding.cc │ ├── coding.h │ ├── coding_test.cc │ ├── comparator.cc │ ├── crc32c.cc │ ├── crc32c.h │ ├── crc32c_test.cc │ ├── env.cc │ ├── env_posix.cc │ ├── env_test.cc │ ├── env_win.cc │ ├── filter_policy.cc │ ├── hash.cc │ ├── hash.h │ ├── histogram.cc │ ├── histogram.h │ ├── logging.cc │ ├── logging.h │ ├── mutexlock.h │ ├── options.cc │ ├── posix_logger.h │ ├── random.h │ ├── status.cc │ ├── testharness.cc │ ├── testharness.h │ ├── testutil.cc │ └── testutil.h ├── leveldbwrapper.cpp ├── leveldbwrapper.h ├── limitedmap.h ├── m4 ├── ax_boost_base.m4 ├── ax_boost_chrono.m4 ├── ax_boost_filesystem.m4 ├── ax_boost_program_options.m4 ├── ax_boost_system.m4 ├── ax_boost_thread.m4 ├── ax_boost_unit_test_framework.m4 ├── ax_check_compile_flag.m4 ├── ax_check_link_flag.m4 ├── ax_check_preproc_flag.m4 ├── ax_pthread.m4 ├── bitcoin_find_bdb48.m4 └── bitcoin_subdir_to_include.m4 ├── main.cpp ├── main.h ├── miner.cpp ├── miner.h ├── mruset.h ├── net.cpp ├── net.h ├── netbase.cpp ├── netbase.h ├── noui.cpp ├── noui.h ├── obj-test └── .gitignore ├── obj └── .gitignore ├── protocol.cpp ├── protocol.h ├── qt ├── Makefile.am ├── 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 ├── coincontroldialog.cpp ├── coincontroldialog.h ├── coincontroltreewidget.cpp ├── coincontroltreewidget.h ├── csvmodelwriter.cpp ├── csvmodelwriter.h ├── editaddressdialog.cpp ├── editaddressdialog.h ├── forms │ ├── aboutdialog.ui │ ├── addressbookpage.ui │ ├── askpassphrasedialog.ui │ ├── coincontroldialog.ui │ ├── editaddressdialog.ui │ ├── intro.ui │ ├── openuridialog.ui │ ├── optionsdialog.ui │ ├── overviewpage.ui │ ├── receivecoinsdialog.ui │ ├── receiverequestdialog.ui │ ├── rpcconsole.ui │ ├── sendcoinsdialog.ui │ ├── sendcoinsentry.ui │ ├── signverifymessagedialog.ui │ └── transactiondescdialog.ui ├── guiconstants.h ├── guiutil.cpp ├── guiutil.h ├── intro.cpp ├── intro.h ├── locale │ ├── bitcoin_ach.ts │ ├── bitcoin_af_ZA.ts │ ├── bitcoin_ar.ts │ ├── bitcoin_be_BY.ts │ ├── bitcoin_bg.ts │ ├── bitcoin_bs.ts │ ├── bitcoin_ca.ts │ ├── bitcoin_ca_ES.ts │ ├── bitcoin_cs.ts │ ├── bitcoin_cy.ts │ ├── bitcoin_da.ts │ ├── bitcoin_de.ts │ ├── bitcoin_de_AT.ts │ ├── bitcoin_el_GR.ts │ ├── bitcoin_en.ts │ ├── bitcoin_eo.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_gl.ts │ ├── bitcoin_gu_IN.ts │ ├── bitcoin_he.ts │ ├── bitcoin_hi_IN.ts │ ├── bitcoin_hr.ts │ ├── bitcoin_hu.ts │ ├── bitcoin_id_ID.ts │ ├── bitcoin_it.ts │ ├── bitcoin_ja.ts │ ├── bitcoin_kk_KZ.ts │ ├── bitcoin_ko_KR.ts │ ├── bitcoin_la.ts │ ├── bitcoin_lt.ts │ ├── bitcoin_lv_LV.ts │ ├── bitcoin_ms_MY.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_sl_SI.ts │ ├── bitcoin_sq.ts │ ├── bitcoin_sr.ts │ ├── bitcoin_sv.ts │ ├── bitcoin_th_TH.ts │ ├── bitcoin_tr.ts │ ├── bitcoin_uk.ts │ ├── bitcoin_vi.ts │ ├── bitcoin_vi_VN.ts │ ├── bitcoin_zh_CN.ts │ └── bitcoin_zh_TW.ts ├── macdockiconhandler.h ├── macdockiconhandler.mm ├── macnotificationhandler.h ├── macnotificationhandler.mm ├── monitoreddatamapper.cpp ├── monitoreddatamapper.h ├── notificator.cpp ├── notificator.h ├── openuridialog.cpp ├── openuridialog.h ├── optionsdialog.cpp ├── optionsdialog.h ├── optionsmodel.cpp ├── optionsmodel.h ├── overviewpage.cpp ├── overviewpage.h ├── paymentrequest.proto ├── paymentrequestplus.cpp ├── paymentrequestplus.h ├── paymentserver.cpp ├── paymentserver.h ├── qvalidatedlineedit.cpp ├── qvalidatedlineedit.h ├── qvaluecombobox.cpp ├── qvaluecombobox.h ├── receivecoinsdialog.cpp ├── receivecoinsdialog.h ├── receiverequestdialog.cpp ├── receiverequestdialog.h ├── res │ ├── bitcoin-qt-res.rc │ ├── icons │ │ ├── add.png │ │ ├── address-book.png │ │ ├── bitcoin.icns │ │ ├── bitcoin.ico │ │ ├── bitcoin.png │ │ ├── bitcoin_testnet.ico │ │ ├── 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_output.png │ ├── images │ │ ├── about.png │ │ ├── splash.png │ │ └── splash_testnet.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 ├── splashscreen.cpp ├── splashscreen.h ├── test │ ├── Makefile.am │ ├── paymentrequestdata.h │ ├── paymentservertests.cpp │ ├── paymentservertests.h │ ├── test_main.cpp │ ├── uritests.cpp │ └── uritests.h ├── trafficgraphwidget.cpp ├── trafficgraphwidget.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 ├── walletframe.cpp ├── walletframe.h ├── walletmodel.cpp ├── walletmodel.h ├── walletmodeltransaction.cpp ├── walletmodeltransaction.h ├── walletview.cpp └── walletview.h ├── rpcblockchain.cpp ├── rpcdump.cpp ├── rpcmining.cpp ├── rpcnet.cpp ├── rpcrawtransaction.cpp ├── rpcwallet.cpp ├── script.cpp ├── script.h ├── serialize.h ├── sync.cpp ├── sync.h ├── test ├── Checkpoints_tests.cpp ├── DoS_tests.cpp ├── Makefile.am ├── README ├── accounting_tests.cpp ├── alert_tests.cpp ├── allocator_tests.cpp ├── base32_tests.cpp ├── base58_tests.cpp ├── base64_tests.cpp ├── bignum_tests.cpp ├── bip32_tests.cpp ├── bloom_tests.cpp ├── canonical_tests.cpp ├── checkblock_tests.cpp ├── compress_tests.cpp ├── data │ ├── alertTests.raw │ ├── base58_encode_decode.json │ ├── base58_keys_invalid.json │ ├── base58_keys_valid.json │ ├── script_invalid.json │ ├── script_valid.json │ ├── sig_canonical.json │ ├── sig_noncanonical.json │ ├── tx_invalid.json │ └── tx_valid.json ├── getarg_tests.cpp ├── hash_tests.cpp ├── hmac_tests.cpp ├── key_tests.cpp ├── miner_tests.cpp ├── mruset_tests.cpp ├── multisig_tests.cpp ├── netbase_tests.cpp ├── pmt_tests.cpp ├── rpc_tests.cpp ├── script_P2SH_tests.cpp ├── script_tests.cpp ├── serialize_tests.cpp ├── sighash_tests.cpp ├── sigopcount_tests.cpp ├── test_bitcoin.cpp ├── transaction_tests.cpp ├── uint160_tests.cpp ├── uint256_tests.cpp ├── util_tests.cpp └── wallet_tests.cpp ├── threadsafety.h ├── txdb.cpp ├── txdb.h ├── txmempool.cpp ├── txmempool.h ├── ui_interface.h ├── uint256.h ├── util.cpp ├── util.h ├── version.cpp ├── version.h ├── wallet.cpp ├── wallet.h ├── walletdb.cpp └── walletdb.h /.gitattributes: -------------------------------------------------------------------------------- 1 | src/version.cpp export-subst 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.tar.gz 2 | 3 | *.exe 4 | src/bitcoin 5 | src/bitcoind 6 | src/bitcoin-cli 7 | src/test/test_bitcoin 8 | src/qt/test/test_bitcoin-qt 9 | 10 | Makefile.in 11 | aclocal.m4 12 | autom4te.cache/ 13 | config.log 14 | config.status 15 | configure 16 | src/bitcoin-config.h 17 | src/bitcoin-config.h.in 18 | src/build-aux/ 19 | src/stamp-h1 20 | share/setup.nsi 21 | share/qt/Info.plist 22 | 23 | src/qt/*.moc 24 | src/qt/moc_*.cpp 25 | src/qt/forms/ui_*.h 26 | 27 | src/qt/test/moc*.cpp 28 | 29 | .deps 30 | .dirstamp 31 | .*.swp 32 | *.*~* 33 | *.bak 34 | *.rej 35 | *.orig 36 | *.o 37 | *.patch 38 | .bitcoin 39 | *.a 40 | *.pb.cc 41 | *.pb.h 42 | 43 | *.log 44 | *.trs 45 | *.dmg 46 | 47 | *.json.h 48 | *.raw.h 49 | 50 | # Compilation and Qt preprocessor part 51 | *.qm 52 | Makefile 53 | bitcoin-qt 54 | Bitcoin-Qt.app 55 | 56 | # Unit-tests 57 | Makefile.test 58 | bitcoin-qt_test 59 | 60 | # Resources cpp 61 | qrc_*.cpp 62 | 63 | # Qt creator 64 | *.pro.user 65 | 66 | # Mac specific 67 | .DS_Store 68 | build 69 | 70 | #lcov 71 | *.gcno 72 | /*.info 73 | test_bitcoin.coverage/ 74 | total.coverage/ 75 | coverage_percent.txt 76 | 77 | #build tests 78 | linux-coverage-build 79 | linux-build 80 | win32-build 81 | qa/pull-tester/run-bitcoind-for-test.sh 82 | qa/pull-tester/build-tests.sh 83 | 84 | !src/leveldb-*/Makefile 85 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2013 Bitcoin Developers 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Building Bitcoin 2 | 3 | See doc/build-*.md for instructions on building bitcoind, 4 | the intended-for-services, no-graphical-interface, reference 5 | implementation of Bitcoin. -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | autoreconf -vif 2 | -------------------------------------------------------------------------------- /contrib/bitcoin-qt.pro: -------------------------------------------------------------------------------- 1 | FORMS += \ 2 | ../src/qt/forms/transactiondescdialog.ui \ 3 | ../src/qt/forms/signverifymessagedialog.ui \ 4 | ../src/qt/forms/sendcoinsentry.ui \ 5 | ../src/qt/forms/sendcoinsdialog.ui \ 6 | ../src/qt/forms/rpcconsole.ui \ 7 | ../src/qt/forms/overviewpage.ui \ 8 | ../src/qt/forms/optionsdialog.ui \ 9 | ../src/qt/forms/intro.ui \ 10 | ../src/qt/forms/editaddressdialog.ui \ 11 | ../src/qt/forms/askpassphrasedialog.ui \ 12 | ../src/qt/forms/addressbookpage.ui \ 13 | ../src/qt/forms/aboutdialog.ui \ 14 | ../src/qt/forms/receivecoinsdialog.ui \ 15 | ../src/qt/forms/receiverequestdialog.ui \ 16 | ../src/qt/forms/openuridialog.ui 17 | 18 | RESOURCES += \ 19 | ../src/qt/bitcoin.qrc 20 | -------------------------------------------------------------------------------- /contrib/bitrpc/README.md: -------------------------------------------------------------------------------- 1 | ### BitRPC ### 2 | Allows for sending of all standard Bitcoin commands via RPC rather than as command line args. -------------------------------------------------------------------------------- /contrib/debian/README.md: -------------------------------------------------------------------------------- 1 | 2 | Debian 3 | ==================== 4 | This directory contains files used to package bitcoind/bitcoin-qt 5 | for Debian-based Linux systems. If you compile bitcoind/bitcoin-qt yourself, there are some useful files here. 6 | 7 | ## bitcoin: URI support ## 8 | 9 | 10 | bitcoin-qt.desktop (Gnome / Open Desktop) 11 | To install: 12 | 13 | sudo desktop-file-install bitcoin-qt.desktop 14 | sudo update-desktop-database 15 | 16 | If you build yourself, you will either need to modify the paths in 17 | the .desktop file or copy or symlink your bitcoin-qt binary to `/usr/bin` 18 | and the `../../share/pixmaps/bitcoin128.png` to `/usr/share/pixmaps` 19 | 20 | bitcoin-qt.protocol (KDE) 21 | 22 | -------------------------------------------------------------------------------- /contrib/debian/bitcoin-qt.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Encoding=UTF-8 3 | Name=Bitcoin 4 | Comment=Bitcoin P2P Cryptocurrency 5 | Comment[fr]=Bitcoin, monnaie virtuelle cryptographique pair à pair 6 | Comment[tr]=Bitcoin, eşten eşe kriptografik sanal para birimi 7 | Exec=/usr/bin/bitcoin-qt %u 8 | Terminal=false 9 | Type=Application 10 | Icon=/usr/share/pixmaps/bitcoin128.png 11 | MimeType=x-scheme-handler/bitcoin; 12 | Categories=Office;Finance; 13 | -------------------------------------------------------------------------------- /contrib/debian/bitcoin-qt.install: -------------------------------------------------------------------------------- 1 | bitcoin-qt usr/bin 2 | share/pixmaps/bitcoin32.xpm usr/share/pixmaps 3 | share/pixmaps/bitcoin16.xpm usr/share/pixmaps 4 | share/pixmaps/bitcoin128.png usr/share/pixmaps 5 | debian/bitcoin-qt.desktop usr/share/applications 6 | debian/bitcoin-qt.protocol usr/share/kde4/services/ 7 | -------------------------------------------------------------------------------- /contrib/debian/bitcoin-qt.lintian-overrides: -------------------------------------------------------------------------------- 1 | # Linked code is Expat - only Debian packaging is GPL-2+ 2 | bitcoin-qt: possible-gpl-code-linked-with-openssl 3 | -------------------------------------------------------------------------------- /contrib/debian/bitcoin-qt.protocol: -------------------------------------------------------------------------------- 1 | [Protocol] 2 | exec=bitcoin-qt '%u' 3 | protocol=bitcoin 4 | input=none 5 | output=none 6 | helper=true 7 | listing= 8 | reading=false 9 | writing=false 10 | makedir=false 11 | deleting=false 12 | -------------------------------------------------------------------------------- /contrib/debian/bitcoind.bash-completion: -------------------------------------------------------------------------------- 1 | contrib/bitcoind.bash-completion bitcoind 2 | -------------------------------------------------------------------------------- /contrib/debian/bitcoind.examples: -------------------------------------------------------------------------------- 1 | debian/examples/bitcoin.conf 2 | -------------------------------------------------------------------------------- /contrib/debian/bitcoind.install: -------------------------------------------------------------------------------- 1 | src/bitcoind usr/bin 2 | -------------------------------------------------------------------------------- /contrib/debian/bitcoind.lintian-overrides: -------------------------------------------------------------------------------- 1 | # Linked code is Expat - only Debian packaging is GPL-2+ 2 | bitcoind: possible-gpl-code-linked-with-openssl 3 | -------------------------------------------------------------------------------- /contrib/debian/bitcoind.manpages: -------------------------------------------------------------------------------- 1 | debian/manpages/bitcoind.1 2 | debian/manpages/bitcoin.conf.5 3 | -------------------------------------------------------------------------------- /contrib/debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /contrib/debian/gbp.conf: -------------------------------------------------------------------------------- 1 | # Configuration file for git-buildpackage and friends 2 | 3 | [DEFAULT] 4 | pristine-tar = True 5 | sign-tags = True 6 | -------------------------------------------------------------------------------- /contrib/debian/patches/README: -------------------------------------------------------------------------------- 1 | 0xxx: Grabbed from upstream development. 2 | 1xxx: Possibly relevant for upstream adoption. 3 | 2xxx: Only relevant for official Debian release. 4 | -------------------------------------------------------------------------------- /contrib/debian/patches/series: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /contrib/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- mode: makefile; coding: utf-8 -*- 3 | 4 | #DEB_MAKE_CHECK_TARGET = test_bitcoin 5 | #build/bitcoind:: 6 | # $(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),,src/test_bitcoin) 7 | 8 | DEB_INSTALL_EXAMPLES_bitcoind += debian/examples/* 9 | DEB_INSTALL_MANPAGES_bitcoind += debian/manpages/* 10 | 11 | %: 12 | dh --with bash-completion $@ 13 | 14 | override_dh_auto_build: 15 | cd src; $(MAKE) -f makefile.unix bitcoind 16 | $(MAKE) 17 | 18 | override_dh_auto_clean: 19 | if [ -f Makefile ]; then $(MAKE) clean; else rm -rf build/; rm -f bitcoin-qt; fi 20 | cd src; $(MAKE) -f makefile.unix clean 21 | 22 | override_dh_auto_configure: 23 | qmake bitcoin-qt.pro USE_QRCODE=1 24 | 25 | override_dh_auto_test: 26 | cd src; $(MAKE) -f makefile.unix test_bitcoin 27 | src/test_bitcoin 28 | 29 | # Ensure wrapper is set executable 30 | binary-post-install/bitcoind: 31 | chmod +x $(cdbs_curdestdir)usr/bin/bitcoind 32 | binary-post-install/bitcoin-qt: 33 | chmod +x $(cdbs_curdestdir)usr/bin/bitcoin-qt 34 | -------------------------------------------------------------------------------- /contrib/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /contrib/debian/watch: -------------------------------------------------------------------------------- 1 | # Run the "uscan" command to check for upstream updates and more. 2 | version=3 3 | # use qa.debian.org redirector; see man uscan 4 | opts=uversionmangle=s/(\d)(alpha|beta|rc)/$1~$2/;s/\-src//,dversionmangle=s/~dfsg\d*// \ 5 | http://sf.net/bitcoin/bitcoin-(\d.*)-linux\.tar\.gz debian 6 | opts=uversionmangle=s/(\d)(alpha|beta|rc)/$1~$2/,dversionmangle=s/~dfsg\d*// \ 7 | http://githubredir.debian.net/github/bitcoin/bitcoin v(.*).tar.gz 8 | -------------------------------------------------------------------------------- /contrib/gitian-descriptors/protobuf-win32.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "protobuf-win32" 3 | suites: 4 | - "precise" 5 | architectures: 6 | - "amd64" 7 | packages: 8 | - "mingw-w64" 9 | - "g++-mingw-w64" 10 | - "zip" 11 | - "faketime" 12 | reference_datetime: "2013-04-15 00:00:00" 13 | remotes: [] 14 | files: 15 | - "protobuf-2.5.0.tar.bz2" 16 | script: | 17 | # 18 | export TZ=UTC 19 | export INSTALLPREFIX=$OUTDIR/staging/deps 20 | export HOST=i686-w64-mingw32 21 | # Integrity Check 22 | echo "13bfc5ae543cf3aa180ac2485c0bc89495e3ae711fc6fab4f8ffe90dfb4bb677 protobuf-2.5.0.tar.bz2" | sha256sum -c 23 | 24 | # 25 | mkdir -p $INSTALLPREFIX 26 | 27 | tar xjf protobuf-2.5.0.tar.bz2 28 | cd protobuf-2.5.0 29 | # First: build a native (linux) protoc 30 | ./configure --enable-shared=no --disable-dependency-tracking 31 | make 32 | mkdir -p $INSTALLPREFIX/host/bin 33 | cp src/protoc $INSTALLPREFIX/host/bin 34 | # Now recompile with the mingw cross-compiler: 35 | make distclean 36 | ./configure --prefix=$INSTALLPREFIX --enable-shared=no --disable-dependency-tracking --with-protoc=$INSTALLPREFIX/host/bin/protoc --host=$HOST CXXFLAGS=-frandom-seed=11 37 | make 38 | make install 39 | cd $INSTALLPREFIX 40 | export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 41 | export FAKETIME=$REFERENCE_DATETIME 42 | zip -r $OUTDIR/protobuf-win32-2.5.0-gitian-r3.zip include lib host 43 | unset LD_PRELOAD 44 | unset FAKETIME 45 | -------------------------------------------------------------------------------- /contrib/gitian-downloader/bluematt-key.pgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/contrib/gitian-downloader/bluematt-key.pgp -------------------------------------------------------------------------------- /contrib/gitian-downloader/devrandom-key.pgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/contrib/gitian-downloader/devrandom-key.pgp -------------------------------------------------------------------------------- /contrib/gitian-downloader/gavinandresen-key.pgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/contrib/gitian-downloader/gavinandresen-key.pgp -------------------------------------------------------------------------------- /contrib/gitian-downloader/laanwj-key.pgp: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: SKS 1.1.0 3 | 4 | mQENBE5UtMEBCADOUz2i9l/D8xYINCmfUDnxi+DXvX5LmZ39ZdvsoE+ugO0SRRGdIHEFO2is 5 | 0xezX50wXu9aneb+tEqM0BuiLo6VxaXpxrkxHpr6c4jf37SkE/H0qsi/txEUp7337y3+4HMG 6 | lUjiuh802I72p1qusjsKBnmnnR0rwNouTcoDmGUDh7jpKCtzFv+2TR2dRthJn7vmmjq3+bG6 7 | PYfqoFY1yHrAGT1lrDBULZsQ/NBLI2+J4oo2LYv3GCq8GNnzrovqvTvui50VSROhLrOe58o2 8 | shE+sjQShAy5wYkPt1R1fQnpfx+5vf+TPnkxVwRb3h5GhCp0YL8XC/BXsd5vM4KlVH2rABEB 9 | AAG0K1dsYWRpbWlyIEouIHZhbiBkZXIgTGFhbiA8bGFhbndqQGdtYWlsLmNvbT6JATgEEwEC 10 | ACIFAk5UtMECGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEHSBCwEjRsmmy6YIAK09 11 | buNXyYQrJBsX16sXxEhx5QPKyF3uHJDFJv66SdnpvIkNoznsaPiRJkbTANop93FZmaGa6wVn 12 | zGDiz7jPA8Dpxx5aAYPhIT+zPJAdXWM3wJ/Gio9besRNzniai8Lwi5MZ9R/5yFGBobm6/AcN 13 | 4sUoqA3NSV2U3I29R0Vwlzo8GVtmyi9ENSi6Oo7AcXNTRt69cxW4nAHkB+amwwDJlcAb31ex 14 | bogYXPhScwqQZixRr+JBkKxBjkTXXnQypT4KI5SegYwQVYfyiZmDP7UHKe/u6pSKKbVphLg8 15 | xLB5spcXse8/a2+onrbNlw6y8TXiJ++Z54PE7zztWTXf2huakeG5AQ0ETlS0wQEIAMNO3OkP 16 | xoPRKWzBLcI7JRITAW+HNaLTq3uN2+4WxA57DEjbL9EDoAv+7wTkDAL40f0T+xiu6GJcLFjw 17 | GJZu/tYu7+mErHjrdo+K4suCQt7w5EXCBvOLjhW4tyYMzNx8hP+oqzOW9iEC+6VV91+DYeqt 18 | EkJuyVXOI4vzBlTw8uGow8aMMsCq8XVvKUZFTPsjGl197Q5B3A+ZOFCR8xqiqdPjuz6MglVV 19 | oFdDNu3EZn8zkGsQlovXoE9ndVeVzx/XMNmsxFaMYsReUs253RIf1FEfgExID0fg2OnyLCjS 20 | 2iFW1RgajS+/saIkKl+N1iuMzJA7wMAM0plhRueOG0MtZSsAEQEAAYkBHwQYAQIACQUCTlS0 21 | wQIbDAAKCRB0gQsBI0bJpmsDB/4waenn2CvSHXyomykfpwf5lMte1V5LvH3z5R2LY+1NopRv 22 | LSz3iC39x69XWiTbhywDfgafnGPW4pWBOff2/bu5/A6z1Hnan1vyrRRD/hx1uMJ7S6q+bIvZ 23 | iVIg1p0jH6tdIIhwX3cydhdRZHo7e9oSMgOUWsr6Ar59NRo9CENwGPE4U61HXfOnxWdrFWoA 24 | XdwZczBeLxmUy6Vo6sKqv+gE4bqrtAM0sY/MsQ9cU95x+52ox/sq44lQMwd3ZBYUP7B1qbHI 25 | hZSZuch6MLi5scLPeau0ZvCaljiaMeivP5+x0gWPRs0kI+9sZxInbqvrsJ6oOBJM3xYGhtn1 26 | zZ7qmZR7 27 | =si/k 28 | -----END PGP PUBLIC KEY BLOCK----- 29 | -------------------------------------------------------------------------------- /contrib/gitian-downloader/linux-download-config: -------------------------------------------------------------------------------- 1 | --- 2 | name: bitcoin 3 | urls: 4 | - http://bitcoin.org/bitcoin-latest-linux-gitian.zip 5 | rss: 6 | - url: http://sourceforge.net/api/file/index/project-id/244765/mtime/desc/limit/100/rss 7 | xpath: //item/link/text() 8 | pattern: bitcoin-\d+.\d+.\d+-linux-gitian.zip 9 | signers: 10 | 0A82509767C7D4A5D14DA2301AE1D35043E08E54: 11 | weight: 40 12 | name: BlueMatt 13 | key: bluematt 14 | BF6273FAEF7CC0BA1F562E50989F6B3048A116B5: 15 | weight: 40 16 | name: Devrandom 17 | key: devrandom 18 | E463A93F5F3117EEDE6C7316BD02942421F4889F: 19 | weight: 40 20 | name: Luke-Jr 21 | key: luke-jr 22 | D762373D24904A3E42F33B08B9A408E71DAAC974: 23 | weight: 40 24 | name: "Pieter Wuille" 25 | key: sipa 26 | 77E72E69DA7EE0A148C06B21B34821D4944DE5F7: 27 | weight: 40 28 | name: tcatm 29 | key: tcatm 30 | 01CDF4627A3B88AAE4A571C87588242FBE38D3A8: 31 | weight: 40 32 | name: "Gavin Andresen" 33 | key: gavinandresen 34 | 71A3B16735405025D447E8F274810B012346C9A6: 35 | weight: 40 36 | name: "Wladimir J. van der Laan" 37 | key: laanwj 38 | AEC1884398647C47413C1C3FB1179EB7347DC10D: 39 | weight: 40 40 | name: "Warren Togami" 41 | key: wtogami 42 | 9692B91BBF0E8D34DFD33B1882C5C009628ECF0C: 43 | weight: 1 44 | name: michagogo 45 | key: michagogo 46 | minimum_weight: 120 47 | -------------------------------------------------------------------------------- /contrib/gitian-downloader/luke-jr-key.pgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/contrib/gitian-downloader/luke-jr-key.pgp -------------------------------------------------------------------------------- /contrib/gitian-downloader/sipa-key.pgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/contrib/gitian-downloader/sipa-key.pgp -------------------------------------------------------------------------------- /contrib/gitian-downloader/tcatm-key.pgp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/contrib/gitian-downloader/tcatm-key.pgp -------------------------------------------------------------------------------- /contrib/gitian-downloader/win32-download-config: -------------------------------------------------------------------------------- 1 | --- 2 | name: bitcoin 3 | urls: 4 | - http://bitcoin.org/bitcoin-latest-win32-gitian.zip 5 | rss: 6 | - url: http://sourceforge.net/api/file/index/project-id/244765/mtime/desc/limit/100/rss 7 | xpath: //item/link/text() 8 | pattern: bitcoin-\d+.\d+.\d+-win32-gitian.zip 9 | signers: 10 | 0A82509767C7D4A5D14DA2301AE1D35043E08E54: 11 | weight: 40 12 | name: BlueMatt 13 | key: bluematt 14 | BF6273FAEF7CC0BA1F562E50989F6B3048A116B5: 15 | weight: 40 16 | name: Devrandom 17 | key: devrandom 18 | E463A93F5F3117EEDE6C7316BD02942421F4889F: 19 | weight: 40 20 | name: Luke-Jr 21 | key: luke-jr 22 | D762373D24904A3E42F33B08B9A408E71DAAC974: 23 | weight: 40 24 | name: "Pieter Wuille" 25 | key: sipa 26 | 77E72E69DA7EE0A148C06B21B34821D4944DE5F7: 27 | weight: 40 28 | name: tcatm 29 | key: tcatm 30 | 01CDF4627A3B88AAE4A571C87588242FBE38D3A8: 31 | weight: 40 32 | name: "Gavin Andresen" 33 | key: gavinandresen 34 | 71A3B16735405025D447E8F274810B012346C9A6: 35 | weight: 40 36 | name: "Wladimir J. van der Laan" 37 | key: laanwj 38 | AEC1884398647C47413C1C3FB1179EB7347DC10D: 39 | weight: 40 40 | name: "Warren Togami" 41 | key: wtogami 42 | 9692B91BBF0E8D34DFD33B1882C5C009628ECF0C: 43 | weight: 1 44 | name: michagogo 45 | key: michagogo 46 | minimum_weight: 120 47 | -------------------------------------------------------------------------------- /contrib/linearize/README.md: -------------------------------------------------------------------------------- 1 | ### Linearize ### 2 | Construct a linear, no-fork, best version of the blockchain. -------------------------------------------------------------------------------- /contrib/linearize/example-linearize.cfg: -------------------------------------------------------------------------------- 1 | 2 | # bitcoind RPC settings 3 | rpcuser=someuser 4 | rpcpass=somepassword 5 | host=127.0.0.1 6 | port=8332 7 | 8 | # bootstrap.dat settings 9 | netmagic=f9beb4d9 10 | max_height=250000 11 | output=bootstrap.dat 12 | 13 | -------------------------------------------------------------------------------- /contrib/macdeploy/README.md: -------------------------------------------------------------------------------- 1 | ### MacDeploy ### 2 | 3 | You will need the appscript package for the fancy disk image creation to work: 4 | 5 | sudo easy_install appscript 6 | 7 | For Snow Leopard (which uses [Python 2.6](http://www.python.org/download/releases/2.6/)), you will need the param_parser package: 8 | 9 | sudo easy_install argparse 10 | 11 | This script should not be run manually, instead, after building as usual: 12 | 13 | make deploy 14 | 15 | During the process, the disk image window will pop up briefly where the fancy 16 | settings are applied. This is normal, please do not interfere. 17 | 18 | When finished, it will produce `Bitcoin-Qt.dmg`. 19 | 20 | -------------------------------------------------------------------------------- /contrib/macdeploy/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/contrib/macdeploy/background.png -------------------------------------------------------------------------------- /contrib/macdeploy/background.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/contrib/macdeploy/background.psd -------------------------------------------------------------------------------- /contrib/macdeploy/fancy.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | window_bounds 6 | 7 | 300 8 | 300 9 | 800 10 | 620 11 | 12 | background_picture 13 | background.png 14 | icon_size 15 | 96 16 | applications_symlink 17 | 18 | items_position 19 | 20 | Applications 21 | 22 | 370 23 | 156 24 | 25 | Bitcoin-Qt.app 26 | 27 | 128 28 | 156 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /contrib/pyminer/README.md: -------------------------------------------------------------------------------- 1 | ### PyMiner ### 2 | 3 | This is a 'getwork' CPU mining client for Bitcoin. It is pure-python, and therefore very, very slow. The purpose is to provide a reference implementation of a miner, for study. 4 | 5 | ### Other Resources ### 6 | 7 | - [BitcoinTalk Thread](https://bitcointalk.org/index.php?topic=3546.0) 8 | - [Jgarzik Repo](https://github.com/jgarzik/pyminer) -------------------------------------------------------------------------------- /contrib/pyminer/example-config.cfg: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # RPC login details 4 | # 5 | host=127.0.0.1 6 | port=8332 7 | 8 | rpcuser=myusername 9 | rpcpass=mypass 10 | 11 | 12 | # 13 | # mining details 14 | # 15 | 16 | threads=4 17 | 18 | # periodic rate for requesting new work, if solution not found 19 | scantime=60 20 | 21 | 22 | # 23 | # misc. 24 | # 25 | 26 | # not really used right now 27 | logdir=/tmp/pyminer 28 | 29 | # set to 1, to enable hashmeter output 30 | hashmeter=0 31 | 32 | 33 | -------------------------------------------------------------------------------- /contrib/qos/README.md: -------------------------------------------------------------------------------- 1 | ### Qos ### 2 | 3 | This is a Linux bash script that will set up tc to limit the outgoing bandwidth for connections to the Bitcoin network. It limits outbound TCP traffic with a source or destination port of 8333, but not if the destination IP is within a LAN (defined as 192.168.x.x). 4 | 5 | This means one can have an always-on bitcoind instance running, and another local bitcoind/bitcoin-qt instance which connects to this node and receives blocks from it. 6 | -------------------------------------------------------------------------------- /contrib/qos/tc.sh: -------------------------------------------------------------------------------- 1 | #network interface on which to limit traffic 2 | IF="eth0" 3 | #limit of the network interface in question 4 | LINKCEIL="1gbit" 5 | #limit outbound Bitcoin protocol traffic to this rate 6 | LIMIT="160kbit" 7 | #defines the address space for which you wish to disable rate limiting 8 | LOCALNET="192.168.0.0/16" 9 | 10 | #delete existing rules 11 | tc qdisc del dev ${IF} root 12 | 13 | #add root class 14 | tc qdisc add dev ${IF} root handle 1: htb default 10 15 | 16 | #add parent class 17 | tc class add dev ${IF} parent 1: classid 1:1 htb rate ${LINKCEIL} ceil ${LINKCEIL} 18 | 19 | #add our two classes. one unlimited, another limited 20 | tc class add dev ${IF} parent 1:1 classid 1:10 htb rate ${LINKCEIL} ceil ${LINKCEIL} prio 0 21 | tc class add dev ${IF} parent 1:1 classid 1:11 htb rate ${LIMIT} ceil ${LIMIT} prio 1 22 | 23 | #add handles to our classes so packets marked with go into the class with "... handle fw ..." 24 | tc filter add dev ${IF} parent 1: protocol ip prio 1 handle 1 fw classid 1:10 25 | tc filter add dev ${IF} parent 1: protocol ip prio 2 handle 2 fw classid 1:11 26 | 27 | #delete any existing rules 28 | #disable for now 29 | #ret=0 30 | #while [ $ret -eq 0 ]; do 31 | # iptables -t mangle -D OUTPUT 1 32 | # ret=$? 33 | #done 34 | 35 | #limit outgoing traffic to and from port 8333. but not when dealing with a host on the local network 36 | # (defined by $LOCALNET) 37 | # --set-mark marks packages matching these criteria with the number "2" 38 | # these packages are filtered by the tc filter with "handle 2" 39 | # this filter sends the packages into the 1:11 class, and this class is limited to ${LIMIT} 40 | iptables -t mangle -A OUTPUT -p tcp -m tcp --dport 8333 ! -d ${LOCALNET} -j MARK --set-mark 0x2 41 | iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 8333 ! -d ${LOCALNET} -j MARK --set-mark 0x2 42 | -------------------------------------------------------------------------------- /contrib/qt_translations.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Helpful little script that spits out a comma-separated list of 4 | # language codes for Qt icons that should be included 5 | # in binary bitcoin distributions 6 | 7 | import glob 8 | import os 9 | import re 10 | import sys 11 | 12 | if len(sys.argv) != 3: 13 | sys.exit("Usage: %s $QTDIR/translations $BITCOINDIR/src/qt/locale"%sys.argv[0]) 14 | 15 | d1 = sys.argv[1] 16 | d2 = sys.argv[2] 17 | 18 | l1 = set([ re.search(r'qt_(.*).qm', f).group(1) for f in glob.glob(os.path.join(d1, 'qt_*.qm')) ]) 19 | l2 = set([ re.search(r'bitcoin_(.*).qm', f).group(1) for f in glob.glob(os.path.join(d2, 'bitcoin_*.qm')) ]) 20 | 21 | print ",".join(sorted(l1.intersection(l2))) 22 | 23 | -------------------------------------------------------------------------------- /contrib/seeds/README.md: -------------------------------------------------------------------------------- 1 | ### Seeds ### 2 | 3 | Utility to generate the pnSeed[] array that is compiled into the client 4 | (see [src/net.cpp](/src/net.cpp)). 5 | 6 | The 600 seeds compiled into the 0.8 release were created from sipa's DNS seed data, like this: 7 | 8 | curl -s http://bitcoin.sipa.be/seeds.txt | head -1000 | makeseeds.py 9 | 10 | The input to makeseeds.py is assumed to be approximately sorted from most-reliable to least-reliable, 11 | with IP:port first on each line (lines that don't match IPv4:port are ignored). 12 | -------------------------------------------------------------------------------- /contrib/seeds/makeseeds.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Generate pnSeed[] from Pieter's DNS seeder 4 | # 5 | 6 | NSEEDS=600 7 | 8 | import re 9 | import sys 10 | from subprocess import check_output 11 | 12 | def main(): 13 | lines = sys.stdin.readlines() 14 | 15 | ips = [] 16 | pattern = re.compile(r"^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}):8333") 17 | for line in lines: 18 | m = pattern.match(line) 19 | if m is None: 20 | continue 21 | ip = 0 22 | for i in range(0,4): 23 | ip = ip + (int(m.group(i+1)) << (8*(i))) 24 | if ip == 0: 25 | continue 26 | ips.append(ip) 27 | 28 | for row in range(0, min(NSEEDS,len(ips)), 8): 29 | print " " + ", ".join([ "0x%08x"%i for i in ips[row:row+8] ]) + "," 30 | 31 | if __name__ == '__main__': 32 | main() 33 | -------------------------------------------------------------------------------- /contrib/spendfrom/README.md: -------------------------------------------------------------------------------- 1 | ### SpendFrom ### 2 | 3 | Use the raw transactions API to send coins received on a particular 4 | address (or addresses). 5 | 6 | ### Usage: ### 7 | Depends on [jsonrpc](http://json-rpc.org/). 8 | 9 | spendfrom.py --from=FROMADDRESS1[,FROMADDRESS2] --to=TOADDRESS --amount=amount \ 10 | --fee=fee --datadir=/path/to/.bitcoin --testnet --dry_run 11 | 12 | With no arguments, outputs a list of amounts associated with addresses. 13 | 14 | With arguments, sends coins received by the `FROMADDRESS` addresses to the `TOADDRESS`. 15 | 16 | ### Notes ### 17 | 18 | - You may explictly specify how much fee to pay (a fee more than 1% of the amount 19 | will fail, though, to prevent bitcoin-losing accidents). Spendfrom may fail if 20 | it thinks the transaction would never be confirmed (if the amount being sent is 21 | too small, or if the transaction is too many bytes for the fee). 22 | 23 | - If a change output needs to be created, the change will be sent to the last 24 | `FROMADDRESS` (if you specify just one `FROMADDRESS`, change will go back to it). 25 | 26 | - If `--datadir` is not specified, the default datadir is used. 27 | 28 | - The `--dry_run` option will just create and sign the the transaction and print 29 | the transaction data (as hexadecimal), instead of broadcasting it. 30 | 31 | - If the transaction is created and broadcast successfully, a transaction id 32 | is printed. 33 | 34 | - If this was a tool for end-users and not programmers, it would have much friendlier 35 | error-handling. 36 | -------------------------------------------------------------------------------- /contrib/spendfrom/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | setup(name='btcspendfrom', 3 | version='1.0', 4 | description='Command-line utility for bitcoin "coin control"', 5 | author='Gavin Andresen', 6 | author_email='gavin@bitcoinfoundation.org', 7 | requires=['jsonrpc'], 8 | scripts=['spendfrom.py'], 9 | ) 10 | -------------------------------------------------------------------------------- /contrib/test-patches/README.md: -------------------------------------------------------------------------------- 1 | ### Test Patches ### 2 | 3 | These patches are applied when the automated pull-tester 4 | tests each pull and when master is tested using jenkins. 5 | You can find more information about the tests run at 6 | [http://jenkins.bluematt.me/pull-tester/files/ 7 | ](http://jenkins.bluematt.me/pull-tester/files/) -------------------------------------------------------------------------------- /contrib/test-patches/temp-revert-2.patch: -------------------------------------------------------------------------------- 1 | commit cfae26916dba311f6f75d444301c1f9362267c3e 2 | Author: Matt Corallo 3 | Date: Sun Mar 24 20:45:50 2013 -0400 4 | 5 | Revert "Checkpoint at first block in 11 March chain fork" 6 | 7 | This reverts commit f817c496a1482d05b22c8e539de67f07db1c09d9. 8 | 9 | diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp 10 | index 62234b9..9b11f0b 100644 11 | --- a/src/checkpoints.cpp 12 | +++ b/src/checkpoints.cpp 13 | @@ -44,7 +44,6 @@ namespace Checkpoints 14 | (193000, uint256("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317")) 15 | (210000, uint256("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e")) 16 | (216116, uint256("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e")) 17 | - (225430, uint256("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932")) 18 | ; 19 | static const CCheckpointData data = { 20 | &mapCheckpoints, 21 | -------------------------------------------------------------------------------- /contrib/testgen/README.md: -------------------------------------------------------------------------------- 1 | ### TestGen ### 2 | 3 | Utilities to generate test vectors for the data-driven Bitcoin tests. 4 | 5 | Usage: 6 | 7 | gen_base58_test_vectors.py valid 50 > ../../src/test/data/base58_keys_valid.json 8 | gen_base58_test_vectors.py invalid 50 > ../../src/test/data/base58_keys_invalid.json -------------------------------------------------------------------------------- /contrib/tidy_datadir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d "$1" ]; then 4 | cd "$1" 5 | else 6 | echo "Usage: $0 " >&2 7 | echo "Removes obsolete Bitcoin database files" >&2 8 | exit 1 9 | fi 10 | 11 | LEVEL=0 12 | if [ -f wallet.dat -a -f addr.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=1; fi 13 | if [ -f wallet.dat -a -f peers.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=2; fi 14 | if [ -f wallet.dat -a -f peers.dat -a -f coins/CURRENT -a -f blktree/CURRENT -a -f blocks/blk00000.dat ]; then LEVEL=3; fi 15 | if [ -f wallet.dat -a -f peers.dat -a -f chainstate/CURRENT -a -f blocks/index/CURRENT -a -f blocks/blk00000.dat ]; then LEVEL=4; fi 16 | 17 | case $LEVEL in 18 | 0) 19 | echo "Error: no Bitcoin datadir detected." 20 | exit 1 21 | ;; 22 | 1) 23 | echo "Detected old Bitcoin datadir (before 0.7)." 24 | echo "Nothing to do." 25 | exit 0 26 | ;; 27 | 2) 28 | echo "Detected Bitcoin 0.7 datadir." 29 | ;; 30 | 3) 31 | echo "Detected Bitcoin pre-0.8 datadir." 32 | ;; 33 | 4) 34 | echo "Detected Bitcoin 0.8 datadir." 35 | ;; 36 | esac 37 | 38 | FILES="" 39 | DIRS="" 40 | 41 | if [ $LEVEL -ge 3 ]; then FILES=$(echo $FILES blk????.dat blkindex.dat); fi 42 | if [ $LEVEL -ge 2 ]; then FILES=$(echo $FILES addr.dat); fi 43 | if [ $LEVEL -ge 4 ]; then DIRS=$(echo $DIRS coins blktree); fi 44 | 45 | for FILE in $FILES; do 46 | if [ -f $FILE ]; then 47 | echo "Deleting: $FILE" 48 | rm -f $FILE 49 | fi 50 | done 51 | 52 | for DIR in $DIRS; do 53 | if [ -d $DIR ]; then 54 | echo "Deleting: $DIR/" 55 | rm -rf $DIR 56 | fi 57 | done 58 | 59 | echo "Done." 60 | -------------------------------------------------------------------------------- /contrib/verifysfbinaries/README.md: -------------------------------------------------------------------------------- 1 | ### Verify SF Binaries ### 2 | This script attempts to download the signature file `SHA256SUMS.asc` from SourceForge. 3 | 4 | It first checks if the signature passes, and then downloads the files specified in the file, and checks if the hashes of these files match those that are specified in the signature file. 5 | 6 | The script returns 0 if everything passes the checks. It returns 1 if either the signature check or the hash check doesn't pass. If an error occurs the return value is 2. -------------------------------------------------------------------------------- /contrib/wallettools/README.md: -------------------------------------------------------------------------------- 1 | ### Wallet Tools ### 2 | These are two simple python scripts which send the appropriate RPC commands to unlock a wallet and change a wallet password. **They are intended to prevent users from having to enter their password as a command-line argument which could then be stored in the console buffer/history in plaintext.** 3 | 4 | Both tools rely on bitcoin/bitcoind running with `server=1` and an `rpcuser` and `rpcpassword` set in `bitcoin.conf`. They can be easily modified for non-standard ports. [walletunlock.py](/contrib/wallettools/walletunlock.py) unlocks the wallet for 60 seconds by default, changeable in code, and both modules rely upon python-json-rpc. 5 | -------------------------------------------------------------------------------- /contrib/wallettools/walletchangepass.py: -------------------------------------------------------------------------------- 1 | from jsonrpc import ServiceProxy 2 | access = ServiceProxy("http://127.0.0.1:8332") 3 | pwd = raw_input("Enter old wallet passphrase: ") 4 | pwd2 = raw_input("Enter new wallet passphrase: ") 5 | access.walletpassphrasechange(pwd, pwd2) -------------------------------------------------------------------------------- /contrib/wallettools/walletunlock.py: -------------------------------------------------------------------------------- 1 | from jsonrpc import ServiceProxy 2 | access = ServiceProxy("http://127.0.0.1:8332") 3 | pwd = raw_input("Enter wallet passphrase: ") 4 | access.walletpassphrase(pwd, 60) -------------------------------------------------------------------------------- /doc/README_windows.txt: -------------------------------------------------------------------------------- 1 | Bitcoin 0.8.2 BETA 2 | 3 | Copyright (c) 2009-2013 Bitcoin Developers 4 | Distributed under the MIT/X11 software license, see the accompanying 5 | file COPYING 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-qt.exe. 22 | 23 | Bitcoin-Qt is the original Bitcoin client and it builds the backbone of the network. 24 | However, it downloads and stores the entire history of Bitcoin transactions; 25 | depending on the speed of your computer and network connection, the synchronization 26 | process can take anywhere from a few hours to a day or more. 27 | 28 | See the bitcoin wiki at: 29 | https://en.bitcoin.it/wiki/Main_Page 30 | for more help and information. 31 | -------------------------------------------------------------------------------- /doc/bitcoin_logo_doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/doc/bitcoin_logo_doxygen.png -------------------------------------------------------------------------------- /doc/files.md: -------------------------------------------------------------------------------- 1 | Used in 0.8.0 2 | --------------------- 3 | * wallet.dat: personal wallet (BDB) with keys and transactions 4 | * peers.dat: peer IP address database (custom format); since 0.7.0 5 | * blocks/blk000??.dat: block data (custom, 128 MiB per file); since 0.8.0 6 | * blocks/rev000??.dat; block undo data (custom); since 0.8.0 (format changed since pre-0.8) 7 | * blocks/index/*; block index (LevelDB); since 0.8.0 8 | * chainstate/*; block chain state database (LevelDB); since 0.8.0 9 | * database/*: BDB database environment; only used for wallet since 0.8.0 10 | 11 | Only used in pre-0.8.0 12 | --------------------- 13 | * blktree/*; block chain index (LevelDB); since pre-0.8, replaced by blocks/index/* in 0.8.0 14 | * coins/*; unspent transaction output database (LevelDB); since pre-0.8, replaced by chainstate/* in 0.8.0 15 | 16 | Only used before 0.8.0 17 | --------------------- 18 | * blkindex.dat: block chain index database (BDB); replaced by {chainstate/*,blocks/index/*,blocks/rev000??.dat} in 0.8.0 19 | * blk000?.dat: block data (custom, 2 GiB per file); replaced by blocks/blk000??.dat in 0.8.0 20 | 21 | Only used before 0.7.0 22 | --------------------- 23 | * addr.dat: peer IP address database (BDB); replaced by peers.dat in 0.7.0 24 | -------------------------------------------------------------------------------- /doc/release-notes.md: -------------------------------------------------------------------------------- 1 | (note: this is a temporary file, to be added-to by anybody, and deleted at 2 | release time) 3 | 4 | -------------------------------------------------------------------------------- /doc/unit-tests.md: -------------------------------------------------------------------------------- 1 | Compiling/running unit tests 2 | ------------------------------------ 3 | 4 | Unit tests will be automatically compiled if dependencies were met in configure 5 | and tests weren't explicitly disabled. 6 | 7 | After configuring, they can be run with 'make check'. 8 | 9 | To run the bitcoind tests manually, launch src/test/test_bitcoin . 10 | 11 | To add more bitcoind tests, add `BOOST_AUTO_TEST_CASE` functions to the existing 12 | .cpp files in the test/ directory or add new .cpp files that 13 | implement new BOOST_AUTO_TEST_SUITE sections. 14 | 15 | To run the bitcoin-qt tests manualy, launch src/qt/test/bitcoin-qt_test 16 | 17 | To add more bitcoin-qt tests, add them to the `src/qt/test/` directory and 18 | the `src/qt/test/test_main.cpp` file. 19 | -------------------------------------------------------------------------------- /qa/pull-tester/pull-tester.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Helper script for pull-tester. 3 | #Param 1: path to bitcoin srcroot 4 | #Param ...: arguments for build-test.sh 5 | 6 | if [ $# -lt 1 ]; then 7 | echo "usage: $0 [bitcoin srcroot] build-test arguments..." 8 | fi 9 | 10 | cd $1 11 | shift 12 | 13 | ./autogen.sh 14 | ./configure 15 | ./qa/pull-tester/build-tests.sh "$@" 16 | -------------------------------------------------------------------------------- /qa/pull-tester/run-bitcoind-for-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DATADIR="@abs_top_builddir@/.bitcoin" 3 | rm -rf "$DATADIR" 4 | mkdir -p "$DATADIR"/regtest 5 | touch "$DATADIR/regtest/debug.log" 6 | tail -q -n 1 -F "$DATADIR/regtest/debug.log" | grep -m 1 -q "Done loading" & 7 | WAITER=$! 8 | PORT=`expr $BASHPID + 10000` 9 | "@abs_top_builddir@/src/bitcoind@EXEEXT@" -connect=0.0.0.0 -datadir="$DATADIR" -rpcuser=user -rpcpassword=pass -listen -keypool=3 -debug -debug=net -logtimestamps -port=$PORT -regtest -rpcport=`expr $PORT + 1` & 10 | BITCOIND=$! 11 | 12 | #Install a watchdog. 13 | (sleep 10 && kill -0 $WAITER 2>/dev/null && kill -9 $BITCOIND $$)& 14 | wait $WAITER 15 | 16 | if [ -n "$TIMEOUT" ]; then 17 | timeout "$TIMEOUT"s "$@" $PORT 18 | RETURN=$? 19 | else 20 | "$@" $PORT 21 | RETURN=$? 22 | fi 23 | 24 | (sleep 15 && kill -0 $BITCOIND 2>/dev/null && kill -9 $BITCOIND $$)& 25 | kill $BITCOIND && wait $BITCOIND 26 | 27 | # timeout returns 124 on timeout, otherwise the return value of the child 28 | exit $RETURN 29 | -------------------------------------------------------------------------------- /share/genbuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ $# -gt 1 ]; then 3 | cd "$2" 4 | fi 5 | if [ $# -gt 0 ]; then 6 | FILE="$1" 7 | shift 8 | if [ -f "$FILE" ]; then 9 | INFO="$(head -n 1 "$FILE")" 10 | fi 11 | else 12 | echo "Usage: $0 " 13 | exit 1 14 | fi 15 | 16 | if [ -e "$(which git)" -a -d ".git" ]; then 17 | # clean 'dirty' status of touched files that haven't been modified 18 | git diff >/dev/null 2>/dev/null 19 | 20 | # get a string like "v0.6.0-66-g59887e8-dirty" 21 | DESC="$(git describe --dirty 2>/dev/null)" 22 | 23 | # get a string like "2012-04-10 16:27:19 +0200" 24 | TIME="$(git log -n 1 --format="%ci")" 25 | fi 26 | 27 | if [ -n "$DESC" ]; then 28 | NEWINFO="#define BUILD_DESC \"$DESC\"" 29 | else 30 | NEWINFO="// No build information available" 31 | fi 32 | 33 | # only update build.h if necessary 34 | if [ "$INFO" != "$NEWINFO" ]; then 35 | echo "$NEWINFO" >"$FILE" 36 | echo "#define BUILD_DATE \"$TIME\"" >>"$FILE" 37 | fi 38 | -------------------------------------------------------------------------------- /share/pixmaps/addressbook16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/addressbook16.bmp -------------------------------------------------------------------------------- /share/pixmaps/addressbook16mask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/addressbook16mask.bmp -------------------------------------------------------------------------------- /share/pixmaps/addressbook20.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/addressbook20.bmp -------------------------------------------------------------------------------- /share/pixmaps/addressbook20mask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/addressbook20mask.bmp -------------------------------------------------------------------------------- /share/pixmaps/bitcoin-bc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/bitcoin-bc.ico -------------------------------------------------------------------------------- /share/pixmaps/bitcoin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/bitcoin.ico -------------------------------------------------------------------------------- /share/pixmaps/bitcoin128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/bitcoin128.png -------------------------------------------------------------------------------- /share/pixmaps/bitcoin16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/bitcoin16.png -------------------------------------------------------------------------------- /share/pixmaps/bitcoin256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/bitcoin256.png -------------------------------------------------------------------------------- /share/pixmaps/bitcoin32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/bitcoin32.png -------------------------------------------------------------------------------- /share/pixmaps/bitcoin64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/bitcoin64.png -------------------------------------------------------------------------------- /share/pixmaps/check.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/check.ico -------------------------------------------------------------------------------- /share/pixmaps/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/favicon.ico -------------------------------------------------------------------------------- /share/pixmaps/nsis-header.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/nsis-header.bmp -------------------------------------------------------------------------------- /share/pixmaps/nsis-wizard.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/nsis-wizard.bmp -------------------------------------------------------------------------------- /share/pixmaps/send16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/send16.bmp -------------------------------------------------------------------------------- /share/pixmaps/send16mask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/send16mask.bmp -------------------------------------------------------------------------------- /share/pixmaps/send16masknoshadow.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/send16masknoshadow.bmp -------------------------------------------------------------------------------- /share/pixmaps/send20.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/send20.bmp -------------------------------------------------------------------------------- /share/pixmaps/send20mask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/pixmaps/send20mask.bmp -------------------------------------------------------------------------------- /share/qt/clean_mac_info_plist.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Jonas Schnelli, 2013 3 | # make sure the Bitcoin-Qt.app contains the right plist (including the right version) 4 | # fix made because of serval bugs in Qt mac deployment (https://bugreports.qt-project.org/browse/QTBUG-21267) 5 | 6 | from string import Template 7 | from datetime import date 8 | 9 | bitcoinDir = "./"; 10 | 11 | inFile = bitcoinDir+"/share/qt/Info.plist" 12 | outFile = "Bitcoin-Qt.app/Contents/Info.plist" 13 | version = "unknown"; 14 | 15 | fileForGrabbingVersion = bitcoinDir+"bitcoin-qt.pro" 16 | for line in open(fileForGrabbingVersion): 17 | lineArr = line.replace(" ", "").split("="); 18 | if lineArr[0].startswith("VERSION"): 19 | version = lineArr[1].replace("\n", ""); 20 | 21 | fIn = open(inFile, "r") 22 | fileContent = fIn.read() 23 | s = Template(fileContent) 24 | newFileContent = s.substitute(VERSION=version,YEAR=date.today().year) 25 | 26 | fOut = open(outFile, "w"); 27 | fOut.write(newFileContent); 28 | 29 | print "Info.plist fresh created" -------------------------------------------------------------------------------- /share/qt/img/reload.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/share/qt/img/reload.xcf -------------------------------------------------------------------------------- /share/qt/make_spinner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # W.J. van der Laan, 2011 3 | # Make spinning .mng animation from a .png 4 | # Requires imagemagick 6.7+ 5 | from __future__ import division 6 | from os import path 7 | from PIL import Image 8 | from subprocess import Popen 9 | 10 | SRC='img/reload_scaled.png' 11 | DST='../../src/qt/res/movies/update_spinner.mng' 12 | TMPDIR='/tmp' 13 | TMPNAME='tmp-%03i.png' 14 | NUMFRAMES=35 15 | FRAMERATE=10.0 16 | CONVERT='convert' 17 | CLOCKWISE=True 18 | DSIZE=(16,16) 19 | 20 | im_src = Image.open(SRC) 21 | 22 | if CLOCKWISE: 23 | im_src = im_src.transpose(Image.FLIP_LEFT_RIGHT) 24 | 25 | def frame_to_filename(frame): 26 | return path.join(TMPDIR, TMPNAME % frame) 27 | 28 | frame_files = [] 29 | for frame in xrange(NUMFRAMES): 30 | rotation = (frame + 0.5) / NUMFRAMES * 360.0 31 | if CLOCKWISE: 32 | rotation = -rotation 33 | im_new = im_src.rotate(rotation, Image.BICUBIC) 34 | im_new.thumbnail(DSIZE, Image.ANTIALIAS) 35 | outfile = frame_to_filename(frame) 36 | im_new.save(outfile, 'png') 37 | frame_files.append(outfile) 38 | 39 | p = Popen([CONVERT, "-delay", str(FRAMERATE), "-dispose", "2"] + frame_files + [DST]) 40 | p.communicate() 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /share/qt/make_windows_icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # create multiresolution windows icon 3 | ICON_SRC=../../src/qt/res/icons/bitcoin.png 4 | ICON_DST=../../src/qt/res/icons/bitcoin.ico 5 | convert ${ICON_SRC} -resize 16x16 bitcoin-16.png 6 | convert ${ICON_SRC} -resize 32x32 bitcoin-32.png 7 | convert ${ICON_SRC} -resize 48x48 bitcoin-48.png 8 | convert bitcoin-16.png bitcoin-32.png bitcoin-48.png ${ICON_DST} 9 | 10 | -------------------------------------------------------------------------------- /share/qt/protobuf.pri: -------------------------------------------------------------------------------- 1 | # Based on: http://code.google.com/p/ostinato/source/browse/protobuf.pri 2 | # 3 | # Qt qmake integration with Google Protocol Buffers compiler protoc 4 | # 5 | # To compile protocol buffers with qt qmake, specify PROTOS variable and 6 | # include this file 7 | # 8 | # Example: 9 | # PROTOS = a.proto b.proto 10 | # include(protobuf.pri) 11 | # 12 | # Set PROTO_PATH if you need to set the protoc --proto_path search path 13 | # Set PROTOC to the path to the protoc compiler if it is not in your $PATH 14 | # 15 | 16 | isEmpty(PROTO_DIR):PROTO_DIR = . 17 | isEmpty(PROTOC):PROTOC = protoc 18 | 19 | PROTOPATHS = 20 | for(p, PROTO_PATH):PROTOPATHS += --proto_path=$${p} 21 | 22 | protobuf_decl.name = protobuf header 23 | protobuf_decl.input = PROTOS 24 | protobuf_decl.output = $${PROTO_DIR}/${QMAKE_FILE_BASE}.pb.h 25 | protobuf_decl.commands = $${PROTOC} --cpp_out="$${PROTO_DIR}" $${PROTOPATHS} --proto_path=${QMAKE_FILE_IN_PATH} ${QMAKE_FILE_NAME} 26 | protobuf_decl.variable_out = GENERATED_FILES 27 | QMAKE_EXTRA_COMPILERS += protobuf_decl 28 | 29 | protobuf_impl.name = protobuf implementation 30 | protobuf_impl.input = PROTOS 31 | protobuf_impl.output = $${PROTO_DIR}/${QMAKE_FILE_BASE}.pb.cc 32 | protobuf_impl.depends = $${PROTO_DIR}/${QMAKE_FILE_BASE}.pb.h 33 | protobuf_impl.commands = $$escape_expand(\\n) 34 | protobuf_impl.variable_out = GENERATED_SOURCES 35 | QMAKE_EXTRA_COMPILERS += protobuf_impl 36 | -------------------------------------------------------------------------------- /share/ui.rc: -------------------------------------------------------------------------------- 1 | bitcoin ICON "pixmaps/bitcoin.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | 5 | check ICON "pixmaps/check.ico" 6 | send16 BITMAP "pixmaps/send16.bmp" 7 | send16mask BITMAP "pixmaps/send16mask.bmp" 8 | send16masknoshadow BITMAP "pixmaps/send16masknoshadow.bmp" 9 | send20 BITMAP "pixmaps/send20.bmp" 10 | send20mask BITMAP "pixmaps/send20mask.bmp" 11 | addressbook16 BITMAP "pixmaps/addressbook16.bmp" 12 | addressbook16mask BITMAP "pixmaps/addressbook16mask.bmp" 13 | addressbook20 BITMAP "pixmaps/addressbook20.bmp" 14 | addressbook20mask BITMAP "pixmaps/addressbook20mask.bmp" 15 | favicon ICON "pixmaps/favicon.ico" 16 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | test_bitcoin 3 | 4 | -------------------------------------------------------------------------------- /src/allocators.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "allocators.h" 6 | 7 | #ifdef WIN32 8 | #ifdef _WIN32_WINNT 9 | #undef _WIN32_WINNT 10 | #endif 11 | #define _WIN32_WINNT 0x0501 12 | #define WIN32_LEAN_AND_MEAN 1 13 | #ifndef NOMINMAX 14 | #define NOMINMAX 15 | #endif 16 | #include 17 | // This is used to attempt to keep keying material out of swap 18 | // Note that VirtualLock does not provide this as a guarantee on Windows, 19 | // but, in practice, memory that has been VirtualLock'd almost never gets written to 20 | // the pagefile except in rare circumstances where memory is extremely low. 21 | #else 22 | #include 23 | #include // for PAGESIZE 24 | #include // for sysconf 25 | #endif 26 | 27 | LockedPageManager* LockedPageManager::_instance = NULL; 28 | boost::once_flag LockedPageManager::init_flag = BOOST_ONCE_INIT; 29 | 30 | /** Determine system page size in bytes */ 31 | static inline size_t GetSystemPageSize() 32 | { 33 | size_t page_size; 34 | #if defined(WIN32) 35 | SYSTEM_INFO sSysInfo; 36 | GetSystemInfo(&sSysInfo); 37 | page_size = sSysInfo.dwPageSize; 38 | #elif defined(PAGESIZE) // defined in limits.h 39 | page_size = PAGESIZE; 40 | #else // assume some POSIX OS 41 | page_size = sysconf(_SC_PAGESIZE); 42 | #endif 43 | return page_size; 44 | } 45 | 46 | bool MemoryPageLocker::Lock(const void *addr, size_t len) 47 | { 48 | #ifdef WIN32 49 | return VirtualLock(const_cast(addr), len); 50 | #else 51 | return mlock(addr, len) == 0; 52 | #endif 53 | } 54 | 55 | bool MemoryPageLocker::Unlock(const void *addr, size_t len) 56 | { 57 | #ifdef WIN32 58 | return VirtualUnlock(const_cast(addr), len); 59 | #else 60 | return munlock(addr, len) == 0; 61 | #endif 62 | } 63 | 64 | LockedPageManager::LockedPageManager() : LockedPageManagerBase(GetSystemPageSize()) 65 | { 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/bitcoin-cli-res.rc: -------------------------------------------------------------------------------- 1 | #include // needed for VERSIONINFO 2 | #include "clientversion.h" // holds the needed client version information 3 | 4 | #define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD 5 | #define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) 6 | #define VER_FILEVERSION VER_PRODUCTVERSION 7 | #define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR 8 | #define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin developers" 9 | 10 | VS_VERSION_INFO VERSIONINFO 11 | FILEVERSION VER_FILEVERSION 12 | PRODUCTVERSION VER_PRODUCTVERSION 13 | FILEOS VOS_NT_WINDOWS32 14 | FILETYPE VFT_APP 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904E4" // U.S. English - multilingual (hex) 19 | BEGIN 20 | VALUE "CompanyName", "Bitcoin" 21 | VALUE "FileDescription", "Bitcoin-cli (OSS RPC client for Bitcoin)" 22 | VALUE "FileVersion", VER_FILEVERSION_STR 23 | VALUE "InternalName", "bitcoin-cli" 24 | VALUE "LegalCopyright", COPYRIGHT_STR 25 | VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." 26 | VALUE "OriginalFilename", "bitcoin-cli.exe" 27 | VALUE "ProductName", "Bitcoin-cli" 28 | VALUE "ProductVersion", VER_PRODUCTVERSION_STR 29 | END 30 | END 31 | 32 | BLOCK "VarFileInfo" 33 | BEGIN 34 | VALUE "Translation", 0x0, 1252 // language neutral - multilingual (decimal) 35 | END 36 | END 37 | -------------------------------------------------------------------------------- /src/bitcoind-res.rc: -------------------------------------------------------------------------------- 1 | #include // needed for VERSIONINFO 2 | #include "clientversion.h" // holds the needed client version information 3 | 4 | #define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD 5 | #define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) 6 | #define VER_FILEVERSION VER_PRODUCTVERSION 7 | #define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR 8 | #define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin developers" 9 | 10 | VS_VERSION_INFO VERSIONINFO 11 | FILEVERSION VER_FILEVERSION 12 | PRODUCTVERSION VER_PRODUCTVERSION 13 | FILEOS VOS_NT_WINDOWS32 14 | FILETYPE VFT_APP 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904E4" // U.S. English - multilingual (hex) 19 | BEGIN 20 | VALUE "CompanyName", "Bitcoin" 21 | VALUE "FileDescription", "Bitcoind (OSS daemon/client for Bitcoin)" 22 | VALUE "FileVersion", VER_FILEVERSION_STR 23 | VALUE "InternalName", "bitcoind" 24 | VALUE "LegalCopyright", COPYRIGHT_STR 25 | VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." 26 | VALUE "OriginalFilename", "bitcoind.exe" 27 | VALUE "ProductName", "Bitcoind" 28 | VALUE "ProductVersion", VER_PRODUCTVERSION_STR 29 | END 30 | END 31 | 32 | BLOCK "VarFileInfo" 33 | BEGIN 34 | VALUE "Translation", 0x0, 1252 // language neutral - multilingual (decimal) 35 | END 36 | END 37 | -------------------------------------------------------------------------------- /src/checkpoints.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef BITCOIN_CHECKPOINT_H 6 | #define BITCOIN_CHECKPOINT_H 7 | 8 | #include 9 | 10 | class CBlockIndex; 11 | class uint256; 12 | 13 | /** Block-chain checkpoints are compiled-in sanity checks. 14 | * They are updated every release or three. 15 | */ 16 | namespace Checkpoints 17 | { 18 | // Returns true if block passes checkpoint checks 19 | bool CheckBlock(int nHeight, const uint256& hash); 20 | 21 | // Return conservative estimate of total number of blocks, 0 if unknown 22 | int GetTotalBlocksEstimate(); 23 | 24 | // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint 25 | CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex); 26 | 27 | double GuessVerificationProgress(CBlockIndex *pindex); 28 | 29 | extern bool fEnabled; 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/clientversion.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENTVERSION_H 2 | #define CLIENTVERSION_H 3 | 4 | #if defined(HAVE_CONFIG_H) 5 | #include "bitcoin-config.h" 6 | #else 7 | // 8 | // client versioning and copyright year 9 | // 10 | 11 | // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it 12 | #define CLIENT_VERSION_MAJOR 0 13 | #define CLIENT_VERSION_MINOR 8 14 | #define CLIENT_VERSION_REVISION 99 15 | #define CLIENT_VERSION_BUILD 0 16 | 17 | // Set to true for release, false for prerelease or test build 18 | #define CLIENT_VERSION_IS_RELEASE false 19 | 20 | // Copyright year (2009-this) 21 | // Todo: update this when changing our copyright comments in the source 22 | #define COPYRIGHT_YEAR 2013 23 | 24 | #endif //HAVE_CONFIG_H 25 | 26 | // Converts the parameter X to a string after macro replacement on X has been performed. 27 | // Don't merge these into one macro! 28 | #define STRINGIZE(X) DO_STRINGIZE(X) 29 | #define DO_STRINGIZE(X) #X 30 | 31 | #endif // CLIENTVERSION_H 32 | -------------------------------------------------------------------------------- /src/coincontrol.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef COINCONTROL_H 6 | #define COINCONTROL_H 7 | 8 | #include "core.h" 9 | 10 | /** Coin Control Features. */ 11 | class CCoinControl 12 | { 13 | public: 14 | CTxDestination destChange; 15 | 16 | CCoinControl() 17 | { 18 | SetNull(); 19 | } 20 | 21 | void SetNull() 22 | { 23 | destChange = CNoDestination(); 24 | setSelected.clear(); 25 | } 26 | 27 | bool HasSelected() const 28 | { 29 | return (setSelected.size() > 0); 30 | } 31 | 32 | bool IsSelected(const uint256& hash, unsigned int n) const 33 | { 34 | COutPoint outpt(hash, n); 35 | return (setSelected.count(outpt) > 0); 36 | } 37 | 38 | void Select(COutPoint& output) 39 | { 40 | setSelected.insert(output); 41 | } 42 | 43 | void UnSelect(COutPoint& output) 44 | { 45 | setSelected.erase(output); 46 | } 47 | 48 | void UnSelectAll() 49 | { 50 | setSelected.clear(); 51 | } 52 | 53 | void ListSelected(std::vector& vOutpoints) 54 | { 55 | vOutpoints.assign(setSelected.begin(), setSelected.end()); 56 | } 57 | 58 | private: 59 | std::set setSelected; 60 | 61 | }; 62 | 63 | #endif // COINCONTROL_H 64 | -------------------------------------------------------------------------------- /src/compat.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto 2 | // Copyright (c) 2009-2013 The Bitcoin developers 3 | // Distributed under the MIT/X11 software license, see the accompanying 4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | #ifndef _BITCOIN_COMPAT_H 7 | #define _BITCOIN_COMPAT_H 8 | 9 | #ifdef WIN32 10 | #ifdef _WIN32_WINNT 11 | #undef _WIN32_WINNT 12 | #endif 13 | #define _WIN32_WINNT 0x0501 14 | #define WIN32_LEAN_AND_MEAN 1 15 | #ifndef NOMINMAX 16 | #define NOMINMAX 17 | #endif 18 | #ifdef FD_SETSIZE 19 | #undef FD_SETSIZE // prevent redefinition compiler warning 20 | #endif 21 | #define FD_SETSIZE 1024 // max number of fds in fd_set 22 | 23 | #include // Must be included before mswsock.h and windows.h 24 | 25 | #include 26 | #include 27 | #include 28 | #else 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #endif 41 | 42 | #ifdef WIN32 43 | #define MSG_DONTWAIT 0 44 | #else 45 | typedef u_int SOCKET; 46 | #include "errno.h" 47 | #define WSAGetLastError() errno 48 | #define WSAEINVAL EINVAL 49 | #define WSAEALREADY EALREADY 50 | #define WSAEWOULDBLOCK EWOULDBLOCK 51 | #define WSAEMSGSIZE EMSGSIZE 52 | #define WSAEINTR EINTR 53 | #define WSAEINPROGRESS EINPROGRESS 54 | #define WSAEADDRINUSE EADDRINUSE 55 | #define WSAENOTSOCK EBADF 56 | #define INVALID_SOCKET (SOCKET)(~0) 57 | #define SOCKET_ERROR -1 58 | #endif 59 | 60 | inline int myclosesocket(SOCKET& hSocket) 61 | { 62 | if (hSocket == INVALID_SOCKET) 63 | return WSAENOTSOCK; 64 | #ifdef WIN32 65 | int ret = closesocket(hSocket); 66 | #else 67 | int ret = close(hSocket); 68 | #endif 69 | hSocket = INVALID_SOCKET; 70 | return ret; 71 | } 72 | #define closesocket(s) myclosesocket(s) 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/init.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto 2 | // Copyright (c) 2009-2013 The Bitcoin developers 3 | // Distributed under the MIT/X11 software license, see the accompanying 4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | #ifndef BITCOIN_INIT_H 7 | #define BITCOIN_INIT_H 8 | 9 | #include 10 | 11 | class CWallet; 12 | 13 | namespace boost { 14 | class thread_group; 15 | }; 16 | 17 | extern std::string strWalletFile; 18 | extern CWallet* pwalletMain; 19 | 20 | void StartShutdown(); 21 | bool ShutdownRequested(); 22 | void Shutdown(); 23 | bool AppInit2(boost::thread_group& threadGroup, bool fForceServer); 24 | 25 | /* The help message mode determines what help message to show */ 26 | enum HelpMessageMode 27 | { 28 | HMM_BITCOIND, 29 | HMM_BITCOIN_QT, 30 | HMM_BITCOIN_CLI 31 | }; 32 | 33 | std::string HelpMessage(HelpMessageMode mode); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /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_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.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/leveldb/.gitignore: -------------------------------------------------------------------------------- 1 | build_config.mk 2 | *.a 3 | *.o 4 | *.dylib* 5 | *.so 6 | *.so.* 7 | *_test 8 | db_bench 9 | leveldbutil 10 | Release 11 | Debug 12 | Benchmark 13 | vs2010.* 14 | -------------------------------------------------------------------------------- /src/leveldb/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file like so: 2 | # Name or Organization 3 | 4 | Google Inc. 5 | 6 | # Initial version authors: 7 | Jeffrey Dean 8 | Sanjay Ghemawat 9 | 10 | # Partial list of contributors: 11 | Kevin Regan 12 | -------------------------------------------------------------------------------- /src/leveldb/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/leveldb/NEWS: -------------------------------------------------------------------------------- 1 | Release 1.2 2011-05-16 2 | ---------------------- 3 | 4 | Fixes for larger databases (tested up to one billion 100-byte entries, 5 | i.e., ~100GB). 6 | 7 | (1) Place hard limit on number of level-0 files. This fixes errors 8 | of the form "too many open files". 9 | 10 | (2) Fixed memtable management. Before the fix, a heavy write burst 11 | could cause unbounded memory usage. 12 | 13 | A fix for a logging bug where the reader would incorrectly complain 14 | about corruption. 15 | 16 | Allow public access to WriteBatch contents so that users can easily 17 | wrap a DB. 18 | -------------------------------------------------------------------------------- /src/leveldb/README: -------------------------------------------------------------------------------- 1 | leveldb: A key-value store 2 | Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com) 3 | 4 | The code under this directory implements a system for maintaining a 5 | persistent key/value store. 6 | 7 | See doc/index.html for more explanation. 8 | See doc/impl.html for a brief overview of the implementation. 9 | 10 | The public interface is in include/*.h. Callers should not include or 11 | rely on the details of any other header files in this package. Those 12 | internal APIs may be changed without warning. 13 | 14 | Guide to header files: 15 | 16 | include/db.h 17 | Main interface to the DB: Start here 18 | 19 | include/options.h 20 | Control over the behavior of an entire database, and also 21 | control over the behavior of individual reads and writes. 22 | 23 | include/comparator.h 24 | Abstraction for user-specified comparison function. If you want 25 | just bytewise comparison of keys, you can use the default comparator, 26 | but clients can write their own comparator implementations if they 27 | want custom ordering (e.g. to handle different character 28 | encodings, etc.) 29 | 30 | include/iterator.h 31 | Interface for iterating over data. You can get an iterator 32 | from a DB object. 33 | 34 | include/write_batch.h 35 | Interface for atomically applying multiple updates to a database. 36 | 37 | include/slice.h 38 | A simple module for maintaining a pointer and a length into some 39 | other byte array. 40 | 41 | include/status.h 42 | Status is returned from many of the public interfaces and is used 43 | to report success and various kinds of errors. 44 | 45 | include/env.h 46 | Abstraction of the OS environment. A posix implementation of 47 | this interface is in util/env_posix.cc 48 | 49 | include/table.h 50 | include/table_builder.h 51 | Lower-level modules that most clients probably won't use directly 52 | -------------------------------------------------------------------------------- /src/leveldb/TODO: -------------------------------------------------------------------------------- 1 | ss 2 | - Stats 3 | 4 | db 5 | - Maybe implement DB::BulkDeleteForRange(start_key, end_key) 6 | that would blow away files whose ranges are entirely contained 7 | within [start_key..end_key]? For Chrome, deletion of obsolete 8 | object stores, etc. can be done in the background anyway, so 9 | probably not that important. 10 | - There have been requests for MultiGet. 11 | 12 | After a range is completely deleted, what gets rid of the 13 | corresponding files if we do no future changes to that range. Make 14 | the conditions for triggering compactions fire in more situations? 15 | -------------------------------------------------------------------------------- /src/leveldb/WINDOWS.md: -------------------------------------------------------------------------------- 1 | # Building LevelDB On Windows 2 | 3 | ## Prereqs 4 | 5 | Install the [Windows Software Development Kit version 7.1](http://www.microsoft.com/downloads/dlx/en-us/listdetailsview.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b). 6 | 7 | Download and extract the [Snappy source distribution](http://snappy.googlecode.com/files/snappy-1.0.5.tar.gz) 8 | 9 | 1. Open the "Windows SDK 7.1 Command Prompt" : 10 | Start Menu -> "Microsoft Windows SDK v7.1" > "Windows SDK 7.1 Command Prompt" 11 | 2. Change the directory to the leveldb project 12 | 13 | ## Building the Static lib 14 | 15 | * 32 bit Version 16 | 17 | setenv /x86 18 | msbuild.exe /p:Configuration=Release /p:Platform=Win32 /p:Snappy=..\snappy-1.0.5 19 | 20 | * 64 bit Version 21 | 22 | setenv /x64 23 | msbuild.exe /p:Configuration=Release /p:Platform=x64 /p:Snappy=..\snappy-1.0.5 24 | 25 | 26 | ## Building and Running the Benchmark app 27 | 28 | * 32 bit Version 29 | 30 | setenv /x86 31 | msbuild.exe /p:Configuration=Benchmark /p:Platform=Win32 /p:Snappy=..\snappy-1.0.5 32 | Benchmark\leveldb.exe 33 | 34 | * 64 bit Version 35 | 36 | setenv /x64 37 | msbuild.exe /p:Configuration=Benchmark /p:Platform=x64 /p:Snappy=..\snappy-1.0.5 38 | x64\Benchmark\leveldb.exe 39 | 40 | -------------------------------------------------------------------------------- /src/leveldb/db/builder.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_DB_BUILDER_H_ 6 | #define STORAGE_LEVELDB_DB_BUILDER_H_ 7 | 8 | #include "leveldb/status.h" 9 | 10 | namespace leveldb { 11 | 12 | struct Options; 13 | struct FileMetaData; 14 | 15 | class Env; 16 | class Iterator; 17 | class TableCache; 18 | class VersionEdit; 19 | 20 | // Build a Table file from the contents of *iter. The generated file 21 | // will be named according to meta->number. On success, the rest of 22 | // *meta will be filled with metadata about the generated table. 23 | // If no data is present in *iter, meta->file_size will be set to 24 | // zero, and no Table file will be produced. 25 | extern Status BuildTable(const std::string& dbname, 26 | Env* env, 27 | const Options& options, 28 | TableCache* table_cache, 29 | Iterator* iter, 30 | FileMetaData* meta); 31 | 32 | } // namespace leveldb 33 | 34 | #endif // STORAGE_LEVELDB_DB_BUILDER_H_ 35 | -------------------------------------------------------------------------------- /src/leveldb/db/db_iter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_DB_DB_ITER_H_ 6 | #define STORAGE_LEVELDB_DB_DB_ITER_H_ 7 | 8 | #include 9 | #include "leveldb/db.h" 10 | #include "db/dbformat.h" 11 | 12 | namespace leveldb { 13 | 14 | class DBImpl; 15 | 16 | // Return a new iterator that converts internal keys (yielded by 17 | // "*internal_iter") that were live at the specified "sequence" number 18 | // into appropriate user keys. 19 | extern Iterator* NewDBIterator( 20 | DBImpl* db, 21 | const Comparator* user_key_comparator, 22 | Iterator* internal_iter, 23 | SequenceNumber sequence, 24 | uint32_t seed); 25 | 26 | } // namespace leveldb 27 | 28 | #endif // STORAGE_LEVELDB_DB_DB_ITER_H_ 29 | -------------------------------------------------------------------------------- /src/leveldb/db/log_format.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | // 5 | // Log format information shared by reader and writer. 6 | // See ../doc/log_format.txt for more detail. 7 | 8 | #ifndef STORAGE_LEVELDB_DB_LOG_FORMAT_H_ 9 | #define STORAGE_LEVELDB_DB_LOG_FORMAT_H_ 10 | 11 | namespace leveldb { 12 | namespace log { 13 | 14 | enum RecordType { 15 | // Zero is reserved for preallocated files 16 | kZeroType = 0, 17 | 18 | kFullType = 1, 19 | 20 | // For fragments 21 | kFirstType = 2, 22 | kMiddleType = 3, 23 | kLastType = 4 24 | }; 25 | static const int kMaxRecordType = kLastType; 26 | 27 | static const int kBlockSize = 32768; 28 | 29 | // Header is checksum (4 bytes), type (1 byte), length (2 bytes). 30 | static const int kHeaderSize = 4 + 1 + 2; 31 | 32 | } // namespace log 33 | } // namespace leveldb 34 | 35 | #endif // STORAGE_LEVELDB_DB_LOG_FORMAT_H_ 36 | -------------------------------------------------------------------------------- /src/leveldb/db/log_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_DB_LOG_WRITER_H_ 6 | #define STORAGE_LEVELDB_DB_LOG_WRITER_H_ 7 | 8 | #include 9 | #include "db/log_format.h" 10 | #include "leveldb/slice.h" 11 | #include "leveldb/status.h" 12 | 13 | namespace leveldb { 14 | 15 | class WritableFile; 16 | 17 | namespace log { 18 | 19 | class Writer { 20 | public: 21 | // Create a writer that will append data to "*dest". 22 | // "*dest" must be initially empty. 23 | // "*dest" must remain live while this Writer is in use. 24 | explicit Writer(WritableFile* dest); 25 | ~Writer(); 26 | 27 | Status AddRecord(const Slice& slice); 28 | 29 | private: 30 | WritableFile* dest_; 31 | int block_offset_; // Current offset in block 32 | 33 | // crc32c values for all supported record types. These are 34 | // pre-computed to reduce the overhead of computing the crc of the 35 | // record type stored in the header. 36 | uint32_t type_crc_[kMaxRecordType + 1]; 37 | 38 | Status EmitPhysicalRecord(RecordType type, const char* ptr, size_t length); 39 | 40 | // No copying allowed 41 | Writer(const Writer&); 42 | void operator=(const Writer&); 43 | }; 44 | 45 | } // namespace log 46 | } // namespace leveldb 47 | 48 | #endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_ 49 | -------------------------------------------------------------------------------- /src/leveldb/db/snapshot.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_DB_SNAPSHOT_H_ 6 | #define STORAGE_LEVELDB_DB_SNAPSHOT_H_ 7 | 8 | #include "leveldb/db.h" 9 | 10 | namespace leveldb { 11 | 12 | class SnapshotList; 13 | 14 | // Snapshots are kept in a doubly-linked list in the DB. 15 | // Each SnapshotImpl corresponds to a particular sequence number. 16 | class SnapshotImpl : public Snapshot { 17 | public: 18 | SequenceNumber number_; // const after creation 19 | 20 | private: 21 | friend class SnapshotList; 22 | 23 | // SnapshotImpl is kept in a doubly-linked circular list 24 | SnapshotImpl* prev_; 25 | SnapshotImpl* next_; 26 | 27 | SnapshotList* list_; // just for sanity checks 28 | }; 29 | 30 | class SnapshotList { 31 | public: 32 | SnapshotList() { 33 | list_.prev_ = &list_; 34 | list_.next_ = &list_; 35 | } 36 | 37 | bool empty() const { return list_.next_ == &list_; } 38 | SnapshotImpl* oldest() const { assert(!empty()); return list_.next_; } 39 | SnapshotImpl* newest() const { assert(!empty()); return list_.prev_; } 40 | 41 | const SnapshotImpl* New(SequenceNumber seq) { 42 | SnapshotImpl* s = new SnapshotImpl; 43 | s->number_ = seq; 44 | s->list_ = this; 45 | s->next_ = &list_; 46 | s->prev_ = list_.prev_; 47 | s->prev_->next_ = s; 48 | s->next_->prev_ = s; 49 | return s; 50 | } 51 | 52 | void Delete(const SnapshotImpl* s) { 53 | assert(s->list_ == this); 54 | s->prev_->next_ = s->next_; 55 | s->next_->prev_ = s->prev_; 56 | delete s; 57 | } 58 | 59 | private: 60 | // Dummy head of doubly-linked list of snapshots 61 | SnapshotImpl list_; 62 | }; 63 | 64 | } // namespace leveldb 65 | 66 | #endif // STORAGE_LEVELDB_DB_SNAPSHOT_H_ 67 | -------------------------------------------------------------------------------- /src/leveldb/db/version_edit_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "db/version_edit.h" 6 | #include "util/testharness.h" 7 | 8 | namespace leveldb { 9 | 10 | static void TestEncodeDecode(const VersionEdit& edit) { 11 | std::string encoded, encoded2; 12 | edit.EncodeTo(&encoded); 13 | VersionEdit parsed; 14 | Status s = parsed.DecodeFrom(encoded); 15 | ASSERT_TRUE(s.ok()) << s.ToString(); 16 | parsed.EncodeTo(&encoded2); 17 | ASSERT_EQ(encoded, encoded2); 18 | } 19 | 20 | class VersionEditTest { }; 21 | 22 | TEST(VersionEditTest, EncodeDecode) { 23 | static const uint64_t kBig = 1ull << 50; 24 | 25 | VersionEdit edit; 26 | for (int i = 0; i < 4; i++) { 27 | TestEncodeDecode(edit); 28 | edit.AddFile(3, kBig + 300 + i, kBig + 400 + i, 29 | InternalKey("foo", kBig + 500 + i, kTypeValue), 30 | InternalKey("zoo", kBig + 600 + i, kTypeDeletion)); 31 | edit.DeleteFile(4, kBig + 700 + i); 32 | edit.SetCompactPointer(i, InternalKey("x", kBig + 900 + i, kTypeValue)); 33 | } 34 | 35 | edit.SetComparatorName("foo"); 36 | edit.SetLogNumber(kBig + 100); 37 | edit.SetNextFile(kBig + 200); 38 | edit.SetLastSequence(kBig + 1000); 39 | TestEncodeDecode(edit); 40 | } 41 | 42 | } // namespace leveldb 43 | 44 | int main(int argc, char** argv) { 45 | return leveldb::test::RunAllTests(); 46 | } 47 | -------------------------------------------------------------------------------- /src/leveldb/db/write_batch_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ 6 | #define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ 7 | 8 | #include "leveldb/write_batch.h" 9 | 10 | namespace leveldb { 11 | 12 | class MemTable; 13 | 14 | // WriteBatchInternal provides static methods for manipulating a 15 | // WriteBatch that we don't want in the public WriteBatch interface. 16 | class WriteBatchInternal { 17 | public: 18 | // Return the number of entries in the batch. 19 | static int Count(const WriteBatch* batch); 20 | 21 | // Set the count for the number of entries in the batch. 22 | static void SetCount(WriteBatch* batch, int n); 23 | 24 | // Return the seqeunce number for the start of this batch. 25 | static SequenceNumber Sequence(const WriteBatch* batch); 26 | 27 | // Store the specified number as the seqeunce number for the start of 28 | // this batch. 29 | static void SetSequence(WriteBatch* batch, SequenceNumber seq); 30 | 31 | static Slice Contents(const WriteBatch* batch) { 32 | return Slice(batch->rep_); 33 | } 34 | 35 | static size_t ByteSize(const WriteBatch* batch) { 36 | return batch->rep_.size(); 37 | } 38 | 39 | static void SetContents(WriteBatch* batch, const Slice& contents); 40 | 41 | static Status InsertInto(const WriteBatch* batch, MemTable* memtable); 42 | 43 | static void Append(WriteBatch* dst, const WriteBatch* src); 44 | }; 45 | 46 | } // namespace leveldb 47 | 48 | 49 | #endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ 50 | -------------------------------------------------------------------------------- /src/leveldb/doc/doc.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin-left: 0.5in; 3 | margin-right: 0.5in; 4 | background: white; 5 | color: black; 6 | } 7 | 8 | h1 { 9 | margin-left: -0.2in; 10 | font-size: 14pt; 11 | } 12 | h2 { 13 | margin-left: -0in; 14 | font-size: 12pt; 15 | } 16 | h3 { 17 | margin-left: -0in; 18 | } 19 | h4 { 20 | margin-left: -0in; 21 | } 22 | hr { 23 | margin-left: -0in; 24 | } 25 | 26 | /* Definition lists: definition term bold */ 27 | dt { 28 | font-weight: bold; 29 | } 30 | 31 | address { 32 | text-align: center; 33 | } 34 | code,samp,var { 35 | color: blue; 36 | } 37 | kbd { 38 | color: #600000; 39 | } 40 | div.note p { 41 | float: right; 42 | width: 3in; 43 | margin-right: 0%; 44 | padding: 1px; 45 | border: 2px solid #6060a0; 46 | background-color: #fffff0; 47 | } 48 | 49 | ul { 50 | margin-top: -0em; 51 | margin-bottom: -0em; 52 | } 53 | 54 | ol { 55 | margin-top: -0em; 56 | margin-bottom: -0em; 57 | } 58 | 59 | UL.nobullets { 60 | list-style-type: none; 61 | list-style-image: none; 62 | margin-left: -1em; 63 | } 64 | 65 | p { 66 | margin: 1em 0 1em 0; 67 | padding: 0 0 0 0; 68 | } 69 | 70 | pre { 71 | line-height: 1.3em; 72 | padding: 0.4em 0 0.8em 0; 73 | margin: 0 0 0 0; 74 | border: 0 0 0 0; 75 | color: blue; 76 | } 77 | 78 | .datatable { 79 | margin-left: auto; 80 | margin-right: auto; 81 | margin-top: 2em; 82 | margin-bottom: 2em; 83 | border: 1px solid; 84 | } 85 | 86 | .datatable td,th { 87 | padding: 0 0.5em 0 0.5em; 88 | text-align: right; 89 | } 90 | -------------------------------------------------------------------------------- /src/leveldb/helpers/memenv/memenv.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_HELPERS_MEMENV_MEMENV_H_ 6 | #define STORAGE_LEVELDB_HELPERS_MEMENV_MEMENV_H_ 7 | 8 | namespace leveldb { 9 | 10 | class Env; 11 | 12 | // Returns a new environment that stores its data in memory and delegates 13 | // all non-file-storage tasks to base_env. The caller must delete the result 14 | // when it is no longer needed. 15 | // *base_env must remain live while the result is in use. 16 | Env* NewMemEnv(Env* base_env); 17 | 18 | } // namespace leveldb 19 | 20 | #endif // STORAGE_LEVELDB_HELPERS_MEMENV_MEMENV_H_ 21 | -------------------------------------------------------------------------------- /src/leveldb/port/README: -------------------------------------------------------------------------------- 1 | This directory contains interfaces and implementations that isolate the 2 | rest of the package from platform details. 3 | 4 | Code in the rest of the package includes "port.h" from this directory. 5 | "port.h" in turn includes a platform specific "port_.h" file 6 | that provides the platform specific implementation. 7 | 8 | See port_posix.h for an example of what must be provided in a platform 9 | specific header file. 10 | 11 | -------------------------------------------------------------------------------- /src/leveldb/port/port.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_PORT_PORT_H_ 6 | #define STORAGE_LEVELDB_PORT_PORT_H_ 7 | 8 | #include 9 | 10 | // Include the appropriate platform specific file below. If you are 11 | // porting to a new platform, see "port_example.h" for documentation 12 | // of what the new port_.h file must provide. 13 | #if defined(LEVELDB_PLATFORM_POSIX) 14 | # include "port/port_posix.h" 15 | #elif defined(LEVELDB_PLATFORM_CHROMIUM) 16 | # include "port/port_chromium.h" 17 | #elif defined(LEVELDB_PLATFORM_WINDOWS) 18 | # include "port/port_win.h" 19 | #endif 20 | 21 | #endif // STORAGE_LEVELDB_PORT_PORT_H_ 22 | -------------------------------------------------------------------------------- /src/leveldb/port/port_posix.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "port/port_posix.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include "util/logging.h" 11 | 12 | namespace leveldb { 13 | namespace port { 14 | 15 | static void PthreadCall(const char* label, int result) { 16 | if (result != 0) { 17 | fprintf(stderr, "pthread %s: %s\n", label, strerror(result)); 18 | abort(); 19 | } 20 | } 21 | 22 | Mutex::Mutex() { PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL)); } 23 | 24 | Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); } 25 | 26 | void Mutex::Lock() { PthreadCall("lock", pthread_mutex_lock(&mu_)); } 27 | 28 | void Mutex::Unlock() { PthreadCall("unlock", pthread_mutex_unlock(&mu_)); } 29 | 30 | CondVar::CondVar(Mutex* mu) 31 | : mu_(mu) { 32 | PthreadCall("init cv", pthread_cond_init(&cv_, NULL)); 33 | } 34 | 35 | CondVar::~CondVar() { PthreadCall("destroy cv", pthread_cond_destroy(&cv_)); } 36 | 37 | void CondVar::Wait() { 38 | PthreadCall("wait", pthread_cond_wait(&cv_, &mu_->mu_)); 39 | } 40 | 41 | void CondVar::Signal() { 42 | PthreadCall("signal", pthread_cond_signal(&cv_)); 43 | } 44 | 45 | void CondVar::SignalAll() { 46 | PthreadCall("broadcast", pthread_cond_broadcast(&cv_)); 47 | } 48 | 49 | void InitOnce(OnceType* once, void (*initializer)()) { 50 | PthreadCall("once", pthread_once(once, initializer)); 51 | } 52 | 53 | } // namespace port 54 | } // namespace leveldb 55 | -------------------------------------------------------------------------------- /src/leveldb/port/thread_annotations.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H 6 | 7 | // Some environments provide custom macros to aid in static thread-safety 8 | // analysis. Provide empty definitions of such macros unless they are already 9 | // defined. 10 | 11 | #ifndef EXCLUSIVE_LOCKS_REQUIRED 12 | #define EXCLUSIVE_LOCKS_REQUIRED(...) 13 | #endif 14 | 15 | #ifndef SHARED_LOCKS_REQUIRED 16 | #define SHARED_LOCKS_REQUIRED(...) 17 | #endif 18 | 19 | #ifndef LOCKS_EXCLUDED 20 | #define LOCKS_EXCLUDED(...) 21 | #endif 22 | 23 | #ifndef LOCK_RETURNED 24 | #define LOCK_RETURNED(x) 25 | #endif 26 | 27 | #ifndef LOCKABLE 28 | #define LOCKABLE 29 | #endif 30 | 31 | #ifndef SCOPED_LOCKABLE 32 | #define SCOPED_LOCKABLE 33 | #endif 34 | 35 | #ifndef EXCLUSIVE_LOCK_FUNCTION 36 | #define EXCLUSIVE_LOCK_FUNCTION(...) 37 | #endif 38 | 39 | #ifndef SHARED_LOCK_FUNCTION 40 | #define SHARED_LOCK_FUNCTION(...) 41 | #endif 42 | 43 | #ifndef EXCLUSIVE_TRYLOCK_FUNCTION 44 | #define EXCLUSIVE_TRYLOCK_FUNCTION(...) 45 | #endif 46 | 47 | #ifndef SHARED_TRYLOCK_FUNCTION 48 | #define SHARED_TRYLOCK_FUNCTION(...) 49 | #endif 50 | 51 | #ifndef UNLOCK_FUNCTION 52 | #define UNLOCK_FUNCTION(...) 53 | #endif 54 | 55 | #ifndef NO_THREAD_SAFETY_ANALYSIS 56 | #define NO_THREAD_SAFETY_ANALYSIS 57 | #endif 58 | 59 | #endif // STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H 60 | -------------------------------------------------------------------------------- /src/leveldb/port/win/stdint.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | // MSVC didn't ship with this file until the 2010 version. 6 | 7 | #ifndef STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 8 | #define STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 9 | 10 | #if !defined(_MSC_VER) 11 | #error This file should only be included when compiling with MSVC. 12 | #endif 13 | 14 | // Define C99 equivalent types. 15 | typedef signed char int8_t; 16 | typedef signed short int16_t; 17 | typedef signed int int32_t; 18 | typedef signed long long int64_t; 19 | typedef unsigned char uint8_t; 20 | typedef unsigned short uint16_t; 21 | typedef unsigned int uint32_t; 22 | typedef unsigned long long uint64_t; 23 | 24 | #endif // STORAGE_LEVELDB_PORT_WIN_STDINT_H_ 25 | -------------------------------------------------------------------------------- /src/leveldb/table/block.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_TABLE_BLOCK_H_ 6 | #define STORAGE_LEVELDB_TABLE_BLOCK_H_ 7 | 8 | #include 9 | #include 10 | #include "leveldb/iterator.h" 11 | 12 | namespace leveldb { 13 | 14 | struct BlockContents; 15 | class Comparator; 16 | 17 | class Block { 18 | public: 19 | // Initialize the block with the specified contents. 20 | explicit Block(const BlockContents& contents); 21 | 22 | ~Block(); 23 | 24 | size_t size() const { return size_; } 25 | Iterator* NewIterator(const Comparator* comparator); 26 | 27 | private: 28 | uint32_t NumRestarts() const; 29 | 30 | const char* data_; 31 | size_t size_; 32 | uint32_t restart_offset_; // Offset in data_ of restart array 33 | bool owned_; // Block owns data_[] 34 | 35 | // No copying allowed 36 | Block(const Block&); 37 | void operator=(const Block&); 38 | 39 | class Iter; 40 | }; 41 | 42 | } // namespace leveldb 43 | 44 | #endif // STORAGE_LEVELDB_TABLE_BLOCK_H_ 45 | -------------------------------------------------------------------------------- /src/leveldb/table/block_builder.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_ 6 | #define STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_ 7 | 8 | #include 9 | 10 | #include 11 | #include "leveldb/slice.h" 12 | 13 | namespace leveldb { 14 | 15 | struct Options; 16 | 17 | class BlockBuilder { 18 | public: 19 | explicit BlockBuilder(const Options* options); 20 | 21 | // Reset the contents as if the BlockBuilder was just constructed. 22 | void Reset(); 23 | 24 | // REQUIRES: Finish() has not been callled since the last call to Reset(). 25 | // REQUIRES: key is larger than any previously added key 26 | void Add(const Slice& key, const Slice& value); 27 | 28 | // Finish building the block and return a slice that refers to the 29 | // block contents. The returned slice will remain valid for the 30 | // lifetime of this builder or until Reset() is called. 31 | Slice Finish(); 32 | 33 | // Returns an estimate of the current (uncompressed) size of the block 34 | // we are building. 35 | size_t CurrentSizeEstimate() const; 36 | 37 | // Return true iff no entries have been added since the last Reset() 38 | bool empty() const { 39 | return buffer_.empty(); 40 | } 41 | 42 | private: 43 | const Options* options_; 44 | std::string buffer_; // Destination buffer 45 | std::vector restarts_; // Restart points 46 | int counter_; // Number of entries emitted since restart 47 | bool finished_; // Has Finish() been called? 48 | std::string last_key_; 49 | 50 | // No copying allowed 51 | BlockBuilder(const BlockBuilder&); 52 | void operator=(const BlockBuilder&); 53 | }; 54 | 55 | } // namespace leveldb 56 | 57 | #endif // STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_ 58 | -------------------------------------------------------------------------------- /src/leveldb/table/iterator.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "leveldb/iterator.h" 6 | 7 | namespace leveldb { 8 | 9 | Iterator::Iterator() { 10 | cleanup_.function = NULL; 11 | cleanup_.next = NULL; 12 | } 13 | 14 | Iterator::~Iterator() { 15 | if (cleanup_.function != NULL) { 16 | (*cleanup_.function)(cleanup_.arg1, cleanup_.arg2); 17 | for (Cleanup* c = cleanup_.next; c != NULL; ) { 18 | (*c->function)(c->arg1, c->arg2); 19 | Cleanup* next = c->next; 20 | delete c; 21 | c = next; 22 | } 23 | } 24 | } 25 | 26 | void Iterator::RegisterCleanup(CleanupFunction func, void* arg1, void* arg2) { 27 | assert(func != NULL); 28 | Cleanup* c; 29 | if (cleanup_.function == NULL) { 30 | c = &cleanup_; 31 | } else { 32 | c = new Cleanup; 33 | c->next = cleanup_.next; 34 | cleanup_.next = c; 35 | } 36 | c->function = func; 37 | c->arg1 = arg1; 38 | c->arg2 = arg2; 39 | } 40 | 41 | namespace { 42 | class EmptyIterator : public Iterator { 43 | public: 44 | EmptyIterator(const Status& s) : status_(s) { } 45 | virtual bool Valid() const { return false; } 46 | virtual void Seek(const Slice& target) { } 47 | virtual void SeekToFirst() { } 48 | virtual void SeekToLast() { } 49 | virtual void Next() { assert(false); } 50 | virtual void Prev() { assert(false); } 51 | Slice key() const { assert(false); return Slice(); } 52 | Slice value() const { assert(false); return Slice(); } 53 | virtual Status status() const { return status_; } 54 | private: 55 | Status status_; 56 | }; 57 | } // namespace 58 | 59 | Iterator* NewEmptyIterator() { 60 | return new EmptyIterator(Status::OK()); 61 | } 62 | 63 | Iterator* NewErrorIterator(const Status& status) { 64 | return new EmptyIterator(status); 65 | } 66 | 67 | } // namespace leveldb 68 | -------------------------------------------------------------------------------- /src/leveldb/table/merger.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_TABLE_MERGER_H_ 6 | #define STORAGE_LEVELDB_TABLE_MERGER_H_ 7 | 8 | namespace leveldb { 9 | 10 | class Comparator; 11 | class Iterator; 12 | 13 | // Return an iterator that provided the union of the data in 14 | // children[0,n-1]. Takes ownership of the child iterators and 15 | // will delete them when the result iterator is deleted. 16 | // 17 | // The result does no duplicate suppression. I.e., if a particular 18 | // key is present in K child iterators, it will be yielded K times. 19 | // 20 | // REQUIRES: n >= 0 21 | extern Iterator* NewMergingIterator( 22 | const Comparator* comparator, Iterator** children, int n); 23 | 24 | } // namespace leveldb 25 | 26 | #endif // STORAGE_LEVELDB_TABLE_MERGER_H_ 27 | -------------------------------------------------------------------------------- /src/leveldb/table/two_level_iterator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_ 6 | #define STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_ 7 | 8 | #include "leveldb/iterator.h" 9 | 10 | namespace leveldb { 11 | 12 | struct ReadOptions; 13 | 14 | // Return a new two level iterator. A two-level iterator contains an 15 | // index iterator whose values point to a sequence of blocks where 16 | // each block is itself a sequence of key,value pairs. The returned 17 | // two-level iterator yields the concatenation of all key/value pairs 18 | // in the sequence of blocks. Takes ownership of "index_iter" and 19 | // will delete it when no longer needed. 20 | // 21 | // Uses a supplied function to convert an index_iter value into 22 | // an iterator over the contents of the corresponding block. 23 | extern Iterator* NewTwoLevelIterator( 24 | Iterator* index_iter, 25 | Iterator* (*block_function)( 26 | void* arg, 27 | const ReadOptions& options, 28 | const Slice& index_value), 29 | void* arg, 30 | const ReadOptions& options); 31 | 32 | } // namespace leveldb 33 | 34 | #endif // STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_ 35 | -------------------------------------------------------------------------------- /src/leveldb/util/arena_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "util/arena.h" 6 | 7 | #include "util/random.h" 8 | #include "util/testharness.h" 9 | 10 | namespace leveldb { 11 | 12 | class ArenaTest { }; 13 | 14 | TEST(ArenaTest, Empty) { 15 | Arena arena; 16 | } 17 | 18 | TEST(ArenaTest, Simple) { 19 | std::vector > allocated; 20 | Arena arena; 21 | const int N = 100000; 22 | size_t bytes = 0; 23 | Random rnd(301); 24 | for (int i = 0; i < N; i++) { 25 | size_t s; 26 | if (i % (N / 10) == 0) { 27 | s = i; 28 | } else { 29 | s = rnd.OneIn(4000) ? rnd.Uniform(6000) : 30 | (rnd.OneIn(10) ? rnd.Uniform(100) : rnd.Uniform(20)); 31 | } 32 | if (s == 0) { 33 | // Our arena disallows size 0 allocations. 34 | s = 1; 35 | } 36 | char* r; 37 | if (rnd.OneIn(10)) { 38 | r = arena.AllocateAligned(s); 39 | } else { 40 | r = arena.Allocate(s); 41 | } 42 | 43 | for (int b = 0; b < s; b++) { 44 | // Fill the "i"th allocation with a known bit pattern 45 | r[b] = i % 256; 46 | } 47 | bytes += s; 48 | allocated.push_back(std::make_pair(s, r)); 49 | ASSERT_GE(arena.MemoryUsage(), bytes); 50 | if (i > N/10) { 51 | ASSERT_LE(arena.MemoryUsage(), bytes * 1.10); 52 | } 53 | } 54 | for (int i = 0; i < allocated.size(); i++) { 55 | size_t num_bytes = allocated[i].first; 56 | const char* p = allocated[i].second; 57 | for (int b = 0; b < num_bytes; b++) { 58 | // Check the "i"th allocation for the known bit pattern 59 | ASSERT_EQ(int(p[b]) & 0xff, i % 256); 60 | } 61 | } 62 | } 63 | 64 | } // namespace leveldb 65 | 66 | int main(int argc, char** argv) { 67 | return leveldb::test::RunAllTests(); 68 | } 69 | -------------------------------------------------------------------------------- /src/leveldb/util/crc32c.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_UTIL_CRC32C_H_ 6 | #define STORAGE_LEVELDB_UTIL_CRC32C_H_ 7 | 8 | #include 9 | #include 10 | 11 | namespace leveldb { 12 | namespace crc32c { 13 | 14 | // Return the crc32c of concat(A, data[0,n-1]) where init_crc is the 15 | // crc32c of some string A. Extend() is often used to maintain the 16 | // crc32c of a stream of data. 17 | extern uint32_t Extend(uint32_t init_crc, const char* data, size_t n); 18 | 19 | // Return the crc32c of data[0,n-1] 20 | inline uint32_t Value(const char* data, size_t n) { 21 | return Extend(0, data, n); 22 | } 23 | 24 | static const uint32_t kMaskDelta = 0xa282ead8ul; 25 | 26 | // Return a masked representation of crc. 27 | // 28 | // Motivation: it is problematic to compute the CRC of a string that 29 | // contains embedded CRCs. Therefore we recommend that CRCs stored 30 | // somewhere (e.g., in files) should be masked before being stored. 31 | inline uint32_t Mask(uint32_t crc) { 32 | // Rotate right by 15 bits and add a constant. 33 | return ((crc >> 15) | (crc << 17)) + kMaskDelta; 34 | } 35 | 36 | // Return the crc whose masked representation is masked_crc. 37 | inline uint32_t Unmask(uint32_t masked_crc) { 38 | uint32_t rot = masked_crc - kMaskDelta; 39 | return ((rot >> 17) | (rot << 15)); 40 | } 41 | 42 | } // namespace crc32c 43 | } // namespace leveldb 44 | 45 | #endif // STORAGE_LEVELDB_UTIL_CRC32C_H_ 46 | -------------------------------------------------------------------------------- /src/leveldb/util/crc32c_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "util/crc32c.h" 6 | #include "util/testharness.h" 7 | 8 | namespace leveldb { 9 | namespace crc32c { 10 | 11 | class CRC { }; 12 | 13 | TEST(CRC, StandardResults) { 14 | // From rfc3720 section B.4. 15 | char buf[32]; 16 | 17 | memset(buf, 0, sizeof(buf)); 18 | ASSERT_EQ(0x8a9136aa, Value(buf, sizeof(buf))); 19 | 20 | memset(buf, 0xff, sizeof(buf)); 21 | ASSERT_EQ(0x62a8ab43, Value(buf, sizeof(buf))); 22 | 23 | for (int i = 0; i < 32; i++) { 24 | buf[i] = i; 25 | } 26 | ASSERT_EQ(0x46dd794e, Value(buf, sizeof(buf))); 27 | 28 | for (int i = 0; i < 32; i++) { 29 | buf[i] = 31 - i; 30 | } 31 | ASSERT_EQ(0x113fdb5c, Value(buf, sizeof(buf))); 32 | 33 | unsigned char data[48] = { 34 | 0x01, 0xc0, 0x00, 0x00, 35 | 0x00, 0x00, 0x00, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 38 | 0x14, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x04, 0x00, 40 | 0x00, 0x00, 0x00, 0x14, 41 | 0x00, 0x00, 0x00, 0x18, 42 | 0x28, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 44 | 0x02, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 46 | }; 47 | ASSERT_EQ(0xd9963a56, Value(reinterpret_cast(data), sizeof(data))); 48 | } 49 | 50 | TEST(CRC, Values) { 51 | ASSERT_NE(Value("a", 1), Value("foo", 3)); 52 | } 53 | 54 | TEST(CRC, Extend) { 55 | ASSERT_EQ(Value("hello world", 11), 56 | Extend(Value("hello ", 6), "world", 5)); 57 | } 58 | 59 | TEST(CRC, Mask) { 60 | uint32_t crc = Value("foo", 3); 61 | ASSERT_NE(crc, Mask(crc)); 62 | ASSERT_NE(crc, Mask(Mask(crc))); 63 | ASSERT_EQ(crc, Unmask(Mask(crc))); 64 | ASSERT_EQ(crc, Unmask(Unmask(Mask(Mask(crc))))); 65 | } 66 | 67 | } // namespace crc32c 68 | } // namespace leveldb 69 | 70 | int main(int argc, char** argv) { 71 | return leveldb::test::RunAllTests(); 72 | } 73 | -------------------------------------------------------------------------------- /src/leveldb/util/filter_policy.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "leveldb/filter_policy.h" 6 | 7 | namespace leveldb { 8 | 9 | FilterPolicy::~FilterPolicy() { } 10 | 11 | } // namespace leveldb 12 | -------------------------------------------------------------------------------- /src/leveldb/util/hash.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include 6 | #include "util/coding.h" 7 | #include "util/hash.h" 8 | 9 | // The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through 10 | // between switch labels. The real definition should be provided externally. 11 | // This one is a fallback version for unsupported compilers. 12 | #ifndef FALLTHROUGH_INTENDED 13 | #define FALLTHROUGH_INTENDED do { } while (0) 14 | #endif 15 | 16 | namespace leveldb { 17 | 18 | uint32_t Hash(const char* data, size_t n, uint32_t seed) { 19 | // Similar to murmur hash 20 | const uint32_t m = 0xc6a4a793; 21 | const uint32_t r = 24; 22 | const char* limit = data + n; 23 | uint32_t h = seed ^ (n * m); 24 | 25 | // Pick up four bytes at a time 26 | while (data + 4 <= limit) { 27 | uint32_t w = DecodeFixed32(data); 28 | data += 4; 29 | h += w; 30 | h *= m; 31 | h ^= (h >> 16); 32 | } 33 | 34 | // Pick up remaining bytes 35 | switch (limit - data) { 36 | case 3: 37 | h += data[2] << 16; 38 | FALLTHROUGH_INTENDED; 39 | case 2: 40 | h += data[1] << 8; 41 | FALLTHROUGH_INTENDED; 42 | case 1: 43 | h += data[0]; 44 | h *= m; 45 | h ^= (h >> r); 46 | break; 47 | } 48 | return h; 49 | } 50 | 51 | 52 | } // namespace leveldb 53 | -------------------------------------------------------------------------------- /src/leveldb/util/hash.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | // 5 | // Simple hash function used for internal data structures 6 | 7 | #ifndef STORAGE_LEVELDB_UTIL_HASH_H_ 8 | #define STORAGE_LEVELDB_UTIL_HASH_H_ 9 | 10 | #include 11 | #include 12 | 13 | namespace leveldb { 14 | 15 | extern uint32_t Hash(const char* data, size_t n, uint32_t seed); 16 | 17 | } 18 | 19 | #endif // STORAGE_LEVELDB_UTIL_HASH_H_ 20 | -------------------------------------------------------------------------------- /src/leveldb/util/histogram.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_UTIL_HISTOGRAM_H_ 6 | #define STORAGE_LEVELDB_UTIL_HISTOGRAM_H_ 7 | 8 | #include 9 | 10 | namespace leveldb { 11 | 12 | class Histogram { 13 | public: 14 | Histogram() { } 15 | ~Histogram() { } 16 | 17 | void Clear(); 18 | void Add(double value); 19 | void Merge(const Histogram& other); 20 | 21 | std::string ToString() const; 22 | 23 | private: 24 | double min_; 25 | double max_; 26 | double num_; 27 | double sum_; 28 | double sum_squares_; 29 | 30 | enum { kNumBuckets = 154 }; 31 | static const double kBucketLimit[kNumBuckets]; 32 | double buckets_[kNumBuckets]; 33 | 34 | double Median() const; 35 | double Percentile(double p) const; 36 | double Average() const; 37 | double StandardDeviation() const; 38 | }; 39 | 40 | } // namespace leveldb 41 | 42 | #endif // STORAGE_LEVELDB_UTIL_HISTOGRAM_H_ 43 | -------------------------------------------------------------------------------- /src/leveldb/util/logging.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | // 5 | // Must not be included from any .h files to avoid polluting the namespace 6 | // with macros. 7 | 8 | #ifndef STORAGE_LEVELDB_UTIL_LOGGING_H_ 9 | #define STORAGE_LEVELDB_UTIL_LOGGING_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | #include "port/port.h" 15 | 16 | namespace leveldb { 17 | 18 | class Slice; 19 | class WritableFile; 20 | 21 | // Append a human-readable printout of "num" to *str 22 | extern void AppendNumberTo(std::string* str, uint64_t num); 23 | 24 | // Append a human-readable printout of "value" to *str. 25 | // Escapes any non-printable characters found in "value". 26 | extern void AppendEscapedStringTo(std::string* str, const Slice& value); 27 | 28 | // Return a human-readable printout of "num" 29 | extern std::string NumberToString(uint64_t num); 30 | 31 | // Return a human-readable version of "value". 32 | // Escapes any non-printable characters found in "value". 33 | extern std::string EscapeString(const Slice& value); 34 | 35 | // If *in starts with "c", advances *in past the first character and 36 | // returns true. Otherwise, returns false. 37 | extern bool ConsumeChar(Slice* in, char c); 38 | 39 | // Parse a human-readable number from "*in" into *value. On success, 40 | // advances "*in" past the consumed number and sets "*val" to the 41 | // numeric value. Otherwise, returns false and leaves *in in an 42 | // unspecified state. 43 | extern bool ConsumeDecimalNumber(Slice* in, uint64_t* val); 44 | 45 | } // namespace leveldb 46 | 47 | #endif // STORAGE_LEVELDB_UTIL_LOGGING_H_ 48 | -------------------------------------------------------------------------------- /src/leveldb/util/mutexlock.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_ 6 | #define STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_ 7 | 8 | #include "port/port.h" 9 | #include "port/thread_annotations.h" 10 | 11 | namespace leveldb { 12 | 13 | // Helper class that locks a mutex on construction and unlocks the mutex when 14 | // the destructor of the MutexLock object is invoked. 15 | // 16 | // Typical usage: 17 | // 18 | // void MyClass::MyMethod() { 19 | // MutexLock l(&mu_); // mu_ is an instance variable 20 | // ... some complex code, possibly with multiple return paths ... 21 | // } 22 | 23 | class SCOPED_LOCKABLE MutexLock { 24 | public: 25 | explicit MutexLock(port::Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu) 26 | : mu_(mu) { 27 | this->mu_->Lock(); 28 | } 29 | ~MutexLock() UNLOCK_FUNCTION() { this->mu_->Unlock(); } 30 | 31 | private: 32 | port::Mutex *const mu_; 33 | // No copying allowed 34 | MutexLock(const MutexLock&); 35 | void operator=(const MutexLock&); 36 | }; 37 | 38 | } // namespace leveldb 39 | 40 | 41 | #endif // STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_ 42 | -------------------------------------------------------------------------------- /src/leveldb/util/options.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "leveldb/options.h" 6 | 7 | #include "leveldb/comparator.h" 8 | #include "leveldb/env.h" 9 | 10 | namespace leveldb { 11 | 12 | Options::Options() 13 | : comparator(BytewiseComparator()), 14 | create_if_missing(false), 15 | error_if_exists(false), 16 | paranoid_checks(false), 17 | env(Env::Default()), 18 | info_log(NULL), 19 | write_buffer_size(4<<20), 20 | max_open_files(1000), 21 | block_cache(NULL), 22 | block_size(4096), 23 | block_restart_interval(16), 24 | compression(kSnappyCompression), 25 | filter_policy(NULL) { 26 | } 27 | 28 | 29 | } // namespace leveldb 30 | -------------------------------------------------------------------------------- /src/leveldb/util/testharness.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "util/testharness.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace leveldb { 13 | namespace test { 14 | 15 | namespace { 16 | struct Test { 17 | const char* base; 18 | const char* name; 19 | void (*func)(); 20 | }; 21 | std::vector* tests; 22 | } 23 | 24 | bool RegisterTest(const char* base, const char* name, void (*func)()) { 25 | if (tests == NULL) { 26 | tests = new std::vector; 27 | } 28 | Test t; 29 | t.base = base; 30 | t.name = name; 31 | t.func = func; 32 | tests->push_back(t); 33 | return true; 34 | } 35 | 36 | int RunAllTests() { 37 | const char* matcher = getenv("LEVELDB_TESTS"); 38 | 39 | int num = 0; 40 | if (tests != NULL) { 41 | for (int i = 0; i < tests->size(); i++) { 42 | const Test& t = (*tests)[i]; 43 | if (matcher != NULL) { 44 | std::string name = t.base; 45 | name.push_back('.'); 46 | name.append(t.name); 47 | if (strstr(name.c_str(), matcher) == NULL) { 48 | continue; 49 | } 50 | } 51 | fprintf(stderr, "==== Test %s.%s\n", t.base, t.name); 52 | (*t.func)(); 53 | ++num; 54 | } 55 | } 56 | fprintf(stderr, "==== PASSED %d tests\n", num); 57 | return 0; 58 | } 59 | 60 | std::string TmpDir() { 61 | std::string dir; 62 | Status s = Env::Default()->GetTestDirectory(&dir); 63 | ASSERT_TRUE(s.ok()) << s.ToString(); 64 | return dir; 65 | } 66 | 67 | int RandomSeed() { 68 | const char* env = getenv("TEST_RANDOM_SEED"); 69 | int result = (env != NULL ? atoi(env) : 301); 70 | if (result <= 0) { 71 | result = 301; 72 | } 73 | return result; 74 | } 75 | 76 | } // namespace test 77 | } // namespace leveldb 78 | -------------------------------------------------------------------------------- /src/leveldb/util/testutil.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #include "util/testutil.h" 6 | 7 | #include "util/random.h" 8 | 9 | namespace leveldb { 10 | namespace test { 11 | 12 | Slice RandomString(Random* rnd, int len, std::string* dst) { 13 | dst->resize(len); 14 | for (int i = 0; i < len; i++) { 15 | (*dst)[i] = static_cast(' ' + rnd->Uniform(95)); // ' ' .. '~' 16 | } 17 | return Slice(*dst); 18 | } 19 | 20 | std::string RandomKey(Random* rnd, int len) { 21 | // Make sure to generate a wide variety of characters so we 22 | // test the boundary conditions for short-key optimizations. 23 | static const char kTestChars[] = { 24 | '\0', '\1', 'a', 'b', 'c', 'd', 'e', '\xfd', '\xfe', '\xff' 25 | }; 26 | std::string result; 27 | for (int i = 0; i < len; i++) { 28 | result += kTestChars[rnd->Uniform(sizeof(kTestChars))]; 29 | } 30 | return result; 31 | } 32 | 33 | 34 | extern Slice CompressibleString(Random* rnd, double compressed_fraction, 35 | int len, std::string* dst) { 36 | int raw = static_cast(len * compressed_fraction); 37 | if (raw < 1) raw = 1; 38 | std::string raw_data; 39 | RandomString(rnd, raw, &raw_data); 40 | 41 | // Duplicate the random data until we have filled "len" bytes 42 | dst->clear(); 43 | while (dst->size() < len) { 44 | dst->append(raw_data); 45 | } 46 | dst->resize(len); 47 | return Slice(*dst); 48 | } 49 | 50 | } // namespace test 51 | } // namespace leveldb 52 | -------------------------------------------------------------------------------- /src/leveldb/util/testutil.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_UTIL_TESTUTIL_H_ 6 | #define STORAGE_LEVELDB_UTIL_TESTUTIL_H_ 7 | 8 | #include "leveldb/env.h" 9 | #include "leveldb/slice.h" 10 | #include "util/random.h" 11 | 12 | namespace leveldb { 13 | namespace test { 14 | 15 | // Store in *dst a random string of length "len" and return a Slice that 16 | // references the generated data. 17 | extern Slice RandomString(Random* rnd, int len, std::string* dst); 18 | 19 | // Return a random key with the specified length that may contain interesting 20 | // characters (e.g. \x00, \xff, etc.). 21 | extern std::string RandomKey(Random* rnd, int len); 22 | 23 | // Store in *dst a string of length "len" that will compress to 24 | // "N*compressed_fraction" bytes and return a Slice that references 25 | // the generated data. 26 | extern Slice CompressibleString(Random* rnd, double compressed_fraction, 27 | int len, std::string* dst); 28 | 29 | // A wrapper that allows injection of errors. 30 | class ErrorEnv : public EnvWrapper { 31 | public: 32 | bool writable_file_error_; 33 | int num_writable_file_errors_; 34 | 35 | ErrorEnv() : EnvWrapper(Env::Default()), 36 | writable_file_error_(false), 37 | num_writable_file_errors_(0) { } 38 | 39 | virtual Status NewWritableFile(const std::string& fname, 40 | WritableFile** result) { 41 | if (writable_file_error_) { 42 | ++num_writable_file_errors_; 43 | *result = NULL; 44 | return Status::IOError(fname, "fake error"); 45 | } 46 | return target()->NewWritableFile(fname, result); 47 | } 48 | }; 49 | 50 | } // namespace test 51 | } // namespace leveldb 52 | 53 | #endif // STORAGE_LEVELDB_UTIL_TESTUTIL_H_ 54 | -------------------------------------------------------------------------------- /src/m4/bitcoin_subdir_to_include.m4: -------------------------------------------------------------------------------- 1 | dnl BITCOIN_SUBDIR_TO_INCLUDE([CPPFLAGS-VARIABLE-NAME],[SUBDIRECTORY-NAME],[HEADER-FILE]) 2 | dnl SUBDIRECTORY-NAME must end with a path separator 3 | AC_DEFUN([BITCOIN_SUBDIR_TO_INCLUDE],[ 4 | if test "x$2" = "x"; then 5 | AC_MSG_RESULT([default]) 6 | else 7 | echo "#include <$2$3.h>" >conftest.cpp 8 | newinclpath=`${CXXCPP} ${CPPFLAGS} -M conftest.cpp 2>/dev/null | [ tr -d '\\n\\r\\\\' | sed -e 's/^.*[[:space:]:]\(\/[^[:space:]]*\)]$3[\.h[[:space:]].*$/\1/' -e t -e d`] 9 | AC_MSG_RESULT([${newinclpath}]) 10 | if test "x${newinclpath}" != "x"; then 11 | eval "$1=\"\$$1\"' -I${newinclpath}'" 12 | fi 13 | fi 14 | ]) 15 | -------------------------------------------------------------------------------- /src/miner.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto 2 | // Copyright (c) 2009-2013 The Bitcoin developers 3 | // Distributed under the MIT/X11 software license, see the accompanying 4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | #ifndef BITCOIN_MINER_H 7 | #define BITCOIN_MINER_H 8 | 9 | #include 10 | 11 | class CBlock; 12 | class CBlockIndex; 13 | struct CBlockTemplate; 14 | class CReserveKey; 15 | class CScript; 16 | class CWallet; 17 | 18 | /** Run the miner threads */ 19 | void GenerateBitcoins(bool fGenerate, CWallet* pwallet); 20 | /** Generate a new block, without valid proof-of-work */ 21 | CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn); 22 | CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey); 23 | /** Modify the extranonce in a block */ 24 | void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce); 25 | /** Do mining precalculation */ 26 | void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1); 27 | /** Check mined block */ 28 | bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); 29 | /** Base sha256 mining transform */ 30 | void SHA256Transform(void* pstate, void* pinput, const void* pinit); 31 | 32 | extern double dHashesPerSec; 33 | extern int64_t nHPSTimerStart; 34 | 35 | #endif // BITCOIN_MINER_H 36 | -------------------------------------------------------------------------------- /src/noui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 Satoshi Nakamoto 2 | // Copyright (c) 2009-2013 The Bitcoin developers 3 | // Distributed under the MIT/X11 software license, see the accompanying 4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | #include "noui.h" 7 | 8 | #include "ui_interface.h" 9 | #include "util.h" 10 | 11 | #include 12 | #include 13 | 14 | static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) 15 | { 16 | std::string strCaption; 17 | // Check for usage of predefined caption 18 | switch (style) { 19 | case CClientUIInterface::MSG_ERROR: 20 | strCaption += _("Error"); 21 | break; 22 | case CClientUIInterface::MSG_WARNING: 23 | strCaption += _("Warning"); 24 | break; 25 | case CClientUIInterface::MSG_INFORMATION: 26 | strCaption += _("Information"); 27 | break; 28 | default: 29 | strCaption += caption; // Use supplied caption (can be empty) 30 | } 31 | 32 | LogPrintf("%s: %s\n", strCaption.c_str(), message.c_str()); 33 | fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str()); 34 | return false; 35 | } 36 | 37 | static bool noui_ThreadSafeAskFee(int64_t /*nFeeRequired*/) 38 | { 39 | return true; 40 | } 41 | 42 | static void noui_InitMessage(const std::string &message) 43 | { 44 | LogPrintf("init message: %s\n", message.c_str()); 45 | } 46 | 47 | void noui_connect() 48 | { 49 | // Connect bitcoind signal handlers 50 | uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox); 51 | uiInterface.ThreadSafeAskFee.connect(noui_ThreadSafeAskFee); 52 | uiInterface.InitMessage.connect(noui_InitMessage); 53 | } 54 | -------------------------------------------------------------------------------- /src/noui.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef BITCOIN_NOUI_H 6 | #define BITCOIN_NOUI_H 7 | 8 | extern void noui_connect(); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/obj-test/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/obj/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /src/qt/aboutdialog.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "aboutdialog.h" 6 | #include "ui_aboutdialog.h" 7 | 8 | #include "clientmodel.h" 9 | 10 | #include "clientversion.h" 11 | 12 | AboutDialog::AboutDialog(QWidget *parent) : 13 | QDialog(parent), 14 | ui(new Ui::AboutDialog) 15 | { 16 | ui->setupUi(this); 17 | 18 | // Set current copyright year 19 | ui->copyrightLabel->setText(tr("Copyright") + QString(" © 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin developers")); 20 | } 21 | 22 | void AboutDialog::setModel(ClientModel *model) 23 | { 24 | if(model) 25 | { 26 | ui->versionLabel->setText(model->formatFullVersion()); 27 | } 28 | } 29 | 30 | AboutDialog::~AboutDialog() 31 | { 32 | delete ui; 33 | } 34 | 35 | void AboutDialog::on_buttonBox_accepted() 36 | { 37 | close(); 38 | } 39 | -------------------------------------------------------------------------------- /src/qt/aboutdialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef ABOUTDIALOG_H 6 | #define ABOUTDIALOG_H 7 | 8 | #include 9 | 10 | class ClientModel; 11 | 12 | namespace Ui { 13 | class AboutDialog; 14 | } 15 | 16 | /** "About" dialog box */ 17 | class AboutDialog : public QDialog 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | explicit AboutDialog(QWidget *parent); 23 | ~AboutDialog(); 24 | 25 | void setModel(ClientModel *model); 26 | 27 | private: 28 | Ui::AboutDialog *ui; 29 | 30 | private slots: 31 | void on_buttonBox_accepted(); 32 | }; 33 | 34 | #endif // ABOUTDIALOG_H 35 | -------------------------------------------------------------------------------- /src/qt/askpassphrasedialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef ASKPASSPHRASEDIALOG_H 6 | #define ASKPASSPHRASEDIALOG_H 7 | 8 | #include 9 | 10 | class WalletModel; 11 | 12 | namespace Ui { 13 | class AskPassphraseDialog; 14 | } 15 | 16 | /** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase. 17 | */ 18 | class AskPassphraseDialog : public QDialog 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | enum Mode { 24 | Encrypt, /**< Ask passphrase twice and encrypt */ 25 | Unlock, /**< Ask passphrase and unlock */ 26 | ChangePass, /**< Ask old passphrase + new passphrase twice */ 27 | Decrypt /**< Ask passphrase and decrypt wallet */ 28 | }; 29 | 30 | explicit AskPassphraseDialog(Mode mode, QWidget *parent); 31 | ~AskPassphraseDialog(); 32 | 33 | void accept(); 34 | 35 | void setModel(WalletModel *model); 36 | 37 | private: 38 | Ui::AskPassphraseDialog *ui; 39 | Mode mode; 40 | WalletModel *model; 41 | bool fCapsLock; 42 | 43 | private slots: 44 | void textChanged(); 45 | 46 | protected: 47 | bool event(QEvent *event); 48 | bool eventFilter(QObject *object, QEvent *event); 49 | }; 50 | 51 | #endif // ASKPASSPHRASEDIALOG_H 52 | -------------------------------------------------------------------------------- /src/qt/bitcoinaddressvalidator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef BITCOINADDRESSVALIDATOR_H 6 | #define BITCOINADDRESSVALIDATOR_H 7 | 8 | #include 9 | 10 | /** Base58 entry widget validator. 11 | Corrects near-miss characters and refuses characters that are not part of base58. 12 | */ 13 | class BitcoinAddressValidator : public QValidator 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit BitcoinAddressValidator(QObject *parent = 0); 19 | 20 | State validate(QString &input, int &pos) const; 21 | 22 | static const int MaxAddressLength = 35; 23 | }; 24 | 25 | #endif // BITCOINADDRESSVALIDATOR_H 26 | -------------------------------------------------------------------------------- /src/qt/bitcoinamountfield.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef BITCOINAMOUNTFIELD_H 6 | #define BITCOINAMOUNTFIELD_H 7 | 8 | #include 9 | 10 | QT_BEGIN_NAMESPACE 11 | class QDoubleSpinBox; 12 | class QValueComboBox; 13 | QT_END_NAMESPACE 14 | 15 | /** Widget for entering bitcoin amounts. 16 | */ 17 | class BitcoinAmountField: public QWidget 18 | { 19 | Q_OBJECT 20 | 21 | Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true) 22 | 23 | public: 24 | explicit BitcoinAmountField(QWidget *parent = 0); 25 | 26 | qint64 value(bool *valid=0) const; 27 | void setValue(qint64 value); 28 | 29 | /** Make read-only **/ 30 | void setReadOnly(bool fReadOnly); 31 | 32 | /** Mark current value as invalid in UI. */ 33 | void setValid(bool valid); 34 | /** Perform input validation, mark field as invalid if entered value is not valid. */ 35 | bool validate(); 36 | 37 | /** Change unit used to display amount. */ 38 | void setDisplayUnit(int unit); 39 | 40 | /** Make field empty and ready for new input. */ 41 | void clear(); 42 | 43 | /** Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907), 44 | in these cases we have to set it up manually. 45 | */ 46 | QWidget *setupTabChain(QWidget *prev); 47 | 48 | signals: 49 | void textChanged(); 50 | 51 | protected: 52 | /** Intercept focus-in event and ',' key presses */ 53 | bool eventFilter(QObject *object, QEvent *event); 54 | 55 | private: 56 | QDoubleSpinBox *amount; 57 | QValueComboBox *unit; 58 | int currentUnit; 59 | 60 | void setText(const QString &text); 61 | QString text() const; 62 | 63 | private slots: 64 | void unitChanged(int idx); 65 | 66 | }; 67 | 68 | #endif // BITCOINAMOUNTFIELD_H 69 | -------------------------------------------------------------------------------- /src/qt/coincontroltreewidget.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "coincontroltreewidget.h" 6 | #include "coincontroldialog.h" 7 | 8 | CoinControlTreeWidget::CoinControlTreeWidget(QWidget *parent) : 9 | QTreeWidget(parent) 10 | { 11 | 12 | } 13 | 14 | void CoinControlTreeWidget::keyPressEvent(QKeyEvent *event) 15 | { 16 | if (event->key() == Qt::Key_Space) // press spacebar -> select checkbox 17 | { 18 | event->ignore(); 19 | int COLUMN_CHECKBOX = 0; 20 | this->currentItem()->setCheckState(COLUMN_CHECKBOX, ((this->currentItem()->checkState(COLUMN_CHECKBOX) == Qt::Checked) ? Qt::Unchecked : Qt::Checked)); 21 | } 22 | else if (event->key() == Qt::Key_Escape) // press esc -> close dialog 23 | { 24 | event->ignore(); 25 | CoinControlDialog *coinControlDialog = (CoinControlDialog*)this->parentWidget(); 26 | coinControlDialog->done(QDialog::Accepted); 27 | } 28 | else 29 | { 30 | this->QTreeWidget::keyPressEvent(event); 31 | } 32 | } -------------------------------------------------------------------------------- /src/qt/coincontroltreewidget.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef COINCONTROLTREEWIDGET_H 6 | #define COINCONTROLTREEWIDGET_H 7 | 8 | #include 9 | #include 10 | 11 | class CoinControlTreeWidget : public QTreeWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit CoinControlTreeWidget(QWidget *parent = 0); 17 | 18 | protected: 19 | virtual void keyPressEvent(QKeyEvent *event); 20 | }; 21 | 22 | #endif // COINCONTROLTREEWIDGET_H -------------------------------------------------------------------------------- /src/qt/csvmodelwriter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef CSVMODELWRITER_H 6 | #define CSVMODELWRITER_H 7 | 8 | #include 9 | #include 10 | 11 | QT_BEGIN_NAMESPACE 12 | class QAbstractItemModel; 13 | QT_END_NAMESPACE 14 | 15 | /** Export a Qt table model to a CSV file. This is useful for analyzing or post-processing the data in 16 | a spreadsheet. 17 | */ 18 | class CSVModelWriter : public QObject 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit CSVModelWriter(const QString &filename, QObject *parent = 0); 24 | 25 | void setModel(const QAbstractItemModel *model); 26 | void addColumn(const QString &title, int column, int role=Qt::EditRole); 27 | 28 | /** Perform export of the model to CSV. 29 | @returns true on success, false otherwise 30 | */ 31 | bool write(); 32 | 33 | private: 34 | QString filename; 35 | const QAbstractItemModel *model; 36 | 37 | struct Column 38 | { 39 | QString title; 40 | int column; 41 | int role; 42 | }; 43 | QList columns; 44 | }; 45 | 46 | #endif // CSVMODELWRITER_H 47 | -------------------------------------------------------------------------------- /src/qt/editaddressdialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef EDITADDRESSDIALOG_H 6 | #define EDITADDRESSDIALOG_H 7 | 8 | #include 9 | 10 | class AddressTableModel; 11 | 12 | namespace Ui { 13 | class EditAddressDialog; 14 | } 15 | 16 | QT_BEGIN_NAMESPACE 17 | class QDataWidgetMapper; 18 | QT_END_NAMESPACE 19 | 20 | /** Dialog for editing an address and associated information. 21 | */ 22 | class EditAddressDialog : public QDialog 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | enum Mode { 28 | NewReceivingAddress, 29 | NewSendingAddress, 30 | EditReceivingAddress, 31 | EditSendingAddress 32 | }; 33 | 34 | explicit EditAddressDialog(Mode mode, QWidget *parent); 35 | ~EditAddressDialog(); 36 | 37 | void setModel(AddressTableModel *model); 38 | void loadRow(int row); 39 | 40 | QString getAddress() const; 41 | void setAddress(const QString &address); 42 | 43 | public slots: 44 | void accept(); 45 | 46 | private: 47 | bool saveCurrentRow(); 48 | 49 | Ui::EditAddressDialog *ui; 50 | QDataWidgetMapper *mapper; 51 | Mode mode; 52 | AddressTableModel *model; 53 | 54 | QString address; 55 | }; 56 | 57 | #endif // EDITADDRESSDIALOG_H 58 | -------------------------------------------------------------------------------- /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 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef GUICONSTANTS_H 6 | #define GUICONSTANTS_H 7 | 8 | /* Milliseconds between model updates */ 9 | static const int MODEL_UPDATE_DELAY = 250; 10 | 11 | /* AskPassphraseDialog -- Maximum passphrase length */ 12 | static const int MAX_PASSPHRASE_SIZE = 1024; 13 | 14 | /* BitcoinGUI -- Size of icons in status bar */ 15 | static const int STATUSBAR_ICONSIZE = 16; 16 | 17 | /* Invalid field background style */ 18 | #define STYLE_INVALID "background:#FF8080" 19 | 20 | /* Transaction list -- unconfirmed transaction */ 21 | #define COLOR_UNCONFIRMED QColor(128, 128, 128) 22 | /* Transaction list -- negative amount */ 23 | #define COLOR_NEGATIVE QColor(255, 0, 0) 24 | /* Transaction list -- bare address (without label) */ 25 | #define COLOR_BAREADDRESS QColor(140, 140, 140) 26 | 27 | /* Tooltips longer than this (in characters) are converted into rich text, 28 | so that they can be word-wrapped. 29 | */ 30 | static const int TOOLTIP_WRAP_THRESHOLD = 80; 31 | 32 | /* Maximum allowed URI length */ 33 | static const int MAX_URI_LENGTH = 255; 34 | 35 | /* Maximum somewhat-sane size of a payment request file */ 36 | static const int MAX_PAYMENT_REQUEST_SIZE = 50000; // bytes 37 | 38 | /* QRCodeDialog -- size of exported QR Code image */ 39 | #define EXPORT_IMAGE_SIZE 256 40 | 41 | #endif // GUICONSTANTS_H 42 | -------------------------------------------------------------------------------- /src/qt/intro.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef INTRO_H 6 | #define INTRO_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | class FreespaceChecker; 13 | 14 | namespace Ui { 15 | class Intro; 16 | } 17 | 18 | /** Introduction screen (pre-GUI startup). 19 | Allows the user to choose a data directory, 20 | in which the wallet and block chain will be stored. 21 | */ 22 | class Intro : public QDialog 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit Intro(QWidget *parent = 0); 28 | ~Intro(); 29 | 30 | QString getDataDirectory(); 31 | void setDataDirectory(const QString &dataDir); 32 | 33 | /** 34 | * Determine data directory. Let the user choose if the current one doesn't exist. 35 | * 36 | * @note do NOT call global GetDataDir() before calling this function, this 37 | * will cause the wrong path to be cached. 38 | */ 39 | static void pickDataDirectory(bool fIsTestnet); 40 | 41 | /** 42 | * Determine default data directory for operating system. 43 | */ 44 | static QString getDefaultDataDirectory(); 45 | 46 | signals: 47 | void requestCheck(); 48 | void stopThread(); 49 | 50 | public slots: 51 | void setStatus(int status, const QString &message, quint64 bytesAvailable); 52 | 53 | private slots: 54 | void on_dataDirectory_textChanged(const QString &arg1); 55 | void on_ellipsisButton_clicked(); 56 | void on_dataDirDefault_clicked(); 57 | void on_dataDirCustom_clicked(); 58 | 59 | private: 60 | Ui::Intro *ui; 61 | QThread *thread; 62 | QMutex mutex; 63 | bool signalled; 64 | QString pathToCheck; 65 | 66 | void startThread(); 67 | void checkPath(const QString &dataDir); 68 | QString getPathToCheck(); 69 | 70 | friend class FreespaceChecker; 71 | }; 72 | 73 | #endif // INTRO_H 74 | -------------------------------------------------------------------------------- /src/qt/macdockiconhandler.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef MACDOCKICONHANDLER_H 6 | #define MACDOCKICONHANDLER_H 7 | 8 | #include 9 | #include 10 | 11 | QT_BEGIN_NAMESPACE 12 | class QIcon; 13 | class QMenu; 14 | class QWidget; 15 | QT_END_NAMESPACE 16 | 17 | #ifdef __OBJC__ 18 | @class DockIconClickEventHandler; 19 | #else 20 | class DockIconClickEventHandler; 21 | #endif 22 | 23 | /** Macintosh-specific dock icon handler. 24 | */ 25 | class MacDockIconHandler : public QObject 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | ~MacDockIconHandler(); 31 | 32 | QMenu *dockMenu(); 33 | void setIcon(const QIcon &icon); 34 | void setMainWindow(QMainWindow *window); 35 | static MacDockIconHandler *instance(); 36 | 37 | void handleDockIconClickEvent(); 38 | 39 | signals: 40 | void dockIconClicked(); 41 | 42 | private: 43 | MacDockIconHandler(); 44 | 45 | DockIconClickEventHandler *m_dockIconClickEventHandler; 46 | QWidget *m_dummyWidget; 47 | QMenu *m_dockMenu; 48 | QMainWindow *mainWindow; 49 | }; 50 | 51 | #endif // MACDOCKICONCLICKHANDLER_H 52 | -------------------------------------------------------------------------------- /src/qt/macnotificationhandler.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef MACNOTIFICATIONHANDLER_H 6 | #define MACNOTIFICATIONHANDLER_H 7 | 8 | #include 9 | 10 | /** Macintosh-specific notification handler (supports UserNotificationCenter and Growl). 11 | */ 12 | class MacNotificationHandler : public QObject 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | /** shows a 10.8+ UserNotification in the UserNotificationCenter 18 | */ 19 | void showNotification(const QString &title, const QString &text); 20 | 21 | /** executes AppleScript */ 22 | void sendAppleScript(const QString &script); 23 | 24 | /** check if OS can handle UserNotifications */ 25 | bool hasUserNotificationCenterSupport(void); 26 | static MacNotificationHandler *instance(); 27 | }; 28 | 29 | 30 | #endif // MACNOTIFICATIONHANDLER_H 31 | -------------------------------------------------------------------------------- /src/qt/monitoreddatamapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "monitoreddatamapper.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | MonitoredDataMapper::MonitoredDataMapper(QObject *parent) : 12 | QDataWidgetMapper(parent) 13 | { 14 | } 15 | 16 | void MonitoredDataMapper::addMapping(QWidget *widget, int section) 17 | { 18 | QDataWidgetMapper::addMapping(widget, section); 19 | addChangeMonitor(widget); 20 | } 21 | 22 | void MonitoredDataMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName) 23 | { 24 | QDataWidgetMapper::addMapping(widget, section, propertyName); 25 | addChangeMonitor(widget); 26 | } 27 | 28 | void MonitoredDataMapper::addChangeMonitor(QWidget *widget) 29 | { 30 | // Watch user property of widget for changes, and connect 31 | // the signal to our viewModified signal. 32 | QMetaProperty prop = widget->metaObject()->userProperty(); 33 | int signal = prop.notifySignalIndex(); 34 | int method = this->metaObject()->indexOfMethod("viewModified()"); 35 | if(signal != -1 && method != -1) 36 | { 37 | QMetaObject::connect(widget, signal, this, method); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/qt/monitoreddatamapper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef MONITOREDDATAMAPPER_H 6 | #define MONITOREDDATAMAPPER_H 7 | 8 | #include 9 | 10 | QT_BEGIN_NAMESPACE 11 | class QWidget; 12 | QT_END_NAMESPACE 13 | 14 | /** Data to Widget mapper that watches for edits and notifies listeners when a field is edited. 15 | This can be used, for example, to enable a commit/apply button in a configuration dialog. 16 | */ 17 | class MonitoredDataMapper : public QDataWidgetMapper 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | explicit MonitoredDataMapper(QObject *parent=0); 23 | 24 | void addMapping(QWidget *widget, int section); 25 | void addMapping(QWidget *widget, int section, const QByteArray &propertyName); 26 | 27 | private: 28 | void addChangeMonitor(QWidget *widget); 29 | 30 | signals: 31 | void viewModified(); 32 | }; 33 | 34 | #endif // MONITOREDDATAMAPPER_H 35 | -------------------------------------------------------------------------------- /src/qt/openuridialog.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "openuridialog.h" 6 | #include "ui_openuridialog.h" 7 | 8 | #include "guiutil.h" 9 | #include "walletmodel.h" 10 | 11 | #include 12 | 13 | OpenURIDialog::OpenURIDialog(QWidget *parent) : 14 | QDialog(parent), 15 | ui(new Ui::OpenURIDialog) 16 | { 17 | ui->setupUi(this); 18 | #if QT_VERSION >= 0x040700 19 | ui->uriEdit->setPlaceholderText("bitcoin:"); 20 | #endif 21 | } 22 | 23 | OpenURIDialog::~OpenURIDialog() 24 | { 25 | delete ui; 26 | } 27 | 28 | QString OpenURIDialog::getURI() 29 | { 30 | return ui->uriEdit->text(); 31 | } 32 | 33 | void OpenURIDialog::accept() 34 | { 35 | SendCoinsRecipient rcp; 36 | if(GUIUtil::parseBitcoinURI(getURI(), &rcp)) 37 | { 38 | /* Only accept value URIs */ 39 | QDialog::accept(); 40 | } else { 41 | ui->uriEdit->setValid(false); 42 | } 43 | } 44 | 45 | void OpenURIDialog::on_selectFileButton_clicked() 46 | { 47 | QString filename = GUIUtil::getOpenFileName(this, tr("Select payment request file to open"), "", "", NULL); 48 | if(filename.isEmpty()) 49 | return; 50 | QUrl fileUri = QUrl::fromLocalFile(filename); 51 | ui->uriEdit->setText("bitcoin:?request=" + QUrl::toPercentEncoding(fileUri.toString())); 52 | } 53 | -------------------------------------------------------------------------------- /src/qt/openuridialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef OPENURIDIALOG_H 6 | #define OPENURIDIALOG_H 7 | 8 | #include 9 | 10 | namespace Ui { 11 | class OpenURIDialog; 12 | } 13 | 14 | class OpenURIDialog : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit OpenURIDialog(QWidget *parent); 20 | ~OpenURIDialog(); 21 | 22 | QString getURI(); 23 | 24 | protected slots: 25 | void accept(); 26 | 27 | private slots: 28 | void on_selectFileButton_clicked(); 29 | 30 | private: 31 | Ui::OpenURIDialog *ui; 32 | }; 33 | 34 | #endif // OPENURIDIALOG_H 35 | -------------------------------------------------------------------------------- /src/qt/optionsdialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef OPTIONSDIALOG_H 6 | #define OPTIONSDIALOG_H 7 | 8 | #include 9 | 10 | class MonitoredDataMapper; 11 | class OptionsModel; 12 | class QValidatedLineEdit; 13 | 14 | namespace Ui { 15 | class OptionsDialog; 16 | } 17 | 18 | /** Preferences dialog. */ 19 | class OptionsDialog : public QDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit OptionsDialog(QWidget *parent); 25 | ~OptionsDialog(); 26 | 27 | void setModel(OptionsModel *model); 28 | void setMapper(); 29 | 30 | protected: 31 | bool eventFilter(QObject *object, QEvent *event); 32 | 33 | private slots: 34 | /* enable only apply button */ 35 | void enableApplyButton(); 36 | /* disable only apply button */ 37 | void disableApplyButton(); 38 | /* enable apply button and OK button */ 39 | void enableSaveButtons(); 40 | /* disable apply button and OK button */ 41 | void disableSaveButtons(); 42 | /* set apply button and OK button state (enabled / disabled) */ 43 | void setSaveButtonState(bool fState); 44 | void on_resetButton_clicked(); 45 | void on_okButton_clicked(); 46 | void on_cancelButton_clicked(); 47 | void on_applyButton_clicked(); 48 | 49 | void showRestartWarning_Proxy(); 50 | void showRestartWarning_Lang(); 51 | void updateDisplayUnit(); 52 | void handleProxyIpValid(QValidatedLineEdit *object, bool fState); 53 | 54 | signals: 55 | void proxyIpValid(QValidatedLineEdit *object, bool fValid); 56 | 57 | private: 58 | Ui::OptionsDialog *ui; 59 | OptionsModel *model; 60 | MonitoredDataMapper *mapper; 61 | bool fRestartWarningDisplayed_Proxy; 62 | bool fRestartWarningDisplayed_Lang; 63 | bool fProxyIpValid; 64 | }; 65 | 66 | #endif // OPTIONSDIALOG_H 67 | -------------------------------------------------------------------------------- /src/qt/overviewpage.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef OVERVIEWPAGE_H 6 | #define OVERVIEWPAGE_H 7 | 8 | #include 9 | 10 | class ClientModel; 11 | class TransactionFilterProxy; 12 | class TxViewDelegate; 13 | class WalletModel; 14 | 15 | namespace Ui { 16 | class OverviewPage; 17 | } 18 | 19 | QT_BEGIN_NAMESPACE 20 | class QModelIndex; 21 | QT_END_NAMESPACE 22 | 23 | /** Overview ("home") page widget */ 24 | class OverviewPage : public QWidget 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit OverviewPage(QWidget *parent = 0); 30 | ~OverviewPage(); 31 | 32 | void setClientModel(ClientModel *clientModel); 33 | void setWalletModel(WalletModel *walletModel); 34 | void showOutOfSyncWarning(bool fShow); 35 | 36 | public slots: 37 | void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance); 38 | 39 | signals: 40 | void transactionClicked(const QModelIndex &index); 41 | 42 | private: 43 | Ui::OverviewPage *ui; 44 | ClientModel *clientModel; 45 | WalletModel *walletModel; 46 | qint64 currentBalance; 47 | qint64 currentUnconfirmedBalance; 48 | qint64 currentImmatureBalance; 49 | 50 | TxViewDelegate *txdelegate; 51 | TransactionFilterProxy *filter; 52 | 53 | private slots: 54 | void updateDisplayUnit(); 55 | void handleTransactionClicked(const QModelIndex &index); 56 | void updateAlerts(const QString &warnings); 57 | }; 58 | 59 | #endif // OVERVIEWPAGE_H 60 | -------------------------------------------------------------------------------- /src/qt/paymentrequestplus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef PAYMENTREQUESTPLUS_H 6 | #define PAYMENTREQUESTPLUS_H 7 | 8 | #include "paymentrequest.pb.h" 9 | 10 | #include "base58.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | // 17 | // Wraps dumb protocol buffer paymentRequest 18 | // with extra methods 19 | // 20 | 21 | class PaymentRequestPlus 22 | { 23 | public: 24 | PaymentRequestPlus() { } 25 | 26 | bool parse(const QByteArray& data); 27 | bool SerializeToString(string* output) const; 28 | 29 | bool IsInitialized() const; 30 | QString getPKIType() const; 31 | // Returns true if merchant's identity is authenticated, and 32 | // returns human-readable merchant identity in merchant 33 | bool getMerchant(X509_STORE* certStore, QString& merchant) const; 34 | 35 | // Returns list of outputs, amount 36 | QList > getPayTo() const; 37 | 38 | const payments::PaymentDetails& getDetails() const { return details; } 39 | 40 | private: 41 | payments::PaymentRequest paymentRequest; 42 | payments::PaymentDetails details; 43 | }; 44 | 45 | #endif // PAYMENTREQUESTPLUS_H 46 | 47 | -------------------------------------------------------------------------------- /src/qt/qvalidatedlineedit.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "qvalidatedlineedit.h" 6 | 7 | #include "guiconstants.h" 8 | 9 | QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) : 10 | QLineEdit(parent), valid(true) 11 | { 12 | connect(this, SIGNAL(textChanged(QString)), this, SLOT(markValid())); 13 | } 14 | 15 | void QValidatedLineEdit::setValid(bool valid) 16 | { 17 | if(valid == this->valid) 18 | { 19 | return; 20 | } 21 | 22 | if(valid) 23 | { 24 | setStyleSheet(""); 25 | } 26 | else 27 | { 28 | setStyleSheet(STYLE_INVALID); 29 | } 30 | this->valid = valid; 31 | } 32 | 33 | void QValidatedLineEdit::focusInEvent(QFocusEvent *evt) 34 | { 35 | // Clear invalid flag on focus 36 | setValid(true); 37 | QLineEdit::focusInEvent(evt); 38 | } 39 | 40 | void QValidatedLineEdit::markValid() 41 | { 42 | setValid(true); 43 | } 44 | 45 | void QValidatedLineEdit::clear() 46 | { 47 | setValid(true); 48 | QLineEdit::clear(); 49 | } 50 | -------------------------------------------------------------------------------- /src/qt/qvalidatedlineedit.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef QVALIDATEDLINEEDIT_H 6 | #define QVALIDATEDLINEEDIT_H 7 | 8 | #include 9 | 10 | /** Line edit that can be marked as "invalid" to show input validation feedback. When marked as invalid, 11 | it will get a red background until it is focused. 12 | */ 13 | class QValidatedLineEdit : public QLineEdit 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit QValidatedLineEdit(QWidget *parent = 0); 19 | void clear(); 20 | 21 | protected: 22 | void focusInEvent(QFocusEvent *evt); 23 | 24 | private: 25 | bool valid; 26 | 27 | public slots: 28 | void setValid(bool valid); 29 | 30 | private slots: 31 | void markValid(); 32 | }; 33 | 34 | #endif // QVALIDATEDLINEEDIT_H 35 | -------------------------------------------------------------------------------- /src/qt/qvaluecombobox.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "qvaluecombobox.h" 6 | 7 | QValueComboBox::QValueComboBox(QWidget *parent) : 8 | QComboBox(parent), role(Qt::UserRole) 9 | { 10 | connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); 11 | } 12 | 13 | QVariant QValueComboBox::value() const 14 | { 15 | return itemData(currentIndex(), role); 16 | } 17 | 18 | void QValueComboBox::setValue(const QVariant &value) 19 | { 20 | setCurrentIndex(findData(value, role)); 21 | } 22 | 23 | void QValueComboBox::setRole(int role) 24 | { 25 | this->role = role; 26 | } 27 | 28 | void QValueComboBox::handleSelectionChanged(int idx) 29 | { 30 | emit valueChanged(); 31 | } 32 | -------------------------------------------------------------------------------- /src/qt/qvaluecombobox.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef QVALUECOMBOBOX_H 6 | #define QVALUECOMBOBOX_H 7 | 8 | #include 9 | #include 10 | 11 | /* QComboBox that can be used with QDataWidgetMapper to select ordinal values from a model. */ 12 | class QValueComboBox : public QComboBox 13 | { 14 | Q_OBJECT 15 | 16 | Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true) 17 | 18 | public: 19 | explicit QValueComboBox(QWidget *parent = 0); 20 | 21 | QVariant value() const; 22 | void setValue(const QVariant &value); 23 | 24 | /** Specify model role to use as ordinal value (defaults to Qt::UserRole) */ 25 | void setRole(int role); 26 | 27 | signals: 28 | void valueChanged(); 29 | 30 | private: 31 | int role; 32 | 33 | private slots: 34 | void handleSelectionChanged(int idx); 35 | }; 36 | 37 | #endif // QVALUECOMBOBOX_H 38 | -------------------------------------------------------------------------------- /src/qt/receivecoinsdialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef RECEIVECOINSDIALOG_H 6 | #define RECEIVECOINSDIALOG_H 7 | 8 | #include 9 | #include 10 | 11 | namespace Ui { 12 | class ReceiveCoinsDialog; 13 | } 14 | class WalletModel; 15 | class OptionsModel; 16 | 17 | /** Dialog for requesting payment of bitcoins */ 18 | class ReceiveCoinsDialog : public QDialog 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit ReceiveCoinsDialog(QWidget *parent = 0); 24 | ~ReceiveCoinsDialog(); 25 | 26 | void setModel(WalletModel *model); 27 | 28 | public slots: 29 | void clear(); 30 | void reject(); 31 | void accept(); 32 | 33 | private: 34 | Ui::ReceiveCoinsDialog *ui; 35 | WalletModel *model; 36 | 37 | private slots: 38 | void on_receiveButton_clicked(); 39 | void updateDisplayUnit(); 40 | }; 41 | 42 | #endif // RECEIVECOINSDIALOG_H 43 | -------------------------------------------------------------------------------- /src/qt/receiverequestdialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef QRCODEDIALOG_H 6 | #define QRCODEDIALOG_H 7 | 8 | #include "walletmodel.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace Ui { 15 | class ReceiveRequestDialog; 16 | } 17 | class OptionsModel; 18 | 19 | /* Label widget for QR code. This image can be dragged, dropped, copied and saved 20 | * to disk. 21 | */ 22 | class QRImageWidget : public QLabel 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit QRImageWidget(QWidget *parent = 0); 28 | QImage exportImage(); 29 | 30 | public slots: 31 | void saveImage(); 32 | void copyImage(); 33 | 34 | protected: 35 | virtual void mousePressEvent(QMouseEvent *event); 36 | }; 37 | 38 | class ReceiveRequestDialog : public QDialog 39 | { 40 | Q_OBJECT 41 | 42 | public: 43 | explicit ReceiveRequestDialog(QWidget *parent = 0); 44 | ~ReceiveRequestDialog(); 45 | 46 | void setModel(OptionsModel *model); 47 | void setInfo(const SendCoinsRecipient &info); 48 | 49 | private slots: 50 | void on_btnCopyURI_clicked(); 51 | void on_btnCopyAddress_clicked(); 52 | 53 | void update(); 54 | 55 | private: 56 | Ui::ReceiveRequestDialog *ui; 57 | OptionsModel *model; 58 | SendCoinsRecipient info; 59 | }; 60 | 61 | #endif // QRCODEDIALOG_H 62 | -------------------------------------------------------------------------------- /src/qt/res/bitcoin-qt-res.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "icons/bitcoin.ico" 2 | IDI_ICON2 ICON DISCARDABLE "icons/bitcoin_testnet.ico" 3 | 4 | #include // needed for VERSIONINFO 5 | #include "../../clientversion.h" // holds the needed client version information 6 | 7 | #define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD 8 | #define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) 9 | #define VER_FILEVERSION VER_PRODUCTVERSION 10 | #define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR 11 | #define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin developers" 12 | 13 | VS_VERSION_INFO VERSIONINFO 14 | FILEVERSION VER_FILEVERSION 15 | PRODUCTVERSION VER_PRODUCTVERSION 16 | FILEOS VOS_NT_WINDOWS32 17 | FILETYPE VFT_APP 18 | BEGIN 19 | BLOCK "StringFileInfo" 20 | BEGIN 21 | BLOCK "040904E4" // U.S. English - multilingual (hex) 22 | BEGIN 23 | VALUE "CompanyName", "Bitcoin" 24 | VALUE "FileDescription", "Bitcoin-Qt (OSS GUI client for Bitcoin)" 25 | VALUE "FileVersion", VER_FILEVERSION_STR 26 | VALUE "InternalName", "bitcoin-qt" 27 | VALUE "LegalCopyright", COPYRIGHT_STR 28 | VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." 29 | VALUE "OriginalFilename", "bitcoin-qt.exe" 30 | VALUE "ProductName", "Bitcoin-Qt" 31 | VALUE "ProductVersion", VER_PRODUCTVERSION_STR 32 | END 33 | END 34 | 35 | BLOCK "VarFileInfo" 36 | BEGIN 37 | VALUE "Translation", 0x0, 1252 // language neutral - multilingual (decimal) 38 | END 39 | END 40 | -------------------------------------------------------------------------------- /src/qt/res/icons/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/add.png -------------------------------------------------------------------------------- /src/qt/res/icons/address-book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/address-book.png -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/bitcoin.icns -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/bitcoin.ico -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/bitcoin.png -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin_testnet.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/bitcoin_testnet.ico -------------------------------------------------------------------------------- /src/qt/res/icons/bitcoin_testnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/bitcoin_testnet.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/clock1.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/clock2.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/clock3.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/clock4.png -------------------------------------------------------------------------------- /src/qt/res/icons/clock5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/clock5.png -------------------------------------------------------------------------------- /src/qt/res/icons/configure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/configure.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect0_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/connect0_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect1_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/connect1_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect2_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/connect2_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect3_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/connect3_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/connect4_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/connect4_16.png -------------------------------------------------------------------------------- /src/qt/res/icons/debugwindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/debugwindow.png -------------------------------------------------------------------------------- /src/qt/res/icons/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/edit.png -------------------------------------------------------------------------------- /src/qt/res/icons/editcopy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/editcopy.png -------------------------------------------------------------------------------- /src/qt/res/icons/editpaste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/editpaste.png -------------------------------------------------------------------------------- /src/qt/res/icons/export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/export.png -------------------------------------------------------------------------------- /src/qt/res/icons/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/filesave.png -------------------------------------------------------------------------------- /src/qt/res/icons/history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/history.png -------------------------------------------------------------------------------- /src/qt/res/icons/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/key.png -------------------------------------------------------------------------------- /src/qt/res/icons/lock_closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/lock_closed.png -------------------------------------------------------------------------------- /src/qt/res/icons/lock_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/lock_open.png -------------------------------------------------------------------------------- /src/qt/res/icons/notsynced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/notsynced.png -------------------------------------------------------------------------------- /src/qt/res/icons/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/overview.png -------------------------------------------------------------------------------- /src/qt/res/icons/qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/qrcode.png -------------------------------------------------------------------------------- /src/qt/res/icons/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/quit.png -------------------------------------------------------------------------------- /src/qt/res/icons/receive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/receive.png -------------------------------------------------------------------------------- /src/qt/res/icons/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/remove.png -------------------------------------------------------------------------------- /src/qt/res/icons/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/send.png -------------------------------------------------------------------------------- /src/qt/res/icons/synced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/synced.png -------------------------------------------------------------------------------- /src/qt/res/icons/toolbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/toolbar.png -------------------------------------------------------------------------------- /src/qt/res/icons/toolbar_testnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/toolbar_testnet.png -------------------------------------------------------------------------------- /src/qt/res/icons/transaction0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/transaction0.png -------------------------------------------------------------------------------- /src/qt/res/icons/transaction2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/transaction2.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_inout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/tx_inout.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/tx_input.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_mined.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/tx_mined.png -------------------------------------------------------------------------------- /src/qt/res/icons/tx_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/icons/tx_output.png -------------------------------------------------------------------------------- /src/qt/res/images/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/images/about.png -------------------------------------------------------------------------------- /src/qt/res/images/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/images/splash.png -------------------------------------------------------------------------------- /src/qt/res/images/splash_testnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/images/splash_testnet.png -------------------------------------------------------------------------------- /src/qt/res/movies/update_spinner.mng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/qt/res/movies/update_spinner.mng -------------------------------------------------------------------------------- /src/qt/sendcoinsentry.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef SENDCOINSENTRY_H 6 | #define SENDCOINSENTRY_H 7 | 8 | #include "walletmodel.h" 9 | 10 | #include 11 | 12 | class WalletModel; 13 | 14 | namespace Ui { 15 | class SendCoinsEntry; 16 | } 17 | 18 | /** 19 | * A single entry in the dialog for sending bitcoins. 20 | * Stacked widget, with different UIs for payment requests 21 | * with a strong payee identity. 22 | */ 23 | class SendCoinsEntry : public QStackedWidget 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit SendCoinsEntry(QWidget *parent = 0); 29 | ~SendCoinsEntry(); 30 | 31 | void setModel(WalletModel *model); 32 | bool validate(); 33 | SendCoinsRecipient getValue(); 34 | 35 | /** Return whether the entry is still empty and unedited */ 36 | bool isClear(); 37 | 38 | void setValue(const SendCoinsRecipient &value); 39 | void setAddress(const QString &address); 40 | 41 | /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases 42 | * (issue https://bugreports.qt-project.org/browse/QTBUG-10907). 43 | */ 44 | QWidget *setupTabChain(QWidget *prev); 45 | 46 | void setFocus(); 47 | 48 | public slots: 49 | void setRemoveEnabled(bool enabled); 50 | void clear(); 51 | 52 | signals: 53 | void removeEntry(SendCoinsEntry *entry); 54 | void payAmountChanged(); 55 | 56 | private slots: 57 | void on_deleteButton_clicked(); 58 | void on_payTo_textChanged(const QString &address); 59 | void on_addressBookButton_clicked(); 60 | void on_pasteButton_clicked(); 61 | void updateDisplayUnit(); 62 | 63 | private: 64 | SendCoinsRecipient recipient; 65 | Ui::SendCoinsEntry *ui; 66 | WalletModel *model; 67 | 68 | bool updateLabel(const QString &address); 69 | }; 70 | 71 | #endif // SENDCOINSENTRY_H 72 | -------------------------------------------------------------------------------- /src/qt/signverifymessagedialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef SIGNVERIFYMESSAGEDIALOG_H 6 | #define SIGNVERIFYMESSAGEDIALOG_H 7 | 8 | #include 9 | 10 | class WalletModel; 11 | 12 | namespace Ui { 13 | class SignVerifyMessageDialog; 14 | } 15 | 16 | class SignVerifyMessageDialog : public QDialog 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit SignVerifyMessageDialog(QWidget *parent); 22 | ~SignVerifyMessageDialog(); 23 | 24 | void setModel(WalletModel *model); 25 | void setAddress_SM(const QString &address); 26 | void setAddress_VM(const QString &address); 27 | 28 | void showTab_SM(bool fShow); 29 | void showTab_VM(bool fShow); 30 | 31 | protected: 32 | bool eventFilter(QObject *object, QEvent *event); 33 | 34 | private: 35 | Ui::SignVerifyMessageDialog *ui; 36 | WalletModel *model; 37 | 38 | private slots: 39 | /* sign message */ 40 | void on_addressBookButton_SM_clicked(); 41 | void on_pasteButton_SM_clicked(); 42 | void on_signMessageButton_SM_clicked(); 43 | void on_copySignatureButton_SM_clicked(); 44 | void on_clearButton_SM_clicked(); 45 | /* verify message */ 46 | void on_addressBookButton_VM_clicked(); 47 | void on_verifyMessageButton_VM_clicked(); 48 | void on_clearButton_VM_clicked(); 49 | }; 50 | 51 | #endif // SIGNVERIFYMESSAGEDIALOG_H 52 | -------------------------------------------------------------------------------- /src/qt/splashscreen.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef SPLASHSCREEN_H 6 | #define SPLASHSCREEN_H 7 | 8 | #include 9 | 10 | /** class for the splashscreen with information of the running client 11 | */ 12 | class SplashScreen : public QSplashScreen 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit SplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0); 18 | }; 19 | 20 | #endif // SPLASHSCREEN_H 21 | -------------------------------------------------------------------------------- /src/qt/test/Makefile.am: -------------------------------------------------------------------------------- 1 | include $(top_srcdir)/src/Makefile.include 2 | 3 | AM_CPPFLAGS += -I$(top_srcdir)/src \ 4 | -I$(top_srcdir)/src/qt \ 5 | -I$(top_builddir)/src/qt \ 6 | $(PROTOBUF_CFLAGS) \ 7 | $(QR_CFLAGS) 8 | bin_PROGRAMS = test_bitcoin-qt 9 | TESTS = test_bitcoin-qt 10 | 11 | TEST_QT_MOC_CPP = moc_uritests.cpp moc_paymentservertests.cpp 12 | 13 | TEST_QT_H = uritests.h paymentservertests.h paymentrequestdata.h 14 | 15 | BUILT_SOURCES = $(TEST_QT_MOC_CPP) 16 | 17 | test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) $(QT_TEST_INCLUDES) 18 | test_bitcoin_qt_SOURCES = test_main.cpp uritests.cpp paymentservertests.cpp $(TEST_QT_H) 19 | nodist_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP) 20 | test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN) $(LIBLEVELDB) \ 21 | $(LIBMEMENV) $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \ 22 | $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) 23 | 24 | CLEANFILES = $(BUILT_SOURCES) *.gcda *.gcno 25 | 26 | -------------------------------------------------------------------------------- /src/qt/test/paymentservertests.h: -------------------------------------------------------------------------------- 1 | #ifndef PAYMENTSERVERTESTS_H 2 | #define PAYMENTSERVERTESTS_H 3 | 4 | #include "../paymentserver.h" 5 | 6 | #include 7 | #include 8 | 9 | class PaymentServerTests : public QObject 10 | { 11 | Q_OBJECT 12 | 13 | private slots: 14 | void paymentServerTests(); 15 | }; 16 | 17 | // Dummy class to receive paymentserver signals. 18 | // If SendCoinsRecipient was a proper QObject, then we could use 19 | // QSignalSpy... but it's not. 20 | class RecipientCatcher : public QObject 21 | { 22 | Q_OBJECT 23 | public slots: 24 | void getRecipient(SendCoinsRecipient r); 25 | public: 26 | SendCoinsRecipient recipient; 27 | }; 28 | 29 | #endif // PAYMENTSERVERTESTS_H 30 | -------------------------------------------------------------------------------- /src/qt/test/test_main.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "paymentservertests.h" 4 | #include "uritests.h" 5 | 6 | #include 7 | #include 8 | 9 | // This is all you need to run all the tests 10 | int main(int argc, char *argv[]) 11 | { 12 | bool fInvalid = false; 13 | 14 | URITests test1; 15 | if (QTest::qExec(&test1) != 0) 16 | fInvalid = true; 17 | 18 | PaymentServerTests test2; 19 | if (QTest::qExec(&test2) != 0) 20 | fInvalid = true; 21 | 22 | return fInvalid; 23 | } 24 | -------------------------------------------------------------------------------- /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/trafficgraphwidget.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef TRAFFICGRAPHWIDGET_H 6 | #define TRAFFICGRAPHWIDGET_H 7 | 8 | #include 9 | #include 10 | 11 | class ClientModel; 12 | 13 | QT_BEGIN_NAMESPACE 14 | class QPaintEvent; 15 | class QTimer; 16 | QT_END_NAMESPACE 17 | 18 | class TrafficGraphWidget : public QWidget 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit TrafficGraphWidget(QWidget *parent = 0); 24 | void setClientModel(ClientModel *model); 25 | int getGraphRangeMins() const; 26 | 27 | protected: 28 | void paintEvent(QPaintEvent *); 29 | 30 | public slots: 31 | void updateRates(); 32 | void setGraphRangeMins(int mins); 33 | void clear(); 34 | 35 | private: 36 | void paintPath(QPainterPath &path, QQueue &samples); 37 | 38 | QTimer *timer; 39 | float fMax; 40 | int nMins; 41 | QQueue vSamplesIn; 42 | QQueue vSamplesOut; 43 | quint64 nLastBytesIn; 44 | quint64 nLastBytesOut; 45 | ClientModel *clientModel; 46 | }; 47 | 48 | #endif // TRAFFICGRAPHWIDGET_H 49 | -------------------------------------------------------------------------------- /src/qt/transactiondesc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef TRANSACTIONDESC_H 6 | #define TRANSACTIONDESC_H 7 | 8 | #include 9 | #include 10 | 11 | class CWallet; 12 | class CWalletTx; 13 | 14 | /** Provide a human-readable extended HTML description of a transaction. 15 | */ 16 | class TransactionDesc: public QObject 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | static QString toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int unit); 22 | 23 | private: 24 | TransactionDesc() {} 25 | 26 | static QString FormatTxStatus(const CWalletTx& wtx); 27 | }; 28 | 29 | #endif // TRANSACTIONDESC_H 30 | -------------------------------------------------------------------------------- /src/qt/transactiondescdialog.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include "transactiondescdialog.h" 6 | #include "ui_transactiondescdialog.h" 7 | 8 | #include "transactiontablemodel.h" 9 | 10 | #include 11 | 12 | TransactionDescDialog::TransactionDescDialog(const QModelIndex &idx, QWidget *parent) : 13 | QDialog(parent), 14 | ui(new Ui::TransactionDescDialog) 15 | { 16 | ui->setupUi(this); 17 | QString desc = idx.data(TransactionTableModel::LongDescriptionRole).toString(); 18 | ui->detailText->setHtml(desc); 19 | } 20 | 21 | TransactionDescDialog::~TransactionDescDialog() 22 | { 23 | delete ui; 24 | } 25 | -------------------------------------------------------------------------------- /src/qt/transactiondescdialog.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef TRANSACTIONDESCDIALOG_H 6 | #define TRANSACTIONDESCDIALOG_H 7 | 8 | #include 9 | 10 | namespace Ui { 11 | class TransactionDescDialog; 12 | } 13 | 14 | QT_BEGIN_NAMESPACE 15 | class QModelIndex; 16 | QT_END_NAMESPACE 17 | 18 | /** Dialog showing transaction details. */ 19 | class TransactionDescDialog : public QDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit TransactionDescDialog(const QModelIndex &idx, QWidget *parent = 0); 25 | ~TransactionDescDialog(); 26 | 27 | private: 28 | Ui::TransactionDescDialog *ui; 29 | }; 30 | 31 | #endif // TRANSACTIONDESCDIALOG_H 32 | -------------------------------------------------------------------------------- /src/qt/transactionfilterproxy.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef TRANSACTIONFILTERPROXY_H 6 | #define TRANSACTIONFILTERPROXY_H 7 | 8 | #include 9 | #include 10 | 11 | /** Filter the transaction list according to pre-specified rules. */ 12 | class TransactionFilterProxy : public QSortFilterProxyModel 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit TransactionFilterProxy(QObject *parent = 0); 18 | 19 | /** Earliest date that can be represented (far in the past) */ 20 | static const QDateTime MIN_DATE; 21 | /** Last date that can be represented (far in the future) */ 22 | static const QDateTime MAX_DATE; 23 | /** Type filter bit field (all types) */ 24 | static const quint32 ALL_TYPES = 0xFFFFFFFF; 25 | 26 | static quint32 TYPE(int type) { return 1< &recipients) : 10 | recipients(recipients), 11 | walletTransaction(0), 12 | keyChange(0), 13 | fee(0) 14 | { 15 | walletTransaction = new CWalletTx(); 16 | } 17 | 18 | WalletModelTransaction::~WalletModelTransaction() 19 | { 20 | delete keyChange; 21 | delete walletTransaction; 22 | } 23 | 24 | QList WalletModelTransaction::getRecipients() 25 | { 26 | return recipients; 27 | } 28 | 29 | CWalletTx *WalletModelTransaction::getTransaction() 30 | { 31 | return walletTransaction; 32 | } 33 | 34 | qint64 WalletModelTransaction::getTransactionFee() 35 | { 36 | return fee; 37 | } 38 | 39 | void WalletModelTransaction::setTransactionFee(qint64 newFee) 40 | { 41 | fee = newFee; 42 | } 43 | 44 | qint64 WalletModelTransaction::getTotalTransactionAmount() 45 | { 46 | qint64 totalTransactionAmount = 0; 47 | foreach(const SendCoinsRecipient &rcp, recipients) 48 | { 49 | totalTransactionAmount += rcp.amount; 50 | } 51 | return totalTransactionAmount; 52 | } 53 | 54 | void WalletModelTransaction::newPossibleKeyChange(CWallet *wallet) 55 | { 56 | keyChange = new CReserveKey(wallet); 57 | } 58 | 59 | CReserveKey *WalletModelTransaction::getPossibleKeyChange() 60 | { 61 | return keyChange; 62 | } 63 | -------------------------------------------------------------------------------- /src/qt/walletmodeltransaction.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011-2013 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #ifndef WALLETMODELTRANSACTION_H 6 | #define WALLETMODELTRANSACTION_H 7 | 8 | #include "walletmodel.h" 9 | 10 | #include 11 | 12 | class SendCoinsRecipient; 13 | 14 | class CReserveKey; 15 | class CWallet; 16 | class CWalletTx; 17 | 18 | /** Data model for a walletmodel transaction. */ 19 | class WalletModelTransaction 20 | { 21 | public: 22 | explicit WalletModelTransaction(const QList &recipients); 23 | ~WalletModelTransaction(); 24 | 25 | QList getRecipients(); 26 | 27 | CWalletTx *getTransaction(); 28 | 29 | void setTransactionFee(qint64 newFee); 30 | qint64 getTransactionFee(); 31 | 32 | qint64 getTotalTransactionAmount(); 33 | 34 | void newPossibleKeyChange(CWallet *wallet); 35 | CReserveKey *getPossibleKeyChange(); 36 | 37 | private: 38 | const QList recipients; 39 | CWalletTx *walletTransaction; 40 | CReserveKey *keyChange; 41 | qint64 fee; 42 | 43 | public slots: 44 | 45 | }; 46 | 47 | #endif // WALLETMODELTRANSACTION_H 48 | -------------------------------------------------------------------------------- /src/test/Checkpoints_tests.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Unit tests for block-chain checkpoints 3 | // 4 | 5 | #include "checkpoints.h" 6 | 7 | #include "uint256.h" 8 | 9 | #include 10 | 11 | using namespace std; 12 | 13 | BOOST_AUTO_TEST_SUITE(Checkpoints_tests) 14 | 15 | BOOST_AUTO_TEST_CASE(sanity) 16 | { 17 | uint256 p11111 = uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"); 18 | uint256 p134444 = uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"); 19 | BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111)); 20 | BOOST_CHECK(Checkpoints::CheckBlock(134444, p134444)); 21 | 22 | 23 | // Wrong hashes at checkpoints should fail: 24 | BOOST_CHECK(!Checkpoints::CheckBlock(11111, p134444)); 25 | BOOST_CHECK(!Checkpoints::CheckBlock(134444, p11111)); 26 | 27 | // ... but any hash not at a checkpoint should succeed: 28 | BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p134444)); 29 | BOOST_CHECK(Checkpoints::CheckBlock(134444+1, p11111)); 30 | 31 | BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 134444); 32 | } 33 | 34 | BOOST_AUTO_TEST_SUITE_END() 35 | -------------------------------------------------------------------------------- /src/test/Makefile.am: -------------------------------------------------------------------------------- 1 | include $(top_srcdir)/src/Makefile.include 2 | 3 | AM_CPPFLAGS += -I$(top_srcdir)/src 4 | 5 | bin_PROGRAMS = test_bitcoin 6 | 7 | TESTS = test_bitcoin 8 | 9 | JSON_TEST_FILES= data/script_valid.json \ 10 | data/base58_keys_valid.json data/sig_canonical.json \ 11 | data/sig_noncanonical.json \ 12 | data/base58_encode_decode.json \ 13 | data/base58_keys_invalid.json \ 14 | data/script_invalid.json data/tx_invalid.json \ 15 | data/tx_valid.json 16 | 17 | RAW_TEST_FILES = data/alertTests.raw 18 | 19 | BUILT_SOURCES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h) 20 | 21 | # test_bitcoin binary # 22 | test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(TESTDEFS) 23 | test_bitcoin_LDADD = $(LIBBITCOIN) $(LIBLEVELDB) $(LIBMEMENV) \ 24 | $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(BDB_LIBS) 25 | test_bitcoin_SOURCES = accounting_tests.cpp alert_tests.cpp \ 26 | allocator_tests.cpp base32_tests.cpp base58_tests.cpp base64_tests.cpp \ 27 | bignum_tests.cpp bloom_tests.cpp canonical_tests.cpp checkblock_tests.cpp \ 28 | Checkpoints_tests.cpp compress_tests.cpp DoS_tests.cpp getarg_tests.cpp \ 29 | key_tests.cpp miner_tests.cpp mruset_tests.cpp multisig_tests.cpp \ 30 | netbase_tests.cpp pmt_tests.cpp rpc_tests.cpp script_P2SH_tests.cpp \ 31 | script_tests.cpp serialize_tests.cpp sigopcount_tests.cpp test_bitcoin.cpp \ 32 | transaction_tests.cpp uint160_tests.cpp uint256_tests.cpp util_tests.cpp \ 33 | wallet_tests.cpp sighash_tests.cpp $(JSON_TEST_FILES) $(RAW_TEST_FILES) 34 | 35 | nodist_test_bitcoin_SOURCES = $(BUILT_SOURCES) 36 | 37 | CLEANFILES = *.gcda *.gcno $(BUILT_SOURCES) 38 | -------------------------------------------------------------------------------- /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/base32_tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "util.h" 4 | 5 | #include 6 | 7 | BOOST_AUTO_TEST_SUITE(base32_tests) 8 | 9 | BOOST_AUTO_TEST_CASE(base32_testvectors) 10 | { 11 | static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"}; 12 | static const std::string vstrOut[] = {"","my======","mzxq====","mzxw6===","mzxw6yq=","mzxw6ytb","mzxw6ytboi======"}; 13 | for (unsigned int i=0; i 6 | 7 | BOOST_AUTO_TEST_SUITE(base64_tests) 8 | 9 | BOOST_AUTO_TEST_CASE(base64_testvectors) 10 | { 11 | static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"}; 12 | static const std::string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"}; 13 | for (unsigned int i=0; i 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | BOOST_AUTO_TEST_SUITE(CheckBlock_tests) 17 | 18 | bool 19 | read_block(const std::string& filename, CBlock& block) 20 | { 21 | namespace fs = boost::filesystem; 22 | fs::path testFile = fs::current_path() / "data" / filename; 23 | #ifdef TEST_DATA_DIR 24 | if (!fs::exists(testFile)) 25 | { 26 | testFile = fs::path(BOOST_PP_STRINGIZE(TEST_DATA_DIR)) / filename; 27 | } 28 | #endif 29 | FILE* fp = fopen(testFile.string().c_str(), "rb"); 30 | if (!fp) return false; 31 | 32 | fseek(fp, 8, SEEK_SET); // skip msgheader/size 33 | 34 | CAutoFile filein = CAutoFile(fp, SER_DISK, CLIENT_VERSION); 35 | if (!filein) return false; 36 | 37 | filein >> block; 38 | 39 | return true; 40 | } 41 | 42 | BOOST_AUTO_TEST_CASE(May15) 43 | { 44 | // Putting a 1MB binary file in the git repository is not a great 45 | // idea, so this test is only run if you manually download 46 | // test/data/Mar12Fork.dat from 47 | // http://sourceforge.net/projects/bitcoin/files/Bitcoin/blockchain/Mar12Fork.dat/download 48 | unsigned int tMay15 = 1368576000; 49 | SetMockTime(tMay15); // Test as if it was right at May 15 50 | 51 | CBlock forkingBlock; 52 | if (read_block("Mar12Fork.dat", forkingBlock)) 53 | { 54 | CValidationState state; 55 | 56 | // After May 15'th, big blocks are OK: 57 | forkingBlock.nTime = tMay15; // Invalidates PoW 58 | BOOST_CHECK(CheckBlock(forkingBlock, state, false, false)); 59 | } 60 | 61 | SetMockTime(0); 62 | } 63 | 64 | BOOST_AUTO_TEST_SUITE_END() 65 | -------------------------------------------------------------------------------- /src/test/compress_tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "main.h" 4 | #include "util.h" 5 | 6 | #include 7 | 8 | #include 9 | 10 | // amounts 0.00000001 .. 0.00100000 11 | #define NUM_MULTIPLES_UNIT 100000 12 | 13 | // amounts 0.01 .. 100.00 14 | #define NUM_MULTIPLES_CENT 10000 15 | 16 | // amounts 1 .. 10000 17 | #define NUM_MULTIPLES_1BTC 10000 18 | 19 | // amounts 50 .. 21000000 20 | #define NUM_MULTIPLES_50BTC 420000 21 | 22 | BOOST_AUTO_TEST_SUITE(compress_tests) 23 | 24 | bool static TestEncode(uint64_t in) { 25 | return in == CTxOutCompressor::DecompressAmount(CTxOutCompressor::CompressAmount(in)); 26 | } 27 | 28 | bool static TestDecode(uint64_t in) { 29 | return in == CTxOutCompressor::CompressAmount(CTxOutCompressor::DecompressAmount(in)); 30 | } 31 | 32 | bool static TestPair(uint64_t dec, uint64_t enc) { 33 | return CTxOutCompressor::CompressAmount(dec) == enc && 34 | CTxOutCompressor::DecompressAmount(enc) == dec; 35 | } 36 | 37 | BOOST_AUTO_TEST_CASE(compress_amounts) 38 | { 39 | BOOST_CHECK(TestPair( 0, 0x0)); 40 | BOOST_CHECK(TestPair( 1, 0x1)); 41 | BOOST_CHECK(TestPair( CENT, 0x7)); 42 | BOOST_CHECK(TestPair( COIN, 0x9)); 43 | BOOST_CHECK(TestPair( 50*COIN, 0x32)); 44 | BOOST_CHECK(TestPair(21000000*COIN, 0x1406f40)); 45 | 46 | for (uint64_t i = 1; i <= NUM_MULTIPLES_UNIT; i++) 47 | BOOST_CHECK(TestEncode(i)); 48 | 49 | for (uint64_t i = 1; i <= NUM_MULTIPLES_CENT; i++) 50 | BOOST_CHECK(TestEncode(i * CENT)); 51 | 52 | for (uint64_t i = 1; i <= NUM_MULTIPLES_1BTC; i++) 53 | BOOST_CHECK(TestEncode(i * COIN)); 54 | 55 | for (uint64_t i = 1; i <= NUM_MULTIPLES_50BTC; i++) 56 | BOOST_CHECK(TestEncode(i * 50 * COIN)); 57 | 58 | for (uint64_t i = 0; i < 100000; i++) 59 | BOOST_CHECK(TestDecode(i)); 60 | } 61 | 62 | BOOST_AUTO_TEST_SUITE_END() 63 | -------------------------------------------------------------------------------- /src/test/data/alertTests.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikehearn/bitcoin/006b893cf3d4e25526811b7ef86928ab229d7497/src/test/data/alertTests.raw -------------------------------------------------------------------------------- /src/test/data/base58_encode_decode.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["", ""], 3 | ["61", "2g"], 4 | ["626262", "a3gV"], 5 | ["636363", "aPEr"], 6 | ["73696d706c792061206c6f6e6720737472696e67", "2cFupjhnEsSn59qHXstmK2ffpLv2"], 7 | ["00eb15231dfceb60925886b67d065299925915aeb172c06647", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"], 8 | ["516b6fcd0f", "ABnLTmg"], 9 | ["bf4f89001e670274dd", "3SEo3LWLoPntC"], 10 | ["572e4794", "3EFU7m"], 11 | ["ecac89cad93923c02321", "EJDM8drfXA6uyA"], 12 | ["10c8511e", "Rt5zm"], 13 | ["00000000000000000000", "1111111111"] 14 | ] 15 | -------------------------------------------------------------------------------- /src/test/data/sig_canonical.json: -------------------------------------------------------------------------------- 1 | [ 2 | "300602010002010001", 3 | "3008020200ff020200ff01", 4 | "304402203932c892e2e550f3af8ee4ce9c215a87f9bb831dcac87b2838e2c2eaa891df0c022030b61dd36543125d56b9f9f3a1f9353189e5af33cdda8d77a5209aec03978fa001", 5 | "30450220076045be6f9eca28ff1ec606b833d0b87e70b2a630f5e3a496b110967a40f90a0221008fffd599910eefe00bc803c688c2eca1d2ba7f6b180620eaa03488e6585db6ba01", 6 | "3046022100876045be6f9eca28ff1ec606b833d0b87e70b2a630f5e3a496b110967a40f90a0221008fffd599910eefe00bc803c688c2eca1d2ba7f6b180620eaa03488e6585db6ba01" 7 | ] 8 | -------------------------------------------------------------------------------- /src/test/hash_tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "hash.h" 4 | #include "util.h" 5 | 6 | #include 7 | 8 | #include 9 | 10 | using namespace std; 11 | 12 | BOOST_AUTO_TEST_SUITE(hash_tests) 13 | 14 | BOOST_AUTO_TEST_CASE(murmurhash3) 15 | { 16 | 17 | #define T(expected, seed, data) BOOST_CHECK_EQUAL(MurmurHash3(seed, ParseHex(data)), expected) 18 | 19 | // Test MurmurHash3 with various inputs. Of course this is retested in the 20 | // bloom filter tests - they would fail if MurmurHash3() had any problems - 21 | // but is useful for those trying to implement Bitcoin libraries as a 22 | // source of test data for their MurmurHash3() primitive during 23 | // development. 24 | // 25 | // The magic number 0xFBA4C795 comes from CBloomFilter::Hash() 26 | 27 | T(0x00000000, 0x00000000, ""); 28 | T(0x6a396f08, 0xFBA4C795, ""); 29 | T(0x81f16f39, 0xffffffff, ""); 30 | 31 | T(0x514e28b7, 0x00000000, "00"); 32 | T(0xea3f0b17, 0xFBA4C795, "00"); 33 | T(0xfd6cf10d, 0x00000000, "ff"); 34 | 35 | T(0x16c6b7ab, 0x00000000, "0011"); 36 | T(0x8eb51c3d, 0x00000000, "001122"); 37 | T(0xb4471bf8, 0x00000000, "00112233"); 38 | T(0xe2301fa8, 0x00000000, "0011223344"); 39 | T(0xfc2e4a15, 0x00000000, "001122334455"); 40 | T(0xb074502c, 0x00000000, "00112233445566"); 41 | T(0x8034d2a0, 0x00000000, "0011223344556677"); 42 | T(0xb4698def, 0x00000000, "001122334455667788"); 43 | 44 | #undef T 45 | } 46 | 47 | BOOST_AUTO_TEST_SUITE_END() 48 | -------------------------------------------------------------------------------- /src/test/sigopcount_tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "key.h" 4 | #include "script.h" 5 | #include "uint256.h" 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | // Helpers: 15 | static std::vector 16 | Serialize(const CScript& s) 17 | { 18 | std::vector sSerialized(s); 19 | return sSerialized; 20 | } 21 | 22 | BOOST_AUTO_TEST_SUITE(sigopcount_tests) 23 | 24 | BOOST_AUTO_TEST_CASE(GetSigOpCount) 25 | { 26 | // Test CScript::GetSigOpCount() 27 | CScript s1; 28 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 0U); 29 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 0U); 30 | 31 | uint160 dummy; 32 | s1 << OP_1 << dummy << dummy << OP_2 << OP_CHECKMULTISIG; 33 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 2U); 34 | s1 << OP_IF << OP_CHECKSIG << OP_ENDIF; 35 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 3U); 36 | BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 21U); 37 | 38 | CScript p2sh; 39 | p2sh.SetDestination(s1.GetID()); 40 | CScript scriptSig; 41 | scriptSig << OP_0 << Serialize(s1); 42 | BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig), 3U); 43 | 44 | std::vector keys; 45 | for (int i = 0; i < 3; i++) 46 | { 47 | CKey k; 48 | k.MakeNewKey(true); 49 | keys.push_back(k.GetPubKey()); 50 | } 51 | CScript s2; 52 | s2.SetMultisig(1, keys); 53 | BOOST_CHECK_EQUAL(s2.GetSigOpCount(true), 3U); 54 | BOOST_CHECK_EQUAL(s2.GetSigOpCount(false), 20U); 55 | 56 | p2sh.SetDestination(s2.GetID()); 57 | BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(true), 0U); 58 | BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(false), 0U); 59 | CScript scriptSig2; 60 | scriptSig2 << OP_1 << dummy << dummy << Serialize(s2); 61 | BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig2), 3U); 62 | } 63 | 64 | BOOST_AUTO_TEST_SUITE_END() 65 | -------------------------------------------------------------------------------- /src/test/test_bitcoin.cpp: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_MODULE Bitcoin Test Suite 2 | 3 | 4 | 5 | #include "db.h" 6 | #include "main.h" 7 | #include "txdb.h" 8 | #include "ui_interface.h" 9 | #include "util.h" 10 | #include "wallet.h" 11 | 12 | #include 13 | #include 14 | 15 | 16 | CWallet* pwalletMain; 17 | CClientUIInterface uiInterface; 18 | 19 | extern bool fPrintToConsole; 20 | extern void noui_connect(); 21 | 22 | struct TestingSetup { 23 | CCoinsViewDB *pcoinsdbview; 24 | boost::filesystem::path pathTemp; 25 | boost::thread_group threadGroup; 26 | 27 | TestingSetup() { 28 | fPrintToDebugger = true; // don't want to write to debug.log file 29 | noui_connect(); 30 | bitdb.MakeMock(); 31 | pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000))); 32 | boost::filesystem::create_directories(pathTemp); 33 | mapArgs["-datadir"] = pathTemp.string(); 34 | pblocktree = new CBlockTreeDB(1 << 20, true); 35 | pcoinsdbview = new CCoinsViewDB(1 << 23, true); 36 | pcoinsTip = new CCoinsViewCache(*pcoinsdbview); 37 | InitBlockIndex(); 38 | bool fFirstRun; 39 | pwalletMain = new CWallet("wallet.dat"); 40 | pwalletMain->LoadWallet(fFirstRun); 41 | RegisterWallet(pwalletMain); 42 | nScriptCheckThreads = 3; 43 | for (int i=0; i < nScriptCheckThreads-1; i++) 44 | threadGroup.create_thread(&ThreadScriptCheck); 45 | } 46 | ~TestingSetup() 47 | { 48 | threadGroup.interrupt_all(); 49 | threadGroup.join_all(); 50 | delete pwalletMain; 51 | pwalletMain = NULL; 52 | delete pcoinsTip; 53 | delete pcoinsdbview; 54 | delete pblocktree; 55 | bitdb.Flush(true); 56 | boost::filesystem::remove_all(pathTemp); 57 | } 58 | }; 59 | 60 | BOOST_GLOBAL_FIXTURE(TestingSetup); 61 | 62 | void Shutdown(void* parg) 63 | { 64 | exit(0); 65 | } 66 | 67 | void StartShutdown() 68 | { 69 | exit(0); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/test/uint160_tests.cpp: -------------------------------------------------------------------------------- 1 | #include "uint256.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | BOOST_AUTO_TEST_SUITE(uint160_tests) 8 | 9 | BOOST_AUTO_TEST_CASE(uint160_equality) 10 | { 11 | uint160 num1 = 10; 12 | uint160 num2 = 11; 13 | BOOST_CHECK(num1+1 == num2); 14 | 15 | uint64_t num3 = 10; 16 | BOOST_CHECK(num1 == num3); 17 | BOOST_CHECK(num1+num2 == num3+num2); 18 | } 19 | 20 | BOOST_AUTO_TEST_SUITE_END() 21 | -------------------------------------------------------------------------------- /src/test/uint256_tests.cpp: -------------------------------------------------------------------------------- 1 | #include "uint256.h" 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | BOOST_AUTO_TEST_SUITE(uint256_tests) 9 | 10 | BOOST_AUTO_TEST_CASE(uint256_equality) 11 | { 12 | uint256 num1 = 10; 13 | uint256 num2 = 11; 14 | BOOST_CHECK(num1+1 == num2); 15 | 16 | uint64_t num3 = 10; 17 | BOOST_CHECK(num1 == num3); 18 | BOOST_CHECK(num1+num2 == num3+num2); 19 | } 20 | 21 | BOOST_AUTO_TEST_CASE(uint256_hex) 22 | { 23 | std::string hexStr = "d35583ed493a5eee756931353144f558e6a9ab3ad6024a63ced7f10daf7faad9"; 24 | uint256 num1; 25 | num1.SetHex(hexStr); 26 | BOOST_CHECK(num1.GetHex() == hexStr); 27 | } 28 | 29 | BOOST_AUTO_TEST_SUITE_END() 30 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Bitcoin developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | #ifndef BITCOIN_VERSION_H 5 | #define BITCOIN_VERSION_H 6 | 7 | #include "clientversion.h" 8 | 9 | #include 10 | 11 | // 12 | // client versioning 13 | // 14 | 15 | static const int CLIENT_VERSION = 16 | 1000000 * CLIENT_VERSION_MAJOR 17 | + 10000 * CLIENT_VERSION_MINOR 18 | + 100 * CLIENT_VERSION_REVISION 19 | + 1 * CLIENT_VERSION_BUILD; 20 | 21 | extern const std::string CLIENT_NAME; 22 | extern const std::string CLIENT_BUILD; 23 | extern const std::string CLIENT_DATE; 24 | 25 | // 26 | // network protocol versioning 27 | // 28 | 29 | static const int PROTOCOL_VERSION = 70002; 30 | 31 | // intial proto version, to be increased after version/verack negotiation 32 | static const int INIT_PROTO_VERSION = 209; 33 | 34 | // disconnect from peers older than this proto version 35 | static const int MIN_PEER_PROTO_VERSION = 209; 36 | 37 | // nTime field added to CAddress, starting with this version; 38 | // if possible, avoid requesting addresses nodes older than this 39 | static const int CADDR_TIME_VERSION = 31402; 40 | 41 | // only request blocks from nodes outside this range of versions 42 | static const int NOBLKS_VERSION_START = 32000; 43 | static const int NOBLKS_VERSION_END = 32400; 44 | 45 | // BIP 0031, pong message, is enabled for all versions AFTER this one 46 | static const int BIP0031_VERSION = 60000; 47 | 48 | // "mempool" command, enhanced "getdata" behavior starts with this version: 49 | static const int MEMPOOL_GD_VERSION = 60002; 50 | 51 | #endif 52 | --------------------------------------------------------------------------------