rust-bitcoin / rust-wallet Goto Github PK
View Code? Open in Web Editor NEW*archived* Library for a Bitcoin Wallet
License: Apache License 2.0
*archived* Library for a Bitcoin Wallet
License: Apache License 2.0
Do this package handle taproot sig?
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
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.
...aka let's setup Travis for this repo
To reproduce: cargo +1.22.0 build
Bumps chart.js from 2.9.3 to 2.9.4.
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
9bd4cf8
Release v2.9.41d92605
Use Object.create(null) as merge
target (#7920)dff7140
When objects are merged together, the target prototype can be polluted. (#7918)d919188
Bump verison number to v2.9.442ed589
Fix Maximum call stack size exception in computeLabelSizes (#7883)063b7dc
[2.9] FitBoxes recursion when dimensions are NaN (#7853)2493cb5
Use node v12.18.2 on Travis CI (#7864)679ec4a
docs: fix rollup external moment (#7587)484f0d1
Preserve object prototypes when cloning (#7404)2df6986
Look for any branch starting with release (#7087) (#7089)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
.
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 languageYou can disable automated security fix PRs for this repo from the Security Alerts page.
Originally posted by @dependabot in velas/JsWalletDesktop#11
The birth
field in defined in https://github.com/rust-bitcoin/rust-wallet/blob/master/src/account.rs#L66 presumably stores the timestamp of the master key creation, however it is nowhere used outside of the MasterAccount
and there is nothing in Bitcoin specs that defines it's usage. Should it be removed?
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 (:
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?
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:
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?
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?
Tag line contains:
#rust-bitcoin on freenode
This is stale, probably should be updated to say librechat
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.
I try to integrate current codebase with initial bip39 implementation. I want to know if I correctly understood bip39 implementation
Create Wallet:
Decrypt Wallet:
RestoreWallet from mnemonic(means database was lost or damaged):
@tamasblummer do you agree with it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.