mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
FIX: Lightning wallet CSV export does not differentiate between paid and expired invoices #5835
This commit is contained in:
parent
8b0e431e74
commit
0bc40d4586
2 changed files with 19 additions and 4 deletions
|
@ -64,6 +64,7 @@
|
|||
"node_alias": "Node alias",
|
||||
"expiresIn": "Expires in {time} minutes",
|
||||
"payButton": "Pay",
|
||||
"payment": "Payment",
|
||||
"placeholder": "Invoice or address",
|
||||
"open_channel": "Open Channel",
|
||||
"funding_amount_placeholder": "Funding amount, for example 0.001",
|
||||
|
|
|
@ -417,12 +417,17 @@ const WalletDetails = () => {
|
|||
};
|
||||
|
||||
const onExportHistoryPressed = async () => {
|
||||
let csvFile = [
|
||||
const csvFileArray = [
|
||||
loc.transactions.date,
|
||||
loc.transactions.txid,
|
||||
`${loc.send.create_amount} (${BitcoinUnit.BTC})`,
|
||||
loc.send.create_memo,
|
||||
].join(','); // CSV header
|
||||
];
|
||||
if (wallet.chain === Chain.OFFCHAIN) {
|
||||
csvFileArray.push(loc.lnd.payment);
|
||||
}
|
||||
|
||||
let csvFile = csvFileArray.join(','); // CSV header
|
||||
const transactions = wallet.getTransactions();
|
||||
|
||||
for (const transaction of transactions) {
|
||||
|
@ -430,17 +435,26 @@ const WalletDetails = () => {
|
|||
|
||||
let hash = transaction.hash;
|
||||
let memo = txMetadata[transaction.hash]?.memo?.trim() ?? '';
|
||||
let status;
|
||||
|
||||
if (wallet.chain === Chain.OFFCHAIN) {
|
||||
hash = transaction.payment_hash;
|
||||
memo = transaction.description;
|
||||
|
||||
status = transaction.ispaid ? loc._.success : loc.lnd.expired;
|
||||
if (hash?.type === 'Buffer' && hash?.data) {
|
||||
const bb = Buffer.from(hash);
|
||||
hash = bb.toString('hex');
|
||||
}
|
||||
}
|
||||
csvFile += '\n' + [new Date(transaction.received).toString(), hash, value, memo].join(','); // CSV line
|
||||
|
||||
const data = [new Date(transaction.received).toString(), hash, value, memo];
|
||||
|
||||
if (wallet.chain === Chain.OFFCHAIN) {
|
||||
// Replace 'condition' with your specific condition
|
||||
data.push(status);
|
||||
}
|
||||
|
||||
csvFile += '\n' + data.join(','); // CSV line
|
||||
}
|
||||
|
||||
await writeFileAndExport(`${wallet.label.replace(' ', '-')}-history.csv`, csvFile);
|
||||
|
|
Loading…
Add table
Reference in a new issue