feat: add BIP353 DNS payment instructions#236
feat: add BIP353 DNS payment instructions#236sdmg15 wants to merge 1 commit intobitcoindevkit:masterfrom
Conversation
ba3c713 to
a0f3e9d
Compare
|
@sdmg15 Hi! Could you make it compile? |
49154f3 to
baf349b
Compare
Pull Request Test Coverage Report for Build 21818410493Details
💛 - Coveralls |
baf349b to
0e9756e
Compare
|
@va-an Thanks for taking a look. I think it should be resolved now. |
0e9756e to
6724be5
Compare
6724be5 to
20ef094
Compare
20ef094 to
977534a
Compare
977534a to
4852673
Compare
|
|
||
| #[cfg(feature = "dns_payment")] | ||
| /// Parse dns recipients in the form "test@me.com:10000" from cli input | ||
| pub(crate) fn parse_dns_recipients(s: &str) -> Result<(String, u64), String> { |
There was a problem hiding this comment.
It would be better to rename it to parse_dns_recipient, because the function parses one recipient at a time.
| pub fn display(&self, pretty: bool) -> Result<String, Error> { | ||
| let mut methods: Vec<String> = Vec::new(); | ||
| self.payment_methods.iter().for_each(|pm| match pm { |
There was a problem hiding this comment.
It looks like you forgot to run cargo fmt 🙂 , please do so.
| #[cfg(feature = "dns_payment")] | ||
| /// Resolves the given hrn payment instructions | ||
| ResolveDnsRecipient { hrn: String , resolver: Option<String>}, |
There was a problem hiding this comment.
| #[cfg(feature = "dns_payment")] | |
| /// Resolves the given hrn payment instructions | |
| ResolveDnsRecipient { hrn: String , resolver: Option<String>}, | |
| #[cfg(feature = "dns_payment")] | |
| /// Resolves BIP-353 DNS payment instructions for a human-readable name. | |
| ResolveDnsRecipient { | |
| /// Human-readable name (e.g. user@domain.com) | |
| hrn: String, | |
| /// DNS resolver address | |
| #[arg(long, default_value = "8.8.8.8")] | |
| resolver: String, | |
| }, |
This will make --help more useful:
-> % cargo run --all-features -- -n bitcoin resolve_dns_recipient --help
Resolves BIP-353 DNS payment instructions for a human-readable name
Usage: bdk-cli resolve_dns_recipient [OPTIONS] <HRN>
Arguments:
<HRN> Human-readable name (e.g. user@domain.com)
Options:
--resolver <RESOLVER> DNS resolver address [default: 8.8.8.8]
--pretty Output results in pretty format (instead of JSON)
-h, --help Print helpPlease note that the type for the resolver has changed.
See the suggested changes in the function itself.
|
|
||
| let mut ip_address = "8.8.8.8:53".to_string(); | ||
| if let Some(res_addr) = resolver_ip { | ||
| ip_address = res_addr; | ||
| } |
There was a problem hiding this comment.
| let mut ip_address = "8.8.8.8:53".to_string(); | |
| if let Some(res_addr) = resolver_ip { | |
| ip_address = res_addr; | |
| } | |
| let ip_address = if resolver_ip.contains(':') { | |
| resolver_ip | |
| } else { | |
| format!("{resolver_ip}:53") | |
| }; |
Please note that resolver_ip should be passed to this function as a String (not Option<String>), because we added a default_value in commands.rs, as proposed here.
Also, in this suggestion I slightly changed the semantics — the user can provide an IP without a port (port 53 will be used), or with a port (the user-specified port will be used). In the vast majority of cases, a DNS server uses the standard port, so we can simplify this a bit for the user.
The error message when creating DNSHrnResolver needs to be updated, since the user may provide an invalid value and receive a confusing "Should not fail" error.
Description
This PR adds support for BIP353 payment instructions.
The following notable changes are done:
resolve_dns_recipientwhich receives a Human Readable Name (HRN) and returns the associated addresscreate_txfor it to support user specifying recipients asHRN.Notes to the reviewers
Here is a list of HRN that could be used to test the implementation:
bdk-cli -n bitcoin resolve_dns_recipient send.some@satsto.mebdk-cli -n bitcoin wallet -w regtest_default_wallet create_tx --to "bcrt1qe497k549sgw9trzym50tdlegq3xx4apjqynjqm:1000" --to_dns "send.some@satsto.me:5000"Changelog notice
resolve_dns_recipientto resolve the DNS payment instructions--to_dnstocreate_txcommand to allow sending to a Human Readable Name (HRN)Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features:
CHANGELOG.md