Skip to content

Commit

Permalink
chore: refactor crates and module structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 30, 2023
1 parent 8f4fc47 commit 929f5ca
Show file tree
Hide file tree
Showing 20 changed files with 1,435 additions and 197 deletions.
1,390 changes: 1,259 additions & 131 deletions Cargo.lock

Large diffs are not rendered by default.

43 changes: 33 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,54 @@
[package]
name = "bp-wallet"
[workspace]
members = ["std", "invoice", "psbt", "esplora", "."]
exclude = ["legacy", "convert"]

[workspace.package]
version = "0.11.0"
description = "Modern, minimalistic & standard-compliant cold wallet library"
keywords = ["bitcoin", "wallet", "descriptor-wallet", "psbt", "taproot"]
categories = ["cryptography::cryptocurrencies"]
readme = "README.md"
authors = ["Dr Maxim Orlovsky <orlovsky@lnp-bp.org>"]
homepage = "https://lnp-bp.org"
repository = "https://github.com/BP-WG/bp-wallet"
rust-version = "1.60" # Due to rust-amplify
edition = "2021"
license = "Apache-2.0"

[lib]
name = "bp"

[dependencies]
[workspace.dependencies]
amplify = "4.0.0"
bitcoin_hashes = "0.12.0"
bech32 = "0.9.1"
bp-primitives = "0.10.6"
serde_crate = { package = "serde", version = "1", features = ["derive"], optional = true }
serde_crate = { package = "serde", version = "1", features = ["derive"] }

[package]
name = "bp-wallet"
version = { workspace = true }
description = "Modern, minimalistic & standard-compliant cold wallet library"
keywords = { workspace = true }
categories = { workspace = true }
readme = "README.md"
authors = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }

[lib]
name = "bp"

[[bin]]
name = "bp"

[dependencies]
amplify = { workspace = true }
bp-std = { path = "std" }
serde_crate = { workspace = true, optional = true }

[features]
default = []
all = ["serde"]
serde = ["serde_crate", "bp-primitives/serde"]
serde = ["serde_crate", "bp-std/serde"]

[patch.crates-io]
bp-primitives = { git = "https://github.com/BP-WG/bp-core", branch = "primitives" }
15 changes: 15 additions & 0 deletions invoice/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "bp-invoice"
version = { workspace = true }
description = "Invoces with Bitcoin protocol"
keywords = { workspace = true }
categories = { workspace = true }
readme = "../README.md"
authors = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }

[dependencies]
14 changes: 14 additions & 0 deletions invoice/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
15 changes: 15 additions & 0 deletions psbt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "psbt"
version = { workspace = true }
description = "Modern, minimalistic & standard-compliant PSBT library"
keywords = { workspace = true }
categories = { workspace = true }
readme = "../README.md"
authors = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }

[dependencies]
14 changes: 14 additions & 0 deletions psbt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
1 change: 1 addition & 0 deletions src/bin/bp/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
56 changes: 0 additions & 56 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,56 +0,0 @@
// Modern, minimalistic & standard-compliant cold wallet library.
//
// SPDX-License-Identifier: Apache-2.0
//
// Written in 2020-2023 by
// Dr Maxim Orlovsky <orlovsky@lnp-bp.org>
//
// Copyright (C) 2020-2023 LNP/BP Standards Association. All rights reserved.
// Copyright (C) 2020-2023 Dr Maxim Orlovsky. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[macro_use]
extern crate amplify;
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde_crate as serde;
pub extern crate bitcoin_hashes as hashes;

mod base58;
mod index;
mod path;
mod key;
mod xpub;
mod descriptors;
mod address;
mod derive;
mod chain;
mod wallet;

pub use address::{
Address, AddressNetwork, AddressParseError, AddressPayload, AddressType, PubkeyHash,
ScriptHash, WPubkeyHash, WScriptHash,
};
pub use bc::{secp256k1, *};
pub use chain::{AddrInfo, BlockInfo, MiningInfo, TxInInfo, TxInfo, TxOutInfo, TxStatus, UtxoInfo};
pub use derive::{Derive, DeriveCompr, DeriveXOnly};
pub use descriptors::TrKey;
pub use index::{
DerivationIndex, HardenedIndex, Idx, IndexError, IndexParseError, NormalIndex,
HARDENED_INDEX_BOUNDARY,
};
pub use key::{ComprPubkey, LegacyPubkey, TaprootPubkey, UncomprPubkey};
pub use path::{DerivationParseError, DerivationPath};
pub use wallet::{Wallet, WalletCache, WalletData, WalletDescr};
pub use xpub::{Xpub, XpubDescriptor, XpubFp, XpubId, XpubMeta};
28 changes: 28 additions & 0 deletions std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "bp-std"
version = { workspace = true }
description = "Modern, minimalistic & standard-compliant cold wallet library"
keywords = { workspace = true }
categories = { workspace = true }
readme = "../README.md"
authors = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }

[lib]
name = "bp"

[dependencies]
amplify = { workspace = true }
bitcoin_hashes = "0.12.0"
bech32 = { workspace = true }
bp-primitives = { workspace = true }
serde_crate = { workspace = true, optional = true }

[features]
default = []
all = ["serde"]
serde = ["serde_crate", "bp-primitives/serde"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions std/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Modern, minimalistic & standard-compliant cold wallet library.
//
// SPDX-License-Identifier: Apache-2.0
//
// Written in 2020-2023 by
// Dr Maxim Orlovsky <orlovsky@lnp-bp.org>
//
// Copyright (C) 2020-2023 LNP/BP Standards Association. All rights reserved.
// Copyright (C) 2020-2023 Dr Maxim Orlovsky. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[macro_use]
extern crate amplify;
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde_crate as serde;
pub extern crate bitcoin_hashes as hashes;

mod base58;
mod index;
mod path;
mod key;
mod xpub;
mod descriptors;
mod address;
mod derive;
mod chain;
mod wallet;

pub use address::{
Address, AddressNetwork, AddressParseError, AddressPayload, AddressType, PubkeyHash,
ScriptHash, WPubkeyHash, WScriptHash,
};
pub use bc::{secp256k1, *};
pub use chain::{AddrInfo, BlockInfo, MiningInfo, TxInInfo, TxInfo, TxOutInfo, TxStatus, UtxoInfo};
pub use derive::{Derive, DeriveCompr, DeriveXOnly};
pub use descriptors::TrKey;
pub use index::{
DerivationIndex, HardenedIndex, Idx, IndexError, IndexParseError, NormalIndex,
HARDENED_INDEX_BOUNDARY,
};
pub use key::{ComprPubkey, LegacyPubkey, TaprootPubkey, UncomprPubkey};
pub use path::{DerivationParseError, DerivationPath};
pub use wallet::{Wallet, WalletCache, WalletData, WalletDescr};
pub use xpub::{Xpub, XpubDescriptor, XpubFp, XpubId, XpubMeta};
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 929f5ca

Please sign in to comment.