feat: display truncated lightning address for winners
- Add truncateLightningAddress utility (shows first 2 chars + ******) - Backend: Include winner_address in past-wins API response - Frontend: Display truncated address in past winners list - Telegram: Add truncated address to draw announcements for transparency Example: username@blink.sv -> us******@blink.sv
This commit is contained in:
@@ -503,6 +503,23 @@ interface PastWinRow {
|
||||
pot_after_fee_sats: number | null;
|
||||
buyer_name: string | null;
|
||||
serial_number: number | null;
|
||||
winning_lightning_address: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate lightning address for privacy
|
||||
* "username@blink.sv" -> "us******@blink.sv"
|
||||
*/
|
||||
function truncateLightningAddress(address: string | null): string | null {
|
||||
if (!address || !address.includes('@')) return address;
|
||||
|
||||
const [username, domain] = address.split('@');
|
||||
|
||||
// Show first 2 chars of username, then asterisks
|
||||
const visibleChars = Math.min(2, username.length);
|
||||
const truncatedUsername = username.substring(0, visibleChars) + '******';
|
||||
|
||||
return `${truncatedUsername}@${domain}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -523,6 +540,7 @@ export async function getPastWins(req: Request, res: Response) {
|
||||
jc.scheduled_at,
|
||||
jc.pot_total_sats,
|
||||
jc.pot_after_fee_sats,
|
||||
jc.winning_lightning_address,
|
||||
tp.buyer_name,
|
||||
t.serial_number
|
||||
FROM jackpot_cycles jc
|
||||
@@ -544,6 +562,7 @@ export async function getPastWins(req: Request, res: Response) {
|
||||
? parseInt(row.pot_after_fee_sats.toString())
|
||||
: null,
|
||||
winner_name: row.buyer_name || 'Anon',
|
||||
winner_address: truncateLightningAddress(row.winning_lightning_address),
|
||||
winning_ticket_serial: row.serial_number
|
||||
? parseInt(row.serial_number.toString())
|
||||
: null,
|
||||
|
||||
Reference in New Issue
Block a user