Skip to content

Commit

Permalink
ADD: Enable lightning/offchain wallet transactions to be exported to csv
Browse files Browse the repository at this point in the history
  • Loading branch information
masikotimo authored and Overtorment committed Apr 27, 2023
1 parent 6700284 commit f273cc6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions screen/wallets/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,15 @@ const WalletDetails = () => {

for (const transaction of transactions) {
const value = formatBalanceWithoutSuffix(transaction.value, BitcoinUnit.BTC, true);
csvFile +=
'\n' +
[new Date(transaction.received).toString(), transaction.hash, value, txMetadata[transaction.hash]?.memo?.trim() ?? ''].join(','); // CSV line

let hash = transaction.hash;
let memo = txMetadata[transaction.hash]?.memo?.trim() ?? '';

if (wallet.chain === Chain.OFFCHAIN) {
hash = transaction.payment_hash;
memo = transaction.description;
}
csvFile += '\n' + [new Date(transaction.received).toString(), hash, value, memo].join(','); // CSV line
}

await writeFileAndExport(`${wallet.label.replace(' ', '-')}-history.csv`, csvFile);
Expand Down Expand Up @@ -629,7 +635,7 @@ const WalletDetails = () => {
<View>
<BlueSpacing20 />
<SecondButton onPress={navigateToWalletExport} testID="WalletExport" title={loc.wallets.details_export_backup} />
{wallet.chain === Chain.ONCHAIN && walletTransactionsLength > 0 && (
{walletTransactionsLength > 0 && (
<>
<BlueSpacing20 />
<SecondButton onPress={onExportHistoryPressed} title={loc.wallets.details_export_history} />
Expand Down

0 comments on commit f273cc6

Please sign in to comment.