forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* btcsimple: the 24 line bitcoin server - closes bitcoin#12 * ponzicoin: An example of an alternative chain, this one is a fast forward of bitcoin to easily study long term effects. - closes bitcoin#11 Build example using ccmake - first configure ('c') then scroll down to enable examples, then configure again and then generate and exit. Default is to build without examples.
- Loading branch information
Michael Gronager
authored and
Michael Gronager
committed
Jan 25, 2012
1 parent
e8d5d85
commit 5bc9ac0
Showing
5 changed files
with
437 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
####################################################### | ||
# this are setting used in SETUP_EXAMPLE macro | ||
####################################################### | ||
SET(TARGET_DEFAULT_PREFIX "example_") | ||
SET(TARGET_DEFAULT_LABEL_PREFIX "Examples") | ||
|
||
SET(TARGET_COMMON_LIBRARIES | ||
btc | ||
btcHTTP | ||
btcNode | ||
) | ||
|
||
IF(ANDROID) | ||
# ADD_SUBDIRECTORY(btcandroidsimple) | ||
ELSE(ANDROID) | ||
|
||
IF(DYNAMIC_BITCOIN) | ||
ADD_SUBDIRECTORY(btcsimple) | ||
ADD_SUBDIRECTORY(ponzicoin) | ||
# ADD_SUBDIRECTORY(btcexplorer) | ||
# ADD_SUBDIRECTORY(btconline) | ||
|
||
IF (wxWidgets_FOUND) | ||
# ADD_SUBDIRECTORY(bitsimpleWX) | ||
ENDIF(wxWidgets_FOUND) | ||
|
||
|
||
ELSE(DYNAMIC_BITCOIN) | ||
#needed on win32 or the linker get confused by _declspec declarations | ||
ADD_DEFINITIONS(-DBTC_LIBRARY_STATIC) | ||
|
||
ENDIF(DYNAMIC_BITCOIN) | ||
|
||
ENDIF(ANDROID) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SET(TARGET_SRC btcsimple.cpp) | ||
|
||
SET(TARGET_ADDED_LIBRARIES btcWallet) | ||
|
||
SETUP_EXAMPLE(btcsimple) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
#include "btcNode/Node.h" | ||
#include "btcNode/NodeRPC.h" | ||
|
||
#include "btcHTTP/Server.h" | ||
|
||
#include "btcWallet/wallet.h" | ||
#include "btcWallet/walletrpc.h" | ||
|
||
#include <boost/thread.hpp> | ||
|
||
using namespace std; | ||
using namespace boost; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
logfile = CDB::dataDir(bitcoin.dataDirSuffix()) + "/debug.log"; | ||
|
||
Node node; // deafult chain is bitcoin | ||
|
||
Wallet wallet(node); // add the wallet | ||
|
||
thread nodeThread(&Node::run, &node); // run this as a background thread | ||
|
||
Server server; | ||
|
||
// Register Server methods. | ||
server.registerMethod(method_ptr(new Stop(server))); | ||
|
||
// Register Node methods. | ||
server.registerMethod(method_ptr(new GetBlockCount(node))); | ||
server.registerMethod(method_ptr(new GetConnectionCount(node))); | ||
server.registerMethod(method_ptr(new GetDifficulty(node))); | ||
server.registerMethod(method_ptr(new GetInfo(node))); | ||
|
||
// Register Wallet methods. - note that we don't have any auth, so anyone (on localhost) can read your balance! | ||
server.registerMethod(method_ptr(new GetBalance(wallet))); | ||
server.registerMethod(method_ptr(new SendToAddress(wallet)), Auth("username","password")); | ||
|
||
server.run(); | ||
|
||
node.shutdown(); | ||
nodeThread.join(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SET(TARGET_SRC ponzicoin.cpp) | ||
|
||
SET(TARGET_ADDED_LIBRARIES btcWallet btcMine) | ||
|
||
SETUP_EXAMPLE(ponzicoin) |
Oops, something went wrong.