Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details.

## [Unreleased]
- Fixed `create_tx --send_all` to reject multiple recipients instead of silently using only the first one
- Renamed the `bip322` feature to `message_signer`

## [3.0.0]

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dns_payment = ["bitcoin-payment-instructions"]

# Internal features
_payjoin-dependencies = ["payjoin", "reqwest", "url", "sqlite"]
bip322 = ["bdk_message_signer"]
message_signer = ["bdk_message_signer"]

# Use this to consensus verify transactions at sync time
verify = []
Expand Down
6 changes: 3 additions & 3 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! All subcommands are defined in the below enums.

#![allow(clippy::large_enum_variant)]
#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
use crate::handlers::offline::{SignMessageCommand, VerifyMessageCommand};
use crate::handlers::{
config::{ListWalletsCommand, SaveConfigCommand},
Expand Down Expand Up @@ -362,10 +362,10 @@ pub enum OfflineWalletSubCommand {
/// Combines multiple PSBTs into one.
CombinePsbt(CombinePsbtCommand),
/// Sign a message using BIP322
#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
SignMessage(SignMessageCommand),
/// Verify a BIP322 signature
#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
VerifyMessage(VerifyMessageCommand),
/// Lock UTXO(s) so they're excluded from coin selection.
LockUtxo(LockUtxoCommand),
Expand Down
5 changes: 3 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ pub enum BDKCliError {
#[cfg(feature = "payjoin")]
#[error("Payjoin database error: {0}")]
PayjoinDb(#[from] crate::handlers::payjoin::db::Error),
#[cfg(feature = "bip322")]

#[cfg(feature = "message_signer")]
#[error("BIP-322 error: {0}")]
Bip322Error(#[from] bdk_message_signer::error::Error),
MessageSignerError(#[from] bdk_message_signer::error::Error),
}

impl From<ExtractTxError> for BDKCliError {
Expand Down
14 changes: 7 additions & 7 deletions src/handlers/offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use {
bdk_wallet::keys::{DescriptorPublicKey, DescriptorSecretKey, SinglePubKey},
std::collections::HashMap,
};
#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
use {
crate::utils::parse_signature_format,
crate::utils::types::MessageResult,
Expand Down Expand Up @@ -73,11 +73,11 @@ impl OfflineWalletSubCommand {
Self::CombinePsbt(combine_psbt_command) => combine_psbt_command
.execute(ctx)?
.write_out(std::io::stdout()),
#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
Self::SignMessage(sign_message_command) => sign_message_command
.execute(ctx)?
.write_out(std::io::stdout()),
#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
Self::VerifyMessage(verify_message_command) => verify_message_command
.execute(ctx)?
.write_out(std::io::stdout()),
Expand Down Expand Up @@ -773,7 +773,7 @@ impl AppCommand<AppContext<OfflineOperations<'_>>> for CombinePsbtCommand {
}
}

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
#[derive(Debug, Parser, Clone, PartialEq)]
pub struct SignMessageCommand {
/// The message to sign
Expand All @@ -793,7 +793,7 @@ pub struct SignMessageCommand {
pub utxos: Option<Vec<OutPoint>>,
}

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
impl AppCommand<AppContext<OfflineOperations<'_>>> for SignMessageCommand {
type Output = MessageResult;

Expand Down Expand Up @@ -823,7 +823,7 @@ impl AppCommand<AppContext<OfflineOperations<'_>>> for SignMessageCommand {
}
}

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
#[derive(Debug, Parser, Clone, PartialEq)]
pub struct VerifyMessageCommand {
/// The signature proof to verify
Expand All @@ -839,7 +839,7 @@ pub struct VerifyMessageCommand {
pub address: String,
}

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
impl AppCommand<AppContext<OfflineOperations<'_>>> for VerifyMessageCommand {
type Output = MessageResult;

Expand Down
8 changes: 4 additions & 4 deletions src/utils/common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{commands::WalletOpts, config::WalletConfig, error::BDKCliError as Error};
#[cfg(feature = "cbf")]
use bdk_kyoto::{Info, Receiver, UnboundedReceiver, Warning};
#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
use bdk_message_signer::SignatureFormat;
#[cfg(feature = "silent-payments")]
use bdk_sp::encoding::SilentPaymentCode;
Expand Down Expand Up @@ -198,7 +198,7 @@ pub(crate) fn parse_sp_code_value_pairs(s: &str) -> Result<(SilentPaymentCode, u
}

/// Function to parse the signature format from a string
#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
pub(crate) fn parse_signature_format(format_str: &str) -> Result<SignatureFormat, Error> {
match format_str.to_lowercase().as_str() {
"legacy" => Ok(SignatureFormat::Legacy),
Expand Down Expand Up @@ -232,10 +232,10 @@ pub fn command_requires_db(command: &OfflineWalletSubCommand) -> bool {
| OfflineWalletSubCommand::FinalizePsbt(_)
| OfflineWalletSubCommand::CombinePsbt(_) => false,

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
OfflineWalletSubCommand::SignMessage(_) => true,

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
OfflineWalletSubCommand::VerifyMessage(_) => true,
#[cfg(feature = "silent-payments")]
OfflineWalletSubCommand::CreateSpTx(_) => true,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct KeychainPair<T> {
pub internal: T,
}

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
#[derive(Serialize, Debug, Default)]
pub struct MessageResult {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod test_offline {
.stderr(predicate::str::contains("Invalid"));
}

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
#[test]
fn test_sign_message_and_verify_message() {
let (cli, mut cmd_init) = setup_wallet_config();
Expand Down Expand Up @@ -216,7 +216,7 @@ mod test_offline {
.stdout(predicate::str::contains("\"valid\": true"));
}

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
#[test]
fn test_verify_message_rejects_tampered_message() {
let (cli, mut cmd_init) = setup_wallet_config();
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ mod test_online {
}
}

#[cfg(feature = "bip322")]
#[cfg(feature = "message_signer")]
#[test]
fn test_verify_message_proof_of_funds_uses_persisted_utxos() {
let env = TestEnv::new().expect("Failed to start bdk_testenv");
Expand Down
Loading