Skip to content

Commit d85feec

Browse files
committed
fix: rename BIP322 commands, validate address ownership before signing and add Bip322Error variant
1 parent 7c9542c commit d85feec

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

.github/workflows/audit.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@ name: Audit
33
on:
44
push:
55
paths:
6-
# Run if workflow changes
7-
- '.github/workflows/audit.yml'
8-
# Run on changed dependencies
96
- '**/Cargo.toml'
107
- '**/Cargo.lock'
11-
# Run if the configuration file changes
12-
- '**/audit.toml'
138
schedule:
149
- cron: '0 0 * * 0' # Once per week
15-
# Run manually
16-
workflow_dispatch:
1710

1811
jobs:
1912

src/commands.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ pub enum OfflineWalletSubCommand {
407407
},
408408
/// Sign a message using BIP322
409409
#[cfg(feature = "bip322")]
410-
SignBip322 {
410+
SignMessage {
411411
/// The message to sign
412412
#[arg(long)]
413413
message: String,
@@ -422,7 +422,7 @@ pub enum OfflineWalletSubCommand {
422422
},
423423
/// Verify a BIP322 signature
424424
#[cfg(feature = "bip322")]
425-
VerifyBip322 {
425+
VerifyMessage {
426426
/// The signature proof to verify
427427
#[arg(long)]
428428
proof: String,

src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ pub enum BDKCliError {
140140
#[cfg(feature = "payjoin")]
141141
#[error("Payjoin create request error: {0}")]
142142
PayjoinCreateRequest(#[from] payjoin::send::v2::CreateRequestError),
143+
144+
#[cfg(feature = "bip322")]
145+
#[error("BIP-322 error: {0}")]
146+
Bip322Error(#[from] bdk_bip322::error::Error),
143147
}
144148

145149
impl From<ExtractTxError> for BDKCliError {

src/handlers.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ pub fn handle_offline_wallet_subcommand(
597597
)?)
598598
}
599599
#[cfg(feature = "bip322")]
600-
SignBip322 {
600+
SignMessage {
601601
message,
602602
signature_type,
603603
address,
@@ -606,16 +606,20 @@ pub fn handle_offline_wallet_subcommand(
606606
let address: Address = parse_address(&address)?;
607607
let signature_format = parse_signature_format(&signature_type)?;
608608

609-
let proof: Bip322Proof = wallet
610-
.sign_bip322(message.as_str(), signature_format, &address, utxos)
611-
.map_err(|e| {
612-
BDKCliError::Generic(format!("Failed to sign BIP-322 message: {e}"))
613-
})?;
609+
if !wallet.is_mine(address.script_pubkey()) {
610+
return Err(Error::Generic(format!(
611+
"Address {} does not belong to this wallet.",
612+
address
613+
)));
614+
}
615+
616+
let proof: Bip322Proof =
617+
wallet.sign_bip322(message.as_str(), signature_format, &address, utxos)?;
614618

615619
Ok(json!({"proof": proof.to_base64()}).to_string())
616620
}
617621
#[cfg(feature = "bip322")]
618-
VerifyBip322 {
622+
VerifyMessage {
619623
proof,
620624
message,
621625
signature_type,

0 commit comments

Comments
 (0)