BIP32 client select compiled into standalone

This commit is contained in:
Ian Coleman
2017-02-19 12:38:39 +11:00
parent cdfaaf00c6
commit 56530adc04
+75
View File
@@ -371,6 +371,15 @@
<a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">BIP32 spec</a> <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">BIP32 spec</a>
</p> </p>
</div> </div>
<div class="form-group">
<label for="bip32-client" class="col-sm-2 control-label" data-translate>Client</label>
<div class="col-sm-10">
<select id="bip32-client" class="client form-control">
<option value="custom">Custom derivation path</option>
<!-- populated by javascript -->
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="bip32-path" class="col-sm-2 control-label" data-translate>BIP32 Derivation Path</label> <label for="bip32-path" class="col-sm-2 control-label" data-translate>BIP32 Derivation Path</label>
<div class="col-sm-10"> <div class="col-sm-10">
@@ -396,6 +405,18 @@
</p> </p>
</div> </div>
</div> </div>
<div class="form-group">
<label for="core-path" class="col-sm-2 control-label" data-translate>Multibit</label>
<div class="col-sm-10">
<p class="form-control no-border">
<span data-translate-html>Use path <code>m/0'/0</code>.</span>
</p>
<p class="form-control no-border">
<span data-translate>For more info see</span>
<a href="https://multibit.org/" target="_blank">MultiBit HD</a>
</p>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label" data-translate>Block Explorers</label> <label class="col-sm-2 control-label" data-translate>Block Explorers</label>
<div class="col-sm-10"> <div class="col-sm-10">
@@ -41224,6 +41245,7 @@ window.Entropy = new (function() {
var DOM = {}; var DOM = {};
DOM.network = $(".network"); DOM.network = $(".network");
DOM.bip32Client = $("#bip32-client");
DOM.phraseNetwork = $("#network-phrase"); DOM.phraseNetwork = $("#network-phrase");
DOM.useEntropy = $(".use-entropy"); DOM.useEntropy = $(".use-entropy");
DOM.entropyContainer = $(".entropy-container"); DOM.entropyContainer = $(".entropy-container");
@@ -41278,6 +41300,7 @@ window.Entropy = new (function() {
function init() { function init() {
// Events // Events
DOM.network.on("change", networkChanged); DOM.network.on("change", networkChanged);
DOM.bip32Client.on("change", bip32ClientChanged);
DOM.useEntropy.on("change", setEntropyVisibility); DOM.useEntropy.on("change", setEntropyVisibility);
DOM.entropy.on("input", delayedEntropyChanged); DOM.entropy.on("input", delayedEntropyChanged);
DOM.entropyMnemonicLength.on("change", entropyChanged); DOM.entropyMnemonicLength.on("change", entropyChanged);
@@ -41303,6 +41326,7 @@ window.Entropy = new (function() {
hidePending(); hidePending();
hideValidationError(); hideValidationError();
populateNetworkSelect(); populateNetworkSelect();
populateClientSelect();
} }
// Event handlers // Event handlers
@@ -41318,6 +41342,23 @@ window.Entropy = new (function() {
} }
} }
function bip32ClientChanged(e) {
var clientIndex = DOM.bip32Client.val();
if (clientIndex == "custom") {
DOM.bip32path.prop("readonly", false);
}
else {
DOM.bip32path.prop("readonly", true);
clients[clientIndex].onSelect();
if (seed != null) {
phraseChanged();
}
else {
rootKeyChanged();
}
}
}
function setEntropyVisibility() { function setEntropyVisibility() {
if (isUsingOwnEntropy()) { if (isUsingOwnEntropy()) {
DOM.entropyContainer.removeClass("hidden"); DOM.entropyContainer.removeClass("hidden");
@@ -41912,6 +41953,16 @@ window.Entropy = new (function() {
} }
} }
function populateClientSelect() {
for (var i=0; i<clients.length; i++) {
var client = clients[i];
var option = $("<option>");
option.attr("value", i);
option.text(client.name);
DOM.bip32Client.append(option);
}
}
function getLanguage() { function getLanguage() {
var defaultLanguage = "english"; var defaultLanguage = "english";
// Try to get from existing phrase // Try to get from existing phrase
@@ -42342,6 +42393,30 @@ window.Entropy = new (function() {
}, },
] ]
var clients = [
{
name: "Bitcoin Core",
onSelect: function() {
DOM.bip32path.val("m/0'/0'");
DOM.hardenedAddresses.prop('checked', true);
},
},
{
name: "blockchain.info",
onSelect: function() {
DOM.bip32path.val("m/44'/0'/0'");
DOM.hardenedAddresses.prop('checked', false);
},
},
{
name: "MultiBit HD",
onSelect: function() {
DOM.bip32path.val("m/0'/0");
DOM.hardenedAddresses.prop('checked', false);
},
}
]
init(); init();
})(); })();