feat: Add Bitcoin address support and improve UX
- Add Bitcoin bech32 address generation with proper BTC WIF private keys (L/K prefix) - Reject FLO/BTC addresses in balance search (ETH addresses and private keys only) - Update search placeholder for clarity - Move notifications to top-right on desktop to avoid Searched addresses overlap
This commit is contained in:
parent
67309e9273
commit
5d1882e6a7
48
index.html
48
index.html
@ -142,8 +142,7 @@
|
||||
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
||||
width="24px" fill="#000000">
|
||||
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||
<path
|
||||
d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z" />
|
||||
<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z" />
|
||||
</svg>
|
||||
<span class="nav-item__title">
|
||||
Retrieve
|
||||
@ -460,24 +459,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
//Moving notification draw so that it does not overlap the menu item
|
||||
(function placeToasts() {
|
||||
//Moving notification draw so that it does not overlap the menu item
|
||||
(function placeToasts() {
|
||||
const drawer = document.getElementById('notification_drawer');
|
||||
const panel = drawer?.shadowRoot?.querySelector('.notification-panel');
|
||||
if (!panel) return;
|
||||
|
||||
const apply = () => {
|
||||
if (window.matchMedia('(min-width: 640px)').matches) {
|
||||
// Desktop: offset from left navbar
|
||||
// Desktop: top-right corner
|
||||
Object.assign(panel.style, {
|
||||
left: 'calc(10rem + 1rem)',
|
||||
bottom: '1rem',
|
||||
top: 'auto',
|
||||
right: '1rem', // optional, lets long toasts wrap before content edge
|
||||
left: 'auto',
|
||||
top: '1rem',
|
||||
right: '1rem',
|
||||
bottom: 'auto',
|
||||
zIndex: '1000'
|
||||
});
|
||||
} else {
|
||||
// Mobile: keep top-right or top-left as you prefer
|
||||
// Mobile: top-center
|
||||
Object.assign(panel.style, {
|
||||
left: '0.5rem',
|
||||
top: '0.5rem',
|
||||
@ -490,7 +489,7 @@
|
||||
|
||||
apply();
|
||||
window.addEventListener('resize', apply);
|
||||
})();
|
||||
})();
|
||||
|
||||
</script>
|
||||
<script>
|
||||
@ -665,7 +664,7 @@
|
||||
</h2>
|
||||
<sm-form oninvalid="handleInvalidSearch()">
|
||||
<div id="input_wrapper">
|
||||
<sm-input id="check_balance_input" class="password-field flex-1" placeholder="Address, private key, or tx hash"
|
||||
<sm-input id="check_balance_input" class="password-field flex-1" placeholder="ETH address, private key, or tx hash"
|
||||
type="password" animate>
|
||||
<svg class="icon" slot="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <g> <rect fill="none" height="24" width="24"></rect> </g> <g> <path d="M21,10h-8.35C11.83,7.67,9.61,6,7,6c-3.31,0-6,2.69-6,6s2.69,6,6,6c2.61,0,4.83-1.67,5.65-4H13l2,2l2-2l2,2l4-4.04L21,10z M7,15c-1.65,0-3-1.35-3-3c0-1.65,1.35-3,3-3s3,1.35,3,3C10,13.65,8.65,15,7,15z"> </path> </g> </svg>
|
||||
<label slot="right" class="interact">
|
||||
@ -777,6 +776,18 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Reject FLO addresses (start with F)
|
||||
if (/^F[a-km-zA-HJ-NP-Z1-9]{26,34}$/.test(keyToConvert)) {
|
||||
notify('FLO addresses are not supported. Please use an ETH address or private key.', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Reject BTC addresses (legacy: 1/3, segwit: bc1)
|
||||
if (/^(1|3)[a-km-zA-HJ-NP-Z1-9]{25,34}$/.test(keyToConvert) || /^bc1[a-z0-9]{39,59}$/i.test(keyToConvert)) {
|
||||
notify('BTC addresses are not supported. Please use an ETH address or private key.', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if it's a valid Ethereum address
|
||||
if (ethOperator.isValidAddress(keyToConvert)) {
|
||||
ethAddress = keyToConvert
|
||||
@ -1812,6 +1823,9 @@
|
||||
const { floID, privKey } = floCrypto.generateNewID();
|
||||
const ethPrivateKey = coinjs.wif2privkey(privKey).privkey;
|
||||
const ethAddress = floEthereum.ethAddressFromPrivateKey(ethPrivateKey)
|
||||
const btcBech32 = btcOperator.bech32Address(privKey);
|
||||
// Convert FLO WIF to Bitcoin WIF format (L/K prefix)
|
||||
const btcPrivKey = btcOperator.convert.wif(privKey);
|
||||
renderElem(getRef('created_address_wrapper'), html`
|
||||
<ul id="generated_addresses" class="grid gap-1-5">
|
||||
<li class="grid gap-0-5">
|
||||
@ -1824,6 +1838,16 @@
|
||||
<sm-copy value="${privKey}"></sm-copy>
|
||||
</div>
|
||||
</li>
|
||||
<li class="grid gap-0-5">
|
||||
<div>
|
||||
<h5>Bitcoin Address</h5>
|
||||
<sm-copy value="${btcBech32}"></sm-copy>
|
||||
</div>
|
||||
<div>
|
||||
<h5>Private Key</h5>
|
||||
<sm-copy value="${btcPrivKey}"></sm-copy>
|
||||
</div>
|
||||
</li>
|
||||
<li class="grid gap-0-5">
|
||||
<div>
|
||||
<h5>Equivalent Ethereum Address</h5>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user