X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fjs%2Findex.js;h=614bcc50923ae77cc224c6468743b5b3af8a933b;hb=bac5eda2c1d565b6e1a97e1ba3e48c9e0ea4eb17;hp=62bab81bf3efa6cf9a1b0f751c2d7f19206f8416;hpb=8131a0711504451fa46551e0074f519215d68310;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/src/js/index.js b/src/js/index.js index 62bab81..614bcc5 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -15,6 +15,7 @@ var showPrivKey = true; var showQr = false; var litecoinUseLtub = true; + var isDefaultBip44ChangeValue = true; var entropyTypeAutoDetect = true; var entropyChangeTimeoutEvent = null; @@ -74,6 +75,7 @@ DOM.bip44accountXprv = $("#bip44 .account-xprv"); DOM.bip44accountXpub = $("#bip44 .account-xpub"); DOM.bip44change = $("#bip44 .change"); + DOM.defaultBip44ChangeValue = $("#bip44 .default-bip44-change-value"); DOM.bip49unavailable = $("#bip49 .unavailable"); DOM.bip49available = $("#bip49 .available"); DOM.bip49path = $("#bip49-path"); @@ -141,7 +143,9 @@ DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); DOM.bip32path.on("input", calcForDerivationPath); DOM.bip44account.on("input", calcForDerivationPath); + DOM.bip44change.on("input", modifiedDefaultBip44ChangeValue); DOM.bip44change.on("input", calcForDerivationPath); + DOM.defaultBip44ChangeValue.on("click", resetDefaultBip44ChangeValue); DOM.bip49account.on("input", calcForDerivationPath); DOM.bip49change.on("input", calcForDerivationPath); DOM.bip84account.on("input", calcForDerivationPath); @@ -822,12 +826,14 @@ var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); var coin = parseIntNoNaN(DOM.bip44coin.val(), 0); var account = parseIntNoNaN(DOM.bip44account.val(), 0); - var change = parseIntNoNaN(DOM.bip44change.val(), 0); - var path = "m/"; - path += purpose + "'/"; - path += coin + "'/"; - path += account + "'/"; - path += change; + var change = parseIntNoNaN(DOM.bip44change.val(), ""); + var path = "m"; + path += "/" + purpose + "'"; + path += "/" + coin + "'"; + path += "/" + account + "'"; + if (change !== "") { + path += "/" + change; + } DOM.bip44path.val(path); var derivationPath = DOM.bip44path.val(); console.log("Using derivation path from BIP44 tab: " + derivationPath); @@ -1134,8 +1140,10 @@ var hexAddress = addressBuffer.toString('hex'); var checksumAddress = libs.ethUtil.toChecksumAddress(hexAddress); address = libs.ethUtil.addHexPrefix(checksumAddress); - privkey = libs.ethUtil.addHexPrefix(privkey); pubkey = libs.ethUtil.addHexPrefix(pubkey); + if (hasPrivkey) { + privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer()); + } } // Stellar is different @@ -1163,6 +1171,11 @@ privkey = convertRipplePriv(privkey); address = convertRippleAdrr(address); } + // Jingtum values are different + if (networks[DOM.network.val()].name == "SWTC - Jingtum") { + privkey = convertJingtumPriv(privkey); + address = convertJingtumAdrr(address); + } // CasinoCoin values are different if (networks[DOM.network.val()].name == "CSC - CasinoCoin") { privkey = convertCasinoCoinPriv(privkey); @@ -1830,6 +1843,7 @@ || (name == "EWT - EnergyWeb") || (name == "PIRL - Pirl") || (name == "MIX - MIX") + || (name == "MOAC - MOAC") || (name == "MUSIC - Musicoin") || (name == "POA - Poa") || (name == "EXP - Expanse") @@ -1870,10 +1884,30 @@ return DOM.bip141tab.hasClass("active"); } + function setBip44ChangeValue() { + if (isDefaultBip44ChangeValue) { + if (networkIsEthereum()) { + DOM.bip44change.val(""); + } else { + DOM.bip44change.val(0); + } + } + } + + function modifiedDefaultBip44ChangeValue() { + isDefaultBip44ChangeValue = false; + } + + function resetDefaultBip44ChangeValue() { + isDefaultBip44ChangeValue = true; + setBip44ChangeValue(); + } + function setHdCoin(coinValue) { DOM.bip44coin.val(coinValue); DOM.bip49coin.val(coinValue); DOM.bip84coin.val(coinValue); + setBip44ChangeValue(); } function showSegwitAvailable() { @@ -2736,6 +2770,14 @@ setHdCoin(214); }, }, + { + name: "MOAC - MOAC", + segwitAvailable: false, + onSelect: function() { + network = libs.bitcoin.networks.bitcoin; + setHdCoin(314); + }, + }, { name: "MUSIC - Musicoin", segwitAvailable: false, @@ -2956,6 +2998,20 @@ setHdCoin(175); }, }, + { + name: "RBTC - RSK", + onSelect: function() { + network = libs.bitcoin.networks.rubycoin; + setHdCoin(137); + }, + }, + { + name: "tRBTC - RSK Testnet", + onSelect: function() { + network = libs.bitcoin.networks.rubycoin; + setHdCoin(37310); + }, + }, { name: "RBY - Rubycoin", onSelect: function() { @@ -3061,6 +3117,13 @@ setHdCoin(105); }, }, + { + name: "SWTC - Jingtum", + onSelect: function() { + network = libs.bitcoin.networks.bitcoin; + setHdCoin(315); + }, + }, { name: "TSTRAT - Stratis Testnet", onSelect: function() {