Skip to content

feat: mostrar valor fiat entonces y ahora en el historial + pipeo fiat completo#119

Open
Delgado74 wants to merge 2 commits into
lachispame:mainfrom
Delgado74:feat/117-valor-fiat-entonces-ahora
Open

feat: mostrar valor fiat entonces y ahora en el historial + pipeo fiat completo#119
Delgado74 wants to merge 2 commits into
lachispame:mainfrom
Delgado74:feat/117-valor-fiat-entonces-ahora

Conversation

@Delgado74

@Delgado74 Delgado74 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Descripción

Implementa el valor fiat "Entonces" y "Ahora" en el historial de transacciones, mostrando el valor original al momento de la transacción junto al valor actual calculado con la tasa de Yadio en tiempo real, en la misma moneda fiat que se usó al crear el pago.

Además, se pipea la metadata fiat a través de todos los flujos de pago (LNURL, Lightning Address, bolt11) para que TransactionInfo pueda recuperarla y mostrarla consistentemente.

Cambios principales

Fiat Then & Now

  • 7history_screen.dart: muestra "Entonces: X.XX CURR" / "Ahora: Y.YY CURR" tanto en la lista como en el detalle de cada transacción, usando el rate actual de Yadio en la moneda original.
  • Fallback: cuando no se conoce la moneda original (receives por callback LNURL), usa el fiat auto-calculado por la wallet como "Entonces" y el rate actual como "Ahora".
  • Envíos: muestra Then & Now en la moneda fiat que el usuario seleccionó al crear el pago ✅
  • Receives por LNURL callback / Lightning Address: muestra Then & Now en CUP (moneda default de la wallet), porque LNBits genera la factura server-side sin nuestros datos fiat.

Pipeo de metadata fiat

  • invoice_service.dart: sendPayment(), sendPaymentToLNURL(), sendPaymentToLightningAddress() y createInvoice() ahora aceptan originalFiatCurrency/Amount/Rate y los incrustan en el memo/description de cada transacción.
  • amount_screen.dart: _processPayment() extrae el fiat del currency selector y lo pasa a los tres métodos de pago.
  • invoice_confirm_screen.dart: recibe los parámetros fiat y los reenvía a sendPayment().

Localización

  • 7 nuevas claves en todos los ARB: history_date_label, history_description_label, history_hash_label, history_fee_label, history_original_rate_label, history_wallet_amount_label, history_wallet_rate_label.

Bugs corregidos durante la implementación

Estos bugs fueron descubiertos al probar el flujo fiat y era necesario resolverlos para que Then & Now funcionara correctamente:

  1. LNBits ignora claves extra personalizadas — LNBits no preserva las claves fiat_currency, fiat_amount, fiat_rate dentro del objeto extra en las respuestas. Solución: incrustar los datos fiat directamente en el memo/description de la factura/pago, y usar un regex de respaldo en TransactionInfo.fromJson() para extraerlos.

  2. extras (plural) vs extra (singular) — el nombre del campo enviado al API de LNBits era extras (incorrecto) en lugar de extra. Corregido para coincidir con el API real.

  3. Endpoint /rates de Yadio roto — el endpoint /rates de YadioService fallaba. Reemplazado por /convert/1/BTC/XXX por moneda.

  4. Valor "Now" negativo en pagos salientes_getCurrentFiatValue() no usaba abs() en amountSats, mostrando valores negativos. Corregido.

  5. USD excluido del fallback de memo — había una condición currency != 'USD' que impedía mostrar Then & Now para transacciones en USD. Eliminada.

  6. Orden de endpoints en createInvoice() — el endpoint LNURLp (/lnurlp/api/v1/invoice) se probaba primero y no preservaba el memo. Reordenado para que el estándar /api/v1/payments vaya primero, con LNURLp como fallback.

Limitaciones conocidas

  • Receives por Lightning Address y LNURL callback estático: estas transacciones son generadas por LNBits server-side, no por la app. Por tanto, no es posible inyectar los datos fiat originales. En estos casos, Then & Now se muestra en CUP (moneda default de la wallet) usando el fiat auto-calculado por LNBits al momento de la transacción.
  • La zona horaria del historial puede no coincidir con la local del dispositivo en algunos casos; queda pendiente para issue separado.

Beneficio para comercios

Esta funcionalidad tiene valor directo para comercios que operan con BTC y llevan contabilidad en fiat:

  • Conciliación de estados de cuenta: cotejar cada transacción contra el valor fiat acordado con el cliente al momento del pago.
  • Ganancias/pérdidas no realizadas: identificar de un vistazo si el BTC ha cambiado de valor frente a la moneda local.
  • Declaraciones fiscales: el valor "Entonces" cumple con el requisito de reportar el valor fiat al momento de la transacción.
  • Soporte multimoneda: cada transacción queda registrada en la moneda fiat que el comerciante seleccionó al crear la factura, no en una moneda default única.

Closes #117

- Embed original fiat in invoice memo and outgoing description
- Wire fiat params through sendPayment, sendPaymentToLNURL,
  sendPaymentToLightningAddress, and createInvoice
- Fix Yadio service: use /convert/1/BTC/XXX
- Add Then & Now in history with current Yadio rate
- Fallback to wallet fiat for Then/Now when original unknown
- Use Yadio as primary conversion in _getAmountInSats
- Fix negative fiat display with abs()
- Remove USD exclusion from memo fallback regex
- Localize history detail labels
- Reorder createInvoice: standard endpoint first, LNURLp fallback
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Delgado74, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 34 minutes and 13 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 996d1e11-76d1-4d7d-abed-e6e880f35cee

📥 Commits

Reviewing files that changed from the base of the PR and between 5b51629 and f84e927.

⛔ Files ignored due to path filters (8)
  • lib/l10n/generated/app_localizations.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_de.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_en.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_es.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_fr.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_it.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_pt.dart is excluded by !**/generated/**
  • lib/l10n/generated/app_localizations_ru.dart is excluded by !**/generated/**
📒 Files selected for processing (13)
  • lib/l10n/app_de.arb
  • lib/l10n/app_en.arb
  • lib/l10n/app_es.arb
  • lib/l10n/app_fr.arb
  • lib/l10n/app_it.arb
  • lib/l10n/app_pt.arb
  • lib/l10n/app_ru.arb
  • lib/models/transaction_info.dart
  • lib/screens/11amount_screen.dart
  • lib/screens/12invoice_confirm_screen.dart
  • lib/screens/7history_screen.dart
  • lib/services/invoice_service.dart
  • lib/services/yadio_service.dart
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: Mostrar valor fiat "Entonces" y "Ahora" en el historial.

1 participant