MCPcopy Create free account
hub / github.com/ElementsProject/lightning / fetch_payment_instructions

Function fetch_payment_instructions

plugins/bip353-plugin/src/main.rs:136–171  ·  view source on GitHub ↗
(
    plugin: Plugin<()>,
    hrn: &HumanReadableName,
)

Source from the content-addressed store, hash-verified

134}
135
136async 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 = bitreq::Proxy::new_socks5(format!(
143 "socks5h://{}:{}",
144 proxy_info.address, proxy_info.port
145 ))?;
146 HTTPHrnResolver::new_proxied(proxy)
147 }
148 None => HTTPHrnResolver::new(),
149 };
150
151 log::debug!(
152 "Trying to fetch payment instructions for `{}@{}`",
153 hrn.user(),
154 hrn.domain(),
155 );
156
157 match tokio::time::timeout(
158 Duration::from_secs(30),
159 PaymentInstructions::parse(
160 &format!("{}@{}", hrn.user(), hrn.domain()),
161 bitcoin::Network::Bitcoin,
162 &hrn_resolver,
163 false,
164 ),
165 )
166 .await
167 {
168 Ok(o) => o.map_err(|e| anyhow!("failed to fetch payment instructions: {e:?}")),
169 Err(_) => Err(anyhow!("timed out fetching payment instructions")),
170 }
171}
172
173fn parse_payment_instructions(
174 payment_instructions: &PaymentInstructions,

Callers 1

fetch_bip353Function · 0.85

Calls 2

get_proxyFunction · 0.85
parseFunction · 0.85

Tested by

no test coverage detected