feat: add lightning preimage to transaction details

Konstantin Ullrich committed Jul 6, 2026 at 14:42 UTC 6cb31493223039a79be9e723b70518c0fe4405a1
3 files changed +23 -11
cw_bitcoin/lib/lightning/lightning_wallet.dart
+9 -1
@@ -441,6 +441,11 @@ class LightningWallet {
441 direction = TransactionDirection.incoming;
442 }
443
444 + String? preimage;
445 + if (payment.details != null && payment.details is PaymentDetails_Lightning) {
446 + preimage = (payment.details as PaymentDetails_Lightning).htlcDetails.preimage;
447 + }
448 +
449 return ElectrumTransactionInfo(
450 WalletType.bitcoin,
451 id: payment.id,
@@ -450,7 +455,10 @@ class LightningWallet {
455 fee: Money(payment.fees, currency),
456 date: DateTime.fromMillisecondsSinceEpoch(payment.timestamp.toInt() * 1000),
457 confirmations: payment.status == PaymentStatus.pending ? 0 : 10,
453 - additionalInfo: {"isLightning": true},
458 + additionalInfo: {
459 + "isLightning": true,
460 + if (preimage != null) "preimage": preimage,
461 + },
462 );
463 }
464
lib/view_model/transaction_details_view_model.dart
+12 -9
@@ -9,7 +9,6 @@ import 'package:cake_wallet/zano/zano.dart';
9 import 'package:cw_core/crypto_amount_format.dart';
10 import 'package:cw_core/crypto_currency.dart';
11 import 'package:cw_core/currency_for_wallet_type.dart';
12 -import 'package:cw_core/utils/print_verbose.dart';
12 import 'package:cw_core/wallet_base.dart';
13 import 'package:cw_core/transaction_info.dart';
14 import 'package:cw_core/wallet_type.dart';
@@ -50,10 +49,9 @@ String _moneroRecipientAddressForDisplay(String raw, WalletType walletType) {
49 return match?.group(0) ?? raw.trim();
50 }
51
53 -bool isLightning(TransactionInfo tx) {
54 - printV(tx.additionalInfo);
55 - return (tx.additionalInfo["isLightning"] as bool?) ?? false;
56 -}
52 +bool isLightning(TransactionInfo tx) => (tx.additionalInfo["isLightning"] as bool?) ?? false;
53 +
54 +bool hasLightningPreimage(TransactionInfo tx) => (tx.additionalInfo["preimage"] as String?) != null;
55
56 class TxDetailRowDefinition {
57 final String keyString;
@@ -188,6 +186,13 @@ class TxDetailRowDefinition {
186 },
187 applicable: (vm) => vm.wallet.type == WalletType.monero),
188
189 + TxDetailRowDefinition(
190 + keyString: "standard_list_item_lightning_preimage",
191 + title: S.current.transaction_preimage,
192 + valueGetter: (vm) => vm.transactionInfo.additionalInfo['preimage'] as String? ?? "",
193 + applicable: (vm) =>
194 + hasLightningPreimage(vm.transactionInfo) && isLightning(vm.transactionInfo),
195 + ),
196
197 TxDetailRowDefinition(
198 keyString: "standard_list_item_transaction_confirmed_key",
@@ -316,10 +321,9 @@ abstract class TransactionDetailsViewModelBase with Store {
321 TransactionPriority? transactionPriority;
322
323 CryptoCurrency get transactionAsset {
324 + if (isEVMCompatibleChain(wallet.type)) return evm!.assetOfTransaction(wallet, transactionInfo);
325
320 - if (isEVMCompatibleChain(wallet.type)) {
321 - return evm!.assetOfTransaction(wallet, transactionInfo);
322 - }
326 + if (isLightning(transactionInfo)) return CryptoCurrency.btcln;
327
328 return switch (wallet.type) {
329 WalletType.solana => solana!.assetOfTransaction(wallet, transactionInfo),
@@ -329,7 +333,6 @@ abstract class TransactionDetailsViewModelBase with Store {
333 };
334 }
335
332 -
336 // TODO integrate these getters with the TransactionInfo object
337 String get formattedPendingStatus {
338 switch (wallet.type) {
res/values/strings_en.arb
+2 -1
@@ -1253,6 +1253,7 @@
1253 "transaction_error": "Transaction Error",
1254 "transaction_key": "Transaction Key",
1255 "transaction_memo_optional": "Transaction Memo (optional)",
1256 + "transaction_preimage": "Preimage",
1257 "transaction_priority_fast": "Fast",
1258 "transaction_priority_fastest": "Fastest",
1259 "transaction_priority_medium": "Medium",
@@ -1452,4 +1453,4 @@
1453 "zcash_card_missing_funds": "Missing funds?",
1454 "zcash_card_scan": "Scan",
1455 "zcash_card_warning": "Do not close the app until the procedure completes, if you do so this process will need to restart from scratch."
1455 -}
\ No newline at end of file
1456 +}