Coder Social home page Coder Social logo

libbtc / libbtc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonasschnelli/libbtc

253.0 33.0 94.0 2.73 MB

Tiny Bitcoin Library written in C

Shell 0.24% C 90.04% C++ 0.30% Python 5.67% Makefile 1.01% M4 0.90% Assembly 0.65% Sage 0.92% CMake 0.18% Dockerfile 0.01% QMake 0.02% HTML 0.01% Ruby 0.06%

libbtc's Introduction

Icon

libbtc – A fast, clean and small bitcoin C library

Build Status Coverage Status

What is libbtc?

Libbtc is a very portable C library for creating and manipulating bitcoin data structures and interacting with the p2p network.

Current features

  • Generating and storing private and public keys
  • ECDSA secp256k1 signing and verification (through libsecp256k1 included as git subtree)
  • Generate recoverable signatures (and recover pubkey from signatures)
  • BIP32 hierarchical deterministic key derivation
  • Transaction generation, manipulation, signing and ser-/deserialization including P2PKH, P2SH, multisig
  • Address generation
  • Base58check encoding
  • Native implementation of SHA256, SHA512, SHA512_HMAC, RIPEMD-160 including NIST testvectors
  • Native constant time AES (+256CBC) cipher implementation including NIST testvectors
  • Keystore (wallet) databases (through logdb https://github.com/liblogdb/liblogdb)
  • Event based bitcoin P2P client capable of connecting to multiple nodes in a single thread (requires libevent)

Advantages of libbtc?

  • No dependencies in case no p2p network client is required (only dependency is libsecp256k1 added as git subtree)
  • The only dependency for the p2p network client is libevent (very portable)
  • optimized for MCU and low mem environments
  • ~full test coverage
  • mem leak free (valgrind check during CI)

The bitcointool CLI

Generate a new privatekey WIF and HEX encoded:
./bitcointool -command genkey
> privatekey WIF: KwmAqzEiP7nJbQi6ofQywSEad4j5b9BXDJvyypQDDLSvrV6wACG8
> privatekey HEX: 102f1d9d91fa1c8d816ef469e74c1153a6b453d2a991e77fe187e5514a7b18ac
Generate the public key and p2pkh address from a WIF encoded private key
/bitcointool -command pubfrompriv -p KwmAqzEiP7nJbQi6ofQywSEad4j5b9BXDJvyypQDDLSvrV6wACG8
> pubkey: 023d86ca58e2519cce1729b4d36dfe5a053ad5f4ae6f7ef9360bee4e657f7e41c9
> p2pkh address: 1N5ZkjyabcZLLHMweJrSkn3qedsPGzAx9m
Generate the P2PKH address from a hex encoded compact public key
./bitcointool -command addrfrompub -pubkey 023d86ca58e2519cce1729b4d36dfe5a053ad5f4ae6f7ef9360bee4e657f7e41c9
> p2pkh address: 1N5ZkjyabcZLLHMweJrSkn3qedsPGzAx9m
Generate new BIP32 master key
./bitcointool -command hdgenmaster
> masterkey: xprv9s21ZrQH143K3C5hLMq2Upsh8mf9Z1p5C4QuXJkiodSSihp324YnWpFfRjvP7gqocJKz4oakVwZn5cUgRYTHtNRvGqU5DU2Gn8MPM9jHvfC
Print HD node
./bitcointool -command hdprintkey -privkey xprv9s21ZrQH143K3C5hLMq2Upsh8mf9Z1p5C4QuXJkiodSSihp324YnWpFfRjvP7gqocJKz4oakVwZn5cUgRYTHtNRvGqU5DU2Gn8MPM9jHvfC
> ext key: xprv9s21ZrQH143K3C5hLMq2Upsh8mf9Z1p5C4QuXJkiodSSihp324YnWpFfRjvP7gqocJKz4oakVwZn5cUgRYTHtNRvGqU5DU2Gn8MPM9jHvfC
> depth: 0
> p2pkh address: 1Fh1zA8mD6S2LBbCqdViEGuV3oDhggX3k4
> pubkey hex: 0394a83fcfa131afc47a3fcd1d32db399a0ffa7e68844546b2df7ed9f5ebd07b09
> extended pubkey: xpub661MyMwAqRbcFgAASPN2qxpRgoVdxUXvZHLWKhALMxyRbW9BZbs34ca9H3LrdsKxdMD4o5Fc7eqDg19cRTj3V9dCCeM4R1DRn8DvUq3rMva
Derive child key (second child key at level 1 in this case)
./bitcointool -command hdderive -keypath m/1h -privkey xprv9s21ZrQH143K3C5hLMq2Upsh8mf9Z1p5C4QuXJkiodSSihp324YnWpFfRjvP7gqocJKz4oakVwZn5cUgRYTHtNRvGqU5DU2Gn8MPM9jHvfC
> ext key: xprv9v5qiRbzrbhUzAVBdtfqi1tQx5tiRJ2jpNtAw8bRec8sTivLw55H85SoRTizNdx2JSVL4sNxmjvseASZkwpUopby3iGiJWnVH3Wjg2GkjrD
> depth: 1
> p2pkh address: 1DFBGZdcADGTcWwDEgf15RGPqnjmW2gokC
> pubkey hex: 0203a85ec401e66a218bf1583112599ee2a1268ebc90d91b7f457c87a50f2b011b
> extended pubkey: xpub695C7w8tgyFnCeZejvCr59q9W7jCpkkbBbomjX13CwfrLXFVUcPXfsmHGiSfpYds2JuHrXAFEoikMX6725W8VgrVL5x4ojBw9QFAPgtdw1G

The bitcoin-send-tx CLI

This tools can be used to broadcast a raw transaction to peers retrived from a dns seed or specified by ip/port. The application will try to connect to max 6 peers, send the transaction two two of them and listens on the remaining ones if the transaction has been relayed back.

Send a raw transaction to random peers on mainnet
./bitcoin-send-tx <txhex>
Send a raw transaction to random peers on testnet and show debug infos
./bitcoin-send-tx -d -t <txhex>
Send a raw transaction to specific peers on mainnet and show debug infos use a timeout of 5s
./bitcoin-send-tx -d -s 5 -i 192.168.1.110:8333,127.0.0.1:8333 <txhex>

How to Build

Install dependencies

Debian / Ubuntu
sudo apt-get install build-essential libevent-dev
OpenBSD
sudo pkg_add autoconf automake libtool libevent
Other

Please submit a pull request to add dependencies for your system, or update these.

Full library including CLI tool and wallet database

./autogen.sh
./configure
make check

Pure library without wallet support

./autogen.sh
./configure --disable-wallet --disable-tools
make check

libbtc's People

Contributors

afk11 avatar cryptocoinlab avatar csjones avatar eklitzke avatar gmkarl avatar hubslave avatar icota avatar jonasschnelli avatar jsarenik avatar laanwj avatar ndrchvzz avatar pashuka avatar promag avatar sergey-chernikov avatar thequantumphysicist avatar tkms1122 avatar xloem 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libbtc's Issues

libbtc won't compile when wallets are disabled

Hello. I discovered an issue recently. With wallets disabled and debug mode enabled, the code won't link.

./autogen.sh
./configure --disable-wallet
make

Here's what I'm seeing at the end of the make process. This is on Ubuntu 18.04.

droark@ubuntu:~/Projects/PersonalGitRepo/libbtc$ make
make[1]: Entering directory '/home/droark/Projects/libbtc'
  CCLD     bitcoin-spv
src/tools/bitcoin_spv-bitcoin-spv.o: In function `main':
/home/droark/libbtc/src/tools/bitcoin-spv.c:166: undefined reference to `btc_wallet_new'
/home/droark/libbtc/src/tools/bitcoin-spv.c:169: undefined reference to `btc_wallet_load'
/home/droark/libbtc/src/tools/bitcoin-spv.c:181: undefined reference to `btc_wallet_set_master_key_copy'
/home/droark/libbtc/src/tools/bitcoin-spv.c:188: undefined reference to `btc_wallet_next_key'
/home/droark/libbtc/src/tools/bitcoin-spv.c:195: undefined reference to `btc_wallet_get_addresses'
/home/droark/libbtc/src/tools/bitcoin-spv.c:204: undefined reference to `btc_wallet_check_transaction'
src/tools/bitcoin_spv-bitcoin-spv.o:/home/droark/Projects/libbtc/./src/logdb/include/logdb/logdb_memdb_llist.h:71: undefined reference to `logdb_llistdb_append'
src/tools/bitcoin_spv-bitcoin-spv.o:(.data.rel+0x8): undefined reference to `logdb_llistdb_init'
src/tools/bitcoin_spv-bitcoin-spv.o:(.data.rel+0x10): undefined reference to `logdb_llist_db_free'
src/tools/bitcoin_spv-bitcoin-spv.o:(.data.rel+0x18): undefined reference to `logdb_llistdb_find'
src/tools/bitcoin_spv-bitcoin-spv.o:(.data.rel+0x20): undefined reference to `logdb_llistdb_size'
src/tools/bitcoin_spv-bitcoin-spv.o:/home/droark/Projects/libbtc/./src/logdb/include/logdb/logdb_memdb_rbtree.h:67: undefined reference to `logdb_rbtree_append'
src/tools/bitcoin_spv-bitcoin-spv.o:(.data.rel+0x48): undefined reference to `logdb_rbtree_init'
src/tools/bitcoin_spv-bitcoin-spv.o:(.data.rel+0x50): undefined reference to `logdb_rbtree_free'
src/tools/bitcoin_spv-bitcoin-spv.o:(.data.rel+0x58): undefined reference to `logdb_rbtree_find'
src/tools/bitcoin_spv-bitcoin-spv.o:(.data.rel+0x60): undefined reference to `logdb_rbtree_size'
./.libs/libbtc.a(libbtc_la-netspv.o):/home/droark/Projects/libbtc/./src/logdb/include/logdb/logdb_memdb_llist.h:71: undefined reference to `logdb_llistdb_append'
./.libs/libbtc.a(libbtc_la-netspv.o):(.data.rel+0x8): undefined reference to `logdb_llistdb_init'
./.libs/libbtc.a(libbtc_la-netspv.o):(.data.rel+0x10): undefined reference to `logdb_llist_db_free'
./.libs/libbtc.a(libbtc_la-netspv.o):(.data.rel+0x18): undefined reference to `logdb_llistdb_find'
./.libs/libbtc.a(libbtc_la-netspv.o):(.data.rel+0x20): undefined reference to `logdb_llistdb_size'
./.libs/libbtc.a(libbtc_la-netspv.o):/home/droark/Projects/libbtc/./src/logdb/include/logdb/logdb_memdb_rbtree.h:67: undefined reference to `logdb_rbtree_append'
./.libs/libbtc.a(libbtc_la-netspv.o):(.data.rel+0x48): undefined reference to `logdb_rbtree_init'
./.libs/libbtc.a(libbtc_la-netspv.o):(.data.rel+0x50): undefined reference to `logdb_rbtree_free'
./.libs/libbtc.a(libbtc_la-netspv.o):(.data.rel+0x58): undefined reference to `logdb_rbtree_find'
./.libs/libbtc.a(libbtc_la-netspv.o):(.data.rel+0x60): undefined reference to `logdb_rbtree_size'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):/home/droark/Projects/libbtc/./src/logdb/include/logdb/logdb_memdb_llist.h:71: undefined reference to `logdb_llistdb_append'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):(.data.rel+0x8): undefined reference to `logdb_llistdb_init'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):(.data.rel+0x10): undefined reference to `logdb_llist_db_free'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):(.data.rel+0x18): undefined reference to `logdb_llistdb_find'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):(.data.rel+0x20): undefined reference to `logdb_llistdb_size'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):/home/droark/Projects/libbtc/./src/logdb/include/logdb/logdb_memdb_rbtree.h:67: undefined reference to `logdb_rbtree_append'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):(.data.rel+0x48): undefined reference to `logdb_rbtree_init'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):(.data.rel+0x50): undefined reference to `logdb_rbtree_free'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):(.data.rel+0x58): undefined reference to `logdb_rbtree_find'
./.libs/libbtc.a(libbtc_la-headersdb_file.o):(.data.rel+0x60): undefined reference to `logdb_rbtree_size'
collect2: error: ld returned 1 exit status
Makefile:1073: recipe for target 'bitcoin-spv' failed
make[1]: *** [bitcoin-spv] Error 1
make[1]: Leaving directory '/home/droark/Projects/libbtc'
Makefile:1899: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

MacOS 10.13.5 with Xcode 9.3.1 generates similar results.

droark:libbtc droark$ make
  CCLD     bitcoin-spv
Undefined symbols for architecture x86_64:
  "_btc_wallet_check_transaction", referenced from:
      _main in bitcoin_spv-bitcoin-spv.o
  "_btc_wallet_get_addresses", referenced from:
      _main in bitcoin_spv-bitcoin-spv.o
  "_btc_wallet_load", referenced from:
      _main in bitcoin_spv-bitcoin-spv.o
  "_btc_wallet_new", referenced from:
      _main in bitcoin_spv-bitcoin-spv.o
  "_btc_wallet_next_key", referenced from:
      _main in bitcoin_spv-bitcoin-spv.o
  "_btc_wallet_set_master_key_copy", referenced from:
      _main in bitcoin_spv-bitcoin-spv.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [bitcoin-spv] Error 1
make: *** [all-recursive] Error 1

I looked for a bit but needed to get back to another project. My workaround was to leave out --disable-wallet. If somebody else can fix this quickly, cool, otherwise I'll take a swing at it when I get a moment.

Thanks.

Portable Alphabetical Checking

Skimming through the code, I noticed some checks to determine if a character is alphabetical by doing something like if (a >= 'A' && a <= 'Z'), notably src/segwit_addr.c and src/utils.c.
C does not guarantee that the alphabetical characters are consecutive, so technically, this is not entirely portable. ASCII does have all alphabetical characters laid out consecutively, though, so because of ASCII's ubiquity, this is a non-issue on virtually every system.

I am only fussing about this because the README reads "Libbtc is a very portable C library." isalpha from the C standard header <ctype.h> is portable and more concise. Possibly slower, but speed should be negligible here.

Is this something worth fixing?

Generate derived public addresses from master public address

./bitcointool --testnet  
-keypath 0/0 
-pubkey tpubD9EDMRKYRLyZNCZxvJDS6tueAkDVjdajrVZGv7rmPoaNZZEUGX5HJvDnBKi5EVG7ivx9tAcbjjEhEHwdkox3pP5iKQZ9FVFHHZoimQ5HwVh 
-c hdderive

Error: Missing extended key (use -p)

It requires a private key. Is it possible to generate derived keys with only public master key?

make check fail on test 1951

When running the make check command in the linux terminal I got this error message:

[...]
Start parsing 1951 transactions...done (took 0 secs)
Sync completed, at height 793492
DEBUG :Disconnect node 2
DEBUG :Disconnect node 9
DEBUG :Disconnect node 10
/bin/bash: line 5: 12155 Segmentation fault ${dir}$tst
FAIL: tests

1 of 1 test failed
Please report to https://github.com/jonasschnelli/libbtc/issues

make[2]: *** [Makefile:2126: check-TESTS] Error 1
make[2]: Leaving directory '/mnt/d/Development/CRYPTOCURRENCIES/libbtc'
make[1]: *** [Makefile:2410: check-am] Error 2
make[1]: Leaving directory '/mnt/d/Development/CRYPTOCURRENCIES/libbtc'
make: *** [Makefile:2026: check-recursive] Error 1

Build libbtc using mingw

Hi guys,

is it possible to get more instructions on how to build this lib under Win OS.

Thank you, Andre

btc_b58check fails on DE0 Nano NIOS II

I am trying to run libbtc on a DE0-Nano running NIOS II, I have been successful so far in implementing it but when I try to derive a child key the code below fails:

int btc_b58check(const void* bin, size_t binsz, const char* base58str)
{
    uint256 buf;

    const uint8_t* binc = bin;

    unsigned i;

    if (binsz < 4) {
        return -4;
    }
    sha256_Raw(bin, binsz - 4, buf);
    sha256_Raw(buf, sizeof(buf), buf);

    if (memcmp(&binc[binsz - 4], buf, 4)) {
        return -1;
    }
    ...
}

the if (memcmp(&binc[binsz - 4], buf, 4)) conditional fails. Would anyone be able to tell me why this happens?
I have tried commenting out this conditional and libbtc is able to produce results but the p2pkh address is not a valid testnet bitcoin address.

Error: The transaction was not requested by the informed nodes

I am trying to send a transaction to one or more peers using libbtc. Why do I get this error?

prayank@ubuntu:~/libbtc$ ./bitcoin-send-tx -d -t -s 60 -i IP-MY-BITCOIN-CORE-TESTNET-NODE:18333 02000000000101f72f9c20d35471cc10c089b0c221c863fba27854b0a103932e1af586b07a190c0100000000fdffffff01e0fd1c0000000000160014d985de537211d9b8963f469f870bab7021a26f2d0247304402204d648628b503722d54ebbfdbd4017a73e53b4364f6331d798a437026de1d274f02202c97f7530b28eda46b89a8d43c6db477db9fd11dc8476f732f1d1fd132e9a613012103d4920a6452ba3afcb340ef085637ae4ce0c4c504c61d537b5ba074988d93044100000000
Start broadcasting transaction: 1b3814985a519c19e77bba0b9c5b86fbd0ee27a7d0ec9f36836892bf455e0128 with timeout 60 seconds
Trying to connect to nodes...


Result:
=============
Max nodes to connect to: 10
Successfully connected to nodes: 0
Informed nodes: 0
Requested from nodes: 0
Seen on other nodes: 0

Error: The transaction was not requested by the informed nodes. This usually happens when the transaction has already been broadcasted

I created this transaction using createrawtransaction and signrawtransactionwithwallet in Bitcoin Core.

DLL support for windows

The library currently is only tested on Windows.

  • for mingw host: LT_INIT([win32-dll]) to enable shared building
  • for mingw host: LDFLAGS += -no-undefined
  • run tests using dll to ensure symbols resolve at runtime

build fails on openbsd 6.1

This is a fairly recent OpenBSD 6.1 snapshot, on newly created VM.

In advance of building libbtc, I used pkg_add to install automake-1.15.1 autoconf-2.69p2 libevent libtool unzip and downloaded https://github.com/libbtc/libbtc/archive/master.zip

Below are logs from:

  • build using system compiler (inc configuring with/without pointing configure at the correct libevent headers)
  • build using gcc/gmake
root@btcvm:/root/libbtc:8# unzip master.zip
-snip-
root@btcvm:/root/libbtc:9# cd libbtc-master
root@btcvm:/root/libbtc-master:10# export AUTOCONF_VERSION=2.69
root@btcvm:/root/libbtc-master:11# export AUTOMAKE_VERSION=1.15
root@btcvm:/root/libbtc-master:12# ./autogen.sh
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux'.
libtoolize: copying file `build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `build-aux/m4'.
libtoolize: copying file `build-aux/m4/libtool.m4'
libtoolize: copying file `build-aux/m4/ltoptions.m4'
libtoolize: copying file `build-aux/m4/ltsugar.m4'
libtoolize: copying file `build-aux/m4/ltversion.m4'
libtoolize: copying file `build-aux/m4/lt~obsolete.m4'
configure.ac:11: installing 'build-aux/compile'
configure.ac:6: installing 'build-aux/config.guess'
configure.ac:6: installing 'build-aux/config.sub'
configure.ac:9: installing 'build-aux/install-sh'
configure.ac:9: installing 'build-aux/missing'
Makefile.am: installing 'build-aux/depcomp'
parallel-tests: installing 'build-aux/test-driver'
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux'.
libtoolize: copying file `build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `build-aux/m4'.
libtoolize: copying file `build-aux/m4/libtool.m4'
libtoolize: copying file `build-aux/m4/ltoptions.m4'
libtoolize: copying file `build-aux/m4/ltsugar.m4'
libtoolize: copying file `build-aux/m4/ltversion.m4'
libtoolize: copying file `build-aux/m4/lt~obsolete.m4'
configure.ac:14: installing 'build-aux/compile'
configure.ac:8: installing 'build-aux/config.guess'
configure.ac:8: installing 'build-aux/config.sub'
configure.ac:12: installing 'build-aux/install-sh'
configure.ac:12: installing 'build-aux/missing'
Makefile.am: installing 'build-aux/depcomp'
parallel-tests: installing 'build-aux/test-driver'
root@btcvm:/root/libbtc-master:13#

root@btcvm:/root/libbtc-master:14# ./configure
checking build system type... x86_64-unknown-openbsd6.1
checking host system type... x86_64-unknown-openbsd6.1
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking how to print strings... print -r
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... no
checking how to convert x86_64-unknown-openbsd6.1 file names to x86_64-unknown-o
penbsd6.1 format... func_convert_file_noop
checking how to convert x86_64-unknown-openbsd6.1 file names to toolchain format
... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... match_pattern /lib[^/]+(\.so\.[
0-9]+\.[0-9]+|\.so|_pic\.a)$
checking for dlltool... no
checking how to associate runtime and link libraries... print -r --
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... openbsd6.1 ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ar... /usr/bin/ar
checking for ranlib... /usr/bin/ranlib
checking for strip... /usr/bin/strip
checking for gcc option to accept ISO C99... -std=gnu99
checking if gcc -std=gnu99 supports -std=gnu99 -pedantic -Wno-unused-function -W
no-long-long -Wno-overlength-strings... yes
checking for __builtin_expect... yes
checking event2/event.h usability... no
checking event2/event.h presence... no
checking for event2/event.h... no
configure: error: libevent headers missing
root@btcvm:/root/libbtc-master:15#

root@btcvm:/root/libbtc-master:15# CPPFLAGS="-I /usr/local/include" ./configur>
checking build system type... x86_64-unknown-openbsd6.1
checking host system type... x86_64-unknown-openbsd6.1
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking how to print strings... print -r
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... no
checking how to convert x86_64-unknown-openbsd6.1 file names to x86_64-unknown-o
penbsd6.1 format... func_convert_file_noop
checking how to convert x86_64-unknown-openbsd6.1 file names to toolchain format
... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... match_pattern /lib[^/]+(\.so\.[
0-9]+\.[0-9]+|\.so|_pic\.a)$
checking for dlltool... no
checking how to associate runtime and link libraries... print -r --
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... openbsd6.1 ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ar... /usr/bin/ar
checking for ranlib... /usr/bin/ranlib
checking for strip... /usr/bin/strip
checking for gcc option to accept ISO C99... -std=gnu99
checking if gcc -std=gnu99 supports -std=gnu99 -pedantic -Wno-unused-function -W
no-long-long -Wno-overlength-strings... yes
checking for __builtin_expect... yes
checking event2/event.h usability... yes
checking event2/event.h presence... yes
checking for event2/event.h... yes
checking for main in -levent... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libbtc.pc
config.status: creating src/libbtc-config.h
config.status: executing depfiles commands
config.status: executing libtool commands
=== configuring in src/secp256k1 (/root/libbtc-master/src/secp256k1)
configure: running /bin/sh ./configure --disable-option-checking '--prefix=/usr/
local'  'CPPFLAGS=-I /usr/local/include' '--enable-module-recovery' --cache-file
=/dev/null --srcdir=.
checking build system type... x86_64-unknown-openbsd6.1
checking host system type... x86_64-unknown-openbsd6.1
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to print strings... print -r
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... no
checking how to convert x86_64-unknown-openbsd6.1 file names to x86_64-unknown-o
penbsd6.1 format... func_convert_file_noop
checking how to convert x86_64-unknown-openbsd6.1 file names to toolchain format
... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... match_pattern /lib[^/]+(\.so\.[
0-9]+\.[0-9]+|\.so|_pic\.a)$
checking for dlltool... no
checking how to associate runtime and link libraries... print -r --
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... openbsd6.1 ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether make supports nested variables... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ar... /usr/bin/ar
checking for ranlib... /usr/bin/ranlib
checking for strip... /usr/bin/strip
checking for gcc... gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... gcc3
checking if gcc supports -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-
externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-ov
erlength-strings... yes
checking if gcc supports -fvisibility=hidden... yes
checking for __int128... no
checking for __builtin_expect... yes
checking native compiler: gcc... ok
checking for x86_64 assembly availability... yes
checking gmp.h usability... no
checking gmp.h presence... no
checking for gmp.h... no
checking for CRYPTO... yes
checking for main in -lcrypto... yes
checking for EC functions in libcrypto... yes
checking for javac... no
configure: WARNING: cannot find JDK; try setting $JAVAC or $JAVA_HOME
checking jni headers... none
configure: WARNING: jni headers/dependencies not found. jni support disabled
checking whether byte ordering is bigendian... no
configure: Using static precomputation: yes
configure: Using assembly optimizations: x86_64
configure: Using field implementation: 32bit
configure: Using bignum implementation: no
configure: Using scalar implementation: 32bit
configure: Using endomorphism optimizations: no
configure: Building ECDH module: no
configure: Building Schnorr signatures module: no
configure: Building ECDSA pubkey recovery module: yes
configure: Using jni: no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libsecp256k1.pc
config.status: creating src/libsecp256k1-config.h
config.status: executing depfiles commands
config.status: executing libtool commands

Options used to compile and link:
  with wallet   = yes
  with tools    = yes
  with net      = yes

  target os     =

  CC            = gcc -std=gnu99
  CFLAGS        = -g -O2 -W -std=gnu99 -pedantic -Wno-unused-function -Wno-long-
long -Wno-overlength-strings
  CXX           =
  CXXFLAGS      =
  LDFLAGS       =

root@btcvm:/root/libbtc-master:16#


root@btcvm:/root/libbtc-master:16# make
  CC       src/libbtc_la-aes256_cbc.lo
  CC       src/libbtc_la-base58.lo
  CC       src/libbtc_la-bip32.lo
  CC       src/libbtc_la-block.lo
  CC       src/libbtc_la-buffer.lo
  CC       src/libbtc_la-chainparams.lo
  CC       src/libbtc_la-commontools.lo
  CC       src/libbtc_la-cstr.lo
  CC       src/libbtc_la-ctaes.lo
  CC       src/libbtc_la-ecc_key.lo
  CC       src/libbtc_la-ecc_libsecp256k1.lo
  CC       src/libbtc_la-memory.lo
  CC       src/libbtc_la-random.lo
  CC       src/libbtc_la-ripemd160.lo
  CC       src/libbtc_la-script.lo
  CC       src/libbtc_la-segwit_addr.lo
  CC       src/libbtc_la-serialize.lo
  CC       src/libbtc_la-sha2.lo
  CC       src/libbtc_la-tx.lo
  CC       src/libbtc_la-txref_code.lo
  CC       src/libbtc_la-utils.lo
  CC       src/libbtc_la-vector.lo
  CC       src/logdb/libbtc_la-logdb_core.lo
  CC       src/logdb/libbtc_la-logdb_memdb_llist.lo
  CC       src/logdb/libbtc_la-logdb_memdb_rbtree.lo
  CC       src/logdb/libbtc_la-logdb_rec.lo
  CC       src/logdb/libbtc_la-red_black_tree.lo
  CC       src/libbtc_la-wallet.lo
  CC       src/libbtc_la-headersdb_file.lo
  CC       src/libbtc_la-net.lo
  CC       src/libbtc_la-netspv.lo
  CC       src/libbtc_la-protocol.lo
build-aux/install-sh: not found
*** Error 1 in src/secp256k1 (Makefile:874 'src/.dirstamp': @build-aux/install-s
h -c -d src)
*** Error 1 in . (Makefile:2567 'src/secp256k1/libsecp256k1.la')
*** Error 1 in /root/libbtc-master (Makefile:1984 'all-recursive')
root@btcvm:/root/libbtc-master:17#

>> started again here with a fresh libbtc-master dir
>> installed g++ and gmake from ports/packages

root@btcvm:/root/libbtc-master:29# CPPFLAGS="-I /usr/local/include" CC=egcc CPP=ecpp ./configure                                                                                                                              
checking build system type... x86_64-unknown-openbsd6.1
checking host system type... x86_64-unknown-openbsd6.1
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... egcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether egcc accepts -g... yes
checking for egcc option to accept ISO C89... none needed
checking whether egcc understands -c and -o together... yes
checking dependency style of egcc... gcc3
checking how to run the C preprocessor... ecpp
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking how to print strings... print -r
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by egcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... no
checking how to convert x86_64-unknown-openbsd6.1 file names to x86_64-unknown-openbsd6.1 format... func_convert_file_noop
checking how to convert x86_64-unknown-openbsd6.1 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$
checking for dlltool... no
checking how to associate runtime and link libraries... print -r --
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from egcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if egcc supports -fno-rtti -fno-exceptions... no
checking for egcc option to produce PIC... -fPIC -DPIC
checking if egcc PIC flag -fPIC -DPIC works... yes
checking if egcc static flag -static works... yes
checking if egcc supports -c -o file.o... yes
checking if egcc supports -c -o file.o... (cached) yes
checking whether the egcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... openbsd6.1 ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ar... /usr/bin/ar
checking for ranlib... /usr/bin/ranlib
checking for strip... /usr/bin/strip
checking for egcc option to accept ISO C99... -std=gnu99
checking if egcc -std=gnu99 supports -std=gnu99 -pedantic -Wno-unused-function -Wno-long-long -Wno-overlength-strings... yes
checking for __builtin_expect... yes
checking event2/event.h usability... yes
checking event2/event.h presence... yes
checking for event2/event.h... yes
checking for main in -levent... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libbtc.pc
config.status: creating src/libbtc-config.h
config.status: executing depfiles commands
config.status: executing libtool commands
=== configuring in src/secp256k1 (/root/libbtc-master/src/secp256k1)
configure: running /bin/sh ./configure --disable-option-checking '--prefix=/usr/local'  'CC=egcc' 'CPPFLAGS=-I /usr/local/include' 'CPP=ecpp' '--enable-module-recovery' --cache-file=/dev/null --srcdir=.
checking build system type... x86_64-unknown-openbsd6.1
checking host system type... x86_64-unknown-openbsd6.1
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking how to print strings... print -r
checking for style of include used by make... GNU
checking for gcc... egcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether egcc accepts -g... yes
checking for egcc option to accept ISO C89... none needed
checking whether egcc understands -c and -o together... yes
checking dependency style of egcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by egcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... no
checking how to convert x86_64-unknown-openbsd6.1 file names to x86_64-unknown-openbsd6.1 format... func_convert_file_noop
checking how to convert x86_64-unknown-openbsd6.1 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$
checking for dlltool... no
checking how to associate runtime and link libraries... print -r --
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from egcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... ecpp
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if egcc supports -fno-rtti -fno-exceptions... no
checking for egcc option to produce PIC... -fPIC -DPIC
checking if egcc PIC flag -fPIC -DPIC works... yes
checking if egcc static flag -static works... yes
checking if egcc supports -c -o file.o... yes
checking if egcc supports -c -o file.o... (cached) yes
checking whether the egcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... openbsd6.1 ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether make supports nested variables... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ar... /usr/bin/ar
checking for ranlib... /usr/bin/ranlib
checking for strip... /usr/bin/strip
checking for gcc... gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking for egcc option to accept ISO C89... (cached) none needed
checking dependency style of egcc... gcc3
checking if egcc supports -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings... yes
checking if egcc supports -fvisibility=hidden... yes
checking for __int128... yes
checking for __builtin_expect... yes
checking native compiler: gcc... ok
checking for x86_64 assembly availability... yes
checking gmp.h usability... yes
checking gmp.h presence... yes
checking for gmp.h... yes
checking for __gmpz_init in -lgmp... yes
checking for CRYPTO... yes
checking for main in -lcrypto... yes
checking for EC functions in libcrypto... yes
checking for javac... no
configure: WARNING: cannot find JDK; try setting $JAVAC or $JAVA_HOME
checking jni headers... none
configure: WARNING: jni headers/dependencies not found. jni support disabled
checking whether byte ordering is bigendian... no
configure: Using static precomputation: yes
configure: Using assembly optimizations: x86_64
configure: Using field implementation: 64bit
configure: Using bignum implementation: gmp
configure: Using scalar implementation: 64bit
configure: Using endomorphism optimizations: no
configure: Building ECDH module: no
configure: Building Schnorr signatures module: no
configure: Building ECDSA pubkey recovery module: yes
configure: Using jni: no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libsecp256k1.pc
config.status: creating src/libsecp256k1-config.h
config.status: executing depfiles commands
config.status: executing libtool commands

Options used to compile and link:
  with wallet   = yes
  with tools    = yes
  with net      = yes

  target os     = 

  CC            = egcc -std=gnu99
  CFLAGS        = -g -O2 -W -std=gnu99 -pedantic -Wno-unused-function -Wno-long-long -Wno-overlength-strings
  CXX           = 
  CXXFLAGS      = 
  LDFLAGS       = 

root@btcvm:/root/libbtc-master:30# gmake
gmake[1]: Entering directory '/root/libbtc-master'
  CC       src/libbtc_la-aes256_cbc.lo
  CC       src/libbtc_la-base58.lo
  CC       src/libbtc_la-bip32.lo
  CC       src/libbtc_la-block.lo
  CC       src/libbtc_la-buffer.lo
  CC       src/libbtc_la-chainparams.lo
  CC       src/libbtc_la-commontools.lo
  CC       src/libbtc_la-cstr.lo
  CC       src/libbtc_la-ctaes.lo
  CC       src/libbtc_la-ecc_key.lo
  CC       src/libbtc_la-ecc_libsecp256k1.lo
  CC       src/libbtc_la-memory.lo
  CC       src/libbtc_la-random.lo
  CC       src/libbtc_la-ripemd160.lo
  CC       src/libbtc_la-script.lo
  CC       src/libbtc_la-segwit_addr.lo
  CC       src/libbtc_la-serialize.lo
  CC       src/libbtc_la-sha2.lo
  CC       src/libbtc_la-tx.lo
  CC       src/libbtc_la-txref_code.lo
  CC       src/libbtc_la-utils.lo
  CC       src/libbtc_la-vector.lo
  CC       src/logdb/libbtc_la-logdb_core.lo
  CC       src/logdb/libbtc_la-logdb_memdb_llist.lo
  CC       src/logdb/libbtc_la-logdb_memdb_rbtree.lo
  CC       src/logdb/libbtc_la-logdb_rec.lo
  CC       src/logdb/libbtc_la-red_black_tree.lo
  CC       src/libbtc_la-wallet.lo
  CC       src/libbtc_la-headersdb_file.lo
  CC       src/libbtc_la-net.lo
  CC       src/libbtc_la-netspv.lo
  CC       src/libbtc_la-protocol.lo
gmake[2]: Entering directory '/root/libbtc-master/src/secp256k1'
  CC       src/libsecp256k1_la-secp256k1.lo
  CCLD     libsecp256k1.la
gmake[2]: Leaving directory '/root/libbtc-master/src/secp256k1'
  CCLD     libbtc.la
  CC       src/tools/bitcointool-bitcointool.o
  CCLD     bitcointool
./.libs/libbtc.a(libbtc_la-utils.o): In function `btc_cheap_random_bytes':
src/utils.c:253: warning: warning: rand() may return deterministic values, is that what you want?
/usr/local/lib/libgmp.so.10.0: warning: warning: vsprintf() is often misused, please use vsnprintf()
  CC       src/tools/bitcoin_send_tx-bitcoin-send-tx.o
  CCLD     bitcoin-send-tx
./.libs/libbtc.a(libbtc_la-utils.o): In function `btc_cheap_random_bytes':
src/utils.c:253: warning: warning: rand() may return deterministic values, is that what you want?
/usr/local/lib/libgmp.so.10.0: warning: warning: vsprintf() is often misused, please use vsnprintf()
./.libs/libbtc.a(libbtc_la-net.o): In function `btc_get_peers_from_dns':
src/net.c:524: warning: warning: sprintf() is often misused, please use snprintf()
src/tools/bitcoin_send_tx-bitcoin-send-tx.o: In function `broadcast_handshake_done':
src/tools/bitcoin-send-tx.c:191: undefined reference to `evutil_inet_ntop'
./.libs/libbtc.a(libbtc_la-net.o): In function `btc_node_set_ipport':
net.c:(.text+0x319): undefined reference to `evutil_parse_sockaddr_port'
./.libs/libbtc.a(libbtc_la-net.o): In function `btc_node_release_events':
net.c:(.text+0x37d): undefined reference to `event_free'
./.libs/libbtc.a(libbtc_la-net.o): In function `btc_node_group_connect_next_nodes':
net.c:(.text+0x6a0): undefined reference to `bufferevent_socket_new'
net.c:(.text+0x6e3): undefined reference to `bufferevent_socket_connect'
net.c:(.text+0x727): undefined reference to `event_new'
./.libs/libbtc.a(libbtc_la-net.o): In function `read_cb':
net.c:(.text+0xe8e): undefined reference to `bufferevent_get_input'
net.c:(.text+0xe9e): undefined reference to `evbuffer_get_length'
net.c:(.text+0xefa): undefined reference to `evbuffer_copyout'
./.libs/libbtc.a(libbtc_la-net.o): In function `btc_get_peers_from_dns':
net.c:(.text+0x10e7): undefined reference to `evutil_getaddrinfo'
net.c:(.text+0x112d): undefined reference to `evutil_inet_ntop'
net.c:(.text+0x11b1): undefined reference to `evutil_inet_ntop'
net.c:(.text+0x11e6): undefined reference to `evutil_freeaddrinfo'
./.libs/libbtc.a(libbtc_la-net.o): In function `btc_node_group_add_peers_by_ip_or_seed':
net.c:(.text+0x12ff): undefined reference to `evutil_parse_sockaddr_port'
net.c:(.text+0x1401): undefined reference to `evutil_parse_sockaddr_port'
collect2: error: ld returned 1 exit status
gmake[1]: *** [Makefile:1082: bitcoin-send-tx] Error 1
gmake[1]: Leaving directory '/root/libbtc-master'
gmake: *** [Makefile:1959: all-recursive] Error 1
root@btcvm:/root/libbtc-master:31# 

p2pkh address do not correspond

Can someone help?
I have my Private key and a public key (1F4DcCRisdSckKP...). from a wallet for years.

When I do :
./bitcointool -c pubfrompriv -p
I get 12ADDdBkbrgWM....... and gives the amount to 0 in the blockchain transaction (https://www.blockchain.com/btc/address/12ADDdBkbrgWM............) because it does not correspond to the original (1F4DcCRisdSckKP...)

Is there a bug somewhere? why my PRIVKEY do not get the correct bitcoin address (or PUBKEY)?

Keep getting "exit status: 135" on "make check" step.

I am running ubuntu 18.04 and continually get "FAIL tests (exit status: 135)" being printed at random stages in the "make check" step each time I run it. I am seeing this in the "test-suite.log" file after running "make check" command. Here is just one example of output:

DEBUG :received command from node 4: inv
DEBUG :received command from node 2: inv
DEBUG :Statecheck: amount of connected nodes: 5
DEBUG :received command from node 4: inv
DEBUG :received command from node 8: headers
DEBUG :Got 2000 headers (took 0 s) from nodFAIL tests (exit status: 135)

I haven't been able to find what exit status 135 means (yet).

make check stucks

Hello! On ubuntu 18 build seems to be completed successfully, however, after i execute make check the only output is:
make[1]: Entering directory '/home/user/githubs/libbtc'
make check-TESTS
make[2]: Entering directory '/home/user/githubs/libbtc'
make[3]: Entering directory '/home/user/githubs/libbtc'

and then it freezes with blinking cursor, doesnt return to shell, nor shows any signs of life
(/home/user/githubs/libbtc is the folder to which i pulled the code)

Loading wallet failed

Run bitcoin-spv under macOS 10.15, when I run bitcoin-spv the second time, it failed with a wrong private key and an error message saying "Loading wallet failed".

this is the correct xpriv
xpriv: xprv9s21ZrQH143K2bPFpDfPLtYjq6DxzthDdwSRB8FmX67JgMm13Nehrvr8tVwDCGhsrajEPAm1dAChoYLXHmVCdFgoy7TePg9ehg7WddEmaDs

the following is the wrong one
xpriv: xprv9s21ZrQH143K2bPFpDfPLtYjq6DxzthDdwSRB8FmX67JgMm13Nehrvr8tVwDCGhsrajEPAm1dAChoYLXHmVCdFgoy7TePg9ehg7WddEmaDsd

so I corrected in wallet.c line 348

char strbuf[196];
memset(strbuf,0,196); // this line should be added.
if (!deser_varlen_from_file(&len, wallet->dbfile)) return false;

now it is ok to run bitcoin-spv any times.

warning: 'be16toh' macro redefined ... ld: error: undefined symbol: letoh16

/disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/portable_endian.h:52:9: warning: 'be16toh' macro redefined [-Wmacro-redefined]
#define be16toh(x) betoh16(x)
        ^
/usr/include/sys/endian.h:77:9: note: previous definition is here
#define be16toh(x)      bswap16((x))
        ^
In file included from /disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/test/net_tests.c:6:
In file included from /disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/serialize.h:34:
/disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/portable_endian.h:53:9: warning: 'le16toh' macro redefined [-Wmacro-redefined]
#define le16toh(x) letoh16(x)
        ^
/usr/include/sys/endian.h:80:9: note: previous definition is here
#define le16toh(x)      ((uint16_t)(x))
        ^
In file included from /disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/test/net_tests.c:6:
In file included from /disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/serialize.h:34:
/disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/portable_endian.h:55:9: warning: 'be32toh' macro redefined [-Wmacro-redefined]
#define be32toh(x) betoh32(x)
        ^
/usr/include/sys/endian.h:78:9: note: previous definition is here
#define be32toh(x)      bswap32((x))
        ^
In file included from /disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/test/net_tests.c:6:
In file included from /disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/serialize.h:34:
/disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/portable_endian.h:56:9: warning: 'le32toh' macro redefined [-Wmacro-redefined]
#define le32toh(x) letoh32(x)
        ^
/usr/include/sys/endian.h:81:9: note: previous definition is here
#define le32toh(x)      ((uint32_t)(x))
        ^
In file included from /disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/test/net_tests.c:6:
In file included from /disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/serialize.h:34:
/disk-samsung/freebsd-ports/finance/libbtc/work/libbtc-0793399/include/btc/portable_endian.h:58:9: warning: 'be64toh' macro redefined [-Wmacro-redefined]
#define be64toh(x) betoh64(x)
        ^
...
...
ld: error: undefined symbol: letoh16
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_u16) in archive libbtc.a
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_varlen) in archive libbtc.a
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_varlen_from_file) in archive libbtc.a
>>> referenced 3 more times

ld: error: undefined symbol: letoh32
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_s32) in archive libbtc.a
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_u32) in archive libbtc.a
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_varlen) in archive libbtc.a
>>> referenced 8 more times

ld: error: undefined symbol: letoh64
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_u64) in archive libbtc.a
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_varlen) in archive libbtc.a
>>> referenced by serialize.c
>>>               serialize.c.o:(deser_varlen_from_file) in archive libbtc.a
>>> referenced 4 more times

OS: FreeBSD 13

Example of creating/signing transaction?

Hi. I'm trying to create a "thin client" that is able to create and sign transactions, to be broadcasted by an external server (one of those "JSON blockchain browser" style servers). I have all the private keys in my client, and also the information from the inputs (also obtained from the external server), but I don't have the blockchain or network connection to other nodes. Are there any examples or documentation on how to do this? I'm having trouble finding how to do a couple of things:

  • I populate a "btc_tx_in" with a tx_outpoint, but where do I get the "script_sig" and the "sequence" values?
  • are the "btc_ecc_sign*" functions related with signing to create script_sig?
  • what about btc_tx_sighash() ?

Thanks!

Ariel.

Additional build notes needed for README.md

When I install this on a minimal Debian 8-based machine (chosen for more security as opposed to my normal Macintosh development environment) the short 3-step build instructions in the README.md are incomplete.

In my case I needed to also install some non-default development tools sudo apt-get install autoconf libtool libevent-dev. Quite possibly there are some other tools that are required but I installed previously. The README.md should probably list any toolchain dependencies.

Create relase tarball

Hi!
This would be really good to include into Solus but to do that I would need a stable tarball. Do you think that you could create one?

support for p2sh

Hello dear J!
i m interested in bitcoin on embedded device and your library looks great.
Does it support p2sh spend transactions?
Is there any documentation regarding how to create and sign transactions using libbtc?
Kind regards,

Is there some error in tx_test.c?

Although the example is not given in the "-h" of the program, I tried the "sign" command.
I think the "sign" command requires 6 parameters, txhex(-x), pkey(-p), scripthex(-s), inputindex(-i), amount(-a), sighashtype(-h).
I found a test case in tx_test.c, then I used the 6 variables in test_tx_sign_p2pkh for the sign command.
The complete command is ”./bitcointool -c sign -p cRpSdivawavdAPgEYGXusWt64cJG9zLcgDPsEvnhHWtizVtmGk5b -a 100000000 -x 02000000……8700000000 -s 76a9149b47fd7adc7a671ed059c9dcbf2eee2e882ea56b88ac -i 0 -h 1“
Return value shows ”Invalid wif privkey“.
Is there a problem with my usage?

Miscalculated NULL termination

In file utils.c, function utils_bin_to_hex(), the following line writes NULL in a memory location beyond the array bound, resulting in an Abort trap 6 error while running the tests.

hex_out[inlen * 2] = '\0'

The array's size should be incremented to include NULL termination.

Signing assertion

Got this in production:
tx.c:880: btc_tx_sign_input: Assertionsigderlen <= 74 && sigderlen >= 70' failed`

looks like assertion not always holds:
assert(sigderlen <= 74 && sigderlen >= 70);

I don't have testcase for it, but needs rethinking.

uncompressed private key wif

Hi, this library is very good library :)
why in btc_privkey_encode_wif() I see the comment "/* always use compressed keys */" and is not the uncompressed version available?
thank's

Maintenance Help Needed (was: Fork...?)

It doesn't look like this repository is being maintained any more.

There are many forks. Has anyone found a good one to support, or is anyone interested in offering one for maintenance until @jonasschnelli or @libbtc update this one? We could make PRs to move any important change requests towards a new fork.

Can I use this for other currencies?

Hi, I'm working on a system that needs to support multiple coins, can I use this to generate keys and transactions for currencies other than bitcoin? has it been tested on the ones that use the same address or transaction formats? (I only need to generate the address and sign transactions, the rest is provided by outside services, like a multi currency "light wallet" that connects to a blockchain explorer). thanks.

pubfrompriv wrong result?

Why the result of bitcointool -c pubfrompriv -p PRIV_KEY for both forms (Compressed/Uncompressed) shows always address in Compressed form?

Remove assert()

In C++ (at least), assert is not the identity function in release mode. It's simply not called at all. This ruined many things the program does, including generating private keys. This is very, very dangerous as it could generate invalid private keys.

fatal error: 'logdb/cstr.h' file not found

When compiling on a Mac (current El Capitan 10.11.6), ./configure results in this warning

=== configuring in src/logdb (/Users/ChristopherA/projects/libbtc/src/logdb)
configure: WARNING: no configuration information is in src/logdb

When doing make results in:

  CC       src/libbtc_la-block.lo
In file included from src/block.c:32:
In file included from ./include/btc/block.h:14:
./include/btc/hash.h:41:10: fatal error: 'logdb/cstr.h' file not found
#include <logdb/cstr.h>
         ^
1 error generated.
make[1]: *** [src/libbtc_la-block.lo] Error 1
make: *** [all-recursive] Error 1

Ripemd160 function is not `extern "C"`

I'm not sure whether this is intended or not, but the function ripemd160() in its header file doesn't have extern "C" declared, which causes name mangling problems. I can fix this myself, but I need to understand the intentions behind this, if any. What I'm using ripemd160 for is basically creating an address from a redeem script. This functionality doesn't seem to be available in libbtc without segwit.

libbtc for software wallet

Is it possible to use libbtc library in creating software wallets for Bitcoin? I plan to support my application with Bitcoin payment.

Support in bitcointool for function #94: Add support for recoverable signatures

@jonasschnelli — can you add support in bitcointool for your new recoverable signatures function? Input should should be the signature value that someone who might have received the a message from someone that did signmessagewithprivkey "privkey" "message" that the receiver could confirm with verifymessage "address" "signature" "message" (which I hope is the same format as named json value from the output of getrawtransaction).

I'm trying to give some other non-C developers a higher quality tool they can prototype with, and my C skills are quite dated and I don't want to give them my quite hacky code.

support for getting scriptPubKey

Hello, I think this is a good library, I can use this library to generate address and signature transactions.
But I don't know if you have the function of get scriptPubKey.
Privkey and scriptPubkey are required for signing transactions.
I can get privkey from your program, but scriptPubkey needs to be obtained from the bitcoind program.
My approach is this:
1 Get pubkey and privkey with bitcointool
2 bitcoin-cli importprivkey <privkey>
3 bitcoin-cli validateaddress <pubkey>
So that I can get scriptPubkey.
Do you have an easy way to get scriptPubkey?

GMP dependency (undefined reference "__gmpn_*")

It's possible I missed something, but the (very small) documentation claims the only dependency is libevent if the networking library is used. I noticed I had to link in libgmp (GMP) also to resolve _gmpn* undefined reference errors. Was there a misconfiguration on my part or was the documentation not accurate? Also the examples references "ecc_start()" and "ecc_stop()" functions but those functions appear to be defined as "btc_ecc_start()" and "btc_ecc_stop()". thanks

Unable to build libbtc.a

Hello Jonas,

First of all, thank you very much for your work. It is exactly what I want to use in my project.

Unfortunately, when I run the commands to build (http://libbtc.github.io/docs/guides/build-and-link/), I do obtain executable tools but not the library itself.

A libbtc.la file is generated but not the libbtc.a or .so I would need. Could you please advise?

Thank you in advance for your support!
Best regards,

0xD3adC0d3

Makefile.am:3: error: Libtool library used but 'LIBTOOL' is undefined

[root@btc libbtc]# ./autogen.sh
configure.ac:26: installing 'build-aux/compile'
configure.ac:5: installing 'build-aux/config.guess'
configure.ac:5: installing 'build-aux/config.sub'
configure.ac:9: installing 'build-aux/install-sh'
configure.ac:9: installing 'build-aux/missing'
Makefile.am:3: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:3: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:3: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:3: If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:3: its definition is in aclocal's search path.
Makefile.am: installing 'build-aux/depcomp'
parallel-tests: installing 'build-aux/test-driver'
autoreconf: automake failed with exit status: 1

in fresh centos 7 x64 system.,
i got this., error.

Wallet Test Fails, Segmentation Fault

(Repost from jonasschnelli/libbtc with minor adjustments.)

Bug Report

Built with ./autogen.sh && ./configure --enable-debug && make check.
Uncommented the wallet test in test/unittester.c, which was commented out for some reason in commit 9dda1cf9.

Running tests with ./tests:

PASSED - test_sha_256()
PASSED - test_sha_512()
PASSED - test_sha_hmac()
PASSED - test_utils()
PASSED - test_cstr()
PASSED - test_buffer()
PASSED - test_serialize()
PASSED - test_memory()
PASSED - test_random()
PASSED - test_bitcoin_hash()
PASSED - test_base58check()
PASSED - test_aes()
PASSED - test_bip32()
PASSED - test_ecc()
PASSED - test_vector()
PASSED - test_tx_serialization()
PASSED - test_invalid_tx_deser()
PASSED - test_tx_sign()
PASSED - test_tx_sighash()
PASSED - test_tx_sighash_ext()
PASSED - test_tx_negative_version()
PASSED - test_block_header()
PASSED - test_script_parse()
PASSED - test_script_op_codeseperator()
PASSED - test_eckey()
xpriv: xprv9uHRZZhk6KAJC1avXpDAp4MDc3sQKNxDiPvvkX8Br5ngLNv1TxvUxt4cV1rGL5hj6KCesnDYUhd7oWgT11eZG7XnxHrnYeSvkzY7d2bhkJ7
Segmentation fault (core dumped)

test-suite.log:

============================================================================
Testsuite summary for libbtc 0.1
============================================================================
# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See ./test-suite.log
Please report to https://github.com/jonasschnelli/libbtc/issues
============================================================================

System Info:
OS: Fedora 27, 64-Bit
uname -r: 4.15.15-300.fc27.x86_64
gdb version: GNU gdb (GDB) Fedora 8.0.1-36.fc27
glibc 2.26

Analysis

Running the tests program with gdb (gdb ./tests) yields the following stack trace:

#0  btc_wallet_free (wallet=0xdc9ab0) at src/wallet.c:245
#1  0x000000000040911a in test_wallet () at test/wallet_tests.c:36
#2  0x0000000000401ce6 in main () at test/unittester.c:117

After experimenting a bit, I found that after the insertion performed by tsearch, the left node pointer is 0x1, unlike the right one, which is 0x0.
This is because, as explained in a comment in misc/tsearch.c, if malloc returns aligned addresses, the lower bits of the left node's address are zero anyway and can be used to store whether the node is a red or a black one in the LSB. The definition of SETLEFT in that case, the macro used to set the left node's value, is defined as:

#define SETLEFT(N,L) (N)->left_node = (((N)->left_node & (uintptr_t) 0x1) \
| (uintptr_t)(L))

In btc_btree_tdestroy:63 in file include/btc/utils.h the tree is destroyed recursively, but the base case is r == 0, so if the node from the red-black tree is red, but has no children, this check might fail and the function could end up destroying a pointer with value 0x1, which has undefined behavior and might result in a segmentation fault, as it does in my case.

Solution

The easy fix is to check for r == 0 || (uintptr_t) r == 1 instead of just r == 0 and clearing the LSB of r afterwards, but then you rely on the implementation of tsearch. I would not write it like that.
(r == NULL seems cleaner to me anyway.)

I just discovered this comments:

/* support substitude for GNU only tdestroy */
/* Let's hope the node struct is always compatible */

With this patch, they introduced a compile-time switch, which, if possible, includes the color bit in the left node, rendering the r == 0 insufficient. If the compiler determines that this is not possible, because malloc returns unaligned addresses, a separate struct member to indicate whether the node is red or black. Either way, the code is not well-defined: either the check fails and it ends up trying to destroy the address 0x1, which is undefined, or your struct is not compatible because of the additional red/black flag, also rendering the code undefined.

The cleanest way would probably be to quit using tsearch and friends and rolling your own red-black tree implementation entirely. tsearch is only supposed to be, and can, in a clean, portable way, only be used together with the other functions of the <search.h> interface and if you opt against using the other functions, it does not make sense to use tsearch either, I think.

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.