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

Function fetch_payment_instructions

plugins/bip353-plugin/src/main.rs:136–168  ·  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 = 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
170fn parse_payment_instructions(
171 payment_instructions: &PaymentInstructions,

Callers 1

fetch_bip353Function · 0.85

Calls 4

get_proxyFunction · 0.85
parseFunction · 0.85
proxyMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected