mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
Merge pull request #3374 from cake-tech/add-preimage-to-transaction-details
feat: add lightning preimage to transaction details
This commit is contained in:
@@ -441,6 +441,11 @@ class LightningWallet {
|
||||
direction = TransactionDirection.incoming;
|
||||
}
|
||||
|
||||
String? preimage;
|
||||
if (payment.details != null && payment.details is PaymentDetails_Lightning) {
|
||||
preimage = (payment.details as PaymentDetails_Lightning).htlcDetails.preimage;
|
||||
}
|
||||
|
||||
return ElectrumTransactionInfo(
|
||||
WalletType.bitcoin,
|
||||
id: payment.id,
|
||||
@@ -450,7 +455,10 @@ class LightningWallet {
|
||||
fee: Money(payment.fees, currency),
|
||||
date: DateTime.fromMillisecondsSinceEpoch(payment.timestamp.toInt() * 1000),
|
||||
confirmations: payment.status == PaymentStatus.pending ? 0 : 10,
|
||||
additionalInfo: {"isLightning": true},
|
||||
additionalInfo: {
|
||||
"isLightning": true,
|
||||
if (preimage != null) "preimage": preimage,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:cake_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/crypto_amount_format.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -50,10 +49,9 @@ String _moneroRecipientAddressForDisplay(String raw, WalletType walletType) {
|
||||
return match?.group(0) ?? raw.trim();
|
||||
}
|
||||
|
||||
bool isLightning(TransactionInfo tx) {
|
||||
printV(tx.additionalInfo);
|
||||
return (tx.additionalInfo["isLightning"] as bool?) ?? false;
|
||||
}
|
||||
bool isLightning(TransactionInfo tx) => (tx.additionalInfo["isLightning"] as bool?) ?? false;
|
||||
|
||||
bool hasLightningPreimage(TransactionInfo tx) => (tx.additionalInfo["preimage"] as String?) != null;
|
||||
|
||||
class TxDetailRowDefinition {
|
||||
final String keyString;
|
||||
@@ -188,6 +186,13 @@ class TxDetailRowDefinition {
|
||||
},
|
||||
applicable: (vm) => vm.wallet.type == WalletType.monero),
|
||||
|
||||
TxDetailRowDefinition(
|
||||
keyString: "standard_list_item_lightning_preimage",
|
||||
title: S.current.transaction_preimage,
|
||||
valueGetter: (vm) => vm.transactionInfo.additionalInfo['preimage'] as String? ?? "",
|
||||
applicable: (vm) =>
|
||||
hasLightningPreimage(vm.transactionInfo) && isLightning(vm.transactionInfo),
|
||||
),
|
||||
|
||||
TxDetailRowDefinition(
|
||||
keyString: "standard_list_item_transaction_confirmed_key",
|
||||
@@ -316,10 +321,9 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
TransactionPriority? transactionPriority;
|
||||
|
||||
CryptoCurrency get transactionAsset {
|
||||
if (isEVMCompatibleChain(wallet.type)) return evm!.assetOfTransaction(wallet, transactionInfo);
|
||||
|
||||
if (isEVMCompatibleChain(wallet.type)) {
|
||||
return evm!.assetOfTransaction(wallet, transactionInfo);
|
||||
}
|
||||
if (isLightning(transactionInfo)) return CryptoCurrency.btcln;
|
||||
|
||||
return switch (wallet.type) {
|
||||
WalletType.solana => solana!.assetOfTransaction(wallet, transactionInfo),
|
||||
@@ -329,7 +333,6 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// TODO integrate these getters with the TransactionInfo object
|
||||
String get formattedPendingStatus {
|
||||
switch (wallet.type) {
|
||||
|
||||
@@ -1253,6 +1253,7 @@
|
||||
"transaction_error": "Transaction Error",
|
||||
"transaction_key": "Transaction Key",
|
||||
"transaction_memo_optional": "Transaction Memo (optional)",
|
||||
"transaction_preimage": "Preimage",
|
||||
"transaction_priority_fast": "Fast",
|
||||
"transaction_priority_fastest": "Fastest",
|
||||
"transaction_priority_medium": "Medium",
|
||||
@@ -1452,4 +1453,4 @@
|
||||
"zcash_card_missing_funds": "Missing funds?",
|
||||
"zcash_card_scan": "Scan",
|
||||
"zcash_card_warning": "Do not close the app until the procedure completes, if you do so this process will need to restart from scratch."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user