Coder Social home page Coder Social logo

bitc's Introduction

BITC

bitc is a thin SPV bitcoin client.

  • 100% C code,
  • support for linux, mac, OpenBSD platforms,
  • console based: uses ncurses,
  • home grown async network i/o stack,
  • home grown poll loop,
  • home grown bitcoin engine,
  • supports encrypted wallet,
  • supports connecting via Tor/Socks5,
  • multi-threaded,
  • valgrind clean.

WARNING: this app is under development and may contain critical bugs.


Screenshots

dashboard


Dependencies


Install

Ubuntu 13.10, Saucy Salamander

You first need to install the libraries this app uses:

   # sudo apt-get install git make clang libssl-dev
   # sudo apt-get install libcurl4-openssl-dev libncurses5-dev
   # sudo apt-get install libleveldb-dev libsnappy-dev
   # sudo apt-get install libstdc++-4.8-dev

then clone the git repository:

   # git clone https://github.com/bit-c/bitc.git

finally build and launch:

   # cd bitc && make
   # ./bitc
Mac OS

You need to install libcurl, leveldb, libsnappy and ncurses via port or brew.


Usage

The first time you launch the app, a message will notify you of the list of files & directory it uses.

bitc uses the folder ~/.bitc to store various items:

what where avg size
block headers ~/.bitc/headers.dat ~ 20MB
peer IP addresses ~/.bitc/peers.dat ~ 2MB
transaction database ~/.bitc/txdb < 1MB
config file ~/.bitc/main.cfg < 1KB
wallet keys ~/.bitc/wallet.cfg < 1KB
tx-label file ~/.bitc/tx-labels.cfg < 1KB
contacts file ~/.bitc/contacts.cfg < 1KB

A log file is generated in /tmp/bitc-$USER.log.

To navigate the UI:

  • <left> and <right> allow you to change panel,
  • <CTRL> + t to initiate a transaction,
  • type q or back quote to exit.

Encrypted wallet

bitc has support for encrypted wallets. The first time you launch the app, it will automatically generate a new bitcoin address for you, and the wallet file will have private key unencrypted.

To turn on encryption, or to change the encryption password:

  # ./bitc -e

The next time you launch the app, you may or may not specify -p on the command line. If you do, you will be able to initiate transactions. If you do not the dashboard will still be functional but you won't be able to initiate transactions.

Note that bitc encrypts each private key separately.

WARNING: please remember to make back-ups.


Importing existing keys

You need to modify your ~/.bitc/wallet.cfg so that it contains the private key as exported by bitcoin-qt with the command dumpprivkey. More on that later.


TOR / SOCKS5 support

Bitc can route all outgoing TCP connections through a socks5 proxy. Since TOR implements a SOCKS5 proxy, you just need to put the entry:

	network.useSocks5="true"

in your main config file to use bitc over Tor (for a local Tor client). If the Tor proxy is not running locally, you need to modify the config options:

 	socks5.hostname="localhost"
	socks5.port=9050

.. in the file ~/.bitc/main.cfg. The default hostname:port is localhost:9050 on linux, and localhost:9150 on mac.


Watch-only Addresses

If you tag a key as

   key0.spendable = "FALSE"

in your ~/.bitc/wallet.cfg, bitc won't attempt to spend the bitcoins held by this address. This is not quite like a watch-only address, but we'll get there eventually.


Problem?

There are still a variety of things that need to be fixed or implemented (cf TODO file), and some of these may explain the behavior you're seeing. If bitc crashes, please collect the log file along with the core dump and open a ticket on github:

https://github.com/bit-c/bitc/issues

Feedback, comments?

Feel free to reach out to me if you have any feedback or if you're planning to use this code in interesting ways.

mailto:[email protected] PGP: 1C774FA3925A3076752B2741054E32DFBEE883DB

bitc's People

Contributors

jturner avatar mx4 avatar

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

bitc's Issues

disable stack-protector on powerpc

I receive this error upon compiling:

 LINK  bitc
bld/addrbook.o: In function `addrbook_get_path':
/home/<redacted>/bitc/src/addrbook.c:155: undefined reference to `__stack_chk_guard'
/home/<redacted>/bitc/src/addrbook.c:155: undefined reference to `__stack_chk_guard'
/home/<redacted>/bitc/src/addrbook.c:163: undefined reference to `__stack_chk_guard'
bld/base58.o: In function `base58_encode':
/home/<redacted>/bitc/src/base58.c:238: undefined reference to `__stack_chk_guard'
/home/<redacted>/bitc/src/base58.c:238: undefined reference to `__stack_chk_guard'
bld/base58.o:/home/<redacted>/bitc/src/base58.c:296: more undefined references to `__stack_chk_guard' follow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bitc] Error 1

Clang:

Debian clang version 3.3-16 (branches/release_33) (based on LLVM 3.3)
Target: powerpc-unknown-linux-gnu
Thread model: posix

Disabling fstack-protector allows it to compile but I have no idea what the implications are of doing that or how to go about fixing it properly.

Can't find libstdc++

After installing the required dependencies on Ubuntu 14.04 make threw an error, unable to find libstdc++ until I added this to LIBS: -L/usr/lib/gcc/x86_64-linux-gnu/4.8/

build issue on amd64 (debian testing)

Built properly in the past, but updated and now see this error. Removed dir and did a clean checkout and got the same error.

CC apps/bitc-cli/ncui.c
apps/bitc-cli/ncui.c:1539:2311: error: array index 3 is past the end of the array (which contains 3 elements) [-Werror,-Warray-bounds]
if (extension ({ size_t **s1_len, __s2_len; (__builtin_constant_p (entry->country_code) && __builtin_constant_p ("US") && (__s1_len = __builtin_strlen (entry->country_code), __s2_len = __builtin_strlen ("US"), (!((size_t)(const void *)((entry->country_code) + 1) - (size_t)(const void *)(entry->country_code) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("US") + 1) - (size_t)(const void *)("US") == 1) || __s2_len >= 4)) ? __builtin_strcmp (entry->country_code, "US") : (__builtin_constant_p (entry->country_code) && ((size_t)(const void *)((entry->country_code) + 1) - (size_t)(const void *)(entry->country_code) == 1) && (__s1_len = __builtin_strlen (entry->country_code), __s1_len < 4) ? (__builtin_constant_p ("US") && ((size_t)(const void )(("US") + 1) - (size_t)(const void )("US") == 1) ? __builtin_strcmp (entry->country_code, "US") : (__extension ({ const unsigned char ***s2 = (const unsigned char *) (const char *) ("US"); int __result = (((const unsigned char *) (const char *) (entry->country_code))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (entry->country_code))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (entry->country_code))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (entry->country_code))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("US") && ((size_t)(const void *)(("US") + 1) - (size_t)(const void *)("US") == 1) && (__s2_len = __builtin_strlen ("US"), __s2_len < 4) ? (__builtin_constant_p (entry->country_code) && ((size_t)(const void )((entry->country_code) + 1) - (size_t)(const void )(entry->country_code) == 1) ? __builtin_strcmp (entry->country_code, "US") : (- (__extension ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (entry->country_code); int __result = (((const unsigned char *) (const char *) ("US"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("US"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("US"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("US"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (entry->country_code, "US")))); }) == 0

Errors during startup

It seems to compile correctly but when running i get this:
./bitc

It looks like you're a new user. Welcome!

Note that bitc uses the directory: ~/.bitc to store:

  • block headers: ~/.bitc/headers.dat -- ~ 20 MB
  • peer IP addresses: ~/.bitc/peers.dat -- ~ 2 MB
  • transaction database: ~/.bitc/txdb -- < 1 MB
  • wallet keys: ~/.bitc/wallet.cfg -- < 1 KB
  • main config file: ~/.bitc/main.cfg -- < 1 KB
  • a contacts file: ~/.bitc/contacts.cfg -- < 1 KB
  • a tx-label file: ~/.bitc/tx-labels.cfg -- < 1 KB

Failed to add address to wallet.
Failed to add key to wallet: Operation not permitted
--- tthis is my logfile from temp
05:08:32.256371| UTIL: new log session: Thu Apr 28 05:08:32 2016
05:08:32.256501| UTIL: changing rlimit core-size: 0 -> ffffffffffffffff
05:08:32.256687| CONFIG: Loading config '/home/jacobbogers/.bitc/main.cfg'
05:08:32.256724| FILE: opening '/home/jacobbogers/.bitc/main.cfg' ro=1 unbuf=0
05:08:32.256893| CONFIG: Loading config '/home/jacobbogers/.bitc/contacts.cfg'
05:08:32.256928| FILE: opening '/home/jacobbogers/.bitc/contacts.cfg' ro=1 unbuf=0
05:08:32.257033| CONFIG: Loading config '/home/jacobbogers/.bitc/tx-labels.cfg'
05:08:32.257065| FILE: opening '/home/jacobbogers/.bitc/tx-labels.cfg' ro=1 unbuf=0
05:08:32.257212| BLCK: Using headers at '/home/jacobbogers/.bitc/headers.dat.
05:08:32.257391| BLCK: Genesis: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
05:08:32.257436| FILE: opening '/home/jacobbogers/.bitc/headers.dat' ro=0 unbuf=0
05:08:32.257494| BLCK: loaded blocks up to 0000000000000000000000000000000000000000000000000000000000000000
05:08:32.257513| BLCK: this took 1 usec
05:08:32.257526| BLCK: loaded 0 headers.
05:08:32.258037| WALLET: plain wallet: 0 key in file '/home/jacobbogers/.bitc/wallet.cfg'.
05:08:32.288588| TXDB: txdb_print_coins: no coins found
05:08:32.288625| TXDB: BALANCE = 0 -- 0.00000000 BTC
05:08:32.288680| BLOOM: filterSize=17 numHashFuncs=9 tweak=5
05:08:32.288734| KEY: EC_KEY_generate_key failed.
05:08:32.288753| Failed to add address to wallet.

Dependency issue in OSX Yosemite

When running the wallet I keep getting this error:

dyld: Library not loaded: /usr/local/lib/libleveldb.1.15.dylib
Referenced from: /Users/solocshaw/bitc/./bitc
Reason: image not found
Trace/BPT trap: 5

testnet address generation and handling

It would be useful for bitc to be able to generate and handle testnet addresses.

Currently, when running on the testnet (-T) the app loads mainnet addresses from the wallet.cfg file, and when generating an address with

$ ./bitc -T -a myTestnetAddr

a mainnet address is generated and added to wallet.cfg.

Create a brew install formula

Could someone who is building this on OS X create a homebrew install formula?

Would be really cool to be able to type brew install bitc on my mac and have it be updated / rebuilt automatically when appropriate.

I'd do it, but I couldn't find several of the dependencies for OS X on a quick search and, being lazy, I'm hoping that someone who is already building could help the rest of us out.

brew formula cookbook

Fixes to compile for Raspbian (Pi)

Nice to have a non-java SPV client -- finally something that the Pi can handle!
I had to make the following additions in order to compile cleanly for Raspbian:
Added to Makefile to fix assembler messages (Rd and Rm should be different in mul)

CFLAGS += -Dlinux -ccc-host-triple armv6-unknown-eabi -march=armv6 -mfpu=vfp -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfloat-abi=hard

Added to block-store.c, txdb.c, and config.c for the PATH_MAX define

#include <linux/limits.h>

Added to hash.c, ncui.c, and txdb.c to fix "_undefined reference to `__isoc99_sscanf'" linker error

#define _GNU_SOURCE

I haven't forked and created a pull request as I don't know the proper way to include these changes so they don't break other platforms.
FYI: uname -m returns armv6l, and uname -i & uname -p both return unknown.

error: comparison of constant -1 with expression of type 'char' is always true

I receive the following error when compiling 777029b:

CC src/main.c
src/main.c:1112:46: error: comparison of constant -1 with expression of type 'char' is always > true [-Werror,-Wtautological-constant-out-of-range-compare]
long_opts, NULL)) != EOF) {
~~~~~~~~~~~~~~~~~ ^ ~~~
1 error generated.
make: *** [bld/main.o] Error 1``

Clang:

Debian clang version 3.3-16 (branches/release_33) (based on LLVM 3.3)
Target: powerpc-unknown-linux-gnu
Thread model: posix

Compiles and works great on OS X though, so!

RPC interface

An optional RPC interface would be awesome, so i can use this on my server.

regards,
bitwave

"Blocks" tab uses doesn't show year in date

Not sure if this is on purpose or some locale-specific weirdness, but the dates in the "Blocks" tab don't show the year, which looks a bit strange for older blocks like the genesis block:

│   2000 │ 27 Jan 09:58:35 │ 00000000dfd5d65c9d8561b4b8f60a63018fe3933ecb131fb37f905f87da951a                 
│      0 │ 03 Jan 19:15:05 │ 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f                 │

If the reason for this is to conserve horizontal space, maybe show the times only for blocks received this year and the year instead.

Problem with lastHashStore

Hi all,

I have been running bitc smoothly until I sent 0.001 btc to the default address assigned by bitc. Afterward, bitc quits automatically while trying to connect to peers showing the following message. Has anybody else seen a similar issue?

ASSERT failed at src/block-store.c:blockstore_get_highest:178
PANIC: Expression 'height1 > 0' not TRUE.
Aborted (core dumped)

I tried to find a relevant section in the code, and it seems like lastHashStore is the immediate cause of the problem. Since peerGroup determines lastHashStore, I suspect that peerGroup is not being set up properly.

peergroup_get_lastblk(btc->peerGroup, &lastHashStore);
blockstore_get_highest(bs, &walletHash, &lastHashStore, &startHash);
...
height0 = blockstore_get_block_height(bs, hash0);
height1 = blockstore_get_block_height(bs, hash1);
ASSERT(height0 > 0);// PANIC

Problem with compilation - unused function 'bitc_openssl_lock_fun'

After make i obtained the following error:

 CC    apps/bitc-cli/main.c
apps/bitc-cli/main.c:363:1: error: unused function 'bitc_openssl_lock_fun'
      [-Werror,-Wunused-function]
bitc_openssl_lock_fun(int mode,
^
apps/bitc-cli/main.c:387:1: error: unused function
      'bitc_openssl_thread_id_fun' [-Werror,-Wunused-function]
bitc_openssl_thread_id_fun(void)
^
2 errors generated.
Makefile:117: recipe for target 'bld/apps/bitc-cli/main.o' failed
make: *** [bld/apps/bitc-cli/main.o] Error 1

Additional info

arch
x86_64

lsb_release -a | grep Description
Description:	Ubuntu 16.04.3 LTS

building on os x fails after recent changes

recent source code doesnt compile on Mac OS X with clang anymore

...
CC src/main.c
src/main.c:388:11: error: incompatible pointer to integer conversion returning 'pthread_t' (aka 'struct _opaque_pthread_t ') from a function with result type 'unsigned long'
[-Werror,-Wint-conversion]
return pthread_self();
^~~~~~~~~~~~~~
1 error generated.
make: *
* [bld/main.o] Error 1
...

error is new, bitc version from 6. februar compiled with clang without problems

fix:
use gcc instead of clang

using too much ram :)

Heya,

i'm just testing out clients for memory usage, and your SPV client peaks at 1GB virtual ram required O_o
why is it so much, are there ways to lower the demands easily?

KDF iteration count far to low to be meaningful.

Picked a file at random to look at.. got crypt.h

Your KDF iteration count is far too low to meaningfully slow attacks. A typical bitcoin-qt wallet uses over 100,000 iterations of SHA512, you're using about 1000. This should really be stored in your wallet and adapted to the users system to get the highest amount you can take with acceptable performance. (Bitcoin-qt uses 100ms worth, subject to a minimum of 25,000 iterations. Reasonable minds might differ on the timings, but I think 1337 iterations is way too little, it's even less than linux distros are using for login passwords)

Static build

Hello,

I want to build statically the bitc binary
I ahve added the "static" flag to the Makefile but I have this error:

/usr/bin/ld: dynamic STT_GNU_IFUNC symbol strcmp' with pointer equality in /usr/bin/../lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.a(strcmp.o)' can not be used when making an executable

What is the right way to compile it statically ?

Thanks

clang: not found

The build is currently hardcoded to use clang. On linuxy platforms gcc is usually installed, it would be nice to have at least a Makefile option to override the C compiler.
(it compiles and works fine in gcc, btw)

split the core of

I'd like to add support for bitc in BitcoinKit.framework so Hive and MacWallet could make use of bitc as the underlaying bitcoin stack.
This would preassume that bitc would keep the core separated from the ui/terminal stuff. Best would be to build a lib (libbtc) where the ui-level (bitc) would make use of that library.
(like libcurl and curl are connected).

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.