Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 118 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "artimonist"
version = "1.6.2"
version = "1.7.0"
edition = "2024"

description = "A tool for generating mnemonics and wallets."
Expand All @@ -21,14 +21,13 @@ testnet = ["artimonist/testnet"]


[dependencies]
artimonist = { version = "1.3.1" }
clap = { version = "^4.5.28", features = ["derive"] }
inquire = { version = "^0.7.5", default-features = false, features = ["crossterm"] }
comfy-table = { version = "^7.1.4", default-features = false }
bip38 = "1.1.1"
thiserror = "2.0.11"
anyhow = "1.0.98"
unicode-normalization = "0.1.24"
artimonist = { version = "1.5" }
clap = { version = "^4.5", features = ["derive"] }
inquire = { version = "^0.7", default-features = false, features = ["crossterm"] }
comfy-table = { version = "^7.1", default-features = false }
thiserror = "2"
anyhow = "1"
unicode-normalization = "0.1"

[profile.release]
codegen-units = 1
Expand All @@ -37,5 +36,5 @@ opt-level = "z"
strip = true

[dev-dependencies]
assert_cmd = "2.0.16"
predicates = "3.1.3"
assert_cmd = "2"
predicates = "3"
10 changes: 4 additions & 6 deletions src/bip32/execute.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::arg::{MasterKey, inquire_derive_path};
use crate::Execute;
use crate::utils::{bip38_encrypt, inquire_password};
use artimonist::bitcoin;
use artimonist::bitcoin::bip32::DerivationPath;
use artimonist::{BIP39, Xpriv, Xpub, bitcoin::Address};
use crate::{Execute, utils::inquire_password};
use artimonist::bitcoin::{self, Address, bip32::DerivationPath};
use artimonist::{BIP38, BIP39, Xpriv, Xpub};
use std::io::Write;

impl Execute for super::arg::Bip32Command {
Expand Down Expand Up @@ -42,7 +40,7 @@ fn derive_xprv(master: &Xpriv, path: &DerivationPath, password: &str) -> anyhow:
writeln!(f, "Extended public key: {xpub}")?;

let (pub_key, priv_wif) = (xpub.to_pub(), xprv.to_priv().to_string());
writeln!(f, "Private key: {}", bip38_encrypt(&priv_wif, password)?)?;
writeln!(f, "Private key: {}", priv_wif.bip38_encrypt(password)?)?;
writeln!(f, "Public key: {pub_key}")?;

let network = artimonist::bitcoin::Network::Bitcoin;
Expand Down
7 changes: 3 additions & 4 deletions src/derive/execute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::{DeriveCommand, arg::MasterKey, multisig::MultiSig};
use crate::Execute;
use crate::utils::{bip38_encrypt, inquire_password};
use artimonist::{BIP39, Xpriv};
use crate::{Execute, utils::inquire_password};
use artimonist::{BIP38, BIP39, Xpriv};
use std::io::{BufWriter, Write};

impl Execute for DeriveCommand {
Expand Down Expand Up @@ -58,7 +57,7 @@ impl Wallet for DeriveCommand {
for index in self.index..self.index + self.amount {
let (addr, pk) = self.derive.wallet(master, self.account, index)?;
let path = format!("{}/0/{index}", self.derive.path(self.account));
writeln!(f, "[{path}]: {addr}, {}", bip38_encrypt(&pk, password)?)?;
writeln!(f, "[{path}]: {addr}, {}", pk.bip38_encrypt(password)?)?;
}
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions src/diagram/output.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::DiagramCommand;
use crate::utils::{bip38_encrypt, unicode_encode};
use crate::utils::unicode_encode;
use anyhow::anyhow;
use artimonist::{BIP85, ComplexDiagram, GenericDiagram, Matrix, SimpleDiagram, Xpriv};
use artimonist::{BIP38, BIP85, ComplexDiagram, GenericDiagram, Matrix, SimpleDiagram, Xpriv};
use std::io::{BufWriter, Write};
use unicode_normalization::UnicodeNormalization;

Expand Down Expand Up @@ -93,7 +93,7 @@ impl<D: GenericDiagram> DeriveTargets for DiagramCommand<D> {
writeln!(f, "Wifs: ")?;
for index in self.index..self.index + self.amount {
let artimonist::Wif { addr, pk } = master.bip85_wif(index)?;
writeln!(f, "({index}): {addr}, {}", bip38_encrypt(&pk, password)?)?;
writeln!(f, "({index}): {addr}, {}", pk.bip38_encrypt(password)?)?;
}
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions src/encrypt/bip38.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{EncryptCommand, arg::EncryptSource};
use crate::utils::{bip38_decrypt, bip38_encrypt};
use crate::{Execute, utils::inquire_password};
use anyhow::anyhow;
use artimonist::BIP38;
use std::fs::File;
use std::io::{BufRead, BufReader, BufWriter, Write};

Expand All @@ -20,9 +20,9 @@ impl<const ENCRYPT: bool> Execute for EncryptCommand<ENCRYPT> {
match &self.source {
EncryptSource::Key(key) => {
if ENCRYPT {
println!("Encrypted private key: {}", bip38_encrypt(key, &password)?);
println!("Encrypted private key: {}", key.bip38_encrypt(&password)?);
} else {
println!("Decrypted private key: {}", bip38_decrypt(key, &password)?);
println!("Decrypted private key: {}", key.bip38_decrypt(&password)?);
}
}
EncryptSource::File(file) => {
Expand All @@ -45,9 +45,9 @@ fn execute_bulk<const ENCRYPT: bool>(file: &str, password: &str) -> anyhow::Resu
.split_ascii_whitespace()
.map(|s| {
if ENCRYPT && s.is_private() {
bip38_encrypt(s, password).unwrap_or(s.to_string())
s.bip38_encrypt(password).unwrap_or(s.to_string())
} else if s.is_encrypted() {
bip38_decrypt(s, password).unwrap_or(s.to_string())
s.bip38_decrypt(password).unwrap_or(s.to_string())
} else {
s.to_string()
}
Expand Down
18 changes: 0 additions & 18 deletions src/utils/bip38.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
mod bip38;
mod inquire;
mod unicode;

pub use bip38::{bip38_decrypt, bip38_encrypt};
pub use inquire::{inquire_password, select_language};
pub use unicode::{unicode_decode, unicode_encode};
6 changes: 3 additions & 3 deletions tests/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ macro_rules! cli_test_error {
#[test]
fn test_encrypt_error() {
cli_test_error!(
"Error: invalid wif private key",
"Error: Invalid WIF: decoded base58 data was an invalid length",
"encrypt",
"6PYPVwvgux4mN96iwj1RGvbiGmmPWpkiQimpkP1fvFGGhT38XxZed6Kdth"
);
cli_test_error!(
"Error: invalid encrypted private key",
"Error: Invalid BIP38 encrypted key",
"decrypt",
"KyyXeMvCn36KuedmVX727NYQ35YEeF4z1ZjXGyqgFpmZM4AcY8ay"
);
cli_test_error!(
"Error: invalid checksum",
"Error: Base58 error: incorrect checksum",
"decrypt",
"6PYPVwvgux4mN96iwj1RGvbiGmmPWpkiQimpkP1fvFGGhT38XxZed6Kdt1"
);
Expand Down