Skip to content

Including the latest rust-wallet and rust-bitcoin as dependencies causes errors #25

Open
@chris-belcher

Description

@chris-belcher
extern crate bitcoin_wallet;                                                    
use bitcoin_wallet::account::MasterAccount;                                     
use bitcoin_wallet::mnemonic;                                                   
                                                                                
extern crate bitcoin;                                                           
use bitcoin::Network;                                                           
                                                                                
fn main() {                                                                     
    const SEED_PHRASE: &str =                                                   
"great rice pitch bitter stay crash among position disease enable sell road";   
    const EXTENSION: &str = "helloworld";                                       
    const PASSPHRASE: &str = "";                                                
                                                                                
    let _master = MasterAccount::from_mnemonic(                                 
        &mnemonic::Mnemonic::from_str(SEED_PHRASE).unwrap(),                    
        0,                                                                      
        Network::Regtest,                                                       
        PASSPHRASE,                                                             
        Some(EXTENSION)                                                         
    ).unwrap();                                                                 
}     
[package]                                                                       
name = "deps-rust-bitcoin"                                                      
version = "0.1.0"                                                               
authors = ["chris-belcher <[email protected]>"]            
edition = "2018"                                                                
                                                                                
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
                                                                                
[dependencies]                                                                  
bitcoin-wallet = "1.1.0"                                                        
bitcoin = "0.25"

The resulting error:

$ cargo check
    Checking deps-rust-bitcoin v0.1.0 (/home/user/coding/rust/projects/deps-rust-bitcoin)
error[E0308]: mismatched types
  --> src/main.rs:17:9
   |
17 |         Network::Regtest,
   |         ^^^^^^^^^^^^^^^^ expected enum `bitcoin::network::constants::Network`, found enum `bitcoin::Network`
   |
   = note: perhaps two different versions of crate `bitcoin` are being used?

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `deps-rust-bitcoin`.

To learn more, run the command again with --verbose.

Changing the line in Cargo.toml to bitcoin = "0.21" make the code correctly compile, however then you're missing the latest updates of rust-bitcoin. Anything bitcoin = "0.22" or above results in the same error.

What's going on here? (I'm slightly new to rust so would appreciate a explanation) How to fix or work around this?

I've noticed when searching github that everyone actually uses bitcoin = "0.21" in combination with rust-wallet
https://github.com/search?l=&p=2&q=bitcoin-wallet+filename%3ACargo.toml+fork%3Atrue&ref=advsearch&type=Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions