Added standard and bech32 conversion UI logic
This commit is contained in:
parent
5c0fbfe953
commit
9a7b55c381
63
index.html
63
index.html
@ -238,18 +238,28 @@
|
|||||||
<p class="panel-footer">Convert address: BTC ⇔ FLO</p>
|
<p class="panel-footer">Convert address: BTC ⇔ FLO</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid gap-0-5">
|
<div class="grid gap-0-5">
|
||||||
<sm-input id="convert_btc_input" placeholder="BTC Address" data-btc-address
|
<div class="flex">
|
||||||
error-text="Invalid BTC address" animate required></sm-input>
|
<sm-input id="convert_btc_input" placeholder="BTC Address" data-btc-address
|
||||||
<button id="convert_flo_btc" class="button--primary justify-self-center">
|
error-text="Invalid BTC address" animate required></sm-input>
|
||||||
<svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg" height="24px"
|
<button id="convert_to_flo" class="button--primary justify-self-center">
|
||||||
viewBox="0 0 24 24" width="24px" fill="#000000">
|
<!-- <svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
||||||
<path d="M0 0h24v24H0z" fill="none" />
|
width="24px" fill="#000000">
|
||||||
<path d="M16 17.01V10h-2v7.01h-3L15 21l4-3.99h-3zM9 3L5 6.99h3V14h2V6.99h3L9 3z" />
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||||
</svg>
|
<path d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z" />
|
||||||
Convert
|
</svg> -->
|
||||||
</button>
|
Get FLO
|
||||||
<sm-input id="convert_flo_input" placeholder="FLO Address" animate></sm-input>
|
</button>
|
||||||
<div class="flex align-center">
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<sm-input id="convert_flo_input" placeholder="FLO Address" animate></sm-input>
|
||||||
|
<button id="convert_to_btc" class="button--primary justify-self-center">
|
||||||
|
<!-- <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="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z" />
|
||||||
|
</svg> -->
|
||||||
|
Get BTC
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@ -1381,20 +1391,31 @@
|
|||||||
getRef('btc_private').value = btc_wif;
|
getRef('btc_private').value = btc_wif;
|
||||||
getRef('priv_key_bech32').value = btc_api.bech32Address(btc_wif);
|
getRef('priv_key_bech32').value = btc_api.bech32Address(btc_wif);
|
||||||
}
|
}
|
||||||
getRef('convert_flo_btc').onclick = evt => {
|
getRef('convert_to_flo').onclick = evt => {
|
||||||
const flo_addr = getRef('convert_flo_input').value.trim();
|
|
||||||
const btc_bech = getRef('convert_btc_input').value.trim();
|
const btc_bech = getRef('convert_btc_input').value.trim();
|
||||||
if (btc_bech === '' && flo_addr === '') {
|
if (btc_bech === '') {
|
||||||
notify('Please enter either FLO or BTC address', 'error');
|
getRef('convert_btc_input').focusIn()
|
||||||
return;
|
return notify('Please enter BTC address', 'error');
|
||||||
}
|
}
|
||||||
console.log(flo_addr, btc_bech)
|
const type = coinjs.addressDecode(btc_bech).type
|
||||||
if (flo_addr !== '') {
|
const isLegacy = /\w{34,35}$/.test(btc_bech)
|
||||||
getRef('convert_btc_input').value = btc_api.convert.legacy2bech(flo_addr);
|
if (type === 'standard') {
|
||||||
} else {
|
getRef('convert_flo_input').value = btc_api.convert.legacy2legacy(btc_bech, 0x23);
|
||||||
|
} else if (type === 'bech32') {
|
||||||
getRef('convert_flo_input').value = btc_api.convert.bech2legacy(btc_bech, 0x23);
|
getRef('convert_flo_input').value = btc_api.convert.bech2legacy(btc_bech, 0x23);
|
||||||
|
} else {
|
||||||
|
getRef('convert_flo_input').value = '';
|
||||||
|
notify(`Multisig address can't be converted to FLO`, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getRef('convert_to_btc').onclick = evt => {
|
||||||
|
const flo_addr = getRef('convert_flo_input').value.trim();
|
||||||
|
if (flo_addr === '') {
|
||||||
|
getRef('convert_flo_input').focusIn();
|
||||||
|
return notify('Please enter FLO address', 'error');
|
||||||
|
}
|
||||||
|
getRef('convert_btc_input').value = btc_api.convert.legacy2bech(flo_addr);
|
||||||
|
}
|
||||||
const txParticipantsObserver = new MutationObserver(mutations => {
|
const txParticipantsObserver = new MutationObserver(mutations => {
|
||||||
mutations.forEach(mutation => {
|
mutations.forEach(mutation => {
|
||||||
if (mutation.type === 'childList') {
|
if (mutation.type === 'childList') {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user