bitcoindevkit / bdk

A modern, lightweight, descriptor-based wallet library written in Rust!
Other
860 stars 307 forks source link

compiler errors when declaring bdk as a dependency #124

Closed ulrichard closed 4 years ago

ulrichard commented 4 years ago

As soon as I add one of the following lines to the Cargo.toml file of my project, I get the following errors:

bdk = { package="magical",  git = "https://github.com/bitcoindevkit/bdk", tag = "0.1.0-beta.1" 
bdk = { git = "https://github.com/bitcoindevkit/bdk", branch = "master" }
Compiling bdk v0.1.0 (https://github.com/bitcoindevkit/bdk#56bcbc4a)                                                                                                          
error[E0432]: unresolved imports `miniscript::descriptor::DescriptorPublicKey`, `miniscript::descriptor::DescriptorXKey`, `miniscript::descriptor::InnerXKey`                    
  --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/descriptor/mod.rs:40:30                                                                                  
   |                                                                                                                                                                             
40 | use miniscript::descriptor::{DescriptorPublicKey, DescriptorXKey, InnerXKey};                                                                                               
   |                              ^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^  ^^^^^^^^^ no `InnerXKey` in `descriptor`                                                                  
   |                              |                    |                                                                                                                         
   |                              |                    no `DescriptorXKey` in `descriptor`                                                                                       
   |                              |                    help: a similar name exists in the module: `Descriptor`                                                                   
   |                              no `DescriptorPublicKey` in `descriptor`                                                                                                       

error[E0432]: unresolved import `miniscript::descriptor::KeyMap`                                                                                                                 
  --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/descriptor/mod.rs:42:5                                                                                   
   |                                                                                                                                                                             
42 |     descriptor::KeyMap, Descriptor, Legacy, Miniscript, MiniscriptKey, ScriptContext, Segwitv0,                                                                             
   |     ^^^^^^^^^^^^^^^^^^ no `KeyMap` in `descriptor`                                                                                                                          

error[E0432]: unresolved import `miniscript::descriptor::DescriptorPublicKey`                                                                                                    
  --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/descriptor/policy.rs:58:5                                                                                
   |                                                                                                                                                                             
58 | use miniscript::descriptor::DescriptorPublicKey;                                                                                                                            
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `DescriptorPublicKey` in `descriptor`                                                                                    

error[E0432]: unresolved imports `miniscript::descriptor::DescriptorPublicKey`, `miniscript::descriptor::DescriptorSecretKey`                                                    
  --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/keys/mod.rs:35:34
   |                                                                                                                                                                             
35 | pub use miniscript::descriptor::{DescriptorPublicKey, DescriptorSecretKey};                                                                                                 
   |                                  ^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^ no `DescriptorSecretKey` in `descriptor`
   |                                  |
   |                                  no `DescriptorPublicKey` in `descriptor`

error[E0432]: unresolved imports `miniscript::descriptor::DescriptorXKey`, `miniscript::descriptor::KeyMap`
  --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/keys/mod.rs:36:30
   |
36 | use miniscript::descriptor::{DescriptorXKey, KeyMap};
   |                              ^^^^^^^^^^^^^^  ^^^^^^ no `KeyMap` in `descriptor`
   |                              |
   |                              no `DescriptorXKey` in `descriptor`
   |                              help: a similar name exists in the module: `Descriptor`

error[E0432]: unresolved import `miniscript::descriptor::DescriptorPublicKey`
  --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/wallet/mod.rs:40:5
   |
40 | use miniscript::descriptor::DescriptorPublicKey;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `DescriptorPublicKey` in `descriptor`

error[E0432]: unresolved imports `miniscript::descriptor::DescriptorPublicKey`, `miniscript::descriptor::DescriptorSecretKey`, `miniscript::descriptor::DescriptorXKey`, `minisc$
ipt::descriptor::KeyMap`
   --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/wallet/signer.rs:105:30
    |
105 | use miniscript::descriptor::{DescriptorPublicKey, DescriptorSecretKey, DescriptorXKey, KeyMap};
    |                              ^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^  ^^^^^^ no `KeyMap` in `descriptor`
    |                              |                    |                    |
    |                              |                    |                    no `DescriptorXKey` in `descriptor`
    |                              |                    |                    help: a similar name exists in the module: `Descriptor`
    |                              |                    no `DescriptorSecretKey` in `descriptor`
    |                              no `DescriptorPublicKey` in `descriptor`

error[E0433]: failed to resolve: could not find `SigHashCache` in `bip143`
   --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/wallet/signer.rs:507:21
    |
507 |             bip143::SigHashCache::new(&psbt.global.unsigned_tx).signature_hash(
    |                     ^^^^^^^^^^^^ could not find `SigHashCache` in `bip143`

error[E0412]: cannot find type `DescriptorPublicKey` in module `$crate::miniscript::descriptor`
  --> /home/richi/.cargo/git/checkouts/bdk-bbcd84aeefa047ed/56bcbc4/src/descriptor/dsl.rs:48:57
   |
48 |                         $crate::miniscript::descriptor::DescriptorPublicKey,
   |                                                         ^^^^^^^^^^^^^^^^^^^ not found in `$crate::miniscript::descriptor`
afilini commented 4 years ago

I think this is because older versions used to depend on a specific branch of our rust-miniscript fork. That was a dumb mistake of mine, because when you push changes to that branch, your old code won't compile anymore, and that's probably what happened here.

We switched to rev-based dependency "pinning", which instead uses the hash of a commit, so that even if you push new changes to a specific branch (as long as those commits exist in your tree) everything will compile fine.

I don't think there's really a way to fix that, I would just suggest to use master or pin it to one of the most recent commits instead of the 0.1.0-beta.1 tag. We are also working on a new tagged release that should be ready pretty soon, if you prefer to wait for that.

ulrichard commented 4 years ago

Hi Alekos, thanks for the quick response. With your suggestion to use master, you mean that I use the third line (second option) of my issue above in my Cargo.toml? The errors above are from exactly this configuration.

afilini commented 4 years ago

Oh right, I didn't notice the second line. I thought you were using the old tag.

That's definitely an issue then, I'll try to work on that today.

afilini commented 4 years ago

Can you try adding this to your Cargo.toml and see if it fixes it?

[patch.crates-io]
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin/", rev = "478e091" }
miniscript = { git = "https://github.com/MagicalBitcoin/rust-miniscript", rev = "d0322ac" }
ulrichard commented 4 years ago

This would help with the errors in bdk, but leads to errors in other dependencies that also depend on rust-bitcoin.

afilini commented 4 years ago

Yes, that would be expected. I changed the way we declare the bitcoin and miniscript dependencies in #123, together with the update to rust-bitcoin 0.25. I'm expecting to merge this very soon, afterwards you will be able to use master with no errors.