(
plugin: Plugin<()>,
hrn: &HumanReadableName,
)
| 134 | } |
| 135 | |
| 136 | async fn fetch_payment_instructions( |
| 137 | plugin: Plugin<()>, |
| 138 | hrn: &HumanReadableName, |
| 139 | ) -> Result<PaymentInstructions, anyhow::Error> { |
| 140 | let hrn_resolver = match get_proxy(plugin) { |
| 141 | Some(proxy_info) => { |
| 142 | let proxy = reqwest::Proxy::all(format!( |
| 143 | "socks5h://{}:{}", |
| 144 | proxy_info.address, proxy_info.port |
| 145 | ))?; |
| 146 | let client = reqwest::Client::builder() |
| 147 | .proxy(proxy) |
| 148 | .timeout(Duration::from_secs(30)) |
| 149 | .build()?; |
| 150 | HTTPHrnResolver::with_client(client) |
| 151 | } |
| 152 | None => HTTPHrnResolver::new(), |
| 153 | }; |
| 154 | |
| 155 | log::debug!( |
| 156 | "Trying to fetch payment instructions for `{}@{}`", |
| 157 | hrn.user(), |
| 158 | hrn.domain(), |
| 159 | ); |
| 160 | PaymentInstructions::parse( |
| 161 | &format!("{}@{}", hrn.user(), hrn.domain()), |
| 162 | bitcoin::Network::Bitcoin, |
| 163 | &hrn_resolver, |
| 164 | false, |
| 165 | ) |
| 166 | .await |
| 167 | .map_err(|e| anyhow!("failed to fetch payment instructions: {:?}", e)) |
| 168 | } |
| 169 | |
| 170 | fn parse_payment_instructions( |
| 171 | payment_instructions: &PaymentInstructions, |
no test coverage detected