-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathscripts.js
More file actions
1648 lines (1403 loc) · 58.3 KB
/
Copy pathscripts.js
File metadata and controls
1648 lines (1403 loc) · 58.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
document.addEventListener('DOMContentLoaded', function() {
initializeDarkMode();
});
// Dark mode functionality
function initializeDarkMode() {
const themeToggle = document.getElementById('theme-toggle');
const sunIcon = themeToggle.querySelector('.sun-icon');
const moonIcon = themeToggle.querySelector('.moon-icon');
// Check for saved theme preference or default to 'light'
const currentTheme = localStorage.getItem('theme') || 'light';
document.documentElement.setAttribute('data-theme', currentTheme);
// Update icon visibility
updateThemeIcon(currentTheme, sunIcon, moonIcon);
// Theme toggle event listener
themeToggle.addEventListener('click', function() {
const currentTheme = document.documentElement.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
updateThemeIcon(newTheme, sunIcon, moonIcon);
// Update aria-pressed for accessibility
themeToggle.setAttribute('aria-pressed', newTheme === 'dark' ? 'true' : 'false');
});
}
function updateThemeIcon(theme, sunIcon, moonIcon) {
if (theme === 'dark') {
sunIcon.style.display = 'none';
moonIcon.style.display = 'block';
} else {
sunIcon.style.display = 'block';
moonIcon.style.display = 'none';
}
}
// Debounce utility function for performance optimization
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Throttle utility function for scroll events
function throttle(func, limit) {
let inThrottle;
return function() {
const args = arguments;
const context = this;
if (!inThrottle) {
func.apply(context, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
}
}
// Statistics calculation function
function updateStatistics(walletsData) {
let totalWallets = 0;
let hardwareWallets = 0;
let softwareWallets = 0;
let lightningWallets = 0;
let documentedWallets = 0;
let psbtWallets = 0;
// Count wallets by category
walletsData.categories.forEach(category => {
const walletCount = category.wallets.length;
totalWallets += walletCount;
if (category.name === 'Hardware Wallets') {
hardwareWallets = walletCount;
} else if (category.name === 'Software Wallets') {
softwareWallets = walletCount;
} else if (category.name === 'Lightning Wallets') {
lightningWallets = walletCount;
}
// Count documented wallets and PSBT support
category.wallets.forEach(wallet => {
// Check if wallet is well documented (has ✅ status)
if (wallet.status && wallet.status.includes('✅')) {
documentedWallets++;
}
// Check for PSBT support
if (wallet.bip174_psbt === 'Yes') {
psbtWallets++;
}
});
});
// Update the DOM elements
document.getElementById('total-wallets').textContent = totalWallets;
document.getElementById('hardware-wallets').textContent = hardwareWallets;
document.getElementById('software-wallets').textContent = softwareWallets;
document.getElementById('lightning-wallets').textContent = lightningWallets;
document.getElementById('documented-wallets').textContent = documentedWallets;
document.getElementById('psbt-wallets').textContent = psbtWallets;
}
function getIconDefinitions(data) {
return (data.icons || []).map(icon => ({
...icon,
text: icon.text || icon.icon
}));
}
function slugify(value) {
return String(value)
.toLowerCase()
.normalize('NFKD')
.replace(/[\u0300-\u036f]/g, '')
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
}
function getWalletAnchorId(walletName) {
return `wallet-${slugify(walletName)}`;
}
function updateLastReviewed(walletsData) {
const lastReviewed = document.getElementById('last-reviewed');
if (!lastReviewed || !walletsData.metadata) return;
const reviewedDate = walletsData.metadata.last_reviewed || walletsData.metadata.last_updated;
if (!reviewedDate) return;
lastReviewed.textContent = `Data last reviewed ${reviewedDate}`;
lastReviewed.dateTime = reviewedDate;
}
function renderFeaturedWallets(walletsData) {
const featuredGrid = document.getElementById('featured-grid');
if (!featuredGrid) return;
const sections = [
{
title: '⚠️ Avoid / Legacy',
className: 'warning-card',
names: ['Arculus', 'BitKey', 'Atomic Wallet', 'Mutiny Wallet']
},
{
title: '🏆 Best Overall',
names: ['COLDCARD Mk5', 'COLDCARD Q', 'COLDCARD Mk4', 'Trezor Safe 7']
},
{
title: '🔧 PSBT + Signers',
names: ['COLDCARD Mk5', 'Jade Plus', 'SeedSigner', 'Passport Core']
},
{
title: '⚡ Lightning Recovery',
names: ['Zeus LN', 'Blixt (LND mobile node wallet)', 'LND (Lightning Network Daemon)', 'OBW (Open Bitcoin Wallet)']
},
{
title: '📱 Mobile Apps',
names: ['BlueWallet', 'Blockstream Green (GreenAddress)', 'CakeWallet', 'Cove Wallet']
},
{
title: '💻 Recovery Apps',
names: ['Sparrow Wallet', 'Bitcoin Safe', 'Bitcoin Core', 'Bitcoin Wallet app']
}
];
const walletByName = new Map();
walletsData.categories.forEach(category => {
category.wallets.forEach(wallet => walletByName.set(wallet.name, wallet));
});
featuredGrid.innerHTML = '';
sections.forEach(section => {
const card = document.createElement('div');
card.className = `featured-card ${section.className || ''}`.trim();
const heading = document.createElement('h3');
heading.textContent = section.title;
card.appendChild(heading);
const list = document.createElement('div');
list.className = 'wallet-list';
section.names.forEach(name => {
const wallet = walletByName.get(name);
const link = document.createElement('a');
link.className = 'wallet-link';
link.href = wallet ? `#${getWalletAnchorId(wallet.name)}` : '#wallet-tables';
link.textContent = name;
list.appendChild(link);
});
card.appendChild(list);
featuredGrid.appendChild(card);
});
}
// Wallet data loading and rendering logic
document.addEventListener('DOMContentLoaded', function() {
// Initialize performance monitoring
const startTime = performance.now();
// Modal handling - set references to the existing global variables
modal = document.getElementById('status-modal');
modalTitle = document.getElementById('modal-title');
modalBody = document.getElementById('modal-body');
const closeModal = document.querySelector('.close-modal');
// Close modal when clicking the X
closeModal.addEventListener('click', function() {
modal.style.display = 'none';
document.body.classList.remove('modal-active');
});
// Close modal when clicking outside of it
window.addEventListener('click', function(e) {
if (e.target === modal) {
modal.style.display = 'none';
document.body.classList.remove('modal-active');
}
});
// Handle escape key to close modal
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape' && modal.style.display === 'block') {
modal.style.display = 'none';
document.body.classList.remove('modal-active');
}
});
// Function to show status info in modal
function showStatusInfo(emoji, meaning, title = 'Status Information') {
// Get modal elements if not already initialized
if (!modal) modal = document.getElementById('status-modal');
if (!modalTitle) modalTitle = document.getElementById('modal-title');
if (!modalBody) modalBody = document.getElementById('modal-body');
modalTitle.textContent = title;
let content = `
<div class="modal-explanation">
<table class="modal-table">
<tr>
<td class="emoji-cell">${emoji}</td>
<td>${meaning}</td>
</tr>
</table>
</div>
`;
modalBody.innerHTML = content;
modal.style.display = 'block';
document.body.classList.add('modal-active');
}
// Delegate click events for status cells
document.addEventListener('click', function(e) {
const statusCell = e.target.closest('.status-cell[data-has-content="true"]');
if (statusCell) {
const emoji = statusCell.textContent.trim();
const meaning = statusCell.getAttribute('aria-label');
if (emoji && meaning) {
showStatusInfo(emoji, meaning, `Status: ${emoji}`);
}
}
// Handle clicks on status headers
const statusHeader = e.target.closest('.status-header');
if (statusHeader) {
showAllStatusIcons();
}
// Handle clicks on path tags
const pathTag = e.target.closest('.wallet-path-tag');
if (pathTag) {
const path = pathTag.getAttribute('data-path');
const pathName = pathTag.getAttribute('data-path-name');
// Get wallet name - find the wallet cell in the same row (more reliable than using column number)
let walletNameElem = pathTag.closest('tr').querySelector('.wallet-name-cell a, .wallet-name-cell span');
const walletName = walletNameElem ? walletNameElem.textContent : 'Wallet';
if (path && pathName) {
showPathDetails(path, pathName, walletName);
}
}
});
// Function to show all status icons in the modal
function showAllStatusIcons() {
modalTitle.textContent = 'Status Icons Legend';
let content = `
<div class="modal-explanation">
<table class="modal-table">
`;
const iconMappings = getIconDefinitions(globalWalletsData || {});
iconMappings.forEach(icon => {
content += `
<tr>
<td class="emoji-cell">${icon.icon}</td>
<td>
<strong>${icon.text}</strong>: ${icon.meaning}
</td>
</tr>
`;
});
content += `
</table>
</div>
`;
modalBody.innerHTML = content;
modal.style.display = 'block';
document.body.classList.add('modal-active');
}
// Use modern fetch with better error handling and caching
fetch('walletsrecovery.json?v=202606022000', {
cache: 'no-cache',
headers: {
'Accept': 'application/json',
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(walletsData => {
globalWalletsData = walletsData;
// Use requestAnimationFrame for smooth rendering
requestAnimationFrame(() => {
renderWalletData(walletsData);
renderFeaturedWallets(walletsData);
updateStatistics(walletsData);
updateLastReviewed(walletsData);
// Keep performance calculation available for debugging without noisy console output.
const endTime = performance.now();
document.documentElement.dataset.renderMs = (endTime - startTime).toFixed(0);
});
})
.catch(error => {
console.error('Error loading wallet data:', error);
document.getElementById('wallet-tables-container').innerHTML =
'<div class="error-box">Error loading wallet data: ' + error.message + '. Please try refreshing the page.</div>';
});
// Setup smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 70, // Account for navbar height
behavior: 'smooth'
});
// Update URL hash without jumping
history.pushState(null, null, targetId);
}
});
});
// Sticky Navbar Logic
const navbar = document.querySelector('.navbar');
const navLinks = document.querySelectorAll('.nav-link');
const navbarToggle = document.querySelector('.navbar-toggle');
const navbarLinks = document.querySelector('.navbar-links');
// Handle mobile menu toggle with accessibility
navbarToggle.addEventListener('click', function() {
const isExpanded = this.getAttribute('aria-expanded') === 'true';
this.classList.toggle('active');
navbarLinks.classList.toggle('active');
this.setAttribute('aria-expanded', !isExpanded);
});
// Close mobile menu when clicking a link
navLinks.forEach(link => {
link.addEventListener('click', function() {
navbarToggle.classList.remove('active');
navbarLinks.classList.remove('active');
navbarToggle.setAttribute('aria-expanded', 'false');
});
});
// Modified scrolling behavior to keep navbar always visible (throttled for performance)
window.addEventListener('scroll', throttle(function() {
// Update active section in navbar
const sections = document.querySelectorAll('section');
let currentSection = '';
sections.forEach(section => {
const sectionTop = section.offsetTop - 100;
if (window.scrollY >= sectionTop) {
currentSection = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${currentSection}`) {
link.classList.add('active');
}
});
}, 100));
});
function renderWalletData(data) {
// Get the container where we'll render the tables
const container = document.getElementById('wallet-tables-container');
if (!container) return;
// Clear any existing content
container.innerHTML = '';
const iconMappings = getIconDefinitions(data);
// Add icon legend first (above tables)
renderIconLegend(iconMappings, container);
// Render each category
data.categories.forEach(category => {
// Create a section for the category
const section = document.createElement('section');
section.className = 'wallet-category';
// Add a heading
const heading = document.createElement('h3');
heading.textContent = category.name;
section.appendChild(heading);
// Add count of wallets in this category
const walletCount = document.createElement('p');
walletCount.className = 'wallet-count';
walletCount.textContent = `${category.wallets.length} wallets`;
walletCount.style.color = '#666';
walletCount.style.marginBottom = '15px';
section.appendChild(walletCount);
// Add search field
const searchContainer = document.createElement('div');
searchContainer.className = 'search-container';
const searchInput = document.createElement('input');
searchInput.type = 'text';
searchInput.className = 'search-input';
searchInput.placeholder = `Search ${category.name}...`;
searchInput.setAttribute('data-category', category.name);
searchContainer.appendChild(searchInput);
// Add path filter buttons
const pathFiltersDiv = document.createElement('div');
pathFiltersDiv.className = 'path-filters';
pathFiltersDiv.style.marginTop = '10px';
pathFiltersDiv.style.marginBottom = '15px';
const allPathsBtn = document.createElement('button');
allPathsBtn.textContent = 'All';
allPathsBtn.className = 'path-filter-btn active';
allPathsBtn.onclick = () => filterTableByPath(table, 'all', pathFiltersDiv, noResults);
pathFiltersDiv.appendChild(allPathsBtn);
// Create buttons for common path types
const pathTypes = [
{ id: 'bip44', text: 'Legacy (BIP44)' },
{ id: 'bip49', text: 'SegWit (BIP49)' },
{ id: 'bip84', text: 'Native SegWit (BIP84)' },
{ id: 'bip48', text: 'Multisig (BIP48)' },
{ id: 'bip86', text: 'Taproot (BIP86)' },
{ id: 'brd', text: 'BRD (m/0\')' }
];
pathTypes.forEach(path => {
const btn = document.createElement('button');
btn.textContent = path.text;
btn.className = 'path-filter-btn';
btn.setAttribute('data-path', path.id);
btn.onclick = () => filterTableByPath(table, path.id, pathFiltersDiv, noResults);
pathFiltersDiv.appendChild(btn);
});
searchContainer.appendChild(pathFiltersDiv);
section.appendChild(searchContainer);
// Create a responsive wrapper for the table
const tableWrapper = document.createElement('div');
tableWrapper.className = 'wallet-table-wrapper';
// Create the table
const table = document.createElement('table');
table.className = 'wallet-table';
table.setAttribute('data-category', category.name);
// Create the table header
const thead = document.createElement('thead');
const headerRow = document.createElement('tr');
// Add header cells for each icon type with normal text
iconMappings.forEach((iconType, index) => {
const th = document.createElement('th');
th.className = 'status-header';
// Show only the emoji icon
th.textContent = iconType.icon;
// Add the meaning as an aria-label
th.setAttribute('aria-label', iconType.meaning);
th.setAttribute('title', iconType.meaning);
th.setAttribute('data-column', index);
th.addEventListener('click', () => sortTable(table, index));
headerRow.appendChild(th);
});
// Add other headers based on the category
let additionalHeaders;
if (category.name === 'Lightning Wallets') {
additionalHeaders = ['Wallet', 'Derivation', 'Output Descriptor', 'Pass', 'Notes'];
} else if (category.name === 'Software Wallets') {
additionalHeaders = ['Wallet', 'Derivation', 'Output Descriptor', 'BIP39', 'WIF', 'PSBT', 'Notes'];
} else {
additionalHeaders = ['Wallet', 'Derivation', 'Output Descriptor', 'BIP39', 'PSBT', 'Notes'];
}
// Create the remaining header cells
additionalHeaders.forEach((headerText, index) => {
const th = document.createElement('th');
th.textContent = headerText;
th.setAttribute('data-column', index + iconMappings.length);
th.addEventListener('click', () => sortTable(table, index + iconMappings.length));
// Set width for specific columns
if (headerText === 'Wallet') {
th.style.minWidth = '150px';
} else if (headerText === 'Derivation') {
th.style.minWidth = '180px';
} else if (headerText === 'Output Descriptor') {
th.style.minWidth = '120px';
} else if (headerText === 'BIP39' || headerText === 'WIF' || headerText === 'PSBT' || headerText === 'Pass') {
th.style.minWidth = '80px';
th.style.textAlign = 'center';
} else if (headerText === 'Notes') {
th.style.minWidth = '250px';
}
headerRow.appendChild(th);
});
thead.appendChild(headerRow);
table.appendChild(thead);
// Create the table body
const tbody = document.createElement('tbody');
// Add rows for each wallet in the category
category.wallets.forEach(wallet => {
const walletStatus = wallet.status || '';
const row = document.createElement('tr');
row.id = getWalletAnchorId(wallet.name);
row.setAttribute('data-wallet-name', wallet.name);
row.classList.toggle('wallet-discontinued', walletStatus.includes('😵'));
row.classList.toggle('wallet-warning', walletStatus.includes('⚠️') || walletStatus.includes('☠️') || walletStatus.includes('⛔️'));
// Add a cell for each icon type
iconMappings.forEach(iconType => {
const cell = document.createElement('td');
cell.className = 'status-cell';
cell.style.textAlign = 'center';
// Check if this wallet's status includes this icon
if (walletStatus.includes(iconType.icon)) {
cell.textContent = iconType.icon;
cell.setAttribute('aria-label', iconType.meaning);
cell.setAttribute('title', iconType.meaning);
cell.setAttribute('data-has-content', 'true');
} else {
// Mark as empty - use a space but no tooltip
cell.innerHTML = ' ';
cell.setAttribute('data-empty', 'true');
// Remove any title/tooltip for empty cells
cell.removeAttribute('title');
cell.removeAttribute('aria-label');
}
row.appendChild(cell);
});
// Wallet name cell with link
const nameCell = document.createElement('td');
nameCell.className = 'wallet-name-cell';
if (wallet.url) {
const nameLink = document.createElement('a');
nameLink.href = wallet.url;
nameLink.textContent = wallet.name;
nameLink.target = '_blank';
nameLink.rel = 'noopener';
nameCell.appendChild(nameLink);
} else {
const nameText = document.createElement('span');
nameText.textContent = wallet.name;
nameCell.appendChild(nameText);
}
nameCell.style.fontWeight = '500';
row.appendChild(nameCell);
// Derivation cell with improved display
const derivationCell = document.createElement('td');
derivationCell.className = 'wallet-derivation';
if (wallet.derivation) {
const derivationContainer = document.createElement('ul');
derivationContainer.className = 'wallet-derivation-container';
derivationContainer.style.listStyle = 'none';
derivationContainer.style.padding = '0';
derivationContainer.style.margin = '0';
// Display supported paths as tags
const pathMapping = {
bip44: { path: "m/44'/0'/0'", name: "Legacy" },
bip49: { path: "m/49'/0'/0'", name: "SegWit" },
bip84: { path: "m/84'/0'/0'", name: "Native SegWit" },
bip48: { path: "m/48'/0'/0'/2'", name: "Multisig" },
bip86: { path: "m/86'/0'/0'", name: "Taproot" },
brd: { path: "m/0'", name: "BRD" }
};
// First show standard paths
Object.entries(pathMapping).forEach(([key, value]) => {
if (wallet.derivation[key]) {
const tagItem = document.createElement('li');
tagItem.style.display = 'inline-block';
tagItem.style.marginBottom = '0';
const tag = document.createElement('span');
tag.className = 'wallet-path-tag active';
tag.textContent = value.name;
tag.setAttribute('aria-label', value.path);
tag.setAttribute('data-path', value.path);
tag.setAttribute('data-path-name', value.name);
tagItem.appendChild(tag);
derivationContainer.appendChild(tagItem);
}
});
// Then show custom paths if any
if (wallet.derivation.custom) {
const tagItem = document.createElement('li');
tagItem.style.display = 'inline-block';
tagItem.style.marginBottom = '0';
const tag = document.createElement('span');
tag.className = 'wallet-path-tag custom';
tag.textContent = 'Custom';
tag.setAttribute('aria-label', wallet.derivation.custom);
tag.setAttribute('data-path', wallet.derivation.custom);
tag.setAttribute('data-path-name', 'Custom');
tagItem.appendChild(tag);
derivationContainer.appendChild(tagItem);
}
derivationCell.appendChild(derivationContainer);
} else if (wallet.paths) {
// Fallback for old format
derivationCell.textContent = 'Legacy format';
} else {
derivationCell.textContent = 'N/A';
}
row.appendChild(derivationCell);
// Output Descriptor cell
const outputDescCell = document.createElement('td');
outputDescCell.style.textAlign = 'center';
outputDescCell.style.fontSize = '0.9em';
if (wallet.output_descriptor) {
const statusSpan = document.createElement('span');
statusSpan.className = 'wallet-status-tag';
switch (wallet.output_descriptor) {
case 'Yes':
statusSpan.textContent = '✓';
statusSpan.style.color = '#22c55e';
statusSpan.setAttribute('title', 'Output Descriptor supported - BIP380 compliant, enables easy wallet recovery and interoperability');
break;
case 'No':
statusSpan.textContent = '✗';
statusSpan.style.color = '#ef4444';
statusSpan.setAttribute('title', 'Output Descriptor not supported - recovery may require manual derivation path configuration');
break;
case 'WIP':
statusSpan.textContent = '⚠';
statusSpan.style.color = '#f59e0b';
statusSpan.setAttribute('title', 'Output Descriptor support in progress - feature is being developed, may not be fully reliable yet');
break;
case 'N/A':
statusSpan.textContent = '—';
statusSpan.style.color = '#6b7280';
statusSpan.setAttribute('title', 'Not applicable - output descriptors not relevant for this wallet type');
break;
default:
statusSpan.textContent = wallet.output_descriptor;
statusSpan.setAttribute('title', `Output Descriptor: ${wallet.output_descriptor}`);
}
outputDescCell.appendChild(statusSpan);
} else {
outputDescCell.textContent = 'N/A';
}
row.appendChild(outputDescCell);
// BIP39 Pass/Passphrase cell with improved display
const passCell = document.createElement('td');
passCell.style.textAlign = 'center';
let passValue;
if (category.name === 'Lightning Wallets') {
passValue = wallet.passphrase || 'N/A';
} else {
passValue = wallet.bip39_pass || 'N/A';
}
const passTag = document.createElement('span');
passTag.className = `wallet-feature ${passValue.toLowerCase().replace(/\s+/g, '')}`;
passTag.textContent = passValue;
// Add tooltip for BIP39 passphrase
if (category.name === 'Lightning Wallets') {
switch (passValue) {
case 'Yes':
passTag.setAttribute('title', 'Passphrase supported - additional security layer for seed phrase');
break;
case 'No':
passTag.setAttribute('title', 'Passphrase not supported - no additional security layer available');
break;
case 'Optional':
passTag.setAttribute('title', 'Passphrase optional - can be used for additional security');
break;
case 'Required':
passTag.setAttribute('title', 'Passphrase required - mandatory additional security layer');
break;
case 'N/A':
passTag.setAttribute('title', 'Not applicable - passphrase not relevant for this wallet type');
break;
default:
passTag.setAttribute('title', `Passphrase: ${passValue}`);
}
} else {
switch (passValue) {
case 'Yes':
passTag.setAttribute('title', 'BIP39 passphrase supported - additional security layer for seed phrase');
break;
case 'No':
passTag.setAttribute('title', 'BIP39 passphrase not supported - no additional security layer available');
break;
case 'Optional':
passTag.setAttribute('title', 'BIP39 passphrase optional - can be used for additional security');
break;
case 'Required':
passTag.setAttribute('title', 'BIP39 passphrase required - mandatory additional security layer');
break;
case 'N/A':
passTag.setAttribute('title', 'Not applicable - BIP39 passphrase not relevant for this wallet type');
break;
default:
passTag.setAttribute('title', `BIP39 passphrase: ${passValue}`);
}
}
passCell.appendChild(passTag);
row.appendChild(passCell);
// Add WIF Support cell for Software Wallets with improved display
if (category.name === 'Software Wallets') {
const wifCell = document.createElement('td');
wifCell.style.textAlign = 'center';
const wifValue = wallet.wif_support || 'N/A';
const wifTag = document.createElement('span');
wifTag.className = `wallet-feature ${wifValue.toLowerCase().replace(/\s+/g, '')}`;
wifTag.textContent = wifValue;
// Add tooltip for WIF support
switch (wifValue) {
case 'Yes':
wifTag.setAttribute('title', 'WIF support - can import/export private keys in WIF format');
break;
case 'No':
wifTag.setAttribute('title', 'No WIF support - cannot import/export private keys in WIF format');
break;
case 'N/A':
wifTag.setAttribute('title', 'Not applicable - WIF support not relevant for this wallet type');
break;
default:
wifTag.setAttribute('title', `WIF support: ${wifValue}`);
}
wifCell.appendChild(wifTag);
row.appendChild(wifCell);
}
// Add BIP174 PSBT cell for all except Lightning with improved display
if (category.name !== 'Lightning Wallets') {
const psbtCell = document.createElement('td');
psbtCell.style.textAlign = 'center';
const psbtValue = wallet.bip174_psbt || 'N/A';
const psbtTag = document.createElement('span');
psbtTag.className = `wallet-feature ${psbtValue.toLowerCase().replace(/\s+/g, '')}`;
psbtTag.textContent = psbtValue;
// Add tooltip for PSBT support
switch (psbtValue) {
case 'Yes':
psbtTag.setAttribute('title', 'BIP174 PSBT supported - enables secure multi-party transactions');
break;
case 'No':
psbtTag.setAttribute('title', 'BIP174 PSBT not supported - cannot participate in multi-party transactions');
break;
case 'WIP':
psbtTag.setAttribute('title', 'BIP174 PSBT support in progress - feature is being developed');
break;
case 'N/A':
psbtTag.setAttribute('title', 'Not applicable - PSBT support not relevant for this wallet type');
break;
default:
psbtTag.setAttribute('title', `BIP174 PSBT: ${psbtValue}`);
}
psbtCell.appendChild(psbtTag);
row.appendChild(psbtCell);
}
// Notes cell with links
const notesCell = document.createElement('td');
notesCell.className = 'notes-cell';
// Format the notes based on its type
if (typeof wallet.notes === 'string') {
// Legacy string format
notesCell.innerHTML = formatNotes(wallet.notes);
} else if (typeof wallet.notes === 'object') {
// New structured format
const formattedNotes = renderStructuredNotes(wallet.notes);
notesCell.innerHTML = formattedNotes;
}
row.appendChild(notesCell);
tbody.appendChild(row);
});
table.appendChild(tbody);
tableWrapper.appendChild(table);
section.appendChild(tableWrapper);
// Add no results message element (hidden by default)
const noResults = document.createElement('div');
noResults.className = 'no-results';
noResults.textContent = 'No matching wallets found.';
noResults.style.display = 'none';
section.appendChild(noResults);
// Add swipe hint for mobile users
const swipeHint = document.createElement('div');
swipeHint.className = 'swipe-hint';
swipeHint.textContent = '← Swipe to see all columns →';
section.insertBefore(swipeHint, tableWrapper);
container.appendChild(section);
// Add search functionality with debouncing for better performance
const debouncedSearch = debounce(() => {
const activePathFilter = pathFiltersDiv.querySelector('.path-filter-btn.active');
const pathType = activePathFilter ? activePathFilter.getAttribute('data-path') || 'all' : 'all';
filterTableByPath(table, pathType, pathFiltersDiv, noResults);
}, 150);
searchInput.addEventListener('input', debouncedSearch);
});
}
// Function to filter table rows based on search term
function filterTable(table, searchTerm, noResultsElement) {
const tbody = table.querySelector('tbody');
const rows = tbody.querySelectorAll('tr');
let hasVisibleRows = false;
rows.forEach(row => {
const cells = row.querySelectorAll('td');
let rowText = '';
cells.forEach(cell => {
rowText += ' ' + cell.textContent.toLowerCase();
});
if (rowText.includes(searchTerm)) {
row.style.display = '';
hasVisibleRows = true;
} else {
row.style.display = 'none';
}
});
// Show "no results" message if needed
if (noResultsElement) {
noResultsElement.style.display = hasVisibleRows ? 'none' : 'block';
}
}
// Function to filter table by derivation path
function filterTableByPath(table, pathType, filterContainer, noResultsElement) {
// Update active button
const buttons = filterContainer.querySelectorAll('.path-filter-btn');
buttons.forEach(btn => {
btn.classList.remove('active');
if ((pathType === 'all' && btn.textContent === 'All') ||
btn.getAttribute('data-path') === pathType) {
btn.classList.add('active');
}
});
const tbody = table.querySelector('tbody');
const rows = tbody.querySelectorAll('tr');
let visibleCount = 0;
const categorySection = table.closest('.wallet-category');
const searchInput = categorySection ? categorySection.querySelector('.search-input') : null;
const searchTerm = searchInput ? searchInput.value.toLowerCase().trim() : '';
rows.forEach(row => {
const rowText = row.textContent.toLowerCase();
const matchesSearch = !searchTerm || rowText.includes(searchTerm);
// If showing all, make all rows visible
if (pathType === 'all') {
row.style.display = matchesSearch ? '' : 'none';
if (matchesSearch) visibleCount++;
return;
}
// Get the wallet object for this row. Wallet is after the dynamic status
// columns, so use the explicit data attribute instead of nth-child.
const walletName = row.getAttribute('data-wallet-name') ||
row.querySelector('.wallet-name-cell a, .wallet-name-cell span')?.textContent ||
'';
const category = table.getAttribute('data-category');
const wallet = findWalletInData(walletName, category);
if (matchesSearch && wallet && wallet.derivation && wallet.derivation[pathType]) {
row.style.display = '';
visibleCount++;
} else {
row.style.display = 'none';
}
});
// Show "no results" message if needed
if (noResultsElement) {
noResultsElement.style.display = visibleCount > 0 ? 'none' : 'block';
}
// Update wallet count
const walletCountElem = categorySection ? categorySection.querySelector('.wallet-count') : null;
if (walletCountElem) {
const totalWallets = rows.length;
if (visibleCount === totalWallets) {
walletCountElem.textContent = `${totalWallets} wallets`;
} else {
walletCountElem.textContent = `${visibleCount} of ${totalWallets} wallets`;
}
}
}
// Helper function to find a wallet in the data by name and category
let globalWalletsData = null;
function findWalletInData(name, categoryName) {