Giter Site home page Giter Site logo

rust-wallet's People

Contributors

dspicher avatar erasmospunk avatar kiminuo avatar krocon avatar kylezs avatar serejkaaa512 avatar stevenroose avatar tamasblummer avatar tcharding avatar thebluematt 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

rust-wallet's Issues

Taproot

Do this package handle taproot sig?

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

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

No longer maintaned

This repo is no longer maintained:

 BlueMatt[m]> Right, rust-wallet isn’t maintained anymore, but bdk is way more than a wallet.

The README.md should probably be updated accordingly so people know not to use this repo or contribute changes.

Bumps [chart.js](https://github.com/chartjs/Chart.js) from 2.9.3 to 2.9.4.

Bumps chart.js from 2.9.3 to 2.9.4.

Release notes

Sourced from chart.js's releases.

v2.9.4

This is the last release of v2 and focused on fixing bugs identified in the v2.9.3 release.

Bugs Fixed

  • #7404 - Preserve prototypes when cloning. Thanks @​iddings
  • #7587 - Fix docs for external moment.js. Thanks @​mojoaxel
  • #7853 - Fix box recursion when dimensions are NaN. Thanks @​alessandroasm
  • #7883 - Fix call stack exception when computing label sizes. Thanks @​silentmatt
  • #7918 - Prevent global prototype pollution via the merge helper
  • #7920 - Use Object.create(null) as merge target, to prevent prototype pollution
Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

Originally posted by @dependabot in velas/JsWalletDesktop#11

Shares converted to mnemonic form intermittently fail to recombine

Roughly half the time shares are generated and converted to their mnemonic representation, they recombine yielding an incorrect result. Here's some sample code to demonstrate the issue:

use bitcoin_wallet::{
    account::Seed,
    error::Error,
    sss::{ShamirSecretSharing, Share},
};

pub fn split(data: &[u8; 32], scheme: &[(u8,u8)]) -> Result<Vec<Share>, Error>
{
    let seed = Seed(data.to_vec());
    ShamirSecretSharing::generate(1, scheme, &seed, None, 1)
}

pub fn combine(shares: &[Share]) -> Result<Vec<u8>, Error>
{
    let seed = ShamirSecretSharing::combine(shares, None)?;
    Ok(seed.0)
}

#[cfg(test)]
mod unit
{
    use super::*;
    use rand::RngCore;

    #[test]
    pub fn sss_roundtrip_internal()
    {
        let mut data = [0u8;32];
        rand::thread_rng().fill_bytes(&mut data);

        let shares = split(&data, &[(2,3)])
            .unwrap();

        let r1 = combine(&shares[..2])
            .unwrap();
        let r2 = combine(&shares[1..3])
            .unwrap();

        assert_eq!(data, &r1[..]);
        assert_eq!(data, &r2[..]);
    }

    #[test]
    pub fn sss_roundtrip_mnemonic()
    {
        let mut data = [0u8;32];
        rand::thread_rng().fill_bytes(&mut data);

        let shares = split(&data, &[(2,3)])
            .unwrap();

        let mnemonics = shares.iter()
            .map(|s| s.to_mnemonic())
            .collect::<Vec<_>>();

        let internals = mnemonics.iter()
            .map(|i| Share::from_mnemonic(&i).unwrap())
            .collect::<Vec<_>>();

        let r1 = combine(&internals[..2])
            .unwrap();
        let r2 = combine(&internals[1..3])
            .unwrap();

        assert_eq!(data, &r1[..]);
        assert_eq!(data, &r2[..]);
    }
}

The sss_roundtrip_internal test never fails, however, the sss_roundtrip_mnemonic test fails intermittently.
Here is some example output (6 success, 3 failure):

% cargo test --package adi
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

% cargo test --project adi
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

% cargo test --package adi
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

% cargo test --package adi
    Finished test [unoptimized + debuginfo] target(s) in 0.02s
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

% cargo test --package adi
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

% cargo test --package adi
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... FAILED

failures:

---- unit::sss_roundtrip_mnemonic stdout ----
thread 'unit::sss_roundtrip_mnemonic' panicked at 'assertion failed: `(left == right)`
  left: `[124, 73, 15, 220, 128, 78, 234, 135, 187, 43, 221, 55, 182, 237, 162, 30, 228, 106, 239, 61, 254, 176, 109, 129, 196, 216, 125, 68, 29, 164, 26, 12]`,
 right: `[14, 153, 8, 23, 69, 184, 201, 116, 216, 126, 136, 164, 120, 231, 52, 206, 176, 198, 221, 190, 86, 44, 196, 53, 6, 169, 139, 77, 47, 5, 189, 198]`', adi/src/lib.rs:99:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    unit::sss_roundtrip_mnemonic

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '-p adi --lib'

% cargo test --package adi
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... FAILED

failures:

---- unit::sss_roundtrip_mnemonic stdout ----
thread 'unit::sss_roundtrip_mnemonic' panicked at 'assertion failed: `(left == right)`
  left: `[190, 184, 191, 130, 17, 80, 154, 245, 204, 38, 145, 178, 106, 235, 87, 21, 79, 57, 239, 33, 35, 99, 180, 148, 143, 242, 250, 8, 226, 203, 232, 151]`,
 right: `[126, 235, 37, 157, 73, 41, 228, 71, 35, 159, 119, 113, 31, 108, 153, 163, 222, 33, 161, 108, 235, 50, 177, 174, 110, 163, 75, 247, 206, 13, 175, 47]`', adi/src/lib.rs:99:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    unit::sss_roundtrip_mnemonic

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '-p adi --lib'

% cargo test --package adi
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... FAILED

failures:

---- unit::sss_roundtrip_mnemonic stdout ----
thread 'unit::sss_roundtrip_mnemonic' panicked at 'assertion failed: `(left == right)`
  left: `[58, 163, 196, 91, 115, 103, 154, 106, 255, 85, 132, 34, 13, 81, 78, 242, 205, 110, 161, 167, 125, 160, 250, 101, 8, 138, 14, 84, 28, 209, 89, 139]`,
 right: `[53, 177, 175, 17, 73, 175, 133, 126, 176, 228, 193, 159, 230, 250, 18, 149, 167, 153, 147, 83, 235, 134, 41, 235, 50, 15, 44, 50, 87, 226, 247, 207]`', adi/src/lib.rs:99:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    unit::sss_roundtrip_mnemonic

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '-p adi --lib'

% cargo test --package adi
     Running target/debug/deps/adi-d0276c4a348266c4

running 2 tests
test unit::sss_roundtrip_internal ... ok
test unit::sss_roundtrip_mnemonic ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

I've been poking around a little. I notice the to_mnemonic function is not actually tested in sss.rs. The from_mnemonic function is tested to correctly parse the TREZOR test vectors, and a roundtrip is tested using the internal Share representation, however there does not appear to be any code that tests converting shares to their mnemonic form. This leads me to suspect an issue with the encoding process. I started combing the code to see if anything jumps out, but would love some help (:

Serde serialization is not used

Crate serde and serde features for bitcoin and bitcoin_hashes are used, however there is no code implementing any of the serde traits. Was it assumed to be created later?

Can't use library for WASM target compilation

Hi guys,

Sorry if this is not quite well structured of an issue; I'm just getting started with WASM in Rust.

So here is what is happening in my tests:

  1. I managed to use the library very easily in a test binary crate, producing mnemonics and such (so I know I'm using the crate correctly)
  2. I can produce a test WASM package (no bitcoin at this point) that I then use in a React app and it works fine as well (so I also know that I can target WASM and make it work in a web app)
  3. But as soon as I add bitcoin-wallet = "1.0.1" to my dependencies for the WASM library, I get this error when compiling:
wasm-pack build
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
   Compiling rustc-serialize v0.3.24
   Compiling secp256k1 v0.15.5
error: failed to run custom build command for `secp256k1 v0.15.5`

Caused by:
  process didn't exit successfully: `/home/username/sandbox/hello-wasm/lib/target/release/build/secp256k1-19305e1eee13d225/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-Wall" "-Wextra" "-DSECP256K1_BUILD=1" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DENABLE_MODULE_ECDH=1" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-DECMULT_WINDOW_SIZE=15" "-DUSE_FIELD_10X26=1" "-DUSE_SCALAR_8X32=1" "-o" "/home/grizzly/sandbox/hello-wasm/lib/target/wasm32-unknown-unknown/release/build/secp256k1-08b329539d811319/out/depend/secp256k1/contrib/lax_der_parsing.o" "-c" "depend/secp256k1/contrib/lax_der_parsing.c"

--- stderr


error occurred: Failed to find tool. Is `clang` installed?



warning: build failed, waiting for other jobs to finish...
error[E0046]: not all trait items implemented, missing: `encode`
    --> /home/username/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.24/src/serialize.rs:1358:1
     |
853  |     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error>;
     |     ---------------------------------------------------------------- `encode` from trait
...
1358 | impl Encodable for path::Path {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `encode` in implementation

error[E0046]: not all trait items implemented, missing: `decode`
    --> /home/username/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.24/src/serialize.rs:1382:1
     |
904  |     fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>;
     |     ----------------------------------------------------------- `decode` from trait
...
1382 | impl Decodable for path::PathBuf {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `decode` in implementation

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0046`.
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
  full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

Any ideas what I might be doing wrong or what is happening here?

Sign P2WSH

The function Account::sign() has a comment above stating that it doesn't work for P2WSH. But this is exactly what I need.
I can try to implement this, but I would need some guidance.
The first problem that I have is that the find() in accounts.rs line 652 does not find the matching instance.
I replicated the comparison in a unit test on my side:
`
assert_eq!(
Address::from_script(&spend.script_pubkey, Network::Bitcoin).unwrap().to_string(),
Address::p2sh(&instantiated[0].script_code, Network::Bitcoin).to_string()
);

    assert_eq!(
        spend.script_pubkey,
        instantiated[0].address.script_pubkey()
    );

`
This is where I struggle already. How should the find in accounts.rs be modified?

`no_std` support

Hello,

I'm attemting to build the library for an embedded environment. Are there plans to support no_std as a target?

rust-bitcoin and rand already support no_std. rust-crypto is the only dependency that does not support no_std. rust-crypto's last commit is in 2016. It seems like it's not in active development anymore. However, in DaGenix/rust-crypto#405 someone mentions @RustCrypto as a successor. The RustCrypto crates are still in active development and have no_std support

From looking at the code, I gather these are the encryption algorithms used. RustCrypto has an implementation for all of them.

rust-crypto RustCrypto no_std Repo
HMAC ✔️ ✔️ https://github.com/RustCrypto/MACs
SHA256 ✔️ ✔️ https://github.com/RustCrypto/hashes/
SHA512 ✔️ ✔️ https://github.com/RustCrypto/hashes/
PBKDF2 ✔️ ✔️ https://github.com/RustCrypto/password-hashes/
AES ✔️ ✔️ https://github.com/RustCrypto/block-ciphers

Is this something the @rust-bitcoin team would be interested in? If so, I could submit multiple pr's slowly replacing rust-crypto with the @RustCrypto crates.

bip39 integration

I try to integrate current codebase with initial bip39 implementation. I want to know if I correctly understood bip39 implementation

Create Wallet:

  1. generate random string
  2. apply aes::decrypt to it with sha2(passphrase) as a key and create mnenonic from it
  3. generate seed from mnemonic
  4. generate master key from seed

Decrypt Wallet:

  1. generated random string was saved in DB as a plain text(during CreateWallet section).
  2. user inputs passpharse
  3. apply 2, 3, 4 items from CreateWallet section

RestoreWallet from mnemonic(means database was lost or damaged):

  1. user inputs mnemonic
  2. apply 3, 4 items from CreateWallet section

@tamasblummer do you agree with it?

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.