fix(wallet): Minibits default Cashu mint, resilient peer-file invoices, named default federation
- Cashu default mint was the local Fedimint guardian (:8175), wrongly surfacing a Fedimint URL in the Cashu mints list. Default is now Minibits (https://mint.minibits.cash/Bitcoin) — Cashu and Fedimint are distinct protocols (Fedimint lives under its own tab). - Peer-file (buy) invoice creation: retry the LND REST call (3× / 400ms) so a transient LND-REST blip (swap pressure / just-restarted / TLS race) no longer hard-fails as an opaque 503, and surface the real error chain ({:#}) in the response + logs instead of a generic "Failed to create invoice". - Autojoined default federation now shows a friendly name ("Archipelago Federation") in the Fedimint tab instead of a bare federation id. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cc2e055e09
commit
790da4bd0f
@ -222,8 +222,12 @@ impl ApiHandler {
|
||||
hyper::Body::from(r#"{"error":"Invoice missing payment hash"}"#),
|
||||
)),
|
||||
Err(e) => {
|
||||
// Surface the FULL error chain ({:#}) — the generic top-level
|
||||
// message hid the real cause (e.g. the LND REST connection
|
||||
// failing), which made this 503 undiagnosable.
|
||||
tracing::warn!("content invoice creation failed: {e:#}");
|
||||
let body = serde_json::json!({
|
||||
"error": format!("Could not create invoice: {e}")
|
||||
"error": format!("Could not create invoice: {e:#}")
|
||||
});
|
||||
Ok(build_response(
|
||||
StatusCode::SERVICE_UNAVAILABLE,
|
||||
|
||||
@ -173,13 +173,42 @@ impl RpcHandler {
|
||||
"value": amount_sats.to_string(),
|
||||
"memo": memo,
|
||||
});
|
||||
let resp = client
|
||||
// LND's REST endpoint can briefly drop/reset connections under load
|
||||
// (swap pressure, just-restarted, TLS handshake races), which used to
|
||||
// hard-fail the buy-file invoice with an opaque 503. Retry the send a
|
||||
// few times with short backoff so a transient blip doesn't surface as
|
||||
// a payment failure. The surrounding error now carries the real cause.
|
||||
let mut last_err: Option<anyhow::Error> = None;
|
||||
let mut resp = None;
|
||||
for attempt in 0..3u32 {
|
||||
match client
|
||||
.post(format!("{LND_REST_BASE_URL}/v1/invoices"))
|
||||
.header("Grpc-Metadata-macaroon", &macaroon_hex)
|
||||
.json(&invoice_body)
|
||||
.send()
|
||||
.await
|
||||
.context("Failed to create invoice")?;
|
||||
{
|
||||
Ok(r) => {
|
||||
resp = Some(r);
|
||||
break;
|
||||
}
|
||||
Err(e) => {
|
||||
last_err = Some(anyhow::anyhow!(
|
||||
"LND REST connect failed (attempt {}): {e}",
|
||||
attempt + 1
|
||||
));
|
||||
tokio::time::sleep(std::time::Duration::from_millis(400)).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
let resp = match resp {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
return Err(last_err.unwrap_or_else(|| {
|
||||
anyhow::anyhow!("Failed to reach LND REST to create invoice")
|
||||
}))
|
||||
}
|
||||
};
|
||||
|
||||
let status = resp.status();
|
||||
let body: serde_json::Value = resp
|
||||
|
||||
@ -1175,8 +1175,13 @@ pub async fn get_balance(data_dir: &Path) -> Result<u64> {
|
||||
}
|
||||
|
||||
/// Default mint URL (local Fedimint).
|
||||
/// Default Cashu mint. Minibits is a well-known public Cashu mint — note this
|
||||
/// is a CASHU mint, distinct from the local Fedimint guardian (:8175), which is
|
||||
/// a separate ecash protocol managed under the Fedimint Federations tab. The
|
||||
/// old default pointed at :8175, which incorrectly surfaced the Fedimint URL in
|
||||
/// the Cashu mints list.
|
||||
fn default_mint_url() -> String {
|
||||
"http://127.0.0.1:8175".to_string()
|
||||
"https://mint.minibits.cash/Bitcoin".to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -1359,11 +1364,11 @@ mod tests {
|
||||
async fn test_save_and_load_wallet_roundtrip() {
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let mut wallet = WalletState {
|
||||
mint_url: "http://127.0.0.1:8175".into(),
|
||||
mint_url: "https://mint.minibits.cash/Bitcoin".into(),
|
||||
..Default::default()
|
||||
};
|
||||
wallet.add_proofs(
|
||||
"http://127.0.0.1:8175",
|
||||
"https://mint.minibits.cash/Bitcoin",
|
||||
vec![Proof {
|
||||
amount: 42,
|
||||
id: "ks1".into(),
|
||||
@ -1375,7 +1380,7 @@ mod tests {
|
||||
TransactionType::Mint,
|
||||
42,
|
||||
"Test mint",
|
||||
"http://127.0.0.1:8175",
|
||||
"https://mint.minibits.cash/Bitcoin",
|
||||
"",
|
||||
);
|
||||
|
||||
@ -1498,7 +1503,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_default_mint_url() {
|
||||
assert_eq!(default_mint_url(), "http://127.0.0.1:8175");
|
||||
assert_eq!(default_mint_url(), "https://mint.minibits.cash/Bitcoin");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1517,9 +1522,11 @@ mod tests {
|
||||
.await
|
||||
.unwrap());
|
||||
// Trailing slash on the home URL still matches.
|
||||
assert!(is_mint_trusted(tmp.path(), "http://127.0.0.1:8175/")
|
||||
assert!(
|
||||
is_mint_trusted(tmp.path(), "https://mint.minibits.cash/Bitcoin/")
|
||||
.await
|
||||
.unwrap());
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -1553,7 +1560,7 @@ mod tests {
|
||||
let err = swap_between_mints(
|
||||
tmp.path(),
|
||||
&default_mint_url(),
|
||||
"http://127.0.0.1:8175/",
|
||||
"https://mint.minibits.cash/Bitcoin/",
|
||||
100,
|
||||
10,
|
||||
)
|
||||
|
||||
@ -95,7 +95,7 @@ pub async fn ensure_default_federation(data_dir: &Path) -> Result<()> {
|
||||
{
|
||||
reg.federations.push(JoinedFederation {
|
||||
federation_id,
|
||||
name: None,
|
||||
name: Some("Archipelago Federation".to_string()),
|
||||
});
|
||||
save_registry(data_dir, ®).await?;
|
||||
}
|
||||
|
||||
@ -884,6 +884,17 @@ function scrollChatToBottom() {
|
||||
}
|
||||
}
|
||||
|
||||
// Wheel over the chat must scroll ONLY the chat — never leak to the contacts
|
||||
// list or the page. CSS overscroll-behavior wasn't enough (the leak happens
|
||||
// even when the chat doesn't overflow), so consume the wheel and apply it to
|
||||
// the chat container directly. Used with `@wheel.prevent` so the default
|
||||
// (page/contacts) scroll never fires.
|
||||
function onChatWheel(e: WheelEvent) {
|
||||
const el = chatScrollEl.value
|
||||
if (!el) return
|
||||
el.scrollTop += e.deltaY
|
||||
}
|
||||
|
||||
async function handleBroadcast() {
|
||||
broadcasting.value = true
|
||||
try { await mesh.broadcastIdentity() } finally { broadcasting.value = false }
|
||||
@ -1593,7 +1604,7 @@ function isImageMime(mime?: string): boolean {
|
||||
<span v-if="activeChatPeer" class="mesh-chat-header-time">{{ timeAgo(activeChatPeer.last_heard) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div ref="chatScrollEl" class="mesh-chat-messages" @scroll="scheduleReadReceipt">
|
||||
<div ref="chatScrollEl" class="mesh-chat-messages" @scroll="scheduleReadReceipt" @wheel.prevent="onChatWheel">
|
||||
<div v-if="chatMessages.length === 0" class="mesh-chat-no-messages">
|
||||
No messages yet. Say hello!
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user