Coder Social home page Coder Social logo

cbitcoin's Introduction

cbitcoin 2.0 - A Bitcoin Library In The C Programming Language

cbitcoin is a bitcoin library written in standard C99 and is licensed under the GPLv3 with additional permissions. It is currently in development stage and should only be used experimentally. The purpose of the library is to make it easier for developers to create bitcoin applications and the library should be versatile enough to be used in many bitcoin projects.

The features include:

  • Bitcoin message structures including serialisation and deserialisation functions.
  • A bitcoin script interpreter.
  • Functions used for validation of POW, merkle trees, transactions etc.
  • Automated bitcoin handshakes, peer discovery and pings.
  • A network address manager.
  • Network seeding, including DNS.
  • Both full and headers only validation.
  • Transaction accounting.
  • A fully validating node.
  • Base-58 encoding/decoding.
  • Bitcoin address/WIF functions.
  • Hierarchical Deterministic keys (BIP0032)
  • Doxygen documentation and well-documented source code.
  • Dependencies can easily be swapped and changed by implementing weakly linked functions.
  • Implementations included that require libevent/libev, OpenSSL and POSIX.
  • Very fast compilation. Much faster than the Satoshi client.
  • Client implementing bitcoin RPC protocol (Incomplete)
  • SPV validation (Planned)
  • SPV node (Planned)
  • Altcoin support (Planned)

If you wish to contact the project leader, Matthew Mitchell, about this project please email [email protected]

Installation

To build, type into your terminal:

./configure
make

If you wish to test the library then type:

make test

You can install individual tests such as make bin/testCBAccounter.

The configure script has the following additonal options:

  • --disable-ec cbitcoin produces two libraries, one for ordinary file IO and another for file IO with error correction. Both are built, but using this option means that the tests (except for testCBFile and testCBHamming72) and the cbitcoin client are linked without EC.
  • --enable-debug for debug builds, using -g instead of -O3.
  • --disable-werror disables the -Werror flag.
  • --disable-stack-protector disables stack protection in the form of -fstack-protector-strong or -fstack-protector-all if strong is not available.

You can also change CFLAGS, LFLAGS and CC before running ./configure to make changes to how cbitcoin is built.

The library will be built into a ./bin directory.

If you are able to get it to work for other systems then please submit the changes. If you think you have found a debug, then you may wish to submit an issue on the gitbub repository page (https://github.com/MatthewLM/cbitcoin/). Otherwise you may wish to try to fix the problem yourself, in which case please submit fixes. You should check to see that the issue is not being worked upon already.

Donations

If you wish to support this project you can donate via the following methods:

Bitcoin: 1D5A1q5d192j5gYuWiP3CSE5fcaaZxe6E9
Charitycoin: CSU54ZAa4VuhiVwzgyAudePmn7eJigkKU5
Paypal: Click here to donate

Contributors

The following list is for all people that have contributed work that has been accepted into cbitcoin. Please consider making your own contribution to be added to the list.

Matthew Mitchell [email protected] - 1D5A1q5d192j5gYuWiP3CSE5fcaaZxe6E9
Christian von Roques
Andrew Miller [email protected] linuxdoctor - 1KB3RsW8H7TFV9awpt6MiXsjDqLD15oax3

Making a Contribution

If you wish to contibute feedback please email Matthew Mitchell at [email protected].

If you wish to contribute code:

  1. Fork the project on github: https://github.com/MatthewLM/cbitcoin
  2. Decide how you'd wish to contribute. You can search for occurances of "???" in the sourcecode. Each time you see comment with "???" it will describe any issues or potential improvements that can be made to the code. Look at the issues on the github repository page and you may find something that you can do from there.
  3. Submit what you intend to do on the github repository page as an issue.
  4. Implement your changes.
  5. Document the changes if possible (See "Documenting" below)
  6. Make a pull request.
  7. Send an email to [email protected] notifying that a request has been made.
  8. The changes will be pulled once approved.

Easy! Please email Matthew Mitchell ([email protected]) if you have any queries.

Coding Guidelines

  • cbitcoin uses an object-orientated approach by implementing reference counting and inheritance on structures. New code should be consistent with this approach. Use the supplied structure_maker.py to make a new structure which inherits CBObject. All structures inheriting CBObject should go into the structures directory as shown. message_maker.py is similar to structure_maker but is for CBMessage structures.
  • The rule for memory management is to retain an object before returning it, to retain an object when giving it to another object, and to release an object once the object is no longer needed by an object or function. When a new object is created it should be retained. There are some exceptions to the rules, such as functions which take a reference from the caller.
  • Filenames should begin with CB.
  • Functions, types and variables with linker visibility outside the library should begin with CB.
  • CamelCase should be used. lowerCamelCase should be used for structure fields and variables except where inappropriate.
  • Constants should be ALL_UPPERCASE_WITH_UNDERSCORES.
  • Constants made visible throughout the library should go in CBConstants.h
  • CBGet functions should be preferred over type-casting.
  • Use comments where appropriate, especially in obscure sections.
  • In structure files, please order functions under "// Functions" alphabetically.
  • Use "???" in comments for areas of confusion or uncertainty where the code may need improving or changed. Look for "???" to find parts in the code that may need work.

Documenting

cbitcoin should contain the following header for each file:

//
//  CBFileName
//  cbitcoin
//
//  Created by Full Name on DD/MM/YYYY.
//  Copyright (c) 2012 Matthew Mitchell
//
//  This file is part of cbitcoin.
//
//  cbitcoin is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//  
//  cbitcoin is distributed in the hope that it will be useful, 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with cbitcoin.  If not, see <http://www.gnu.org/licenses/>.
//
//  Additional Permissions under GNU GPL version 3 section 7
//
//  Notwithstanding the terms of the license, when you distribute
//  a covered work in non-source form, you are not required to provide
//  source code corresponding to the covered work.
//
//  If you modify this Program, or any covered work, by linking or
//  combining it with OpenSSL (or a modified version of that library),
//  containing parts covered by the terms of the OpenSSL License, the
//  licensors of this Program grant you additional permission to convey
//  the resulting work.

Header files should contain information for documentation. cbitcoin uses a Doxygen syntax (See http://www.stack.nl/~dimitri/doxygen/manual.html). Please document all files as well as structures and functions that are exposed by the library. Brief descriptions should be included. Details can be added at a later date, especially once code has been properly implemented. Files should be documented like this:

/**
 @file
 @brief Brief description of file.
 @details More in depth description of file.
 */

Structures should be documented like this:

/**
 @brief Brief decription of structure.
 */
typedef struct {
	int someInt; /**< Description of data field. */
} CBSomeStruct;

Functions should be documented like this:

/**
 @brief Brief decription of function.
 @param someParam Brief decription of the function parameter.
 @returns What the function returns.
 */
int CBSomeFunc(int someParam);

It may be that other elements are documented and should be documented in a similar fashion and please leave helpful comments in the source code. Type "???" if you wish to provide any details that should be brought forward to other contributors.

Thank You!

cbitcoin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cbitcoin's Issues

Extracting CBScript from CBAddress

Is there a way to go from an CBAddress (derived from a human readable string) to a CBScript? I have this code so far, but it is seg faulting:

CBAddress * address = CBNewAddressFromString(CBNewByteArrayFromString(addressString, true), false);
// extract script from address, get uint8_t * 20 byte ripemd 160 bit hash (equal to address without checksum bytes)?
uint8_t* addrraw = CBByteArrayGetData(CBGetByteArray(address));
CBFreeAddress(address);


CBScript * self;
CBInitScriptPubKeyHashOutput(self,addrraw);

By the way, great library!

Issues building on OS X

I was able to compile successfully on OS X but ran into some issues, so thought I would document them here.

First, I installed libcrypto and libevent using homebrew:

brew install openssl
brew install libevent

Which installs to /usr/local

Here's how I configure and make:

CC=/usr/bin/gcc LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include" ./configure
CC=/usr/bin/gcc LFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include" make

Note: the second command requires LFLAGS instead of LDFLAGS, otherwise it fails here:

/usr/bin/gcc -L/opt/local/lib -L/usr/local/ssl/lib   -flat_namespace -dynamiclib -undefined dynamic_lookup -install_name @executable_path/libcbitcoin-network.2.0.dylib -o bin/libcbitcoin-network.2.0.dylib build/CBLibEventSockets.o build/CBCallbackQueue.o -levent_core

since the paths are hardcoded to /opt/local in the ./configure script, but my libraries reside in /usr/local and the ./configure script only looks in LDFLAGS, not LFLAGS, to test for the existence of libevent.

CONFIGFLAGS="-Wall -Wextra -Wno-uninitialized -Wno-pointer-to-int-cast -pedantic -std=gnu99 -D_GNU_SOURCE -I/opt/local/ssl/include -I/opt/local/include -I/usr/local/ssl/include"
CONFIGFLAGS+=" $CFLAGS"
CONFIGLFLAGS=" $LFLAGS"

I'm not very familiar with autoconf... but I suppose I could also edit the CONFIGFLAGS in configure.ac. Can I also add $LDFLAGS in addition to $LFLAGS? What's the difference?

After getting past setting correct lib and include paths, I failed here:

/usr/bin/gcc  build/CBRPCServer.o  build/asprintf.o  build/main.o -L/Users/Donald/Development/Repositories/cbitcoin/bin -Wl,-rpath=/Users/Donald/Development/Repositories/cbitcoin/bin -lcbitcoin.2.0 -lcbitcoin-network.2.0 -lcbitcoin-storage.2.0 -lcbitcoin-threads.2.0 -lpthread -lcbitcoin-logging.2.0 -lcbitcoin-crypto.2.0 -lcrypto -lcbitcoin.2.0 -lcbitcoin-file-ec.2.0 -lcbitcoin-rand.2.0 -L/opt/local/lib -levent_core -levent_pthreads -o bin/cbitcoin

ld: unknown option: -rpath=/Users/Donald/Development/Repositories/cbitcoin/bin

I found out that Apple's gcc compiler does not support -rpath, but you can instead use:

DYLD_LIBRARY_PATH=$(BINDIR)

More info here: https://dev.lsstcorp.org/trac/wiki/LinkingDarwin

After that, everything compiles!

ChangeLog

Of course, it's your project, Matthew, but WorkLog.txt not very interesting for other people.
Short changelog could be more useful

CBAssociativeArray - In function ‘CBAssociativeArrayDelete’: unknown type name ‘IMPLEMENT’

COMPILING ./build/obj/CBAssociativeArray.o
./src/CBAssociativeArray.c: In function ‘CBAssociativeArrayDelete’:
./src/CBAssociativeArray.c:154:4: error: unknown type name ‘IMPLEMENT’
./src/CBAssociativeArray.c:154:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘!’ token
./src/CBAssociativeArray.c:156:3: error: expected ‘}’ before ‘else’
./src/CBAssociativeArray.c: In function ‘CBAssociativeArrayInsert’:
./src/CBAssociativeArray.c:210:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c:214:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c:218:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c:220:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c:236:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c:242:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c:246:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c:250:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c:252:5: warning: multi-line comment [-Wcomment]
./src/CBAssociativeArray.c: In function ‘CBAssociativeArrayDelete’:
./src/CBAssociativeArray.c:167:1: warning: control reaches end of non-void function [-Wreturn-type]
Traceback (most recent call last):
File "./BUILD.py", line 122, in
compile(cflags + libflags,object,source,clean)
File "./BUILD.py", line 44, in compile
subprocess.check_call("gcc -c " + flags + " -o " + output + " " + source, shell=True)
File "/usr/lib64/python2.7/subprocess.py", line 511, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'gcc -c -Wall -Wno-overflow -Wno-uninitialized -pedantic -std=c99 -I./build/include -m64 -O2 -fpic -o ./build/obj/CBAssociativeArray.o ./src/CBAssociativeArray.c' returned non-zero exit status 1

Tried compilation on Fedora 17
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC)

Makefile fails on Linux Mint 13 Maya.

I do not know how to resolve this problem which I think has to do with weak linking. I solved it with the python script but can't get it to work with the makefile for some reason.

cc -L/opt/local/lib -L/usr/local/ssl/lib -shared -ldl -L/lib/x86_64-linux-gnu/ -o bin/libcbitcoin-crypto.so.2.0 build/CBOpenSSLCrypto.o -lcrypto -lssl
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(sha1_one.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libcrypto.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [crypto] Error 1

configure script

configure ships alongside with configure.ac
But it can be easy obtained with autoconf

"undefined reference to" problem when building on Linux Mint.

cc -lcbitcoin.2.0 -lcbitcoin-crypto.2.0 -lcbitcoin-network.2.0 -lcbitcoin-file-ec.2.0 -lcbitcoin-storage.2.0 -lcbitcoin-rand.2.0 -L/opt/local/lib -levent_core -levent_pthreads -L/media/sf_BitEagle_Projects/cbitcoin/bin build/testCBAddressBroadcast.o -o bin/testCBAddressBroadcast
build/testCBAddressBroadcast.o: In function `main':
testCBAddressBroadcast.c:(.text.startup+0x17e): undefined reference to `CBNewByteArrayWithDataCopy'

There is a problem during the linking of testCBAddressBroadcast. This is odd as the library is built.

Ubuntu: should temporary disable -Werror to compile

Hi Matthew, compiling in Ubuntu there is a warning, and with -Werror enabled, the make aborts:
cc -c -I/home/Unencrypted/Research/cbitcoin/library/include -I/home/Unencrypted/Research/cbitcoin/library/dependencies/threads -Wall -Wno-uninitialized -Wno-pointer-to-int-cast -pedantic -std=gnu99 -I/opt/local/ssl/include -I/opt/local/include -I/usr/local/ssl/include -Werror -DCB_HAVE_ASPRINTF -fPIC -O3 -DCB_LINUX -I//home/Unencrypted/Research/cbitcoin/client-server/include client-server/src/CBRPCServer.c -o build/CBRPCServer.o
client-server/src/CBRPCServer.c: In function ‘CBRPCServerRespond’:
client-server/src/CBRPCServer.c:99:3: error: implicit declaration of function ‘asprintf’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make: *** [build/CBRPCServer.o] Error 1

Comments style

Source code commented in C++ style (//) and documented with doxygen style (/** */)

For unification will nicely use C style (/* */) for comments in code

Valigrind error when running bin/testCBAddressManager

I get this when I run it with valgrind and --track-origins=yes.

==22141== Syscall param write(buf) points to uninitialised byte(s)
==22141==    at 0x5B68900: __write_nocancel (syscall-template.S:82)
==22141==    by 0x5AFB882: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1289)
==22141==    by 0x5AFB749: new_do_write (fileops.c:543)
==22141==    by 0x5AFCEB4: _IO_do_write@@GLIBC_2.2.5 (fileops.c:516)
==22141==    by 0x5AFDD3E: _IO_switch_to_get_mode (genops.c:189)
==22141==    by 0x5AFBA96: _IO_file_seekoff@@GLIBC_2.2.5 (fileops.c:999)
==22141==    by 0x5AF4F25: rewind (rewind.c:37)
==22141==    by 0x567D149: CBFileAppend (CBFileEC.c:69)
==22141==    by 0x5473AFA: CBDatabaseCreateDeletionIndex (CBDatabase.c:270)
==22141==    by 0x5473195: CBInitDatabase (CBDatabase.c:112)
==22141==    by 0x54721A1: CBNewAddressStorage (CBAddressStorage.c:37)
==22141==    by 0x401F67: main (testCBAddressManager.c:226)
==22141==  Address 0x402a009 is not stack'd, malloc'd or (recently) free'd
==22141==  Uninitialised value was created by a stack allocation
==22141==    at 0x546F750: ??? (in /media/sf_BitEagle_Projects/cbitcoin/bin/libcbitcoin-storage.2.0.so)

VERSION RECEIVE IP FAIL

Hi after doing ./configure, make, make test, I got this error:
VERSION RECEIVE IP FAIL ERROR VERSION: 2.0 pre-alpha ERROR STACK TRACE: ...
Could you please check this issue? Thanks.
I am using Ubuntu.
PROCESSING BLOCK 99 V | cbitcoin | 31/03/2014 07:26:20 GMT | 22 | Processing block 000000009674d4bfb624b2ab6136ba44cb815f696378841fa420f2903bc8b35a V | cbitcoin | 31/03/2014 07:26:20 GMT | 22 | Block 000000009674d4bfb624b2ab6136ba44cb815f696378841fa420f2903bc8b35a finished processing. V | cbitcoin | 31/03/2014 07:26:20 GMT | 22 | Processing block 24fcc166538f80f2b479f748fb18e266b09b7fc2e3c2bd07b5363d7c00fef742 V | cbitcoin | 31/03/2014 07:26:20 GMT | 22 | Block 24fcc166538f80f2b479f748fb18e266b09b7fc2e3c2bd07b5363d7c00fef742 finished processing. V | cbitcoin | 31/03/2014 07:26:20 GMT | 22 | Processing block 9f0001cb98920a580263efc976af424f8c490136c42df930b780a008cdadc718 W | cbitcoin | 31/03/2014 07:26:20 GMT | 22 | Block 9f0001cb98920a580263efc976af424f8c490136c42df930b780a008cdadc718 is bad. V | cbitcoin | 31/03/2014 07:26:20 GMT | 22 | Processing block ccfd13c5ed7e0bd7f8445af0f3b3518aee24cb911b0436d48b21ab9a01039e96 W | cbitcoin | 31/03/2014 07:26:20 GMT | 22 | Block ccfd13c5ed7e0bd7f8445af0f3b3518aee24cb911b0436d48b21ab9a01039e96 is bad. gcc build/testCBInventory.o -L/home/username/Desktop/cbitcoin/bin -lcbitcoin.2.0 -lcbitcoin-network.2.0 -lcbitcoin-storage.2.0 -lcbitcoin-threads.2.0 -lcbitcoin-logging.2.0 -lcbitcoin-crypto.2.0 -lcbitcoin.2.0 -lcbitcoin-file-ec.2.0 -lcbitcoin-rand.2.0 -L/opt/local/lib -lpthread -levent_core -levent_pthreads -lcrypto -o bin/testCBInventory bin/testCBInventory Session = 1337544566i gcc build/testCBNetworkCommunicator.o -L/home/username/Desktop/cbitcoin/bin -lcbitcoin.2.0 -lcbitcoin-network.2.0 -lcbitcoin-storage.2.0 -lcbitcoin-threads.2.0 -lcbitcoin-logging.2.0 -lcbitcoin-crypto.2.0 -lcbitcoin.2.0 -lcbitcoin-file-ec.2.0 -lcbitcoin-rand.2.0 -L/opt/local/lib -lpthread -levent_core -levent_pthreads -lcrypto -o bin/testCBNetworkCommunicator bin/testCBNetworkCommunicator You may need to move your mouse around if this test stalls. V | cbitcoin | 31/03/2014 07:26:33 GMT | 01 | Starting network event loop. V | cbitcoin | 31/03/2014 07:27:30 GMT | 02 | Starting network event loop. V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Starting network event loop. V | cbitcoin | 31/03/2014 07:28:23 GMT | 01 | Now listening on the IPv4 network on port 45562. V | cbitcoin | 31/03/2014 07:28:23 GMT | 02 | Now listening on the IPv4 network on port 45563. V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Made a connection to peer [::ffff:127.0.0.1]:45562 V | cbitcoin | 31/03/2014 07:28:23 GMT | 02 | Accepted an incoming connection from [::ffff:0.0.0.0]:39331. 1 incoming connections. V | cbitcoin | 31/03/2014 07:28:23 GMT | 01 | Accepted an incoming connection from [::ffff:64.160.10.64]:17099. 1 incoming connections. V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Made a connection to peer [::ffff:127.0.0.1]:45563 V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Sending message of type version (0) to [::ffff:127.0.0.1]:45562. V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Did connect to [::ffff:127.0.0.1]:45562 V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Sending message of type version (0) to [::ffff:127.0.0.1]:45563. V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Did connect to [::ffff:127.0.0.1]:45563 V | cbitcoin | 31/03/2014 07:28:23 GMT | 02 | Received a message header from [::ffff:0.0.0.0]:39331 with the type version and expected size of 110. V | cbitcoin | 31/03/2014 07:28:23 GMT | 01 | Received a message header from [::ffff:64.160.10.64]:17099 with the type version and expected size of 110. V | cbitcoin | 31/03/2014 07:28:23 GMT | 02 | Processing message from [::ffff:0.0.0.0]:39331 with the type version. V | cbitcoin | 31/03/2014 07:28:23 GMT | 01 | Processing message from [::ffff:64.160.10.64]:17099 with the type version. V | cbitcoin | 31/03/2014 07:28:23 GMT | 01 | Sending message of type version (0) to [::ffff:64.160.10.64]:17099. V | cbitcoin | 31/03/2014 07:28:23 GMT | 01 | Sending message of type verack (1) to [::ffff:64.160.10.64]:17099. V | cbitcoin | 31/03/2014 07:28:23 GMT | 01 | [::ffff:127.0.0.1]:45564 sent us their version: Version = 60001 Full blocks = 1 Timestamp = 1396250903 Our addr = [::ffff:0.0.0.0]:0 User agent = /cbitcoin:2.0(pre-alpha)/ Block height = 0 V | cbitcoin | 31/03/2014 07:28:23 GMT | 02 | Sending message of type version (0) to [::ffff:0.0.0.0]:39331. V | cbitcoin | 31/03/2014 07:28:23 GMT | 02 | Sending message of type verack (1) to [::ffff:0.0.0.0]:39331. V | cbitcoin | 31/03/2014 07:28:23 GMT | 02 | [::ffff:127.0.0.1]:45564 sent us their version: Version = 60001 Full blocks = 1 Timestamp = 1396250903 Our addr = [::ffff:0.0.0.0]:0 User agent = /cbitcoin:2.0(pre-alpha)/ Block height = 0 V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Received a message header from [::ffff:127.0.0.1]:45562 with the type version and expected size of 110. V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Processing message from [::ffff:127.0.0.1]:45562 with the type version. V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | Sending message of type verack (1) to [::ffff:127.0.0.1]:45562. V | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | [::ffff:127.0.0.1]:45562 sent us their version: Version = 60001 Full blocks = 1 Timestamp = 1396250903 Our addr = [::ffff:64.160.10.64]:17099 User agent = /cbitcoin:2.0(pre-alpha)/ Block height = 0 E | cbitcoin | 31/03/2014 07:28:23 GMT | 03 | VERSION RECEIVE IP FAIL | | | | | | | | ERROR VERSION: 2.0 pre-alpha | | | | ERROR STACK TRACE: | | | | bin/testCBNetworkCommunicator(onMessageReceived+0x296) [0x80495dd] | | | | /home/zhumabekuly/Desktop/cbitcoin/bin/libcbitcoin.2.0.so(CBNetworkCommunicatorOnMessageReceived+0x67e) [0x40043817] | | | | /home/zhumabekuly/Desktop/cbitcoin/bin/libcbitcoin.2.0.so(CBNetworkCommunicatorOnCanReceive+0x2e3) [0x40042310] | | | | /home/zhumabekuly/Desktop/cbitcoin/bin/libcbitcoin-network.2.0.so(CBCanReceive+0x7b) [0x400775c4] | | | | /usr/lib/i386-linux-gnu/libevent_core-2.0.so.5(event_base_loop+0x3ba) [0x402b5e4a] | | | | /usr/lib/i386-linux-gnu/libevent_core-2.0.so.5(event_base_dispatch+0x23) [0x402b6fa3] | | | | /home/zhumabekuly/Desktop/cbitcoin/bin/libcbitcoin-network.2.0.so(CBStartEventLoop+0x44) [0x40077001] | | | | /home/zhumabekuly/Desktop/cbitcoin/bin/libcbitcoin-threads.2.0.so(CBRunThread+0x51) [0x400a7f8f] | | | | /lib/i386-linux-gnu/libpthread.so.0(+0x6d78) [0x400e0d78] | | | | /lib/i386-linux-gnu/libc.so.6(clone+0x5e) [0x401eafee] | | | | make: *** [bin/testCBNetworkCommunicator] Error 1

make test: "Failed to seek to the end of a log file for reading the first overwrite entry."

Hi, I'm using Ubuntu, and after ./configure (disabled -Werror otherwise doesn't compile), make all, make examples, make test, I got this error, any hint?
...
Session = 1391018629i
V | cbitcoin | 29/01/2014 18:03:49 GMT | 01 | Starting network event loop.
cc -c -I/home/Unencrypted/Research/cbitcoin/library/include -I/home/Unencrypted/Research/cbitcoin/library/dependencies/threads -Wall -Wno-uninitialized -Wno-pointer-to-int-cast -pedantic -std=gnu99 -I/opt/local/ssl/include -I/opt/local/include -I/usr/local/ssl/include -DCB_HAVE_ASPRINTF -fPIC -O3 -DCB_LINUX -I/home/Unencrypted/Research/cbitcoin/library/dependencies/sockets/ -I/home/Unencrypted/Research/cbitcoin/library/dependencies/storage library/test/testCBDatabase.c -o build/testCBDatabase.o
cc build/testCBDatabase.o -L/home/Unencrypted/Research/cbitcoin/bin -lcbitcoin.2.0 -lcbitcoin-network.2.0 -lcbitcoin-storage.2.0 -lcbitcoin-threads.2.0 -lcbitcoin-logging.2.0 -lcbitcoin-crypto.2.0 -lcbitcoin.2.0 -lcbitcoin-file-ec.2.0 -lcbitcoin-rand.2.0 -L/opt/local/lib -lpthread -levent_core -levent_pthreads -lcrypto -o bin/testCBDatabase
bin/testCBDatabase
Session = 1391018630i
E | cbitcoin | 29/01/2014 18:03:53 GMT | 00 | Failed to seek to the end of a log file for reading the first overwrite entry.
| | | |
| | | | ERROR VERSION: 2.0 pre-alpha
| | | | ERROR STACK TRACE:
| | | | /home/Unencrypted/Research/cbitcoin/bin/libcbitcoin-storage.2.0.so(CBDatabaseEnsureConsistent+0x643) [0x2baa04beb403]
| | | | /home/Unencrypted/Research/cbitcoin/bin/libcbitcoin-storage.2.0.so(CBInitDatabase+0x141) [0x2baa04beb671]
| | | | /home/Unencrypted/Research/cbitcoin/bin/libcbitcoin-storage.2.0.so(CBNewDatabase+0x55) [0x2baa04bebad5]
| | | | bin/testCBDatabase() [0x403327]
| | | | /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x2baa05abb76d]
| | | | bin/testCBDatabase() [0x408e7d]
| | | |
E | cbitcoin | 29/01/2014 18:03:53 GMT | 00 | The database is inconsistent and could not be recovered in CBNewDatabase
| | | |
| | | | ERROR VERSION: 2.0 pre-alpha
| | | | ERROR STACK TRACE:
| | | | /home/Unencrypted/Research/cbitcoin/bin/libcbitcoin-storage.2.0.so(CBInitDatabase+0x2f4) [0x2baa04beb824]
| | | | /home/Unencrypted/Research/cbitcoin/bin/libcbitcoin-storage.2.0.so(CBNewDatabase+0x55) [0x2baa04bebad5]
| | | | bin/testCBDatabase() [0x403327]
| | | | /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x2baa05abb76d]
| | | | bin/testCBDatabase() [0x408e7d]
| | | |
E | cbitcoin | 29/01/2014 18:03:53 GMT | 00 | Could not initialise a database object.
| | | |
| | | | ERROR VERSION: 2.0 pre-alpha
| | | | ERROR STACK TRACE:
| | | | /home/Unencrypted/Research/cbitcoin/bin/libcbitcoin-storage.2.0.so(CBNewDatabase+0x98) [0x2baa04bebb18]
| | | | bin/testCBDatabase() [0x403327]
| | | | /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x2baa05abb76d]
| | | | bin/testCBDatabase() [0x408e7d]
| | | |
RECOVERY INIT DATABASE FAIL
make: *** [bin/testCBDatabase] Error 1

CBNetworkCommunicator is buggy

CBNetworkCommunicator crashes in the testCBNetworkCommunicator unit test occasionally or fails to complete. There seems to be a problem with the CBAddressManager. This needs to be fixed. Anyone can help resolve this.

Compilation fails

cbitcoin-master$ ./BUILD.py
COMPILING ./build/obj/CBNetworkCommunicator.o
./src/CBNetworkCommunicator.c:25:35: fatal error: CBNetworkCommunicator.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
File "./BUILD.py", line 122, in
compile(cflags + libflags,object,source,clean)
File "./BUILD.py", line 44, in compile
subprocess.check_call("gcc -c " + flags + " -o " + output + " " + source, shell=True)
File "/usr/lib64/python2.7/subprocess.py", line 511, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'gcc -c -Wall -Wno-overflow -Wno-uninitialized -pedantic -std=c99 -I./build/include -m64 -O2 -fpic -o ./build/obj/CBNetworkCommunicator.o ./src/CBNetworkCommunicator.c' returned non-zero exit status 1

When I copy manually *.h from include to build/include the compilation continues.

Best regards
Michal Ambroz

Building of CBLibEventSockets.o fails

cc -c -Wall -Wno-overflow -Wno-uninitialized -pedantic -std=c99 -I/home/r000n/fresh/cbitcoin/include -I/usr/local/ssl/include -I/opt/local/include -O3 -fPIC dependencies/sockets/CBLibEventSockets.c -o build/CBLibEventSockets.o
dependencies/sockets/CBLibEventSockets.c: In function ‘CBSocketBind’:
dependencies/sockets/CBLibEventSockets.c:45:18: error: storage size of ‘hints’ isn’t known
dependencies/sockets/CBLibEventSockets.c:48:19: error: ‘AI_PASSIVE’ undeclared (first use in this function)
dependencies/sockets/CBLibEventSockets.c:48:19: note: each undeclared identifier is reported only once for each function it appears in
dependencies/sockets/CBLibEventSockets.c:54:2: warning: implicit declaration of function ‘getaddrinfo’ [-Wimplicit-function-declaration]
dependencies/sockets/CBLibEventSockets.c:57:39: error: dereferencing pointer to incomplete type
dependencies/sockets/CBLibEventSockets.c:58:30: error: dereferencing pointer to incomplete type
dependencies/sockets/CBLibEventSockets.c:58:46: error: dereferencing pointer to incomplete type
dependencies/sockets/CBLibEventSockets.c:58:63: error: dereferencing pointer to incomplete type
dependencies/sockets/CBLibEventSockets.c:63:43: error: dereferencing pointer to incomplete type
dependencies/sockets/CBLibEventSockets.c:63:57: error: dereferencing pointer to incomplete type
dependencies/sockets/CBLibEventSockets.c:69:2: warning: implicit declaration of function ‘freeaddrinfo’ [-Wimplicit-function-declaration]
dependencies/sockets/CBLibEventSockets.c:45:18: warning: unused variable ‘hints’ [-Wunused-variable]
make: *** [build/CBLibEventSockets.o] Error 1

serializing tx inputs

I believe I have managed to create a txinput by inputting some char arrays and simple integers for the script and prevOut info. However, I am having a tough time serializing the tx inputs and then recovering the data from a char* array. Is there an example somewhere showing how to go from a string to txinput and back?

CBTransactionInput* serializeddata_to_obj(char* datastring){
CBByteArray* data = CBNewByteArrayFromString(datastring,true);
CBTransactionInput* txinput = CBNewTransactionInputFromData(data);
//CBDestroyByteArray(data);
return txinput;
}

char* obj_to_serializeddata(CBTransactionInput * txinput){
CBTransactionInputPrepareBytes(txinput);
CBTransactionInputSerialise(txinput);
CBByteArray* serializeddata = CBGetMessage(txinput)->bytes;

//CBByteArray* data = CBNewByteArrayFromString(serializeddata,true);
CBTransactionInput* newtxinput = CBNewTransactionInputFromData(serializeddata);
printf( "Sequence:%d and prevOutIndex:%d\n", newtxinput->sequence, newtxinput->prevOut.index );
return (char *)CBByteArrayGetData(serializeddata);

}

Creation of MakeFile

A make file would be a good idea for the library. The best make file would allow people to run the unit tests and configure the dependencies as they wish.

Not yet portable

Was attempting to compile for MIPS, but there's a check only allowing x86 or x64 arch and --prefix doesn't do anything.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.