fix: use preimage field for Bitcoin txid and make mempool link icon-only

Correct Bitcoin transaction display to use the preimage field which
contains the actual txid (with optional output index like "txid:0").

Changes:
- Extract txid from preimage field, removing output index if present
- Use preimage instead of payment_hash for Bitcoin transactions
- Make mempool.space link icon-only with tooltip
- Icon is larger (size-4) and properly aligned with txid display

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Alejandro Gómez
2026-01-19 14:08:14 +01:00
parent 1dd3841220
commit 3eb8cea9e0

View File

@@ -130,6 +130,16 @@ function isBitcoinTransaction(transaction: Transaction): boolean {
return isBitcoinAddress;
}
/**
* Helper: Extract txid from preimage field
* Bitcoin preimage format: "txid" or "txid:outputIndex"
* We only need the txid part for mempool.space
*/
function extractTxid(preimage: string): string {
// Remove output index if present (e.g., "txid:0" -> "txid")
return preimage.split(":")[0];
}
/**
* Helper: Get mempool.space URL for a Bitcoin transaction
*/
@@ -1354,21 +1364,19 @@ export default function WalletViewer() {
if (isBitcoin) {
// Bitcoin on-chain transaction - show Transaction ID with mempool.space link
// For Bitcoin txs, payment_hash contains the txid (preimage is also the txid)
const txid =
selectedTransaction.payment_hash ||
selectedTransaction.preimage;
if (!txid) {
// For Bitcoin txs, preimage contains the txid (possibly with :outputIndex)
if (!selectedTransaction.preimage) {
return null;
}
const txid = extractTxid(selectedTransaction.preimage);
return (
<div>
<Label className="text-xs text-muted-foreground">
Transaction ID
</Label>
<div className="flex items-start gap-2">
<div className="flex items-center gap-2">
<p className="text-xs font-mono break-all bg-muted p-2 rounded flex-1">
{txid}
</p>
@@ -1376,10 +1384,10 @@ export default function WalletViewer() {
href={getMempoolUrl(txid, walletInfo?.network)}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1 text-xs text-primary hover:underline mt-2 flex-shrink-0"
className="text-primary hover:text-primary/80 transition-colors flex-shrink-0"
title="View on mempool.space"
>
<ExternalLink className="size-3" />
View on mempool.space
<ExternalLink className="size-4" />
</a>
</div>
</div>