Bitcoin Forum
November 01, 2024, 07:31:33 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Poll
Question: Should I use Idiegogo.com or Rockethub.com for donations?
Idiegogo.com - 2 (40%)
Rockethub.com - 3 (60%)
Total Voters: 5

Pages: « 1 2 3 4 5 6 [7] 8 »  All
  Print  
Author Topic: [ANN] cbitcoin 2.0 - A Bitcoin Library in C  (Read 17212 times)
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
February 19, 2013, 08:59:23 PM
 #121

I've almost decided now to continue using GPLv3 but with an exception for OpenSSL and another exception allowing for distribution of binary forms without the source code (thought the GPL does allow for these exceptions to be removed when conveying copies).

And my mind is settled on using a copy-left license. Sorry for all those that do not like copy-left.

I'm currently working upon an "accounter", which is code that looks for transactions with particular output scripts and can thus keep track of transactions and balances for bitcoin addresses or whatever type of output. It also keeps track of unspent outputs. Bizarrely this is more awkward than I thought it would be. This code does not manage private keys.

I will be looking at modifying the database code to store the index on disk, to prevent high memory usage, and looking to cache certain pieces of data. At the moment the entire index is loaded to memory.

Why not just use a BSD license if you're going to take the teeth out of the GPL?

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
onelineproof
Member
**
Offline Offline

Activity: 100
Merit: 16


View Profile WWW
March 11, 2013, 07:35:46 AM
 #122

Hi, not sure if it's useful, but I created lightweight bitcoin wallet tool called cwallet, implemented in C: https://github.com/piratelinux/cwallet

It's good for reading the address and private key pairs in a wallet, as well as creating a paper wallet with QR codes. There's a CLI version and a GUI version.

I recently did some hacking around and added a feature that let's you see the address associated with a brainwallet as well as try to "hack" the password of an address generated by a brainwallet. I still didn't add this into the repo yet. I also plan to have a feature that lets you check the balance associated with an address by querying the Bitcoin network.

The uncorrupted Bitmark protocol: https://github.com/bitmark-protocol/bitmark
Email <my username>@gmail.com 0xB6AC822C451D63046A2849E97DB7011CD53B564
paulie_w
Sr. Member
****
Offline Offline

Activity: 420
Merit: 250


View Profile
March 13, 2013, 10:03:56 AM
 #123

so how did this one handle the recent fork situation? :-)
rlh
Hero Member
*****
Offline Offline

Activity: 804
Merit: 1004


View Profile
August 23, 2013, 04:59:38 PM
 #124

What's the story on this project?  Any further momentum?

A Personal Quote on BTT from 2011:
"I'd be willing to make a moderate "investment" if the value of the BTC went below $2.00.  Otherwise I'll just have to live with my 5 BTC and be happy. :/"  ...sigh.  If only I knew.
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
August 23, 2013, 05:25:11 PM
 #125

Hi. I was busy for quite a few months earlier in the year, but I'm now able to put more work towards this.

The most up-to-date branch is this one: https://github.com/MatthewLM/cbitcoin/tree/accountingAndNodes

I've finished the accounting code now which keeps track of balances, transactions and unspent outputs for "accounts". These accounts are calculated with a list of watched outputs, so you can watch bitcoin addresses for wallets or whatever, and store the account information. It was designed so that you could have multiple accounts.

Now I'm working on finishing off the node code (both full validation and SPV). Progress has not been so bad for that. I'm currently working on producing features for the protocol version 60000, but other things such as the bloom filtering can come later.
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1081


I may write code in exchange for bitcoins.


View Profile
August 24, 2013, 03:07:54 AM
 #126

Thanks for this, I may just try it out!  I didn't see what kind of licensing in your OP?  Is it GPL?
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
August 24, 2013, 12:54:10 PM
 #127

Hi, the license for the most up-to-date code is the GPLv3 with additional permissions and can be found here: http://cbitcoin.com/license.html and here: https://github.com/MatthewLM/cbitcoin/blob/accountingAndNodes/LICENSE

I'll make sure to add it to the OP.
rlh
Hero Member
*****
Offline Offline

Activity: 804
Merit: 1004


View Profile
September 04, 2013, 03:46:20 PM
 #128

I have this in my Watchlist, but somehow I've missed the additional discussion.  Thanks for the update.  I'll be keeping my eye on this project once it near, fully implemented.

A Personal Quote on BTT from 2011:
"I'd be willing to make a moderate "investment" if the value of the BTC went below $2.00.  Otherwise I'll just have to live with my 5 BTC and be happy. :/"  ...sigh.  If only I knew.
hivewallet
Sr. Member
****
Offline Offline

Activity: 378
Merit: 325


hivewallet.com


View Profile WWW
October 08, 2013, 09:38:37 AM
 #129

Wow, nice work. This could be great for embedded devices!

Hive, a beautiful, secure wallet with an app platform for Mac OS X, Android and Mobile Web. Translators wanted! iOS and OS X devs see BitcoinKit.
Tweets @hivewallet. Skype us here. Donations appreciated at 1HLRg9C1GsfEVH555hgcjzDeas14jen2Cn
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
October 08, 2013, 02:15:30 PM
 #130

Thanks. The library may be useful for embedded devices, though there will need to be at least a partial implementation of the C standard library, and to use all of the features you will to implement things like the cryptography, threading and network functions. At the moment cbitcoin has a core library which is in C99 only, and it has separated libraries which use POSIX libraries, libevent and OpenSSL. These separated libraries can be replaced by alternative code or ignored if they are not needed. So for instance if you want to use cbitcoin but don't want networking, the networking functions do not need to be implemented and thus there is no need to link to libevent.
hivewallet
Sr. Member
****
Offline Offline

Activity: 378
Merit: 325


hivewallet.com


View Profile WWW
December 11, 2013, 08:39:40 PM
 #131

cbitcoin now has a fully validating node implementation. There is still much work to do. There are a lot of memory leaks that have not been resolved yet for a start.

Once again, thanks to people who have donated. The donations are now worth a good amount of money. I'm still open for more bitcoin donations (1D5A1q5d192j5gYuWiP3CSE5fcaaZxe6E9), and I would be happy to receive any offers for code contribution.

I haven't implemented a headers-only node as of yet. Before I do that I will like to test cbitcoin over the real bitcoin network by implementing a basic client. Now that should not be too difficult (I hope) since I can extend an interface on-top of the node software.

Wow Matthew, congratulations! That's a massive achievement!

Hive, a beautiful, secure wallet with an app platform for Mac OS X, Android and Mobile Web. Translators wanted! iOS and OS X devs see BitcoinKit.
Tweets @hivewallet. Skype us here. Donations appreciated at 1HLRg9C1GsfEVH555hgcjzDeas14jen2Cn
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
December 11, 2013, 08:45:20 PM
 #132

Thanks. I've not actually tested it running on the bitcoin network yet so let's hope it goes smoothly!  Smiley
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
January 18, 2014, 07:18:10 PM
 #133

I've fixed the address generation example and also added a (basic) generator for all upper-case and digit addresses such as this one I just generated: 17BK2E43VFA57KE6X5GQUAH12ECE7WL227.

cbitcoin now supports HD keys (BIP0032), it can properly construct and sign transactions of the standard types, various other things have been improved and there is a client on the way.
linuxdoctor
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
February 11, 2014, 03:53:44 AM
 #134

cbitcoin now has a fully validating node implementation. There is still much work to do. There are a lot of memory leaks that have not been resolved yet for a start.

Yes, I've found one. This is from dependencies/random/CBRand.c:

Code:
bool CBGet32RandomBytes(uint8_t * bytes){
FILE * f = fopen("/dev/random", "r");
return fread(bytes, 1, 32, f) == 32;
}

I'm looking at the cbitcoin library for my own edification and possibly integrating it into something. I'm new to bitcoin in general and before I begin to use it (if I decide to use it) I want to know everything I can about it. Reading the code of various implementations of different parts of bitcoin (servers, miners, clients, etc.) has been an education.

Anyway, in looking at this file (quite by accident incidentally) I discovered that you did not close the file after reading from it. Which means every time you get some RandomBytes you will use a new file descriptor. This will leak a lot of memory and waste file descriptors to boot. It becomes a race between running out of memory or running out of file descriptors.
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
February 11, 2014, 02:31:51 PM
 #135

Thank you linuxdoctor. I've added a fix and it will be available in the next commit. If you want to know anything about the library make sure to get in touch.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 11, 2014, 02:36:25 PM
 #136

It becomes a race between running out of memory or running out of file descriptors.

Typically the # of file descriptors is quite small compared to available memory so I'd think the latter would be the main problem but still a memory leak nonetheless.

Glad to see this project is still going (has been a while since I'd followed this topic).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
linuxdoctor
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 22, 2014, 02:16:39 AM
 #137

I've been away doing other projects but spent a few hours playing with cbitcoin this evening and found a few more bugs and possible solutions. I've compiled some unified diffs. The diffs are between the current git repository  and a fork (named cbitcoin-2014-03-21).

1. Function CBNewBlockChainStorage() crashes when trying to free self->database which is never initialized at this point. At this point, the function is doing cleanup on an error but should just free self since everything before it has already been freed.
Code:
--- ./library/dependencies/storage/CBBlockChainStorage.c        2014-03-21 19:53:02.744321264 -0400
+++ ../cbitcoin-2014-03-21/./library/dependencies/storage/CBBlockChainStorage.c 2014-03-21 01:17:12.000000000 -0400
@@ -38,7 +38,7 @@
                CBFreeIndex(self->blockHashIndex);
        }
        CBLogError("Could not load one of the block chain storage indices.");
-       CBFreeDatabase(self->database);
+       free(self);
        return false;
 }
 void CBFreeBlockChainStorage(CBDepObject self){

2. Function CBOnUpToDate is never declared (nor do I know how to use it) nor is CBCallBacks callbacks initialized to point to it. This then  crashes cbitcoin example server whenever some routine tries to access callbacks->updatetodate. Simple fix.
Code:
--- ./client-server/src/main.c  2014-03-21 19:53:02.738321373 -0400
+++ ../cbitcoin-2014-03-21/./client-server/src/main.c   2014-03-21 18:36:45.608202593 -0400
@@ -66,6 +66,9 @@
 void CBOnTransactionUnconfirmed(CBNode * node, uint8_t * txHash){
        
 }
+void CBOnUpToDate(CBNode * node, bool truefalse){
+
+}
 CBNetworkAddress * CBReadNetworkAddress(char * ipStr, bool isPublic){
        CBSocketAddress saddr = {NULL, 8333};
        char * portStart;
@@ -286,7 +289,8 @@
                CBOnNewTransaction,
                CBOnTransactionConfirmed,
                CBOnDoubleSpend,
-               CBOnTransactionUnconfirmed
+               CBOnTransactionUnconfirmed,
+               CBOnUpToDate
        };
        CBNodeFull * node = CBNewNodeFull(database, nodeFlags, otherTxsSizeLimit, callbacks);
        if (!node) {

3. This is a tricky one. in CBEcdsaVerify() if o2i_ECPublicKey() fails it writes a NULL into key which EC_KEY then tries to free. Result: crash. This is a work around which creates two copies of the new EC_KEY. If key gets stomped on then we can free the copy in eckey. Interestingly, ECDSA_verify harmlessly passes over any NULL value in key (although I wouldn't count on any future version doing so).
Code:
--- ./library/dependencies/crypto/CBOpenSSLCrypto.c     2014-03-21 19:53:02.741321318 -0400
+++ ../cbitcoin-2014-03-21/./library/dependencies/crypto/CBOpenSSLCrypto.c      2014-03-21 19:44:44.181601752 -0400
@@ -84,9 +84,13 @@
        RIPEMD160(data, len, output);
 }
 bool CBEcdsaVerify(uint8_t * signature, uint8_t sigLen, uint8_t * hash, uint8_t * pubKey, uint8_t keyLen){
-       EC_KEY * key = EC_KEY_new_by_curve_name(NID_secp256k1);
+       EC_KEY *eckey, * key;
+       int res = 0;
+
+       eckey = key = EC_KEY_new_by_curve_name(NID_secp256k1);
        o2i_ECPublicKey(&key, (const unsigned char **)&pubKey, keyLen);
-       int res = ECDSA_verify(0, hash, 32, signature, sigLen, key);
-       EC_KEY_free(key);
+       if ( key != NULL )
+               res = ECDSA_verify(0, hash, 32, signature, sigLen, key);
+       EC_KEY_free(eckey);
        return res == 1;
 }
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
March 23, 2014, 04:12:30 PM
 #138

Thanks very much linuxdoctor. I've added your fixes, except for the second one which is not included in my latest source code. There are several bugs I'm working on at once, I'll hopefully push them to github later or sometime soon.
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
March 29, 2014, 01:33:11 PM
 #139

You can now donate via Paypal or Charitycoin:

Paypal: Click here!

Charitycoin: CSU54ZAa4VuhiVwzgyAudePmn7eJigkKU5
MatthewLM (OP)
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
June 04, 2014, 02:02:23 PM
 #140

cbitcoin is now using the MIT license.
Pages: « 1 2 3 4 5 6 [7] 8 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!