maaku
Legendary
Offline
Activity: 905
Merit: 1011
|
|
December 31, 2011, 11:39:37 PM |
|
I, too, would use and contribute to this project if it were released under a more permissive license (BSD preferably, LGPL if you must). As it stands I cannot even look at this code due to the possibility of legal risk to my company.
|
I'm an independent developer working on bitcoin-core, making my living off community donations. If you like my work, please consider donating yourself: 13snZ4ZyCzaL7358SmgvHGC9AxskqumNxP
|
|
|
|
|
|
|
|
The forum strives to allow free discussion of any ideas. All policies are built around this principle. This doesn't mean you can post garbage, though: posts should actually contain ideas, and these ideas should be argued reasonably.
|
|
|
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
|
|
|
|
genjix (OP)
Legendary
Offline
Activity: 1232
Merit: 1072
|
|
January 08, 2012, 09:30:46 PM |
|
Today we enter a new era with all core components done. But this is not the end. This is the beginning! Everything is still far from finished: https://bitcoinconsultancy.com/wiki/index.php?title=LibbitcoinServices: - blockchain -- bdb_blockchain (berkeley db) -- postgresql_blockchain - network - transaction memory pool Other: - scripting system - full validation of blocks and unconfirmed transactions - all the usual utilities like base58, encryption, hashing Todo (minor things): - wallet - node discovery Headers: include/bitcoin/error.hpp include/bitcoin/address.hpp include/bitcoin/network/channel.hpp include/bitcoin/network/discovery.hpp include/bitcoin/network/handshake.hpp include/bitcoin/network/shared_const_buffer.hpp include/bitcoin/network/network.hpp include/bitcoin/block.hpp include/bitcoin/data_helpers.hpp include/bitcoin/exporter.hpp include/bitcoin/validate.hpp include/bitcoin/constants.hpp include/bitcoin/transaction_pool.hpp include/bitcoin/types.hpp include/bitcoin/messages.hpp include/bitcoin/blockchain/postgresql_blockchain.hpp include/bitcoin/blockchain/organizer.hpp include/bitcoin/blockchain/bdb_blockchain.hpp include/bitcoin/blockchain/blockchain.hpp include/bitcoin/utility/threads.hpp include/bitcoin/utility/elliptic_curve_key.hpp include/bitcoin/utility/assert.hpp include/bitcoin/utility/ripemd.hpp include/bitcoin/utility/logger.hpp include/bitcoin/utility/sha256.hpp include/bitcoin/utility/base58.hpp include/bitcoin/utility/big_number.hpp include/bitcoin/utility/serializer.hpp include/bitcoin/utility/clock.hpp include/bitcoin/script.hpp include/bitcoin/transaction.hpp The benchmark I use for how the API is progressing is the classical poller application which has become much more intuitive and simple yet flexible and powerful since the early days: #include <bitcoin/bitcoin.hpp> using namespace libbitcoin;
using std::placeholders::_1; using std::placeholders::_2;
class pollapp : public threaded_service, public std::enable_shared_from_this<pollapp> { public: pollapp();
void start(std::string hostname, unsigned int port);
private: void handle_connect(const std::error_code& ec, channel_ptr node); void initial_ask_blocks(const std::error_code& ec, const message::block_locator& loc);
void recv_inv(const std::error_code& ec, const message::inventory& packet); void recv_blk(const std::error_code& ec, const message::block& blk);
void handle_store(const std::error_code& ec, block_info info, const hash_digest& block_hash); void ask_blocks(const std::error_code& ec, const message::block_locator& loc, const hash_digest& hash_stop);
network_ptr network_; handshake_ptr handshake_; blockchain_ptr chain_; channel_ptr node_; };
typedef std::shared_ptr<pollapp> pollapp_ptr;
pollapp::pollapp() { network_ = std::make_shared<network>(); handshake_ = std::make_shared<handshake>(); chain_ = std::make_shared<bdb_blockchain>("database/"); }
void pollapp::start(std::string hostname, unsigned int port) { handshake_->connect(network_, "localhost", 8333, std::bind(&pollapp::handle_connect, shared_from_this(), _1, _2)); }
void pollapp::handle_connect(const std::error_code& ec, channel_ptr node) { if (ec) { log_fatal() << ec.message(); return; } node_ = node; chain_->fetch_block_locator( std::bind(&pollapp::initial_ask_blocks, shared_from_this(), _1, _2)); }
void handle_send_packet(const std::error_code& ec) { if (ec) log_error() << ec.message(); }
void pollapp::initial_ask_blocks(const std::error_code& ec, const message::block_locator& loc) { if (ec) { log_fatal() << ec.message(); return; } node_->subscribe_inventory( std::bind(&pollapp::recv_inv, shared_from_this(), _1, _2)); node_->subscribe_block( std::bind(&pollapp::recv_blk, shared_from_this(), _1, _2)); ask_blocks(ec, loc, null_hash); }
void pollapp::recv_inv(const std::error_code& ec, const message::inventory& packet) { if (ec) { log_fatal() << ec.message(); return; } message::get_data getdata; for (const message::inventory_vector& ivv: packet.inventories) { if (ivv.type != message::inventory_type::block) continue; getdata.inventories.push_back(ivv); } node_->send(getdata, handle_send_packet); // Re-subscribe node_->subscribe_inventory( std::bind(&pollapp::recv_inv, shared_from_this(), _1, _2)); }
void pollapp::recv_blk(const std::error_code& ec, const message::block& blk) { if (ec) { log_fatal() << ec.message(); return; } chain_->store(blk, std::bind(&pollapp::handle_store, shared_from_this(), _1, _2, hash_block_header(blk))); // Re-subscribe node_->subscribe_block( std::bind(&pollapp::recv_blk, shared_from_this(), _1, _2)); }
void pollapp::handle_store(const std::error_code& ec, block_info info, const hash_digest& block_hash) { if (ec) { log_fatal() << ec.message(); return; } switch (info.status) { case block_status::orphan: chain_->fetch_block_locator( std::bind(&pollapp::ask_blocks, shared_from_this(), _1, _2, block_hash)); break;
case block_status::rejected: log_error() << "Rejected block " << pretty_hex(block_hash); break;
case block_status::confirmed: log_debug() << "block #" << info.depth; break; } }
void pollapp::ask_blocks(const std::error_code& ec, const message::block_locator& loc, const hash_digest& hash_stop) { if (ec) { log_fatal() << ec.message(); return; } message::get_blocks packet; packet.locator_start_hashes = loc; packet.hash_stop = hash_stop; node_->send(packet, std::bind(&handle_send_packet, _1)); }
int main(int argc, const char** argv) { bdb_blockchain::setup("database/");
pollapp_ptr app = std::make_shared<pollapp>(); app->start("localhost", 8333); // Wait for CTRL-D while (true) { char n; std::cin >> n; if (std::cin.eof()) break; } return 0; }
|
|
|
|
fellowtraveler
|
|
January 09, 2012, 10:50:10 AM |
|
Can you please post a code sample of how to perform multi-sign transactions on the blockchain using your library.
This is a necessary piece for me.
|
|
|
|
genjix (OP)
Legendary
Offline
Activity: 1232
Merit: 1072
|
|
January 09, 2012, 12:00:25 PM |
|
Can you please post a code sample of how to perform multi-sign transactions on the blockchain using your library.
This is a necessary piece for me.
Multi-signature transactions are restricted by IsStandard() right now, so you won't be able to use them until 15th Feb. They will be available then. https://en.bitcoin.it/wiki/BIP_0016On February 1, 2012, the block-chain will be examined to determine the number of blocks supporting pay-to-script-hash for the previous 7 days. If 550 or more contain "/P2SH/" in their coinbase, then all blocks with timestamps after 15 Feb 2012, 00:00:00 GMT shall have their pay-to-script-hash transactions fully validated. Approximately 1,000 blocks are created in a week; 550 should, therefore, be approximately 55% of the network supporting the new feature.
If a majority of hashing power does not support the new validation rules, then rollout will be postponed (or rejected if it becomes clear that a majority will never be achieved).
|
|
|
|
fellowtraveler
|
|
January 10, 2012, 03:13:04 PM |
|
1. I'm sure there are mining groups now who would accept certain more exotic transaction types.
2. Even if multi-sign isn't accepted yet, I still need to get started on my code, so I still need to see a code sample using your library (preferably.) It will be months before this stuff is fully ready, IMO.
3. Once low-trust servers are popping up to take advantage of such code, I can almost guarantee you there will be a sea change in the Bitcoin community as various miners, exchanges, et al jump on board.
Need sample code!
------------------------
|
|
|
|
genjix (OP)
Legendary
Offline
Activity: 1232
Merit: 1072
|
|
February 01, 2012, 10:49:41 PM |
|
OK, I'm getting ready to finalise a 1.0 release by the end of this month (Feb).
License will now be Lesser AGPL. You can link and use libbitcoin in your closed source project, but the changes you make to libbitcoin must be public. I will give explicit permission through email to people 'myusername'@riseup.net (signed with my GPG key) if you want to be sure.
Will be heavily documenting and writing tutorials soon.
On the development front: - I have written a blockchain fuzzer which I will use to stress test the blockchain algorithm. - Node discovery needs to be completed (should be easy- the tricky part is designing a good API). - A high level synchronous interface for easy programming and integration of bitcoin in your project. This might not make it to 1.0 release. fellowtraveler, this is what you're asking for.
Right now the project is still rough around the edges, but it is rapidly approaching production capability in a rough way. We will have to smooth out some things while using it and the API may change a lot early on. I will also be making a test client as a proof of concept in order to perfect the API better.
libbitcoin requires advanced C++ knowledge (for now). It is heavily built around asynchronous interfaces and the library is thread safe. An understanding of thread contexts is required but I'll document this in the tutorials.
|
|
|
|
btc_artist
Full Member
Offline
Activity: 154
Merit: 101
Bitcoin!
|
|
February 01, 2012, 11:23:04 PM |
|
License will now be Lesser AGPL.
You mean the Lesser GPL (LGPL) license, right? http://www.gnu.org/licenses/lgpl.html To my (very limited) knowledge, a Lesser AGPL license doesn't exist.
|
BTC: 1CDCLDBHbAzHyYUkk1wYHPYmrtDZNhk8zf LTC: LMS7SqZJnqzxo76iDSEua33WCyYZdjaQoE
|
|
|
Red Emerald
|
|
February 02, 2012, 02:01:42 AM |
|
Keep up the great work.
Reading through this is much easier than trying to read through the Satoshi client although there aren't too many comments (yet (hopefully)).
|
|
|
|
genjix (OP)
Legendary
Offline
Activity: 1232
Merit: 1072
|
|
February 02, 2012, 03:24:34 AM |
|
Red Emerald: As the codebase matures I'll start adding a ton of comments. The thing I hate more than uncommented code is out of date comments. License will now be Lesser AGPL.
You mean the Lesser GPL (LGPL) license, right? http://www.gnu.org/licenses/lgpl.html To my (very limited) knowledge, a Lesser AGPL license doesn't exist. I'm collaborating with the SFLC/FSF to sort that out. They resolved a bunch of licensing issues for me already. First tutorial (of many) is written. Just a high level overview. Next one should have some code, and then we'll go back and break everything down as we go along. [libbitcoin] Overviewlibbitcoin is a bitcoin library targeted towards high end use. The library places a heavy focus around asychronicity. The enables a big scope for future scalability as each component has its own thread pool. By increasing the number of threads for that component the library is able to scale outwards across CPU cores. This will be vital in the future as the demands of the bitcoin network grow. I tried to explain the design principles behind libbitcoin and why things are done how they are.
|
|
|
|
btc_artist
Full Member
Offline
Activity: 154
Merit: 101
Bitcoin!
|
|
February 02, 2012, 04:28:06 AM |
|
Good deal.
|
BTC: 1CDCLDBHbAzHyYUkk1wYHPYmrtDZNhk8zf LTC: LMS7SqZJnqzxo76iDSEua33WCyYZdjaQoE
|
|
|
LightRider
Legendary
Offline
Activity: 1500
Merit: 1021
I advocate the Zeitgeist Movement & Venus Project.
|
|
February 02, 2012, 08:55:12 AM |
|
Well done! Looking forward to a richer bitcoin ecosystem.
|
|
|
|
|
genjix (OP)
Legendary
Offline
Activity: 1232
Merit: 1072
|
|
February 04, 2012, 04:07:49 PM Last edit: February 04, 2012, 06:51:45 PM by genjix |
|
Python bindings + tutorials are going to be released later this week: import bitcoin import time
class Application:
def __init__(self): self.stopped = False self.net = bitcoin.network() self.channel = None
def start(self): self.net.connect("localhost", 8333, self.handle_connect)
def stop(self): self.stopped = True
def is_stopped(self): return self.stopped
def create_version_message(self): vers = bitcoin.version() vers.version = 60000 vers.services = 1 vers.address_me.servies = 1 vers.address_me.ip = \ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1] vers.address_me.port = 8333 vers.address_you.services = 1 vers.address_you.ip = \ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1] vers.address_you.port = 8333 vers.user_agent = "/libbitcoin:0.4/example:1/"; vers.start_height = 0 vers.nonce = 42 return vers
# First we send our version message then the node will reply back def handle_connect(self, ec, channel): # check the error_code if ec: print 'Could not connect:', ec self.stop() return self.channel = channel version_message = self.create_version_message() self.channel.send_version(version_message, self.handle_send) self.channel.subscribe_version(self.read_version_reply)
def handle_send(self, ec): if ec: print 'Problem sending:', ec self.stop()
def read_version_reply(self, ec, vers): if ec: print 'Problem in reply:', ec self.stop() return # Display the version message back print vers.address_me.ip self.stop()
if __name__ == "__main__": app = Application() app.start() while not app.is_stopped(): time.sleep(0.1)
Some more stuff (crappy/hackish testing files): import bitcoin
d = bitcoin.data_chunk("001212") print d h = bitcoin.hash_digest("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f") print h if h == "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f": print 'Yes' print len(h)
tx = bitcoin.transaction() print bitcoin.hash_transaction(tx)
netaddr = bitcoin.network_address() print netaddr.ip
s = bitcoin.script() o = bitcoin.operation() o.code = bitcoin.opcode.special s.push_operation(o) o.code = bitcoin.opcode.nop o.data = bitcoin.data_chunk("deadbeef") s.push_operation(o) o = bitcoin.operation() o.code = bitcoin.opcode.hash160 s.push_operation(o) print s print s.operations() print s.type()
import bitcoin
raw_tx_repr = "010000000187493c4c15c76df9f69ddd7aeb7ffbcddad4b7a979210f19602282d5b9862581000000008a47304402202d9e9f75be9c8a4c4304931b032e1de83fd2c6af2c1154a3d2b885efd5c3bfda02201184139215fb74499eae9c71ae86354c41b4d20b95a6b1fffcb8f1c5f051288101410497d11f5c33adb7c3fed0adc637358279de04f72851b7b93fb4a8655613729047c7e2908966551b5fb7f6899f6c3dd358b57eb20a61b2c9909aa106eac6310f9fffffffff0140420f00000000001976a91407e761706c63b36e5a328fab1d94e9397f40704d88b000000000" raw_tx = bitcoin.data_chunk(raw_tx_repr) print raw_tx print len(raw_tx)
ex = bitcoin.satoshi_exporter() tx = ex.load_transaction(raw_tx) print "txhash", bitcoin.hash_transaction(tx) print tx print ex.save_transaction(tx) print len(ex.save_transaction(tx)) assert str(ex.save_transaction(tx)) == raw_tx_repr import bitcoin
ec = bitcoin.elliptic_curve_key() print ec.new_key_pair() privdat = ec.private_key() print privdat
ec1 = bitcoin.elliptic_curve_key() ec1.set_private_key(privdat) assert str(ec1.private_key()) == str(privdat)
h = bitcoin.hash_digest("f003f0c1193019db2497a675fd05d9f2edddf9b67c59e677c48d3dbd4ed5f00b") print h sig = ec1.sign(h) print ec.verify(h, sig)
|
|
|
|
genjix (OP)
Legendary
Offline
Activity: 1232
Merit: 1072
|
|
February 05, 2012, 08:47:45 PM |
|
libbitcoin is licensed as Lesser AGPL: - When used in the p2p network, you only need to provide changes on demand (LGPL). - When used on a webserver, you must proactively provide sourcecode for any changes you have made to libbitcoin. - Applications can link against libbitcoin, and they do not need to release their changes publically. Thanks to Aaron Williamson of the SFLC and Richard Stallman of the FSF for helping draft up this license.
|
|
|
|
genjix (OP)
Legendary
Offline
Activity: 1232
Merit: 1072
|
|
February 06, 2012, 02:55:42 PM |
|
[libbitcoin] First stepsThis tutorial will create a simple program in Python using libbitcoin’s Python bindings to read the version information of a remote bitcoin node. We will need to connect to the bitcoin node and send it a version packet. The other bitcoin node should respond back with their own version packet which we can examine.
|
|
|
|
Dusty
|
|
February 15, 2012, 02:09:05 PM Last edit: February 17, 2012, 07:37:27 AM by Dusty |
|
Is there a (even not so) simple way to use this library to dump the raw bytes of a transaction or even a full block?
I.e: something like example #3 of the post above, but in reverse: give the program the hash of a tx so he can get it from the network or the db, and dump it to stdout.
Thanks for any help
|
|
|
|
|
genjix (OP)
Legendary
Offline
Activity: 1232
Merit: 1072
|
|
February 17, 2012, 04:17:43 AM |
|
So I'm running debian 6.0.4 (squeeze) and trying to get this installed for a small project. I'm just going to install it on an ubuntu system instead, but figured I would post my error log anyway. http://pastie.org/private/3jnuenhclxaf4f90wpbyfw https://bitcoinconsultancy.com/wiki/Build_libbitcoinYour g++ is outdated. @znort, try google-protobuf or something. And dont use the boost headers in ubuntu... they are missing async_connect function. Use 1.48 from boostr website as per instructions above. @Dusty, sure. Use the network component to connect to a bitcoin node, then fashion a get_data packet. Send it to the node and subscribe to either transactions or blocks. Then once you received the block and/or tx, create an exporter object to serialise them and print the bytes to the screen. Hopefully I can get this next tutorial out soon, and it will clarify some points for you. Just been very busy this week with exchange stuff :/ Constantly stressed for time
|
|
|
|
Red Emerald
|
|
February 17, 2012, 07:36:51 AM |
|
Yeah I noticed your requirements have higher requirements for libboost and g++. I needed to upgrade my ubuntu server anyways, so I'm building it on there now. Installing boost is sure taking a while.
|
|
|
|
Red Emerald
|
|
February 17, 2012, 07:01:20 PM Last edit: February 17, 2012, 07:16:52 PM by Red Emerald |
|
Add these 2 lines to the end of your /etc/apt/sources.list deb http://ppa.launchpad.net/zgenjix/libbitcoin/ubuntu oneiric main deb-src http://ppa.launchpad.net/zgenjix/libbitcoin/ubuntu oneiric main I think this should be " http://ppa.launchpad.net/genjix" without a "z" I also added it to "/etc/apt/sources.list.d/libbitcoin.list" instead of "/etc/apt/sources.list" Now lets see if I can get the python bindings built [user@silo python-bitcoin]$ make mkdir -p bitcoin g++ -fPIC -Wall -ansi `pkg-config --cflags libbitcoin` -I/usr/include/python2.7 -c main.cpp -o main.o In file included from /home/user/usr/include/bitcoin/exporter.hpp:7:0, from /home/user/usr/include/bitcoin/network/channel.hpp:17, from /home/user/usr/include/bitcoin/bitcoin.hpp:8, from main.cpp:4: /home/user/usr/include/bitcoin/constants.hpp:37:75: warning: missing braces around initializer for ‘std::array<unsigned char, 32ul>::value_type [32] {aka unsigned char [32]}’ [-Wmissing-braces] /home/user/usr/include/bitcoin/constants.hpp:39:62: warning: missing braces around initializer for ‘std::array<unsigned char, 20ul>::value_type [20] {aka unsigned char [20]}’ [-Wmissing-braces] main.cpp: In member function ‘void handshake_wrapper::start(boost::python::api::object)’: main.cpp:288:61: error: no matching function for call to ‘libbitcoin::handshake::start(pyfunction<const std::error_code&>)’ main.cpp:288:61: note: candidate is: /home/user/usr/include/bitcoin/network/handshake.hpp:31:10: note: void libbitcoin::handshake::start(libbitcoin::channel_ptr, libbitcoin::handshake::handshake_handler) /home/user/usr/include/bitcoin/network/handshake.hpp:31:10: note: candidate expects 2 arguments, 1 provided main.cpp: In member function ‘void handshake_wrapper::ready(channel_wrapper, boost::python::api::object)’: main.cpp:299:14: error: ‘class libbitcoin::handshake’ has no member named ‘ready’ /home/user/usr/include/boost/system/error_code.hpp: At global scope: /home/user/usr/include/boost/system/error_code.hpp:214:35: warning: ‘boost::system::posix_category’ defined but not used [-Wunused-variable] /home/user/usr/include/boost/system/error_code.hpp:215:35: warning: ‘boost::system::errno_ecat’ defined but not used [-Wunused-variable] /home/user/usr/include/boost/system/error_code.hpp:216:35: warning: ‘boost::system::native_ecat’ defined but not used [-Wunused-variable] /home/user/usr/include/boost/asio/error.hpp:244:45: warning: ‘boost::asio::error::system_category’ defined but not used [-Wunused-variable] /home/user/usr/include/boost/asio/error.hpp:246:45: warning: ‘boost::asio::error::netdb_category’ defined but not used [-Wunused-variable] /home/user/usr/include/boost/asio/error.hpp:248:45: warning: ‘boost::asio::error::addrinfo_category’ defined but not used [-Wunused-variable] /home/user/usr/include/boost/asio/error.hpp:250:45: warning: ‘boost::asio::error::misc_category’ defined but not used [-Wunused-variable] make: *** [default] Error 1
|
|
|
|
|