Skip to content

Commit 72656ec

Browse files
committed
feat: integrate BIP 353 dns payment instructions
1 parent 1dc41d0 commit 72656ec

File tree

7 files changed

+478
-5
lines changed

7 files changed

+478
-5
lines changed

Cargo.lock

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ shlex = { version = "1.3.0", optional = true }
3737
payjoin = { version = "=1.0.0-rc.1", features = ["v1", "v2", "io", "_test-utils"], optional = true}
3838
reqwest = { version = "0.13.2", default-features = false, optional = true }
3939
url = { version = "2.5.8", optional = true }
40+
bitcoin-payment-instructions = { version = "0.7.0", optional = true}
4041

4142
[features]
4243
default = ["repl", "sqlite"]
@@ -52,7 +53,8 @@ redb = ["bdk_redb"]
5253
cbf = ["bdk_kyoto", "_payjoin-dependencies"]
5354
electrum = ["bdk_electrum", "_payjoin-dependencies"]
5455
esplora = ["bdk_esplora", "_payjoin-dependencies"]
55-
rpc = ["bdk_bitcoind_rpc", "_payjoin-dependencies"]
56+
rpc = ["bdk_bitcoind_rpc", "_payjoin-dependencies"]
57+
dns_payment = ["bitcoin-payment-instructions"]
5658

5759
# Internal features
5860
_payjoin-dependencies = ["payjoin", "reqwest", "url"]

src/commands.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
//! All subcommands are defined in the below enums.
1414
1515
#![allow(clippy::large_enum_variant)]
16+
1617
use bdk_wallet::bitcoin::{
1718
Address, Network, OutPoint, ScriptBuf,
1819
bip32::{DerivationPath, Xpriv},
1920
};
2021
use clap::{Args, Parser, Subcommand, ValueEnum, value_parser};
2122
use clap_complete::Shell;
2223

24+
#[cfg(feature = "dns_payment")]
25+
use crate::utils::parse_dns_recipient;
2326
#[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))]
2427
use crate::utils::parse_proxy_auth;
2528
use crate::utils::{parse_address, parse_outpoint, parse_recipient};
@@ -182,6 +185,16 @@ pub enum CliSubCommand {
182185
#[arg(value_enum)]
183186
shell: Shell,
184187
},
188+
189+
#[cfg(feature = "dns_payment")]
190+
/// Resolves BIP-353 DNS payment instructions for a human-readable name.
191+
ResolveDnsRecipient {
192+
/// Human-readable name (e.g. user@domain.com)
193+
hrn: String,
194+
/// DNS resolver address
195+
#[arg(long, default_value = "8.8.8.8")]
196+
resolver: String,
197+
},
185198
}
186199

187200
/// Wallet operation subcommands.
@@ -354,6 +367,14 @@ pub enum OfflineWalletSubCommand {
354367
// Address and amount parsing is done at run time in handler function.
355368
#[arg(env = "ADDRESS:SAT", long = "to", required = true, value_parser = parse_recipient)]
356369
recipients: Vec<(ScriptBuf, u64)>,
370+
#[cfg(feature = "dns_payment")]
371+
/// Adds DNS recipients to the transaction
372+
#[arg(long = "to_dns", value_parser = parse_dns_recipient)]
373+
dns_recipients: Vec<(String, u64)>,
374+
#[cfg(feature = "dns_payment")]
375+
/// Custom resolver DNS IP to be used for resolution.
376+
#[arg(long = "dns_resolver", default_value = "8.8.8.8:53")]
377+
dns_resolver: String,
357378
/// Sends all the funds (or all the selected utxos). Requires only one recipient with value 0.
358379
#[arg(long = "send_all", short = 'a')]
359380
send_all: bool,

0 commit comments

Comments
 (0)