├── .gitignore
├── CMakeLists.txt
├── DESIGN.md
├── LICENSE.md
├── README.md
├── TODO.md
├── bitchat
├── CMakeLists.txt
└── main.cpp
├── bitsharesgui
├── bitshares.qrc
├── bitsharesgui.pro
├── bitsharesguiprecomp.h
├── bitsharesmainwindow.cpp
├── bitsharesmainwindow.h
├── bitsharesmainwindow.ui
├── bitsharestreemodel.cpp
├── bitsharestreemodel.h
├── bshare_gui.cpp
├── bshare_gui.h
├── bshare_gui.ui
├── bshare_viewport.cpp
├── bshare_viewport.hpp
├── bshare_viewports
│ ├── bshare_viewport_mail.cpp
│ └── bshare_viewport_mail.hpp
├── chatwidget.cpp
├── chatwidget.h
├── chatwidget.ui
├── images
│ └── pencil_small.png
├── main.cpp
├── profileeditor.cpp
├── profileeditor.h
├── profileeditor.ui
├── selfsizingmainwindow.cpp
├── selfsizingmainwindow.h
├── selfsizingwidget.cpp
├── selfsizingwidget.h
├── ui_bitsharesmainwindow.h
└── ui_profileeditor.h
├── build.cmd
├── cli_client
├── CMakeLists.txt
└── main.cpp
├── coding_standards.md
├── configs
├── a.json
├── b.json
└── c.json
├── doc
├── bitname.dox
├── doxygen.cfg
└── mainpage.dox
├── include
└── bts
│ ├── address.hpp
│ ├── addressbook
│ ├── addressbook.hpp
│ └── contact.hpp
│ ├── application.hpp
│ ├── bitchat
│ ├── bitchat_channel.hpp
│ ├── bitchat_client.hpp
│ ├── bitchat_message_cache.hpp
│ ├── bitchat_message_db.hpp
│ ├── bitchat_messages.hpp
│ └── bitchat_private_message.hpp
│ ├── bitchat_message.hpp
│ ├── bitmessage.hpp
│ ├── bitname
│ ├── bitname_block.hpp
│ ├── bitname_channel.hpp
│ ├── bitname_client.hpp
│ ├── bitname_db.hpp
│ ├── bitname_fork_db.hpp
│ ├── bitname_hash.hpp
│ ├── bitname_messages.hpp
│ ├── bitname_miner.hpp
│ └── bitname_record.hpp
│ ├── blockchain
│ ├── asset.hpp
│ ├── block.hpp
│ ├── blockchain_channel.hpp
│ ├── blockchain_client.hpp
│ ├── blockchain_db.hpp
│ ├── blockchain_market_db.hpp
│ ├── blockchain_messages.hpp
│ ├── blockchain_printer.hpp
│ ├── blockchain_time_keeper.hpp
│ ├── fork_tree.hpp
│ ├── outputs.hpp
│ ├── proof.hpp
│ ├── transaction.hpp
│ └── trx_validation_state.hpp
│ ├── config.hpp
│ ├── db
│ ├── fwd.hpp
│ ├── level_map.hpp
│ ├── level_pod_map.hpp
│ └── peer.hpp
│ ├── difficulty.hpp
│ ├── extended_address.hpp
│ ├── keychain.hpp
│ ├── merkle_tree.hpp
│ ├── network
│ ├── broadcast_manager.hpp
│ ├── channel.hpp
│ ├── channel_id.hpp
│ ├── channel_pow_stats.hpp
│ ├── connection.hpp
│ ├── feature_id.hpp
│ ├── get_public_ip.hpp
│ ├── message.hpp
│ ├── server.hpp
│ ├── stcp_socket.hpp
│ └── upnp.hpp
│ ├── peer
│ ├── peer_channel.hpp
│ ├── peer_db.hpp
│ ├── peer_host.hpp
│ └── peer_messages.hpp
│ ├── profile.hpp
│ ├── proof_of_work.hpp
│ ├── rpc
│ └── rpc_server.hpp
│ ├── small_hash.hpp
│ ├── units.hpp
│ ├── wallet.hpp
│ └── wallet_cache.hpp
├── keyhotee
├── AddContactDialog.ui
├── AddressBook
│ ├── AddressBookModel.cpp
│ ├── AddressBookModel.hpp
│ ├── ContactView.ui
│ └── ContactsTable.ui
├── CMakeLists.txt
├── EditContactDialog.cpp
├── EditContactDialog.hpp
├── EditContactDialog.ui
├── Keyhotee.qrc
├── KeyhoteeMainWindow.cpp
├── KeyhoteeMainWindow.hpp
├── KeyhoteeMainWindow.ui
├── LoginDialog.cpp
├── LoginDialog.hpp
├── LoginDialog.ui
├── images
│ └── contact_icon.png
├── main.cpp
└── profile_wizard
│ ├── ProfileEditPage.ui
│ ├── ProfileIntroPage.ui
│ ├── ProfileNymPage.ui
│ ├── ProfileWizard.cpp
│ └── ProfileWizard.hpp
├── src
├── account.cpp
├── account.hpp
├── address.cpp
├── addressbook
│ └── addressbook.cpp
├── application.cpp
├── bitchat
│ ├── bitchat_channel.cpp
│ ├── bitchat_client.cpp
│ ├── bitchat_message_cache.cpp
│ ├── bitchat_message_db.cpp
│ ├── bitchat_messages.cpp
│ └── bitchat_private_message.cpp
├── bitchat_message.cpp
├── bitname
│ ├── bitname_block.cpp
│ ├── bitname_channel.cpp
│ ├── bitname_client.cpp
│ ├── bitname_db.cpp
│ ├── bitname_fork_db.cpp
│ ├── bitname_hash.cpp
│ ├── bitname_messages.cpp
│ ├── bitname_miner.cpp
│ └── bitname_record.cpp
├── blockchain
│ ├── asset.cpp
│ ├── block.cpp
│ ├── blockchain_channel.cpp
│ ├── blockchain_client.cpp
│ ├── blockchain_db.cpp
│ ├── blockchain_market_db.cpp
│ ├── blockchain_messages.cpp
│ ├── blockchain_outputs.cpp
│ ├── blockchain_printer.cpp
│ ├── blockchain_time_keeper.cpp
│ ├── transaction.cpp
│ └── trx_validation_state.cpp
├── difficulty.cpp
├── extended_address.cpp
├── keychain.cpp
├── main.cpp
├── merkle_tree.cpp
├── miner.cpp
├── miner.hpp
├── network
│ ├── channel_pow_stats.cpp
│ ├── connection.cpp
│ ├── get_public_ip.cpp
│ ├── server.cpp
│ ├── stcp_socket.cpp
│ └── upnp.cpp
├── peer
│ ├── peer_channel.cpp
│ ├── peer_db.cpp
│ └── peer_messages.cpp
├── profile.cpp
├── proof_of_work.cpp
├── rpc
│ └── rpc_server.cpp
├── small_hash.cpp
├── wallet.cpp
└── wallet_cache.cpp
├── tasks.md
├── tests
├── CMakeLists.txt
├── blockchain_tests.cpp
├── chain.html
├── pow_test.cpp
├── timekeeper.cpp
├── unit_tests.cpp
└── wallet_test.cpp
└── vendor
├── SFMT-src-1.4
├── LICENSE.txt
├── SFMT-alti.h
├── SFMT-common.h
├── SFMT-params.h
├── SFMT-params11213.h
├── SFMT-params1279.h
├── SFMT-params132049.h
├── SFMT-params19937.h
├── SFMT-params216091.h
├── SFMT-params2281.h
├── SFMT-params4253.h
├── SFMT-params44497.h
├── SFMT-params607.h
├── SFMT-params86243.h
├── SFMT-sse2.h
├── SFMT.c
├── SFMT.h
└── test.c
├── leveldb-1.12.0
├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── db
│ ├── builder.cc
│ ├── builder.h
│ ├── c.cc
│ ├── 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
├── helpers
│ └── memenv
│ │ ├── memenv.cc
│ │ └── memenv.h
├── 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
├── port
│ ├── atomic_pointer.h
│ ├── port.h
│ ├── port_example.h
│ ├── port_posix.cc
│ ├── port_posix.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
│ ├── 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
└── miniupnp
└── miniupnpc
├── CMakeLists.txt
├── bsdqueue.h
├── codelength.h
├── connecthostport.c
├── connecthostport.h
├── declspec.h
├── igd_desc_parse.c
├── igd_desc_parse.h
├── minihttptestserver.c
├── minisoap.c
├── minisoap.h
├── minissdpc.c
├── minissdpc.h
├── miniupnpc.c
├── miniupnpc.h
├── miniupnpcmodule.c
├── miniupnpcstrings.h.cmake
├── miniupnpctypes.h
├── miniwget.c
├── miniwget.h
├── minixml.c
├── minixml.h
├── minixmlvalid.c
├── portlistingparse.c
├── portlistingparse.h
├── receivedata.c
├── receivedata.h
├── testigddescparse.c
├── testminiwget.c
├── testminixml.c
├── testupnpreplyparse.c
├── upnpc.c
├── upnpcommands.c
├── upnpcommands.h
├── upnperrors.c
├── upnperrors.h
├── upnpreplyparse.c
├── upnpreplyparse.h
└── wingenminiupnpcstrings.c
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Compiled Dynamic libraries
8 | *.so
9 | *.dylib
10 | *.dll
11 |
12 | # Compiled Static libraries
13 | *.lai
14 | *.la
15 | *.a
16 | *.lib
17 |
18 |
19 | #CMake->MSVC artifacts
20 | *.sln
21 | *.vcxproj
22 | ALL_BUILD
23 | ZERO_CHECK
24 |
25 | #MSVC secondary artifacts
26 | *.suo
27 | *.vcxproj.filters
28 | *.vcxproj.user
29 | *.pdb
30 | *.ilk
31 | *.lastbuildstate
32 | *.sdf
33 | *.opensdf
34 | Debug/
35 | Release/
36 |
37 | # Log files
38 | *.tlog
39 |
40 | #DLN
41 | vendor/qt.5.1
42 |
43 |
44 | fc
45 | doc/html
46 | CMakeCache.txt
47 | Makefile
48 | CMakeFiles
49 | cmake_install.cmake
50 | ecc_test
51 | pow_test
52 | unit_tests
53 | wallet_test
54 | libbshare.a
55 | tests/dds_test
56 | tests/pow_test
57 | vendor/miniupnp/miniupnpc/miniupnpcstrings.h
58 | bitshared
59 | bitchatc
60 | bitchat/bitchat
61 | tests/blockchain_tests
62 | *automoc.cpp
63 | src/gui/sexc
64 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | bitshares - Polymorphic Digital Asset Library
2 | =========
3 |
4 | BitShares is a new blockchain that pays dividends and enables users
5 | to short and trade any arbitrary asset type.
6 |
7 |
8 | Project Status
9 | ------------
10 | This code is only fit for developers and the api, design is evolving
11 | rapidly. If you would like to be involved please contact me via
12 | github or bytemaster on bitcointalk.org
13 |
14 | Dependencies
15 | -------------------
16 | g++ 4.6, VC2010
17 | boost 1.54
18 | OpenSSL
19 | Qt 5.1 (for GUI only)
20 | cmake 2.8.11.2
21 |
22 | Build
23 | --------------------
24 |
25 | git clone https://github.com/InvictusInnovations/BitShares.git
26 | cd BitShares
27 | git clone https://github.com/InvictusInnovations/fc.git
28 | cmake .
29 | make
30 |
31 | Coding Standards
32 | ----------------
33 | all lower case names with underscores with the exception of macros.
34 | private implmentation classes in the detail namespace.
35 | Make it look like the rest of the code.
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | TODO List
2 | ---------------------------
3 | 1) make bitchat messages have flexible encryption algorithms
4 | 2) bitchat messages should support the best compression possible
5 |
--------------------------------------------------------------------------------
/bitchat/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set( sources main.cpp )
3 | add_executable( bitchat ${sources} )
4 | target_link_libraries( bitchat upnpc-static bshare fc leveldb ${BOOST_LIBRARIES} upnpc-static )
5 |
--------------------------------------------------------------------------------
/bitsharesgui/bitshares.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/pencil_small.png
4 |
5 |
6 |
--------------------------------------------------------------------------------
/bitsharesgui/bitsharesgui.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2013-08-14T18:36:27
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10 | QMAKE_CXX=/opt/local/bin/g++
11 | QMAKE_LINK=/opt/local/bin/g++
12 | QMAKE_CC=/opt/local/bin/gcc
13 |
14 | TARGET = bitsharesgui
15 | TEMPLATE = app
16 |
17 | !win32 {
18 | QMAKE_CXXFLAGS += -std=c++11
19 | }
20 |
21 | win32 {
22 | LIBS += ../Debug/bshare.lib ../fc/Debug/fc_debug.lib
23 | } else {
24 | LIBS += ../libbshare.a ../fc/libfc.a
25 | LIBS += -L${BOOST_LIBRARY_DIR} -lboost_context -lboost_thread -lboost_system -lboost_chrono -lboost_filesystem -lboost_system -lboost_date_time -lboost_coroutine
26 | LIBS += ../libbshare.a ../fc/libfc.a
27 | }
28 |
29 |
30 | INCLUDEPATH += ../include
31 | INCLUDEPATH += /usr/local/include
32 | INCLUDEPATH += ../fc/include
33 |
34 | #PRECOMPILED_HEADER = bitsharesguiprecomp.h
35 |
36 | SOURCES += main.cpp \
37 | bitsharesmainwindow.cpp \
38 | profileeditor.cpp \
39 | bitsharestreemodel.cpp \
40 | chatwidget.cpp \
41 | selfsizingwidget.cpp \
42 | selfsizingmainwindow.cpp
43 |
44 | HEADERS += \
45 | bitsharesmainwindow.h \
46 | profileeditor.h \
47 | bitsharestreemodel.h \
48 | chatwidget.h \
49 | selfsizingwidget.h \
50 | selfsizingmainwindow.h \
51 | bitsharesguiprecomp.h
52 |
53 | FORMS += \
54 | bitsharesmainwindow.ui \
55 | profileeditor.ui \
56 | chatwidget.ui
57 |
58 |
59 | #SOURCES += main.cpp \
60 | # bshare_gui.cpp \
61 | # bshare_viewport.cpp \
62 | # bshare_viewports/bshare_viewport_mail.cpp
63 |
64 | #HEADERS += \
65 | # bshare_gui.h \
66 | # bshare_viewport.hpp \
67 | # bshare_viewports/bshare_viewport_mail.hpp
68 |
69 | #FORMS += \
70 | # bshare_gui.ui
71 |
72 | RESOURCES += \
73 | bitshares.qrc
74 |
75 |
--------------------------------------------------------------------------------
/bitsharesgui/bitsharesguiprecomp.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSHARESGUIPRECOMP_H
2 | #define BITSHARESGUIPRECOMP_H
3 |
4 | #include
5 | #include
6 |
7 |
8 | #define VERSIONNUM (int32_t(1))
9 |
10 |
11 | #endif // BITSHARESGUIPRECOMP_H
12 |
--------------------------------------------------------------------------------
/bitsharesgui/bitsharesmainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSHARESMAINWINDOW_H
2 | #define BITSHARESMAINWINDOW_H
3 |
4 | #include "bitsharestreemodel.h"
5 | #include "selfsizingmainwindow.h"
6 |
7 | namespace Ui {
8 | class BitSharesMainWindow;
9 | }
10 |
11 | class BitSharesMainWindow : public SelfSizingMainWindow
12 | {
13 | Q_OBJECT
14 |
15 | void readSettings();
16 | void writeSettings();
17 | void closeEvent(QCloseEvent *event);
18 | bool okToContinue() { return true; }
19 |
20 | public:
21 | explicit BitSharesMainWindow(QWidget *parent = 0);
22 | ~BitSharesMainWindow();
23 |
24 | private slots:
25 |
26 | void on_actionExit_triggered();
27 |
28 | void on_actionCreateMail_triggered();
29 |
30 | private:
31 | Ui::BitSharesMainWindow *ui;
32 | BitSharesTreeModel _bitSharesTreeModel;
33 |
34 | };
35 |
36 | #endif // BITSHARESMAINWINDOW_H
37 |
--------------------------------------------------------------------------------
/bitsharesgui/bitsharestreemodel.h:
--------------------------------------------------------------------------------
1 | #ifndef BITSHARESTREEMODEL_H
2 | #define BITSHARESTREEMODEL_H
3 |
4 | #include
5 |
6 | class BitSharesTreeModel : public QAbstractItemModel
7 | {
8 | Q_OBJECT
9 | public:
10 | explicit BitSharesTreeModel(QObject *parent = 0);
11 |
12 | int columnCount(const QModelIndex & parent = QModelIndex()) const;
13 | int rowCount(const QModelIndex & parent = QModelIndex()) const;
14 | Qt::ItemFlags flags ( const QModelIndex & index ) const;
15 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
16 | QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
17 | QModelIndex parent(const QModelIndex & index) const;
18 | signals:
19 |
20 | public slots:
21 |
22 | };
23 |
24 | #endif // BITSHARESTREEMODEL_H
25 |
--------------------------------------------------------------------------------
/bitsharesgui/bshare_gui.h:
--------------------------------------------------------------------------------
1 | #ifndef BSHARE_GUI_H
2 | #define BSHARE_GUI_H
3 |
4 | //Qt libs
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | //bshare libs
12 | #include "bshare_viewport.hpp"
13 |
14 | namespace Ui {
15 | class bshare_gui;
16 | }
17 |
18 | class bshare_gui : public QWidget
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit bshare_gui(QWidget *parent = 0);
24 | ~bshare_gui();
25 |
26 | private:
27 | Ui::bshare_gui *ui;
28 |
29 | /** Private Variables **/
30 | QStandardItemModel * bshare_menu_treeview_model;
31 | bshare_viewport * viewport_controller;
32 |
33 | /** Private Functions **/
34 | };
35 |
36 | #endif // BSHARE_GUI_H
37 |
--------------------------------------------------------------------------------
/bitsharesgui/bshare_gui.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | bshare_gui
4 |
5 |
6 |
7 | 0
8 | 0
9 | 800
10 | 500
11 |
12 |
13 |
14 | Form
15 |
16 |
17 |
18 |
19 | 10
20 | 9
21 | 781
22 | 481
23 |
24 |
25 |
26 | -
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/bitsharesgui/bshare_viewport.cpp:
--------------------------------------------------------------------------------
1 | #include "bshare_viewport.hpp"
2 |
3 | bshare_viewport::bshare_viewport(QWidget *parent) :
4 | QWidget(parent)
5 | {
6 | /***
7 | ** Notes about structure
8 | **
9 | ** This class is a QWidget with a QStackedWidget attached
10 | ** allowing multiple widgets to be called in one area.
11 | ** Instead of calling the qstackedwidget, we will be calling
12 | ** bshare_viewport functions to control the stackedwidget/viewport.
13 | ** The benifits should be apparent.
14 | ***/
15 |
16 | layout = new QGridLayout(this);
17 | this->setLayout(layout);
18 | //layout settings
19 | //layout->setMargin(0);
20 |
21 | /**
22 | * Initialize viewport
23 | **/
24 | stacked_widget_viewport = new QStackedWidget(0);
25 | stacked_widget_viewport->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
26 | stacked_widget_viewport->setStyleSheet("QStackedWidget{border:1px solid #000;}");
27 | layout->addWidget(stacked_widget_viewport, 0,0, 1,1, Qt::AlignLeft);
28 |
29 | mail_view = new bshare_viewport_mail(0);
30 | mail_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
31 | //Add to (stacked widget)viewport
32 | stacked_widget_viewport->addWidget(mail_view);
33 | }
34 |
35 |
36 |
37 | /***
38 | * Group of Functions
39 | * Select which view should be showing
40 | ***/
41 | void bshare_viewport::show_view(QString view){
42 | if(view == "mail"){
43 | stacked_widget_viewport->setCurrentIndex(0);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/bitsharesgui/bshare_viewport.hpp:
--------------------------------------------------------------------------------
1 | #ifndef BSHARE_VIEWPORT_HPP
2 | #define BSHARE_VIEWPORT_HPP
3 |
4 | //qt libs
5 | #include
6 | #include
7 |
8 | //bshare libs
9 | #include "bshare_viewports/bshare_viewport_mail.hpp"
10 |
11 | class bshare_viewport : public QWidget
12 | {
13 | Q_OBJECT
14 | public:
15 | explicit bshare_viewport(QWidget *parent = 0);
16 |
17 | private:
18 | /** Private Variables **/
19 | QGridLayout * layout;
20 |
21 | //Contains everything in one widget
22 | QStackedWidget * stacked_widget_viewport;
23 |
24 | //Account
25 |
26 | //Trade
27 |
28 | //Contacts
29 |
30 | //Identities
31 |
32 | //Mail
33 | bshare_viewport_mail * mail_view;
34 |
35 | //Favorites
36 |
37 | /** Private Functions **/
38 | void show_view(QString);
39 |
40 |
41 | signals:
42 |
43 | public slots:
44 |
45 | };
46 |
47 | #endif // BSHARE_VIEWPORT_HPP
48 |
--------------------------------------------------------------------------------
/bitsharesgui/bshare_viewports/bshare_viewport_mail.hpp:
--------------------------------------------------------------------------------
1 | #ifndef BSHARE_VIEWPORT_MAIL_HPP
2 | #define BSHARE_VIEWPORT_MAIL_HPP
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | class bshare_viewport_mail : public QWidget
13 | {
14 | Q_OBJECT
15 | public:
16 | explicit bshare_viewport_mail(QWidget *parent = 0);
17 | private:
18 | QGridLayout * layout;
19 |
20 | //To
21 | QLabel * to_label;
22 | //HBoxLayout (Hints the input to stretch horizontally)
23 | QWidget * to_input_container_widget;
24 | QHBoxLayout * to_input_container;
25 |
26 | QLineEdit * to_input;
27 |
28 | //From
29 | QLabel * from_label;
30 | QLineEdit * from_input;
31 |
32 | //Subject
33 | QLabel * subject_label;
34 | QLineEdit * subject_input;
35 |
36 | //Body (Rich text editor functionality)
37 | QTextEdit * message_input;
38 |
39 |
40 | signals:
41 |
42 | public slots:
43 |
44 | };
45 |
46 | #endif // BSHARE_VIEWPORT_MAIL_HPP
47 |
--------------------------------------------------------------------------------
/bitsharesgui/chatwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef CHATWIDGET_H
2 | #define CHATWIDGET_H
3 |
4 | //DLN only include one of these
5 | #include "selfsizingwidget.h"
6 | //#include "selfsizingmainwindow.h"
7 | #include
8 |
9 | class StringListModel : public QStringListModel
10 | {
11 | public:
12 | StringListModel(QObject* parent) : QStringListModel(parent) {}
13 | void append(const QString& string)
14 | {
15 | insertRows(rowCount(), 1);
16 | setData(index(rowCount()-1), string);
17 | }
18 |
19 | StringListModel& operator<<(const QString& string)
20 | {
21 | append(string);
22 | return *this;
23 | }
24 | };
25 |
26 |
27 | namespace Ui {
28 | class ChatWidget;
29 | }
30 |
31 | class ChatWidget : public SelfSizingWidget
32 | {
33 | Q_OBJECT
34 | //identity
35 | //contact
36 | //communication data
37 | //session message history (list model)
38 | public:
39 | explicit ChatWidget(QWidget *parent = 0);
40 | ~ChatWidget();
41 |
42 | void setContact(QString contactName);
43 | bool eventFilter(QObject *watched, QEvent *e);
44 |
45 | private slots:
46 | void sendCurrentChatMessage();
47 | void sendChatMessage(QString messageToSend);
48 | void messageReceived(QString receivedMessage);
49 | private:
50 |
51 |
52 | Ui::ChatWidget *ui;
53 | StringListModel* chatViewModel;
54 | };
55 |
56 | #endif // CHATWIDGET_H
57 |
--------------------------------------------------------------------------------
/bitsharesgui/chatwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ChatWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Form
15 |
16 |
17 | -
18 |
19 |
-
20 |
21 |
22 | Chat
23 |
24 |
25 |
26 | -
27 |
28 |
29 | Qt::Vertical
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/bitsharesgui/images/pencil_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Xenland/BitShares/f8d5bf4ef0517fd566119c2f8daf7776b0be00aa/bitsharesgui/images/pencil_small.png
--------------------------------------------------------------------------------
/bitsharesgui/main.cpp:
--------------------------------------------------------------------------------
1 | #if 1
2 | #include "bitsharesmainwindow.h"
3 | #else
4 | #include "bshare_gui.h"
5 | #endif
6 | #include
7 | #include
8 | #include
9 |
10 | int main(int argc, char *argv[])
11 | {
12 | QApplication application(argc, argv);
13 | #if 1
14 | BitSharesMainWindow mainWindow;
15 | mainWindow.show();
16 | #else
17 | bshare_gui bshare_window;
18 | bshare_window.setWindowTitle("Bitshares | Invictus Innovations");
19 | bshare_window.show();
20 | qDebug() << "RUNNING";
21 | fc::usleep( fc::microseconds(1000) );
22 | #endif
23 | return application.exec();
24 | }
25 |
--------------------------------------------------------------------------------
/bitsharesgui/profileeditor.cpp:
--------------------------------------------------------------------------------
1 | #include "profileeditor.h"
2 | #include "ui_profileeditor.h"
3 |
4 | ProfileEditor::ProfileEditor(QWidget *parent) :
5 | QDialog(parent),
6 | ui(new Ui::ProfileEditor)
7 | {
8 | ui->setupUi(this);
9 | }
10 |
11 | ProfileEditor::~ProfileEditor()
12 | {
13 | delete ui;
14 | }
15 |
--------------------------------------------------------------------------------
/bitsharesgui/profileeditor.h:
--------------------------------------------------------------------------------
1 | #ifndef PROFILEEDITOR_H
2 | #define PROFILEEDITOR_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class ProfileEditor;
8 | }
9 |
10 | class ProfileEditor : public QDialog
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | explicit ProfileEditor(QWidget *parent = 0);
16 | ~ProfileEditor();
17 |
18 | private:
19 | Ui::ProfileEditor *ui;
20 | };
21 |
22 | #endif // PROFILEEDITOR_H
23 |
--------------------------------------------------------------------------------
/bitsharesgui/profileeditor.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ProfileEditor
6 |
7 |
8 |
9 | 0
10 | 0
11 | 400
12 | 300
13 |
14 |
15 |
16 | Dialog
17 |
18 |
19 |
20 |
21 | 30
22 | 240
23 | 341
24 | 32
25 |
26 |
27 |
28 | Qt::Horizontal
29 |
30 |
31 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | buttonBox
40 | accepted()
41 | ProfileEditor
42 | accept()
43 |
44 |
45 | 248
46 | 254
47 |
48 |
49 | 157
50 | 274
51 |
52 |
53 |
54 |
55 | buttonBox
56 | rejected()
57 | ProfileEditor
58 | reject()
59 |
60 |
61 | 316
62 | 260
63 |
64 |
65 | 286
66 | 274
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/bitsharesgui/selfsizingmainwindow.cpp:
--------------------------------------------------------------------------------
1 | #include "selfsizingmainwindow.h"
2 | #include
3 | #include
4 | #include
5 |
6 |
7 | SelfSizingMainWindow::SelfSizingMainWindow(QWidget *parent) :
8 | QMainWindow(parent)
9 | {
10 | }
11 |
12 | // this should be called in constructor of derived classes after call to setupUi
13 | void SelfSizingMainWindow::readSettings()
14 | {
15 | QSettings settings("Invictus Innovations","BitSharesGUI");
16 | settings.beginGroup(windowTitle());
17 | restoreGeometry(settings.value("geometry").toByteArray());
18 | restoreState(settings.value("state").toByteArray(),VERSIONNUM);
19 | settings.endGroup();
20 | }
21 |
22 | void SelfSizingMainWindow::writeSettings()
23 | {
24 | QSettings settings("Invictus Innovations","BitSharesGUI");
25 | settings.beginGroup(windowTitle());
26 | settings.setValue("geometry", saveGeometry());
27 | settings.setValue("state", saveState(VERSIONNUM));
28 | settings.endGroup();
29 | }
30 |
31 | void SelfSizingMainWindow::closeEvent(QCloseEvent *event)
32 | {
33 | if (okToContinue())
34 | {
35 | writeSettings();
36 | event->accept();
37 | }
38 | else
39 | {
40 | event->ignore();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/bitsharesgui/selfsizingmainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef SELFSIZINGMAINWINDOW_H
2 | #define SELFSIZINGMAINWINDOW_H
3 |
4 | #include
5 |
6 | class SelfSizingMainWindow : public QMainWindow
7 | {
8 | Q_OBJECT
9 |
10 | protected:
11 | virtual void readSettings();
12 | virtual void writeSettings();
13 | virtual void closeEvent(QCloseEvent *event);
14 | virtual bool okToContinue() { return true; }
15 |
16 | public:
17 | explicit SelfSizingMainWindow(QWidget *parent = 0);
18 |
19 | signals:
20 |
21 | public slots:
22 |
23 | };
24 |
25 | #endif // SELFSIZINGMAINWINDOW_H
26 |
--------------------------------------------------------------------------------
/bitsharesgui/selfsizingwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "selfsizingwidget.h"
2 | #include
3 | #include
4 |
5 | SelfSizingWidget::SelfSizingWidget(QWidget *parent) :
6 | QWidget(parent)
7 | {
8 | }
9 |
10 | // this should be called in constructor of derived classes after call to setupUi
11 | void SelfSizingWidget::readSettings()
12 | {
13 | QSettings settings("Invictus Innovations","BitSharesGUI");
14 | settings.beginGroup(windowTitle());
15 | restoreGeometry(settings.value("geometry").toByteArray());
16 | settings.endGroup();
17 | }
18 |
19 | void SelfSizingWidget::writeSettings()
20 | {
21 | QSettings settings("Invictus Innovations","BitSharesGUI");
22 | settings.beginGroup(windowTitle());
23 | settings.setValue("geometry", saveGeometry());
24 | settings.endGroup();
25 | }
26 |
27 | void SelfSizingWidget::closeEvent(QCloseEvent *event)
28 | {
29 | if (okToContinue())
30 | {
31 | writeSettings();
32 | event->accept();
33 | }
34 | else
35 | {
36 | event->ignore();
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/bitsharesgui/selfsizingwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef SELFSIZINGWIDGET_H
2 | #define SELFSIZINGWIDGET_H
3 |
4 | #include
5 |
6 | class SelfSizingWidget : public QWidget
7 | {
8 | Q_OBJECT
9 |
10 | protected:
11 | virtual void readSettings();
12 | virtual void writeSettings();
13 | virtual void closeEvent(QCloseEvent *event);
14 | virtual bool okToContinue() { return true; }
15 |
16 | public:
17 | explicit SelfSizingWidget(QWidget *parent = 0);
18 |
19 | signals:
20 |
21 | public slots:
22 |
23 | };
24 |
25 | #endif // SELFSIZINGWIDGET_H
26 |
--------------------------------------------------------------------------------
/bitsharesgui/ui_profileeditor.h:
--------------------------------------------------------------------------------
1 | /********************************************************************************
2 | ** Form generated from reading UI file 'profileeditor.ui'
3 | **
4 | ** Created by: Qt User Interface Compiler version 5.1.1
5 | **
6 | ** WARNING! All changes made in this file will be lost when recompiling UI file!
7 | ********************************************************************************/
8 |
9 | #ifndef UI_PROFILEEDITOR_H
10 | #define UI_PROFILEEDITOR_H
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 |
20 | QT_BEGIN_NAMESPACE
21 |
22 | class Ui_ProfileEditor
23 | {
24 | public:
25 | QDialogButtonBox *buttonBox;
26 |
27 | void setupUi(QDialog *ProfileEditor)
28 | {
29 | if (ProfileEditor->objectName().isEmpty())
30 | ProfileEditor->setObjectName(QStringLiteral("ProfileEditor"));
31 | ProfileEditor->resize(400, 300);
32 | buttonBox = new QDialogButtonBox(ProfileEditor);
33 | buttonBox->setObjectName(QStringLiteral("buttonBox"));
34 | buttonBox->setGeometry(QRect(30, 240, 341, 32));
35 | buttonBox->setOrientation(Qt::Horizontal);
36 | buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
37 |
38 | retranslateUi(ProfileEditor);
39 | QObject::connect(buttonBox, SIGNAL(accepted()), ProfileEditor, SLOT(accept()));
40 | QObject::connect(buttonBox, SIGNAL(rejected()), ProfileEditor, SLOT(reject()));
41 |
42 | QMetaObject::connectSlotsByName(ProfileEditor);
43 | } // setupUi
44 |
45 | void retranslateUi(QDialog *ProfileEditor)
46 | {
47 | ProfileEditor->setWindowTitle(QApplication::translate("ProfileEditor", "Dialog", 0));
48 | } // retranslateUi
49 |
50 | };
51 |
52 | namespace Ui {
53 | class ProfileEditor: public Ui_ProfileEditor {};
54 | } // namespace Ui
55 |
56 | QT_END_NAMESPACE
57 |
58 | #endif // UI_PROFILEEDITOR_H
59 |
--------------------------------------------------------------------------------
/build.cmd:
--------------------------------------------------------------------------------
1 | cmake -G "Visual Studio 11"
--------------------------------------------------------------------------------
/cli_client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable( cli_client main.cpp )
2 | target_link_libraries( cli_client upnpc-static bshare fc leveldb ${BOOST_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} )
3 |
--------------------------------------------------------------------------------
/coding_standards.md:
--------------------------------------------------------------------------------
1 | General Coding Standards
2 | ================
3 | - 3 spaces instead of tabs
4 | - all c++ headers end in .hpp
5 | - all c headers end in .h
6 | - pragma once instead of header guards
7 | - use private implementation classes for long-lived objects
8 | - long-lived objects are anything that could be allocated on the heap without
9 | significant overhead. Not temporaries or 'structs'.
10 |
11 | Example of using private implementation:
12 |
13 | namespace detail { class_name_impl; }
14 | class class_name
15 | {
16 | public:
17 | class_name();
18 | ~class_name();
19 |
20 | private:
21 | std::unique_ptr my;
22 | };
23 |
24 | This should be used anytime where the private members would require an additional include
25 | dependency not required by the public API.
26 |
27 |
28 | - note the formatting of the class, braces, indentions, etc.
29 | - avoid abreviations as much as possible
30 | - const std::string& x (not const string &x)
31 | - char* y (not char *y)
32 | - always use {} for conditionals and loops.
33 |
34 | Here is an example of proper usage of braces:
35 |
36 | while( true )
37 | {
38 | }
39 |
40 | try {
41 |
42 | }
43 | catch ( ... )
44 | {
45 | }
46 |
47 | switch( x )
48 | {
49 | case a:
50 | break;
51 | case b:
52 | {
53 | int local = 0;
54 | break;
55 | }
56 | default:
57 | break;
58 | }
59 |
60 | GUI Coding Standards
61 | --------------------
62 | The following list includes is an example of high-level standard.
63 |
64 | - follow the Qt conventions
65 | - ClassName
66 | - methodName
67 | - _member_variable
68 | - local_varaible
69 | - ClassName.hpp
70 | - ClassName.cpp
71 | - No namespaces unless creating a GUI library
72 |
73 |
74 |
75 |
76 | Library Coding Standards
77 | ------------------------
78 | All classes within a library are namespaced.
79 |
80 | - follow stdlib and boost naming convention (generally)
81 | - class_name
82 | - set_method_name
83 | - _member_variable
84 | - local_variable
85 |
86 |
--------------------------------------------------------------------------------
/configs/a.json:
--------------------------------------------------------------------------------
1 | {
2 | "data_dir": "data/aa",
3 | "server_config": {
4 | "port": 9876,
5 | "chain": "",
6 | "bootstrap_endpoints": [],
7 | "blacklist": []
8 | },
9 | "bitname_config": {
10 | "data_dir": "data/aa",
11 | "max_mining_effort": 1
12 | },
13 | "rpc_config": {
14 | "port": 6789,
15 | "user": "rpc_user",
16 | "pass": "rpc_pass"
17 | },
18 | "ids": [{
19 | "label": "dan",
20 | "key": "c7714b9021d9ec9078a58012e164f163a5228721164c68059dff61ad566a3b0b",
21 | "broadcast": "1eeb411196ba463fadccd460d254d54e343f21fe01493e4bddecd025e22d7caa",
22 | "recv_channels": [
23 | 0
24 | ]
25 | },{
26 | "label": "stan",
27 | "key": "9a7821bf393904e39999e5cc600d424177680327efc11e7858c29f88ef70a201",
28 | "broadcast": "34822a38bbdf80af0c72f1ea50f7946fa5c518f780ed804d7c0ab20c96c3d50b",
29 | "recv_channels": [
30 | 0
31 | ]
32 | },{
33 | "label": "mkdali",
34 | "key": "08cd0cef10069d250343884aa5fd4b55c03ca1dd14e22e56376c62b6ad190efd",
35 | "broadcast": "9ad09e5a5f7f8bb13b90cd3a46d71b389a9b3a9585eac88c9c48614ec810f39a",
36 | "recv_channels": [
37 | 0
38 | ]
39 | }
40 | ],
41 | "contacts": [{
42 | "label": "scott",
43 | "key": "02ee9f61b6c3f71d6887efb0678aa0cd2c73bb825ab5197649b98d80d5c6022ccc",
44 | "recv_broadcast": null,
45 | "send_channels": [
46 | 0
47 | ]
48 | },{
49 | "label": "trish",
50 | "key": "026ff2741e8827ad4c73c37bdd333df94a1493aa95429f1d1b92aac5163dfbcc62",
51 | "recv_broadcast": null,
52 | "send_channels": [
53 | 0
54 | ]
55 | }
56 | ]
57 | }
--------------------------------------------------------------------------------
/configs/b.json:
--------------------------------------------------------------------------------
1 | {
2 | "data_dir": "data/bb",
3 | "server_config": {
4 | "port": 9877,
5 | "chain": "",
6 | "bootstrap_endpoints": [],
7 | "blacklist": []
8 | },
9 | "bitname_config": {
10 | "data_dir": "data/bb",
11 | "max_mining_effort": 1
12 | },
13 | "rpc_config": {
14 | "port": 5789,
15 | "user": "rpc_user",
16 | "pass": "rpc_pass"
17 | },
18 | "ids": [{
19 | "label": "scott",
20 | "key": "ba85dd2da5d908ff677042adfbff779853fd44cc246ccdaf45c6e9730fbe6e81",
21 | "broadcast": "2d29a97188fcb258450fbb83ddb03053cbdfd5361ec57cf08ed010935b0bd804",
22 | "recv_channels": [
23 | 0
24 | ]
25 | },{
26 | "label": "scott2",
27 | "key": "5f74816e700996a49a1e716d57dc3754adeaa1ed37aeef1b6cc497381d20034e",
28 | "broadcast": "82f2b99a1f8fe7f85beb9d1a30c895245aacfa2d2495a66528a7381d05692574",
29 | "recv_channels": [
30 | 0
31 | ]
32 | }
33 | ],
34 | "contacts": [{
35 | "label": "dan",
36 | "key": "03ad7290bace92ee96d05cd3e2b1049c6dfe078fa603dc12aa17bad23cc125803f",
37 | "recv_broadcast": null,
38 | "send_channels": [
39 | 0
40 | ]
41 | }
42 | ]
43 | }
--------------------------------------------------------------------------------
/configs/c.json:
--------------------------------------------------------------------------------
1 | {
2 | "server_config": {
3 | "port": 9878,
4 | "chain": "",
5 | "bootstrap_endpoints": [],
6 | "blacklist": []
7 | },
8 | "rpc_config": {
9 | "port": 8789,
10 | "user": "rpc_user",
11 | "pass": "rpc_pass"
12 | },
13 | "ids": [{
14 | "label": "trish",
15 | "key": "69a20e1989844781c43195af281db99b0b184cde3922d77f5f24faa35beaa062",
16 | "broadcast": "0af4827159be57dbce42e7575d9a4abffe420f3ddc6bc92aac49653587e367c7",
17 | "recv_channels": [
18 | 0
19 | ]
20 | }
21 | ],
22 | "contacts": [{
23 | "label": "dan",
24 | "key": "03ad7290bace92ee96d05cd3e2b1049c6dfe078fa603dc12aa17bad23cc125803f",
25 | "recv_broadcast": null,
26 | "send_channels": [
27 | 0
28 | ]
29 | },{
30 | "label": "scott",
31 | "key": "02ee9f61b6c3f71d6887efb0678aa0cd2c73bb825ab5197649b98d80d5c6022ccc",
32 | "recv_broadcast": null,
33 | "send_channels": [
34 | 0
35 | ]
36 | }
37 | ]
38 | }
--------------------------------------------------------------------------------
/doc/bitname.dox:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | @defgroup bit_id BitID
4 | @brief Provides a name/key block chain.
5 |
6 | @section bit_id_protocol Bit ID Protocol
7 |
8 | BitID uses the standard inventory / fetch broadcast system as
9 | everything else in the BitShares system. When a node first
10 | connects it will send a request for any new valid blocks since
11 | its last connection. The remote node will respond with up to
12 | 1000 headers and an indication of how many more there are.
13 |
14 | These headers will be added to the fork database and any additional
15 | headers will be requested. When the remote node reports that
16 | there are no more new headers, then the client will consult the
17 | fork tree and start downloading and verifing the blocks on the
18 | longest fork and pushing them into the name_db.
19 |
20 | If an error occurs on the name_db push, then the next fork in
21 | the fork_db chain is attempted provided its difficulty is
22 | greater than the current name_db head.
23 |
24 | While we are synchronizing with the network we do not participate
25 | in the broadcast of new names because we are unable to validate
26 | them.
27 | */
28 |
--------------------------------------------------------------------------------
/doc/mainpage.dox:
--------------------------------------------------------------------------------
1 | /**
2 | @mainpage BitShares
3 |
4 | BitShares is a new dividend-paying crypto-asset known as a polymorphic digital
5 | asset that facilitates hedging against price fluxuations in other assets such
6 | as gold, silver, and dollars.
7 |
8 | This project is divided into two parts:
9 |
10 | - libBitShares - which implements the a
11 | reusable toolkit to enable the development of a wide variety of BitShares
12 | enabled applications.
13 | - BitShares - which provides a fully function client to the BitShares
14 | network
15 |
16 |
17 | @section design_principles Design Principles
18 |
19 | libBitShares is targeted for high performance and reusability and borrows many of the
20 | design principles employed by libbitcoin (http://libbitcoin.dyne.org). Specifically,
21 | it is designed to be asynchronous and yet easy to follow.
22 |
23 | -# Scalability - The library should facilitate the development of applications that scale to thousands of concurrent opperations.
24 | -# Intuitive - The library should model concepts in a clear and intuitive manner.
25 | -# Layered - The library should support development of higher-level APIs
26 | -# No Blocking - There should be no blocking except at the lowest level.
27 |
28 | libBitShares is implementing a financial system that requires a high degree of stability and
29 | correctness. These are requirements that can be designed into the development process to ensure
30 | that the resulting code is as free from bugs as possible.
31 |
32 | -# Simplicity. It is very important for the implementation to be simple and easy to follow.
33 | -# Consistant. It is very important to follow consistant design patterns and avoid special cases.
34 | -# Testable. It is very important for as many components in the system to be independently testable as possible
35 | -# Robust. Errors should be detected, handled, and logged in a robust and meaninful manner. All assumptions,
36 | must be documented and checked
37 | -# Documented. All code must be intential and have a purpose and this purpose should be documented.
38 |
39 | @section development_process Development Process
40 |
41 |
42 |
43 |
44 | */
45 |
--------------------------------------------------------------------------------
/include/bts/address.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 |
8 | namespace bts
9 | {
10 | /**
11 | * @brief encapsulates an encoded, checksumed public key in
12 | * binary form. It can be converted to base58 for display
13 | * or input purposes and can also be constructed from an ecc
14 | * public key.
15 | *
16 | * An valid address is 20 bytes with the following form:
17 | *
18 | * First 3-bits are 0, followed by bits to 3-127 of sha256(pub_key), followed
19 | * a 32 bit checksum calculated as the first 32 bits of the sha256 of
20 | * the first 128 bits of the address.
21 | *
22 | * The result of this is an address that can be 'verified' by
23 | * looking at the first character (base58) and has a built-in
24 | * checksum to prevent mixing up characters.
25 | *
26 | * It is stored as 20 bytes.
27 | */
28 | struct address
29 | {
30 | address(); ///< constructs empty / null address
31 | address( const std::string& base58str ); ///< converts to binary, validates checksum
32 | address( const fc::ecc::public_key& pub ); ///< converts to binary
33 |
34 | bool is_valid()const;
35 |
36 | operator std::string()const; ///< converts to base58 + checksum
37 |
38 | fc::array addr; ///< binary representation of address
39 | };
40 |
41 |
42 | inline bool operator == ( const address& a, const address& b ) { return a.addr == b.addr; }
43 | inline bool operator != ( const address& a, const address& b ) { return a.addr != b.addr; }
44 | inline bool operator < ( const address& a, const address& b ) { return a.addr < b.addr; }
45 |
46 | } // namespace bts
47 |
48 | FC_REFLECT( bts::address, (addr) )
49 |
50 | namespace fc
51 | {
52 | void to_variant( const bts::address& var, fc::variant& vo );
53 | void from_variant( const fc::variant& var, bts::address& vo );
54 | }
55 |
56 | namespace std
57 | {
58 | template<>
59 | struct hash
60 | {
61 | public:
62 | size_t operator()(const bts::address &a) const
63 | {
64 | size_t s;
65 | memcpy( (char*)&s, &a.addr.data[sizeof(a)-sizeof(s)], sizeof(s) );
66 | return s;
67 | }
68 | };
69 | }
70 |
--------------------------------------------------------------------------------
/include/bts/addressbook/addressbook.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace fc { class path; }
6 |
7 | namespace bts { namespace addressbook {
8 |
9 | namespace detail { class addressbook_impl; }
10 |
11 | /**
12 | * Provides indexes for effecient lookup of contacts
13 | * and abstracts the storage of the addressbook on
14 | * disk.
15 | */
16 | class addressbook
17 | {
18 | public:
19 | addressbook();
20 | ~addressbook();
21 |
22 | void open( const fc::path& abook_dir );
23 |
24 | /**
25 | * @return a list of all known bitname_label's that can be used to lookup
26 | * contacts.
27 | */
28 | std::vector get_known_bitnames()const;
29 |
30 | fc::optional get_contact_by_bitname( const std::string& bitname_label )const;
31 | std::string get_bitname_by_address( const bts::address& bitname_address )const;
32 | void store_contact( const contact& contact_to_store );
33 |
34 | private:
35 | std::unique_ptr my;
36 | };
37 |
38 | typedef std::shared_ptr addressbook_ptr;
39 |
40 | } } // bts::addressbook
41 |
--------------------------------------------------------------------------------
/include/bts/addressbook/contact.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts { namespace addressbook {
5 |
6 | /**
7 | * Ultimately this class is used to manage all information
8 | * known about an individual contact.
9 | */
10 | struct contact
11 | {
12 | contact()
13 | :version(0),next_send_trx_id(0){}
14 |
15 | /** just incase we update the contact datafields
16 | * in future versions.
17 | **/
18 | uint32_t version;
19 |
20 | std::string first_name;
21 | std::string last_name;
22 | std::string company;
23 |
24 | /** bitname used by this contact (should line up with send_msg_address */
25 | std::string bitname_id;
26 |
27 | /** Key used to encode private messages sent to this contact */
28 | fc::ecc::public_key send_msg_address;
29 | /** channels this contact is expected to be listening on */
30 | std::vector send_msg_channels;
31 |
32 | /**
33 | * Private key to which broadcast messages are
34 | * sent.
35 | */
36 | fc::ecc::private_key recv_broadcast_msg_address;
37 |
38 | /** channels on which this contact broadcasts */
39 | std::vector recv_broadcast_msg_channels;
40 |
41 | /** used to generate adresses for sending funds to this
42 | * contact.
43 | */
44 | extended_public_key send_trx_address;
45 |
46 | /**
47 | * Incremented everytime a new trx is created to
48 | * this contact.
49 | */
50 | uint32_t next_send_trx_id;
51 |
52 | /**
53 | * Addresses that this uesr has the private
54 | * keys to. This address is given to the
55 | * contact who can use these keys to
56 | * send us money.
57 | */
58 | extended_public_key recv_trx_address;
59 | };
60 |
61 | } } // bts::addressbook
62 |
63 | #include
64 | FC_REFLECT( bts::addressbook::contact,
65 | (version)
66 | (first_name)
67 | (last_name)
68 | (company)
69 | (bitname_id)
70 | (send_msg_address)
71 | (send_msg_channels)
72 | (recv_broadcast_msg_address)
73 | (recv_broadcast_msg_channels)
74 | (send_trx_address)
75 | (recv_trx_address)
76 | )
77 |
78 |
--------------------------------------------------------------------------------
/include/bts/bitchat/bitchat_channel.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts { namespace bitchat {
6 |
7 | namespace detail { class channel_impl; }
8 |
9 | class encrypted_message;
10 |
11 | class channel_delegate
12 | {
13 | public:
14 | virtual ~channel_delegate(){}
15 |
16 | virtual void handle_message( const encrypted_message& pm, const network::channel_id& c ) = 0;
17 |
18 | };
19 |
20 | struct channel_config
21 | {
22 | channel_config( const fc::path& p = fc::path() )
23 | :data_dir(p){}
24 |
25 | fc::path data_dir;
26 | };
27 |
28 | /**
29 | * @brief Implements the message broadcast/routing for a single channel.
30 | *
31 | * This class is agnostic to anything but message routing. It does not
32 | * handle private messages nor attempt to decrypt anything, instead it
33 | * manages the bandwidth and passes all messages it receives through
34 | * to the delegate.
35 | */
36 | class channel
37 | {
38 | public:
39 | channel( const bts::peer::peer_channel_ptr& peers, const network::channel_id& c, channel_delegate* d );
40 | ~channel();
41 |
42 | network::channel_id get_id()const;
43 |
44 | void configure( const channel_config& conf );
45 |
46 | void broadcast( encrypted_message&& m );
47 |
48 | private:
49 | std::shared_ptr my;
50 | };
51 |
52 | typedef std::shared_ptr channel_ptr;
53 |
54 | } } // bts::bitchat
55 |
--------------------------------------------------------------------------------
/include/bts/bitchat/bitchat_client.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | namespace bts { namespace bitchat
11 | {
12 | namespace detail { class client_impl; }
13 |
14 | class client_delegate
15 | {
16 | public:
17 | virtual void bitchat_message_received( const decrypted_message& m ){}
18 | };
19 |
20 | /**
21 | * Provides checked conversion of public key to / from bitchat address
22 | * TODO: move this someplace else, this type of address representation
23 | * is only useful for user-facing interfaces, under the hood we just
24 | * deal with public keys.
25 | struct address
26 | {
27 | address( const fc::ecc::public_key& k );
28 | address( const std::string& a );
29 |
30 | operator std::string()const;
31 | operator fc::ecc::public_key()const;
32 |
33 | uint32_t check;
34 | fc::ecc::public_key_data key;
35 | };
36 | */
37 |
38 |
39 | /**
40 | * Provides a simple chat client that hides both the
41 | * sender and receiver of the message.
42 | *
43 | */
44 | class client
45 | {
46 | public:
47 | client( const bts::peer::peer_channel_ptr& s, client_delegate* d );
48 | ~client();
49 |
50 | void configure( const fc::path& dir );
51 |
52 | /** sets the private keys that are used to receive incoming messages*/
53 | void set_receive_keys( const std::vector& recv_keys );
54 |
55 | void join_channel( uint16_t chan_num );
56 | void send_message( const decrypted_message& m, const fc::ecc::public_key& to, uint16_t chan = 0);
57 |
58 | private:
59 | std::unique_ptr my;
60 | };
61 |
62 | typedef std::shared_ptr client_ptr;
63 | } } // bts::bitchat
64 |
65 |
66 |
--------------------------------------------------------------------------------
/include/bts/bitchat/bitchat_message_cache.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts { namespace bitchat {
6 |
7 | namespace detail { class message_cache_impl; }
8 |
9 | /**
10 | * Caches encrypted messages for up to 1 month.
11 | * Once 'full', messages can be bumped based upon difficulty with the least difficult going first.
12 | */
13 | class message_cache
14 | {
15 | public:
16 | message_cache();
17 | ~message_cache();
18 |
19 | void open( const fc::path& db_dir );
20 |
21 | void cache( const encrypted_message& msg );
22 | std::vector get_inventory( const fc::time_point& start_time, const fc::time_point& end_time );
23 |
24 | private:
25 | std::unique_ptr my;
26 | };
27 |
28 |
29 |
30 | } } // bts::bitchat
31 |
--------------------------------------------------------------------------------
/include/bts/bitchat/bitchat_messages.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts { namespace bitchat {
5 |
6 | // other protocol messages... not encapsulated by data_message
7 | struct inv_message
8 | {
9 | static const message_type type = message_type::inv_msg;
10 | std::vector items;
11 | };
12 |
13 | struct get_priv_message
14 | {
15 | static const message_type type = message_type::get_priv_msg;
16 | get_priv_message(){}
17 | get_priv_message( const fc::uint128& p )
18 | {
19 | items.push_back(p);
20 | }
21 | std::vector items;
22 | };
23 |
24 | /**
25 | * Used to request all inventory after the given time.
26 | */
27 | struct get_inv_message
28 | {
29 | static const message_type type = message_type::get_inv_msg;
30 | fc::time_point_sec after;
31 | };
32 |
33 | } } // bts::bitchat
34 |
35 | FC_REFLECT( bts::bitchat::inv_message, (items) )
36 | FC_REFLECT( bts::bitchat::get_priv_message, (items) )
37 | FC_REFLECT( bts::bitchat::get_inv_message, (after) )
38 |
--------------------------------------------------------------------------------
/include/bts/bitname/bitname_hash.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace bts { namespace bitname {
4 |
5 | /**
6 | * Performs a hash on n that will generate collisions for names
7 | * that look similar in some fonts / cases. For example the
8 | * following strings would generate collisions:
9 | *
10 | * GN00B, 6MOO8, gmoob
11 | * rin, njm
12 | */
13 | uint64_t name_hash( const std::string& n );
14 |
15 | } }
16 |
--------------------------------------------------------------------------------
/include/bts/bitname/bitname_record.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts { namespace bitname {
6 |
7 | /**
8 | * Summary information about a name registered on the
9 | * bitname blockchain.
10 | */
11 | struct name_record
12 | {
13 | name_record()
14 | :revoked(false),age(0),repute(0){}
15 |
16 | /** handle to/from hex conversion */
17 | uint64_t get_name_hash()const;
18 | void set_name_hash( uint64_t h );
19 |
20 | fc::time_point_sec last_update; ///< the most recent update of this name
21 | fc::ecc::public_key_data pub_key; ///< the public key paired to this name.
22 | bool revoked; ///< this name has been canceled, by its owner (invalidating the public key)
23 | uint32_t age; ///< first block this name was registered in
24 | uint32_t repute; ///< how many repute points have been earned by this name
25 | std::string name_hash; ///< the unique hash assigned to this name, in hex format
26 | fc::optional name; ///< if we know the name that generated the hash
27 | };
28 |
29 | } } // bts::bitname
30 |
31 | #include
32 | FC_REFLECT( bts::bitname::name_record,
33 | (last_update)
34 | (pub_key)
35 | (revoked)
36 | (age)
37 | (repute)
38 | (name_hash)
39 | (name)
40 | )
41 |
--------------------------------------------------------------------------------
/include/bts/blockchain/blockchain_market_db.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | namespace bts { namespace blockchain {
8 |
9 | namespace detail { class market_db_impl; }
10 |
11 | /**
12 | * Bids: (offers to buy Base Unit with Quote Unit)
13 | * Quote Unit, Base Unit Price UnspentOutput
14 | *
15 | * Asks: (offers to sell Base Unit for Quote Unit ) includes open short orders when BaseUnit = BTS)
16 | * Quote Unit, Base Unit Price UnspentOutput
17 | *
18 | */
19 | struct market_order
20 | {
21 | market_order( const price& p, const output_reference& loc );
22 | market_order(){}
23 | asset_type base_unit;
24 | asset_type quote_unit;
25 | fc::uint128_t ratio; // 64.64
26 | output_reference location;
27 |
28 | price get_price()const;
29 | };
30 | bool operator < ( const market_order& a, const market_order& b );
31 | bool operator == ( const market_order& a, const market_order& b );
32 |
33 | /**
34 | * Manages the current state of the market to enable effecient
35 | * pairing of the highest bid with the lowest ask.
36 | */
37 | class market_db
38 | {
39 | public:
40 | market_db();
41 | ~market_db();
42 |
43 | void open( const fc::path& db_dir );
44 | std::vector get_bids( asset::type quote_unit, asset::type base_unit )const;
45 | std::vector get_asks( asset::type quote_unit, asset::type base_unit )const;
46 |
47 | void insert_bid( const market_order& m );
48 | void insert_ask( const market_order& m );
49 | void remove_bid( const market_order& m );
50 | void remove_ask( const market_order& m );
51 |
52 | /** @pre quote > base */
53 | fc::optional get_highest_bid( asset::type quote, asset::type base );
54 | /** @pre quote > base */
55 | fc::optional get_lowest_ask( asset::type quote, asset::type base );
56 |
57 | private:
58 | std::unique_ptr my;
59 | };
60 |
61 | } } // bts::blockchain
62 |
63 | FC_REFLECT( bts::blockchain::market_order, (base_unit)(quote_unit)(ratio)(location) );
64 |
--------------------------------------------------------------------------------
/include/bts/blockchain/blockchain_printer.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts { namespace blockchain {
5 |
6 | std::string pretty_print( const trx_block& b, blockchain_db& db );
7 |
8 | } }
9 |
--------------------------------------------------------------------------------
/include/bts/blockchain/proof.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts { namespace blockchain {
6 |
7 | /**
8 | * @brief Data that is paired with
9 | */
10 | struct proof
11 | {
12 | proof()
13 | :branch_path(),nonce(0){}
14 |
15 | /**
16 | * Does not include the leaf_hash which must be passed to the
17 | * merkle_root() method to properly reconstruct the merkle root.
18 | *
19 | * The leaf is not included in this struct because it can always be
20 | * calculated from the header and it is helpful to avoid an extra
21 | * 28 bytes.
22 | *
23 | * Includes the full merkle branch to the hash of the header.
24 | */
25 | merkle_branch branch_path;
26 | uint32_t nonce;
27 | };
28 |
29 | } } // bts::blockchain
30 |
31 | FC_REFLECT( bts::blockchain::proof, (branch_path)(nonce) )
32 |
--------------------------------------------------------------------------------
/include/bts/db/fwd.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts { namespace db {
5 |
6 | class peer;
7 | typedef std::shared_ptr peer_ptr;
8 |
9 | class peer_ram;
10 | typedef std::shared_ptr peer_ram_ptr;
11 |
12 | }} // namespace bts::db
13 |
--------------------------------------------------------------------------------
/include/bts/db/peer.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | namespace bts { namespace db
11 | {
12 | /**
13 | * @brief abstracts the interface to the peer database
14 | *
15 | * There may be multiple backends for storing IP/Port/stats
16 | * for various peers in the network. This interface
17 | * abstracts that process.
18 | */
19 | class peer
20 | {
21 | public:
22 | virtual ~peer(){}
23 |
24 | struct record
25 | {
26 | record():failures(0){}
27 |
28 | fc::ip::endpoint contact;
29 | fc::time_point last_com;
30 | uint32_t failures;
31 | std::set channels;
32 | std::unordered_set features;
33 | };
34 |
35 | virtual void store( const record& r ) = 0;
36 | virtual void remove( const fc::ip::endpoint& ep ) = 0;
37 | virtual void update_last_com( const fc::ip::endpoint& ep,
38 | const fc::time_point& ) = 0;
39 |
40 | virtual record fetch( const fc::ip::endpoint& ep )const = 0;
41 | virtual std::vector get_all_peers()const = 0;
42 | virtual std::vector get_peers_on_channel( const network::channel_id& cid )const = 0;
43 | virtual std::vector get_peers_with_feature( const std::string& s )const = 0;
44 |
45 | };
46 | typedef std::shared_ptr peer_ptr;
47 |
48 |
49 | } } // namespace bts::db
50 |
51 | #include
52 | FC_REFLECT( bts::db::peer::record,
53 | (contact)
54 | (last_com)
55 | (failures)
56 | (channels)
57 | (features) )
58 |
--------------------------------------------------------------------------------
/include/bts/difficulty.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts
6 | {
7 |
8 | /**
9 | * Calculates the difficulty of hash as
10 | *
11 | * (max224() / hash) >> 24
12 | */
13 | uint64_t difficulty( const fc::sha224& hash_value );
14 |
15 | /** return 2^224 -1 */
16 | const fc::bigint& max224();
17 |
18 | } // namespace bts
19 |
--------------------------------------------------------------------------------
/include/bts/merkle_tree.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts {
6 |
7 | /**
8 | * Provides a merkle branch that proves a hash was
9 | * included in the root.
10 | */
11 | struct merkle_branch
12 | {
13 | merkle_branch()
14 | :branch(0){}
15 |
16 | uint160 calculate_root()const;
17 |
18 | uint32_t branch;
19 | std::vector mid_states;
20 | };
21 |
22 | /**
23 | * Maintains a merkle tree as updates are made via
24 | * get/set.
25 | */
26 | struct merkle_tree
27 | {
28 | void resize( uint64_t s );
29 | uint64_t size();
30 |
31 | /**
32 | * Updates all hashes in the merkle branch to index.
33 | * @throw out_of_range_exception if index > size
34 | */
35 | void set( uint64_t index, const uint160& val );
36 |
37 | /**
38 | * @throw out_of_range_exception if index > size
39 | */
40 | uint160 get( uint32_t index );
41 |
42 | /**
43 | * @return the full merkle branch for the tree.
44 | */
45 | merkle_branch get_branch( uint32_t index )const;
46 |
47 | /**
48 | * @note do not modify this field directly, it will
49 | * automatically be updated after every call to
50 | * set / get.
51 | */
52 | uint160 mroot;
53 |
54 | /**
55 | * mtree[0] is the leef layer of the tree
56 | * mtree[mtree.size()-1].size() should always be 2
57 | *
58 | * @note only modify this via get/set to keep the
59 | * struture accurate. This is public for
60 | * serialization purposes only.
61 | *
62 | * TODO: update fc::reflect to support private
63 | * members.
64 | */
65 | std::vector< std::vector < uint160 > > mtree;
66 | };
67 |
68 | }
69 | #include
70 | FC_REFLECT( bts::merkle_branch, (branch)(mid_states) )
71 | FC_REFLECT( bts::merkle_tree, (mroot)(mtree) )
72 |
73 |
--------------------------------------------------------------------------------
/include/bts/network/channel.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts { namespace network {
6 |
7 | class channel
8 | {
9 | public:
10 | virtual ~channel(){}
11 |
12 | virtual void handle_message( const connection_ptr&,
13 | const message& m ) = 0;
14 | virtual void handle_subscribe( const connection_ptr& c )=0;
15 | virtual void handle_unsubscribe( const connection_ptr& c )=0;
16 | };
17 |
18 | typedef std::shared_ptr channel_ptr;
19 |
20 | } }
21 |
22 |
23 |
--------------------------------------------------------------------------------
/include/bts/network/channel_pow_stats.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts { namespace network {
5 |
6 | /**
7 | * Tracks the bandwidth used by a specific channel and calculates
8 | * the average proof-of-work per message to get an idea of what
9 | * is required to broadcast on the network.
10 | *
11 | * If the bandwidth is above the target bandwidth over the last
12 | * 5 minutes then the required proof-of-work for rebroadcast is
13 | * 5% above average, otherwise it is 5% below average.
14 | */
15 | class channel_pow_stats
16 | {
17 | public:
18 | channel_pow_stats();
19 |
20 | /**
21 | * Updates the weighted-average bits per microsecond handled by
22 | * a particular channel using the system clock to measure elapsed
23 | * time between calls.
24 | *
25 | * @param bytes_received the bytes received since the last call
26 | * @param msg_pow the proof of work associated with these bytes.
27 | *
28 | * @pre msg_pow < target_pow
29 | *
30 | * @return true if these bytes can be received / processed at the given
31 | * proof of work level.
32 | */
33 | bool update_bpus_avg( uint64_t bytes_recv, const mini_pow& msg_pow );
34 |
35 | mini_pow target_pow;
36 | mini_pow average_pow;
37 | uint64_t target_bits_per_usec;
38 | uint64_t avg_bits_per_usec;
39 | fc::time_point last_recv;
40 | };
41 |
42 | } }
43 |
44 | #include
45 | FC_REFLECT( bts::network::channel_pow_stats,
46 | (target_pow)
47 | (average_pow)
48 | (target_bits_per_usec)
49 | (avg_bits_per_usec)
50 | (last_recv)
51 | )
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/include/bts/network/feature_id.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace bts { namespace network {
4 |
5 | /**
6 | * Different nodes may support different features that are not necessarily
7 | * associated with channels. Feature IDs allow us to identify these nodes.
8 | */
9 | enum feature_id
10 | {
11 | unspecified = 0,
12 | kad = 1 /** node participates in a KAD hash table **/
13 | };
14 |
15 | } }
16 |
17 | FC_REFLECT_ENUM( bts::network::feature_id, (unspecified)(kad) )
18 |
--------------------------------------------------------------------------------
/include/bts/network/get_public_ip.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace bts { namespace network {
4 |
5 | fc::ip::address get_public_ip();
6 |
7 | } }
8 |
--------------------------------------------------------------------------------
/include/bts/network/stcp_socket.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 |
6 | namespace bts { namespace network {
7 |
8 | /**
9 | * Uses ECDH to negotiate a blowfish key for communicating
10 | * with other nodes on the network.
11 | */
12 | class stcp_socket : public virtual fc::iostream
13 | {
14 | public:
15 | stcp_socket();
16 | ~stcp_socket();
17 | fc::tcp_socket& get_socket() { return _sock; }
18 | void accept();
19 |
20 | void connect_to( const fc::ip::endpoint& ep );
21 |
22 | virtual size_t readsome( char* buffer, size_t max );
23 | virtual bool eof()const;
24 |
25 | virtual size_t writesome( const char* buffer, size_t len );
26 | virtual void flush();
27 | virtual void close();
28 |
29 | void get( char& c ) { read( &c, 1 ); }
30 |
31 | private:
32 | fc::ecc::private_key _priv_key;
33 | fc::array _buf;
34 | uint32_t _buf_len;
35 | fc::tcp_socket _sock;
36 | fc::aes_encoder _send_aes;
37 | fc::aes_decoder _recv_aes;
38 | };
39 |
40 | typedef std::shared_ptr stcp_socket_ptr;
41 |
42 | } } // bts::network
43 |
--------------------------------------------------------------------------------
/include/bts/network/upnp.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts { namespace network {
6 |
7 | namespace detail { class upnp_service_impl; }
8 |
9 | class upnp_service
10 | {
11 | public:
12 | upnp_service();
13 | ~upnp_service();
14 |
15 | void map_port( uint16_t p );
16 | private:
17 | std::unique_ptr my;
18 | };
19 |
20 | } }
21 |
--------------------------------------------------------------------------------
/include/bts/peer/peer_channel.hpp:
--------------------------------------------------------------------------------
1 | /** @file peer_channel.hpp
2 | * @brief Defines messages exchanged on the peer/discovery channel (0)
3 | */
4 | #pragma once
5 | #include
6 | #include
7 | #include
8 |
9 | namespace bts { namespace peer {
10 |
11 | namespace detail { class peer_channel_impl; }
12 |
13 | /**
14 | * Tracks a contact address and the last time it was heard about.
15 | struct host
16 | {
17 | fc::ip::endpoint ep;
18 | fc::time_point_sec last_com;
19 | };
20 | */
21 |
22 | /**
23 | * Manages the state of all peers including what channels they
24 | * are connected to and known IPs of hosts that we are not
25 | * connected to.
26 | *
27 | * The peer channel is how the nodes communicate information about
28 | * eachother, their features, and meta information about the channels
29 | * they are subscribed to.
30 | */
31 | class peer_channel
32 | {
33 | public:
34 | peer_channel( const network::server_ptr& netw );
35 | ~peer_channel();
36 |
37 | /**
38 | * broadcasts the new channel subscription to all connected nodes. If less than
39 | * the minimum number of connections exist to this channel, new connections are
40 | * opened.
41 | */
42 | void subscribe_to_channel( const network::channel_id& chan, const network::channel_ptr& c );
43 | void unsubscribe_from_channel( const network::channel_id& chan );
44 |
45 | /**
46 | * @return a list of all known hosts.
47 | */
48 | std::vector get_known_hosts()const;
49 |
50 | /**
51 | * @return a list of connections subscribed to a particular channel.
52 | */
53 | std::vector get_connections( const network::channel_id& chan );
54 | private:
55 | std::shared_ptr my;
56 | };
57 |
58 | typedef std::shared_ptr peer_channel_ptr;
59 |
60 |
61 |
62 | } }
63 |
64 | //#include
65 | //FC_REFLECT( bts::peer::host, (ep)(last_com) )
66 |
67 |
--------------------------------------------------------------------------------
/include/bts/peer/peer_db.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts { namespace peer {
5 |
6 | using network::channel_id;
7 |
8 |
9 | /**
10 | * Maintains a database of peers indexed by age, channels, and features. This
11 | * index is persistant and enables a node to maintain a large set of potential
12 | * bootstrap nodes for future connections and to quickly connect to new channels
13 | * when they need to.
14 | */
15 | class peer_db
16 | {
17 | public:
18 | peer_db();
19 | ~peer_db();
20 |
21 | void open( const fc::path& dbdir, bool create = true );
22 | void close();
23 |
24 | /**
25 | * On a fresh startup the entire database is 'out of date' and therefore
26 | * all hosts should be reset to 1 hour old so they can expire if we have
27 | * not heard about them in 2 hours.
28 | */
29 | void reset_ages( const fc::time_point_sec& s );
30 |
31 | void store( const host& r );
32 | host fetch_record( const fc::ip::endpoint& ep );
33 |
34 | /** Removes a host from the DB, presumably because we attempted to connect
35 | * to it and were unable to.
36 | *
37 | * TODO: how do we prevent purging the entire DB if the internet goes down
38 | * and no hosts are reachable? Perhaps only perge nodes if we are successfully
39 | * connected to other nodes.
40 | */
41 | void remove( const fc::ip::endpoint& ep );
42 |
43 | void add_channel( const fc::ip::endpoint& e, const channel_id& c );
44 | void remove_channel( const fc::ip::endpoint& e, const channel_id& c );
45 |
46 | std::vector fetch_hosts( const channel_id& c, uint32_t limit = 10 );
47 | void purge_old( const fc::time_point& age );
48 |
49 | private:
50 | std::unique_ptr my;
51 |
52 | }; // peer_db
53 |
54 | } } // bts::peer
55 |
56 | FC_REFLECT( bts::peer::host, (ep)(last_com)(first_com)(channels)(features) )
57 |
--------------------------------------------------------------------------------
/include/bts/peer/peer_host.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace bts { namespace peer {
10 |
11 | using network::channel_id;
12 |
13 | /**
14 | * Tracks a contact address and the last time it was heard about.
15 | */
16 | struct host
17 | {
18 | host( const fc::ip::endpoint& ep, const network::channel_id& c, const fc::time_point_sec& = fc::time_point::now() );
19 | host(){}
20 |
21 | fc::ip::endpoint ep;
22 | fc::time_point_sec last_com;
23 |
24 | /**
25 | * hosts that we hear about frequently and that never leave our DB are probably long lived nodes
26 | * and thus good candidates for seed hosts...
27 | */
28 | fc::time_point_sec first_com; // set when a host is added to the database
29 | std::vector channels; // TODO: defien size limit for unpacking these
30 | std::vector< fc::enum_type > features; // TODO: define size limit for unpacking these
31 | };
32 |
33 | } } // bts::peer
34 |
35 | FC_REFLECT( bts::peer::host, (ep)(last_com)(first_com)(channels)(features) )
36 |
--------------------------------------------------------------------------------
/include/bts/proof_of_work.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 |
6 | namespace bts {
7 |
8 | /** typedef to the same size */
9 | typedef fc::ripemd160 pow_hash;
10 |
11 | /**
12 | * The purpose of this method is to generate a determinstic proof-of-work
13 | * that cannot be optimized via ASIC or extreme parallelism.
14 | *
15 | * @param in - initial hash
16 | * @param buffer_128m - 128 MB buffer used for scratch space.
17 | * @return processed hash after doing proof of work.
18 | */
19 | pow_hash proof_of_work( const fc::sha256& in, unsigned char* buffer_128m );
20 | pow_hash proof_of_work( const fc::sha256& in );
21 |
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/include/bts/rpc/rpc_server.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts { namespace rpc {
5 |
6 | namespace detail { class server_impl; }
7 |
8 | /**
9 | * @brief provides a JSON-RPC interface bitshare components
10 | *
11 | * Before any RPC commands will be processed, the user must call
12 | * the login method and get a valid response.
13 | *
14 | * @code
15 | * { "method":"login", "params":["user","pass"], "id":0 }
16 | * @endcode
17 | *
18 | * TODO: Implement SSL connections, perhaps with CERT requirement
19 | * TODO: Restrict connections to a user-specified interface (ie: loopback)
20 | */
21 | class server
22 | {
23 | public:
24 | struct config
25 | {
26 | config()
27 | :port(0){}
28 |
29 | uint16_t port;
30 | std::string user;
31 | std::string pass;
32 | };
33 |
34 | server();
35 | ~server();
36 |
37 | void configure( const config& cfg );
38 | void set_bitname_client( const bts::bitname::client_ptr& name_cl );
39 |
40 | private:
41 | std::unique_ptr my;
42 | };
43 |
44 | typedef std::shared_ptr server_ptr;
45 |
46 | } } // bts::rpc
47 |
48 | FC_REFLECT( bts::rpc::server::config, (port)(user)(pass) )
49 |
--------------------------------------------------------------------------------
/include/bts/small_hash.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts
5 | {
6 | typedef fc::ripemd160 uint160;
7 |
8 | /**
9 | * Performs ripemd160(seed);
10 | */
11 | uint160 small_hash( const fc::sha512& seed );
12 |
13 | /**
14 | * The goal of the small hash is to be secure using as few
15 | * bits as possible.
16 | *
17 | * Performs small_hash( sha512(data,len) )
18 | */
19 | uint160 small_hash( const char* data, size_t len );
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/include/bts/units.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | namespace bts
5 | {
6 |
7 | /**
8 | * All balanes are annotated with a unit, each BitShare
9 | * chain supports 8 basic units
10 | */
11 | enum unit_type
12 | {
13 | BitShares = 0,
14 | BitGold = 1,
15 | BitSilver = 2,
16 | BitUSD = 3,
17 | BitEUR = 4,
18 | BitYUAN = 5,
19 | BitGBP = 6,
20 | BitBTC = 7,
21 | NumUnits
22 | };
23 |
24 | struct bond_type
25 | {
26 | bond_type():issue_type(BitShares),backing_type(BitShares){}
27 | unit_type issue_type;
28 | unit_type backing_type;
29 | };
30 |
31 | } // namespace bts
32 |
33 | FC_REFLECT_ENUM( bts::unit_type,
34 | (BitShares)
35 | (BitGold)
36 | (BitSilver)
37 | (BitUSD)
38 | (BitEUR)
39 | (BitYUAN)
40 | (BitGBP)
41 | (BitBTC)
42 | (NumUnits)
43 | )
44 |
45 | FC_REFLECT( bts::bond_type, (issue_type)(backing_type) )
46 |
47 | // TODO: define raw pack to 1 byte
48 |
49 |
--------------------------------------------------------------------------------
/include/bts/wallet.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace bts
6 | {
7 | /**
8 | * @class wallet
9 | * @brief A deterministic wallet that generates a family of public/private keys.
10 | *
11 | * A wallet can deterministicaly generate a whole family of public / private keys
12 | * given an initial secret value. If only the master public key is given, then
13 | * all other public keys could be generated, however, the private keys could not
14 | * be generated. This makes it easy to have read-only wallets that do not
15 | * require access to the secret.
16 | *
17 | * This wallet class only conserns itself with the generation of the deterministic
18 | * keys and does not implement any storage system or caching.
19 | */
20 | class wallet
21 | {
22 | public:
23 | wallet();
24 | ~wallet();
25 |
26 | /**
27 | * The seed should be the hash of a long pass phrase and not something that
28 | * would end up in a dictionary attack.
29 | */
30 | void set_seed( const fc::sha256& s, bool stretch = true );
31 |
32 | /**
33 | * Used to generate public keys without any private keys.
34 | */
35 | void set_master_public_key( const fc::ecc::public_key& k );
36 | fc::ecc::public_key get_master_public_key()const;
37 |
38 | /**
39 | * @throws if no seed has been set.
40 | */
41 | fc::ecc::private_key get_master_private_key()const;
42 |
43 | /**
44 | * @throws if set_seed() or set_master_public_key() has not been called
45 | */
46 | fc::ecc::public_key get_public_key( uint32_t index );
47 |
48 | /**
49 | * @throws if no seed has been set.
50 | */
51 | fc::ecc::private_key get_private_key( uint32_t index );
52 |
53 | private:
54 | fc::sha256 _stretched_seed;
55 | fc::optional _master_priv;
56 | fc::optional _master_pub;
57 | };
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/keyhotee/AddressBook/AddressBookModel.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace Detail { class AddressBookModelImpl; }
6 |
7 | class AddressBookModel : public QAbstractTableModel
8 | {
9 | public:
10 | AddressBookModel( bts::addressbook::addressbook_ptr abook );
11 | ~AddressBookModel();
12 |
13 | enum Columns
14 | {
15 | FirstName,
16 | LastName,
17 | Id,
18 | Age,
19 | Repute,
20 | NumColumns
21 | };
22 | void storeContact( const bts::addressbook::contact& new_contact );
23 |
24 | virtual int rowCount( const QModelIndex& parent = QModelIndex() )const;
25 | virtual int columnCount( const QModelIndex& parent = QModelIndex() )const;
26 |
27 | virtual bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() );
28 |
29 | virtual QVariant headerData( int section, Qt::Orientation o, int role = Qt::DisplayRole )const;
30 | virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole )const;
31 |
32 | private:
33 | std::unique_ptr my;
34 | };
35 |
--------------------------------------------------------------------------------
/keyhotee/AddressBook/ContactsTable.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ContactsTable
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 543
11 |
12 |
13 |
14 | Form
15 |
16 |
17 |
18 | 0
19 |
20 |
21 | 0
22 |
23 |
24 | 0
25 |
26 |
27 | 0
28 |
29 |
30 | 5
31 |
32 | -
33 |
34 |
35 | Qt::Horizontal
36 |
37 |
38 |
39 | 278
40 | 20
41 |
42 |
43 |
44 |
45 | -
46 |
47 |
48 | Add Contact
49 |
50 |
51 |
52 | -
53 |
54 |
55 | Qt::Vertical
56 |
57 |
58 | 9
59 |
60 |
61 |
62 | true
63 |
64 |
65 | true
66 |
67 |
68 | true
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/keyhotee/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set( CMAKE_INCLUDE_CURRENT_DIR ON)
2 | set( CMAKE_AUTOMOC ON )
3 | find_package( Qt5Widgets )
4 | find_package( Qt5WebKitWidgets )
5 | include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
6 |
7 | # Only build the Keyhotee gui when we find Qt
8 | IF( NOT Qt5Widgets_DIR MATCHES Qt5Widgets_DIR-NOTFOUND )
9 |
10 | set( headers
11 | profile_wizard/ProfileWizard.hpp
12 | )
13 |
14 | qt5_wrap_ui( profile_wizard/UiProfileEditPage profile_wizard/ProfileEditPage.ui )
15 | qt5_wrap_ui( profile_wizard/UiProfileIntroPage profile_wizard/ProfileIntroPage.ui )
16 | qt5_wrap_ui( profile_wizard/UiNymPage profile_wizard/ProfileNymPage.ui )
17 | qt5_wrap_ui( UiLoginDialog LoginDialog.ui )
18 | qt5_wrap_ui( UiEditContactDialog EditContactDialog.ui )
19 | qt5_wrap_ui( UiKeyhoteeMainWindow KeyhoteeMainWindow.ui )
20 | QT5_ADD_RESOURCES( KeyhoteeQRC Keyhotee.qrc )
21 |
22 | set( sources
23 | Keyhotee.qrc
24 |
25 | profile_wizard/ProfileEditPage.ui
26 | profile_wizard/ProfileIntroPage.ui
27 | profile_wizard/ProfileNymPage.ui
28 | profile_wizard/ProfileWizard.cpp
29 |
30 | AddressBook/AddressBookModel.hpp
31 | AddressBook/AddressBookModel.cpp
32 |
33 | LoginDialog.ui
34 | LoginDialog.cpp
35 |
36 | EditContactDialog.ui
37 | EditContactDialog.cpp
38 |
39 | KeyhoteeMainWindow.ui
40 | KeyhoteeMainWindow.cpp
41 | main.cpp )
42 |
43 | add_executable( Keyhotee MACOSX_BUNDLE WIN32 ${sources} )
44 | target_link_libraries( Keyhotee upnpc-static bshare fc leveldb ${BOOST_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} Qt5::Widgets Qt5::WebKitWidgets)
45 |
46 | ENDIF( NOT Qt5Widgets_DIR MATCHES Qt5Widgets_DIR-NOTFOUND )
47 |
--------------------------------------------------------------------------------
/keyhotee/EditContactDialog.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | namespace Ui { class EditContactDialog; }
8 |
9 | class EditContactDialog : public QDialog
10 | {
11 | public:
12 | EditContactDialog( QWidget* parent );
13 | ~EditContactDialog();
14 |
15 | void validateId( const QString& id );
16 | void lookupId();
17 |
18 | void setContact( const bts::addressbook::contact& con );
19 | bts::addressbook::contact getContact()const;
20 |
21 | private:
22 | std::unique_ptr ui;
23 | bts::addressbook::contact _contact;
24 | bool _complete;
25 | fc::time_point _last_validate;
26 | };
27 |
--------------------------------------------------------------------------------
/keyhotee/Keyhotee.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/contact_icon.png
4 |
5 |
6 |
--------------------------------------------------------------------------------
/keyhotee/KeyhoteeMainWindow.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace Ui { class KeyhoteeMainWindow; }
6 |
7 | class KeyhoteeMainWindow : public QMainWindow
8 | {
9 | public:
10 | KeyhoteeMainWindow();
11 | ~KeyhoteeMainWindow();
12 |
13 | void addContact();
14 |
15 | private:
16 | std::unique_ptr ui;
17 | };
18 |
--------------------------------------------------------------------------------
/keyhotee/LoginDialog.cpp:
--------------------------------------------------------------------------------
1 | #include "LoginDialog.hpp"
2 | #include
3 | #include
4 |
5 | #include
6 | #include
7 |
8 | LoginDialog::LoginDialog( QWidget* parent )
9 | :QDialog(parent)
10 | {
11 | ui.reset( new Ui::LoginDialog() );
12 | ui->setupUi(this);
13 | connect( ui->login, &QPushButton::clicked, this, &LoginDialog::onLogin );
14 | connect( ui->quit, &QPushButton::clicked, this, &LoginDialog::onQuit );
15 | }
16 |
17 | LoginDialog::~LoginDialog()
18 | {}
19 |
20 |
21 | void LoginDialog::onLogin()
22 | {
23 | try {
24 | password = ui->password->text().toStdString();
25 | auto pro = bts::application::instance()->load_profile(password);
26 | if( pro )
27 | {
28 | accept();
29 | }
30 | }
31 | catch ( const fc::exception& e )
32 | {
33 | wlog( "error ${w}", ("w",e.to_detail_string()) );
34 | }
35 | ui->password->setText(QString());
36 | shake();
37 | }
38 | void LoginDialog::shake( )
39 | {
40 | move( pos() + QPoint(10,0) );
41 | fc::usleep( fc::microseconds( 50*1000 ) );
42 | move( pos() + QPoint(-20,0) );
43 | fc::usleep( fc::microseconds( 50*1000 ) );
44 | move( pos() + QPoint(20,0) );
45 | fc::usleep( fc::microseconds( 50*1000 ) );
46 | move( pos() + QPoint(-10,0) );
47 | }
48 | void LoginDialog::onQuit()
49 | {
50 | qApp->quit();
51 | reject();
52 | }
53 |
--------------------------------------------------------------------------------
/keyhotee/LoginDialog.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace Ui { class LoginDialog; }
6 |
7 | class LoginDialog : public QDialog
8 | {
9 | public:
10 | LoginDialog( QWidget* parent = nullptr );
11 | ~LoginDialog();
12 |
13 | void onLogin();
14 | void onQuit();
15 | void shake();
16 |
17 | std::string password;
18 | private:
19 | std::unique_ptr ui;
20 | };
21 |
--------------------------------------------------------------------------------
/keyhotee/LoginDialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | LoginDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 302
10 | 188
11 |
12 |
13 |
14 | Keyhotee Login
15 |
16 |
17 | -
18 |
19 |
20 | -
21 |
22 |
23 | Password
24 |
25 |
26 |
27 | -
28 |
29 |
30 | QLineEdit::Password
31 |
32 |
33 |
34 | -
35 |
36 |
37 | Quit
38 |
39 |
40 | false
41 |
42 |
43 | false
44 |
45 |
46 |
47 | -
48 |
49 |
50 | Login
51 |
52 |
53 | true
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/keyhotee/images/contact_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Xenland/BitShares/f8d5bf4ef0517fd566119c2f8daf7776b0be00aa/keyhotee/images/contact_icon.png
--------------------------------------------------------------------------------
/keyhotee/profile_wizard/ProfileIntroPage.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | IntroPage
4 |
5 |
6 |
7 | 0
8 | 0
9 | 469
10 | 377
11 |
12 |
13 |
14 | WizardPage
15 |
16 |
17 | -
18 |
19 |
20 |
21 | about:blank
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | QWebView
31 | QWidget
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/keyhotee/profile_wizard/ProfileWizard.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | namespace Ui {
6 | class IntroPage;
7 | } // namespace Ui
8 |
9 | class NymPage;
10 | class ProfileEditPage;
11 |
12 | class ProfileWizard : public QWizard
13 | {
14 | public:
15 | ProfileWizard( QWidget* parent );
16 | ~ProfileWizard();
17 |
18 | enum Pages
19 | {
20 | Page_Intro,
21 | Page_Profile,
22 | Page_FirstNym
23 | };
24 |
25 | public slots:
26 | void showHelp();
27 | void createProfile( int result );
28 |
29 | private:
30 | NymPage* _nym_page;
31 | ProfileEditPage* _profile_edit;
32 | Ui::IntroPage* _profile_intro_ui;
33 | };
34 |
--------------------------------------------------------------------------------
/src/address.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | namespace bts
8 | {
9 | address::address()
10 | {
11 | memset( addr.data, 0, sizeof(addr.data) );
12 | }
13 | address::address( const std::string& base58str )
14 | {
15 | std::vector v = fc::from_base58( fc::string(base58str) );
16 | if( v.size() )
17 | memcpy( addr.data, v.data(), std::min( v.size(), sizeof(addr) ) );
18 |
19 | if( !is_valid() )
20 | {
21 | FC_THROW_EXCEPTION( exception, "invalid address ${a}", ("a", base58str) );
22 | }
23 | }
24 |
25 | address::address( const fc::ecc::public_key& pub )
26 | {
27 | auto dat = pub.serialize();
28 | auto dat_hash = small_hash(dat.data, sizeof(dat) );
29 | // set the version number
30 | ((char*)&dat_hash)[0] &= 0x0f; // set first 4 bits to 0
31 | ((char*)&dat_hash)[0] |= 0x10; // set the first 4 bits to 0001
32 | auto check = fc::ripemd160::hash( (char*)&dat_hash, 16 );
33 | memcpy( addr.data, (char*)&dat_hash, sizeof(addr) );
34 | memcpy( &addr.data[16], (char*)&check, 4 );
35 | }
36 |
37 | /**
38 | * Checks the address to verify it has a
39 | * valid checksum and prefix.
40 | */
41 | bool address::is_valid()const
42 | {
43 | if( (addr.data[0] & 0xf0) != 0x10 ) // version 1
44 | {
45 | FC_THROW_EXCEPTION( exception, "invalid address version" );
46 | return false;
47 | }
48 | auto check = fc::ripemd160::hash( addr.data, 16 );
49 | return memcmp(&addr.data[16], &check, 4 ) == 0;
50 | }
51 |
52 | address::operator std::string()const
53 | {
54 | return fc::to_base58( addr.data, sizeof(addr) );
55 | }
56 | } // namespace bts
57 |
58 |
59 | namespace fc
60 | {
61 | void to_variant( const bts::address& var, variant& vo )
62 | {
63 | vo = std::string(var);
64 | }
65 | void from_variant( const variant& var, bts::address& vo )
66 | {
67 | vo = bts::address( var.as_string() );
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/addressbook/addressbook.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | namespace bts { namespace addressbook {
8 |
9 | namespace detail
10 | {
11 | class addressbook_impl
12 | {
13 | public:
14 | db::level_map _contact_db;
15 | db::level_map _address_index;
16 | };
17 | }
18 |
19 | addressbook::addressbook()
20 | :my( new detail::addressbook_impl() )
21 | {
22 | }
23 |
24 | addressbook::~addressbook()
25 | {
26 | }
27 |
28 | void addressbook::open( const fc::path& abook_dir )
29 | { try {
30 |
31 | if( !fc::exists( abook_dir ) )
32 | {
33 | fc::create_directories( abook_dir );
34 | }
35 | my->_contact_db.open( abook_dir / "contact_db" );
36 | my->_address_index.open( abook_dir / "address_index" );
37 |
38 | } FC_RETHROW_EXCEPTIONS( warn, "", ("directory", abook_dir) ) }
39 |
40 | std::vector addressbook::get_known_bitnames()const
41 | {
42 | std::vector known_bitnames;
43 | auto itr = my->_contact_db.begin();
44 | while( itr.valid() )
45 | {
46 | known_bitnames.push_back(itr.key());
47 | ++itr;
48 | }
49 | return known_bitnames;
50 | }
51 |
52 | fc::optional addressbook::get_contact_by_bitname( const std::string& bitname_id )const
53 | { try {
54 | fc::optional con;
55 | auto itr = my->_contact_db.find(bitname_id);
56 | if( itr.valid() ) con = itr.value();
57 | return con;
58 | } FC_RETHROW_EXCEPTIONS( warn, "", ("bitname_id", bitname_id) ) }
59 |
60 | std::string addressbook::get_bitname_by_address( const bts::address& bitname_address )const
61 | { try {
62 | return my->_address_index.fetch( bitname_address );
63 | } FC_RETHROW_EXCEPTIONS( warn, "", ("bitname_address", bitname_address) ) }
64 |
65 | void addressbook::store_contact( const contact& contact_param )
66 | { try {
67 | my->_contact_db.store( contact_param.bitname_id, contact_param );
68 | my->_address_index.store( bts::address(contact_param.send_msg_address), contact_param.bitname_id );
69 | } FC_RETHROW_EXCEPTIONS( warn, "", ("contact", contact_param) ) }
70 |
71 | } } // bts::addressbook
72 |
--------------------------------------------------------------------------------
/src/bitchat/bitchat_messages.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | namespace bts { namespace bitchat {
4 |
5 | const message_type inv_message::type;
6 | const message_type get_priv_message::type;
7 | const message_type get_inv_message::type;
8 | const message_type encrypted_message::type;
9 |
10 | } } // bts::bitchat
11 |
--------------------------------------------------------------------------------
/src/bitname/bitname_messages.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | namespace bts { namespace bitname {
4 |
5 | const message_type name_inv_message::type = name_inv_msg;
6 | const message_type block_inv_message::type = block_inv_msg;
7 | const message_type get_name_inv_message::type = get_name_inv_msg;
8 | const message_type get_headers_message::type = get_headers_msg;
9 | const message_type get_block_message::type = get_block_msg;
10 | const message_type get_block_index_message::type = get_block_index_msg;
11 | const message_type get_name_header_message::type = get_name_header_msg;
12 | const message_type name_header_message::type = name_header_msg;
13 | const message_type block_message::type = block_msg;
14 | const message_type block_index_message::type = block_index_msg;
15 | const message_type headers_message::type = headers_msg;
16 |
17 | } } // bts::bitname
18 |
--------------------------------------------------------------------------------
/src/bitname/bitname_record.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace bts { namespace bitname {
5 | uint64_t name_record::get_name_hash()const
6 | {
7 | uint64_t result = 0;
8 | fc::from_hex( name_hash, (char*)&result, sizeof(result) );
9 | return result;
10 | }
11 |
12 | void name_record::set_name_hash( uint64_t nhash )
13 | {
14 | name_hash = fc::to_hex( (char*)&nhash, sizeof(nhash) );
15 | }
16 |
17 | } } // bts::bitname
18 |
--------------------------------------------------------------------------------
/src/blockchain/blockchain_messages.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | namespace bts { namespace blockchain {
4 |
5 | const message_type trx_inv_message::type;
6 | const message_type block_inv_message::type;
7 | const message_type get_trx_inv_message::type;
8 | const message_type get_trxs_message::type;
9 | const message_type get_full_block_message::type;
10 | const message_type get_trx_block_message::type;
11 | const message_type trxs_message::type;
12 | const message_type full_block_message::type;
13 | const message_type trx_block_message::type;
14 |
15 | } } // bts::bitchat
16 |
--------------------------------------------------------------------------------
/src/blockchain/blockchain_outputs.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | namespace bts { namespace blockchain {
4 |
5 | const claim_type_enum claim_by_signature_output::type = claim_type_enum::claim_by_signature;
6 | const claim_type_enum claim_by_bid_output::type = claim_type_enum::claim_by_bid;
7 | const claim_type_enum claim_by_long_output::type = claim_type_enum::claim_by_long;
8 | const claim_type_enum claim_by_cover_output::type = claim_type_enum::claim_by_cover;
9 | const claim_type_enum claim_by_opt_execute_output::type = claim_type_enum::claim_by_opt_execute;
10 | const claim_type_enum claim_by_password_output::type = claim_type_enum::claim_by_password;
11 | const claim_type_enum claim_by_escrow_output::type = claim_type_enum::claim_by_password;
12 | const claim_type_enum claim_by_multi_sig_output::type = claim_type_enum::claim_by_multi_sig;
13 |
14 |
15 | const claim_type_enum claim_by_signature_input::type = claim_type_enum::claim_by_signature;
16 | const claim_type_enum claim_by_bid_input::type = claim_type_enum::claim_by_bid;
17 | const claim_type_enum claim_by_long_input::type = claim_type_enum::claim_by_long;
18 | const claim_type_enum claim_by_cover_input::type = claim_type_enum::claim_by_cover;
19 | const claim_type_enum claim_by_opt_execute_input::type = claim_type_enum::claim_by_opt_execute;
20 | const claim_type_enum claim_by_password_input::type = claim_type_enum::claim_by_password;
21 | const claim_type_enum claim_by_multi_sig_input::type = claim_type_enum::claim_by_multi_sig;
22 |
23 | bool claim_by_bid_output::is_ask( asset::type out_unit )const
24 | {
25 | return ask_price.quote_unit == out_unit;
26 | }
27 |
28 | bool claim_by_bid_output::is_bid( asset::type out_unit )const
29 | {
30 | return !is_ask(out_unit);
31 | }
32 |
33 | bool claim_by_bid_output::operator == ( const claim_by_bid_output& other )const
34 | {
35 | return (other.pay_address == pay_address) &&
36 | (other.ask_price == ask_price) &&
37 | (other.min_trade == min_trade);
38 | }
39 |
40 | } } // bts::blockchain
41 |
--------------------------------------------------------------------------------
/src/difficulty.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | namespace bts
6 | {
7 | const fc::bigint& max224()
8 | {
9 | static fc::bigint m = [](){
10 | char data[224/8+1];
11 | memset( data, 0xff, sizeof(data) );
12 | data[0] = 0;
13 | return fc::bigint(data,sizeof(data));
14 | }();
15 | return m;
16 | }
17 |
18 | uint64_t difficulty( const fc::sha224& hash_value )
19 | {
20 | if( hash_value == fc::sha224() ) return uint64_t(-1); // div by 0
21 |
22 | auto dif = max224() / fc::bigint( (char*)&hash_value, sizeof(hash_value) );
23 | // TODO... restore this dif >>= 24;
24 | int64_t tmp = dif.to_int64();
25 | // possible if hash_value starts with 1
26 | if( tmp < 0 ) tmp = 0;
27 | return tmp;
28 | }
29 |
30 |
31 | } // bts
32 |
--------------------------------------------------------------------------------
/src/merkle_tree.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace bts {
5 |
6 | uint160 merkle_branch::calculate_root()const
7 | {
8 | if( mid_states.size() == 0 ) return uint160();
9 | if( mid_states.size() == 1 ) return mid_states[0];
10 | FC_ASSERT( !"TODO: Merged Mining is Not Yet Implemented" );
11 | }
12 |
13 | } // namespace bts
14 |
--------------------------------------------------------------------------------
/src/miner.cpp:
--------------------------------------------------------------------------------
1 | #include "miner.hpp"
2 |
3 |
4 | miner::miner( block_chain& bc, account& a )
5 | :_block_chain(bc),_mining_account(a)
6 | {
7 | }
8 |
9 | miner::~miner()
10 | {
11 | }
12 |
13 | void miner::start( float effort )
14 | {
15 | }
16 |
17 | void miner::stop()
18 | {
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/src/miner.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "api.hpp"
3 | #include
4 |
5 | class account;
6 |
7 |
8 | /**
9 | * The miner will monitor the block chain for changes and
10 | * attempt to solve new blocks as they come in. When a new
11 | * block is solved it will be 'added' to the chain.
12 | */
13 | class miner
14 | {
15 | public:
16 | miner( block_chain& bc, account& a );
17 | ~miner();
18 |
19 | void start( float effort = 1);
20 | void stop();
21 |
22 | private:
23 | fc::thread _mining_thread;
24 | block_chain& _block_chain;
25 | account& _mining_account;
26 | float _effort;
27 | };
28 |
--------------------------------------------------------------------------------
/src/network/get_public_ip.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | namespace bts { namespace network
6 | {
7 | /**
8 | * Attempts to connect to checkip.dyndns.org to and then parse the
9 | * HTML for the IP address.
10 | *
11 | * @throw if no IP could be discovered.
12 | */
13 | fc::ip::address get_public_ip()
14 | {
15 | fc::http::connection con;
16 | con.connect_to( fc::ip::endpoint::from_string( "91.198.22.70:80" ) );
17 | auto reply = con.request( "GET", "/", std::string() );
18 |
19 | std::string s( reply.body.data(), reply.body.data() + reply.body.size() );
20 | // ilog( "${body}", ( "body", s) );
21 | auto pos = s.find( "Address: " );
22 | auto end = s.find( "