bitcoindevkit / bdk-cli

A CLI wallet library and REPL tool to demo and test the BDK library
Other
111 stars 65 forks source link

Error - Failed to compile bdk-cli #101

Closed nourou4them closed 2 years ago

nourou4them commented 2 years ago

Describe the bug
I tried to install the binaries on my machine by running the following command:

cargo install --git https://github.com/bitcoindevkit/bdk-cli --features=electrum,compiler

Then, I encountered the following error message:

Updating git repository `https://github.com/bitcoindevkit/bdk-cli`
  Installing bdk-cli v0.5.0 (https://github.com/bitcoindevkit/bdk-cli#80260e1d)
    Updating crates.io index
  Downloaded instant v0.1.12
  Downloaded getrandom v0.1.16
  Downloaded itoa v1.0.2
  Downloaded lock_api v0.4.7
  Downloaded once_cell v1.12.0
  Downloaded base64 v0.10.1
  Downloaded proc-macro-error-attr v1.0.4
  Downloaded structopt v0.3.26
  Downloaded ansi_term v0.12.1
  Downloaded bech32 v0.8.1
  Downloaded cc v1.0.73
  Downloaded fs2 v0.4.3
  Downloaded dirs-sys-next v0.1.2
  Downloaded dirs-next v2.0.0
  Downloaded memchr v2.5.0
  Downloaded parking_lot v0.11.2
  Downloaded quote v1.0.20
  Downloaded scopeguard v1.1.0
  Downloaded rand_core v0.5.1
  Downloaded rand_chacha v0.2.2
  Downloaded smallvec v1.8.0
  Downloaded serde_derive v1.0.137
  Downloaded rand v0.7.3
  Downloaded unicode-segmentation v1.9.0
  Downloaded rand_core v0.4.2
  Downloaded unicode-ident v1.0.1
  Downloaded textwrap v0.11.0
  Downloaded strsim v0.8.0
  Downloaded zeroize v1.3.0
  Downloaded nix v0.22.3
  Downloaded log v0.4.17
  Downloaded proc-macro-error v1.0.4
  Downloaded pin-project-lite v0.2.9
  Downloaded sct v0.6.1
  Downloaded ryu v1.0.10
  Downloaded serde_json v1.0.81
  Downloaded utf8parse v0.2.0
  Downloaded socks v0.3.4
  Downloaded crc32fast v1.3.2
  Downloaded memoffset v0.6.5
  Downloaded spin v0.5.2
  Downloaded version_check v0.9.4
  Downloaded untrusted v0.7.1
  Downloaded termcolor v1.1.3
  Downloaded webpki v0.21.4
  Downloaded clap v2.34.0
  Downloaded aho-corasick v0.7.18
  Downloaded proc-macro2 v1.0.40
  Downloaded env_logger v0.7.1
  Downloaded syn v1.0.98
  Downloaded base64-compat v1.0.0
  Downloaded webpki-roots v0.19.0
  Downloaded miniscript v6.1.0
  Downloaded parking_lot_core v0.8.5
  Downloaded autocfg v1.1.0
  Downloaded crossbeam-utils v0.8.9
  Downloaded unicode-normalization v0.1.9
  Downloaded crossbeam-epoch v0.9.9
  Downloaded unicode-width v0.1.9
  Downloaded atty v0.2.14
  Downloaded byteorder v1.4.3
  Downloaded lazy_static v1.4.0
  Downloaded structopt-derive v0.4.18
  Downloaded serde v1.0.137
  Downloaded ppv-lite86 v0.2.16
  Downloaded nibble_vec v0.1.0
  Downloaded humantime v1.3.0
  Downloaded heck v0.3.3
  Downloaded fd-lock v3.0.2
  Downloaded endian-type v0.1.2
  Downloaded cfg-if v1.0.0
  Downloaded bitflags v1.3.2
  Downloaded smallvec v0.6.14
  Downloaded regex v1.5.6
  Downloaded radix_trie v0.2.1
  Downloaded rustyline v9.0.0
  Downloaded base64 v0.11.0
  Downloaded bitcoin_hashes v0.9.7
  Downloaded electrum-client v0.8.0
  Downloaded secp256k1 v0.20.3
  Downloaded vec_map v0.8.2
  Downloaded fxhash v0.2.1
  Downloaded bdk-macros v0.6.0
  Downloaded sled v0.34.7
  Downloaded secp256k1-sys v0.4.2
  Downloaded quick-error v1.2.3
  Downloaded rustls v0.16.0
  Downloaded libc v0.2.126
  Downloaded bitcoin v0.27.1
  Downloaded tokio v1.14.1
  Downloaded regex-syntax v0.6.26
  Downloaded bip39 v1.0.1
  Downloaded bitcoin_hashes v0.10.0
  Downloaded maybe-uninit v2.0.0
  Downloaded bdk v0.18.0
  Downloaded ring v0.16.20
  Downloaded 96 crates (12.3 MB) in 0.95s (largest was `ring` at 5.1 MB)
   Compiling libc v0.2.126
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.40
   Compiling unicode-ident v1.0.1
   Compiling quote v1.0.20
   Compiling autocfg v1.1.0
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile `quote` due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `proc-macro2` due to previous error
error: could not compile `libc` due to previous error
error: failed to compile `bdk-cli v0.5.0 (https://github.com/bitcoindevkit/bdk-cli#80260e1d)`, intermediate artifacts can be found at `/tmp/cargo-installebWrRC`

To Reproduce

cargo install --git https://github.com/bitcoindevkit/bdk-cli --features=electrum,compiler

or

cargo install bdk-cli --features electrum

Expected behavior
I expected a clean installation and compiling, and then being able to run bdk-cli.

Build environment

Additional context
I tried first to run this installation command, with Fulcrum as a feature an then received an error message:

~$ cargo install --git https://github.com/bitcoindevkit/bdk-cli --features=fulcrum,compiler
    Updating git repository `https://github.com/bitcoindevkit/bdk-cli`
  Installing bdk-cli v0.5.0 (https://github.com/bitcoindevkit/bdk-cli#80260e1d)
error: failed to compile `bdk-cli v0.5.0 (https://github.com/bitcoindevkit/bdk-cli#80260e1d)`, intermediate artifacts can be found at `/tmp/cargo-installQZEW56`

Caused by:
  Package `bdk-cli v0.5.0 (/home/ubuntu/.cargo/git/checkouts/bdk-cli-7ad4595d2026f0f8/80260e1)` does not have the feature `fulcrum`

After some researchs, I have found that fulcrum was not part of the features:

At most one blockchain feature can be enabled, available blockchain client features are: electrum, esplora-ureq (blocking), esplora-reqwest (async), compact_filters and rpc.

afilini commented 2 years ago

You need a C compiler installed because bdk uses the secp256k1 cryptographic library, which is written in C. On Ubuntu you can probably install just gcc using apt, or even better you can install build-essentials which contains a few packages useful for building C code. See: https://linuxhint.com/install-build-essential-ubuntu/

For the missing feature issue you should keep in mind that fulcrum (like electrumx and electrs) implements the electrum protocol. So bdk only has one feature called "electrum" which can be used with all these different server implementations.

afilini commented 2 years ago

I'm also moving this issue to the bdk-cli repo since it's related to installing that tool, not just the main rust library.

nourou4them commented 2 years ago

Thank you. Installing gcc made it work.

Now I am stuck at the sync step. I have followed this 4 videos series and replicated all the steps, on testnet, even receiving and sending a transaction.

Now, I wanted to add my flucrum server by launching this command :

bdk-cli wallet --descriptor "wpkh(descriptor_numbers)" --server ssl://domain_name:50002 sync

I can see that it tried to connect to the server but there is then the following error messages:

Notice that the domain has a valid certificate and I didn't add the derivation path, otherwise, I would have this error : bdk_cli] Descriptor(Miniscript(Unexpected("Error while parsing simple public key")))

Thanks for your help.

afilini commented 2 years ago

Notice that the domain has a valid certificate

It's a self signed certificate though, right? Those are a bit harder to get working, I would suggest you start by just using a plain tcp connection and then move to ssl once you are more familiar with it.

I would have this error : bdk_cli] Descriptor(Miniscript(Unexpected("Error while parsing simple public key")))

This is a completely unrelated error but it's hard to debug without seeing the full descriptor. I'm guessing maybe you tried adding a derivation path to a raw public key, which doesn't make sense. Derivation paths are applied to extended keys to derive raw single keys, if you already have a raw key (starts with 02, 03 or 04 in hex) then you don't need a path at all

nourou4them commented 2 years ago

It's a self signed certificate though, right? Those are a bit harder to get working, I would suggest you start by just using a plain tcp connection and then move to ssl once you are more familiar with it.

Ok I will try that.

This is a completely unrelated error but it's hard to debug without seeing the full descriptor. I'm guessing maybe you tried adding a derivation path to a raw public key, which doesn't make sense. Derivation paths are applied to extended keys to derive raw single keys, if you already have a raw key (starts with 02, 03 or 04 in hex) then you don't need a path at all

Yes you are right. I made the mistake of using the pub key derivation path found on an address. Your explanation led me to remove the derivation path and I just parsed the xpub like "wpkh(xpub)". And it works this time, using just a main() function inside a new cargo projetct. It seems like the bdk-cli only use the testnet for now while I needed the mainnet.

Thanks a lot.

nourou4them commented 2 years ago

So, I tried using the plain tcp connection to sync with the server but I have an error. Just created issue #639 on the bdk repo.

nourou4them commented 2 years ago

Update: Using the bdk, I managed to sync by accessing to my server via a tcp connection, like you advised. Thanks. I am closing this issue.