mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-07 03:12:14 +00:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a8d06d03e | ||
|
|
88311463c7 | ||
|
|
cd7c8327b1 | ||
|
|
0cda44d5f6 | ||
|
|
7258b102c1 | ||
|
|
8d18f379fd | ||
|
|
3abab9b087 | ||
|
|
b18eb97ae3 | ||
|
|
88ea3e40ee | ||
|
|
8a9f391376 | ||
|
|
e40acc3ab0 | ||
|
|
56ad960105 | ||
|
|
f128bd58c4 | ||
|
|
0eda54f5a7 | ||
|
|
ed6d9d3905 | ||
|
|
47b64d3ee1 | ||
|
|
bc33f5ee53 | ||
|
|
c0df01895d | ||
|
|
b3cc3930d0 | ||
|
|
c18511dd0d | ||
|
|
7ebdf61c99 | ||
|
|
daab55dc61 | ||
|
|
7b742f87d3 | ||
|
|
4d9c184a84 | ||
|
|
d5e01cc6e2 | ||
|
|
adedbf9169 | ||
|
|
f36d10080a | ||
|
|
8335cf17bc |
@@ -118,7 +118,7 @@
|
||||
<div class="container">
|
||||
|
||||
<h1 class="text-center">Mnemonic Code Converter</h1>
|
||||
<p class="version">v0.2.0</p>
|
||||
<p class="version">v0.2.5</p>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@@ -270,6 +270,15 @@
|
||||
<textarea id="root-key" class="root-key form-control" data-show-qr></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group litecoin-ltub-container hidden">
|
||||
<label for="litecoin-use-ltub" class="col-sm-2 control-label" data-translate>Prefixes</label>
|
||||
<div class="col-sm-10 checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="litecoin-use-ltub" class="litecoin-use-ltub">
|
||||
Use <code>Ltpv / Ltub</code> instead of <code>xprv / xpub</code>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -403,6 +412,13 @@
|
||||
<span data-translate>Use hardened addresses</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2"></div>
|
||||
<label class="col-sm-10">
|
||||
<input class="p2wpkh-nested-in-p2sh" type="checkbox">
|
||||
<span data-translate>Use SegWit addresses (ie P2WPKH Nested In P2SH)</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="core-path" class="col-sm-2 control-label" data-translate>Bitcoin Core</label>
|
||||
<div class="col-sm-10">
|
||||
@@ -16926,6 +16942,16 @@ module.exports = {
|
||||
wif: 0xef
|
||||
},
|
||||
litecoin: {
|
||||
messagePrefix: '\x19Litecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x30,
|
||||
scriptHash: 0x32,
|
||||
wif: 0xb0
|
||||
},
|
||||
litecoinLtub: {
|
||||
messagePrefix: '\x19Litecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x019da462,
|
||||
@@ -22104,7 +22130,8 @@ module.exports = {
|
||||
|
||||
}).call(this,require("buffer").Buffer)
|
||||
},{"bs58check":80,"buffer":4}]},{},[33])(33)
|
||||
});</script>
|
||||
});
|
||||
</script>
|
||||
<script>bitcoinjs.bitcoin.networks.shadow = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
@@ -22160,6 +22187,17 @@ bitcoinjs.bitcoin.networks.dash = {
|
||||
wif: 0xcc,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.maza = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x09,
|
||||
wif: 0xe0,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dashtn = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
@@ -22291,6 +22329,39 @@ bitcoinjs.bitcoin.networks.zetacoin = {
|
||||
scriptHash: 0x09,
|
||||
wif: 0xe0,
|
||||
}
|
||||
|
||||
bitcoinjs.bitcoin.networks.myriadcoin = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x00, // TODO set this correctly
|
||||
wif: 0xb2,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.pivx = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
public: 0x022d2533,
|
||||
private: 0x0221312b
|
||||
},
|
||||
pubKeyHash: 0x1e,
|
||||
scriptHash: 0x0d,
|
||||
wif: 0xd4,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.pivxtestnet = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
public: 0x3a8061a0,
|
||||
private: 0x3a805837
|
||||
},
|
||||
pubKeyHash: 0x8b,
|
||||
scriptHash: 0x13,
|
||||
wif: 0xef,
|
||||
};
|
||||
</script>
|
||||
<script>(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethUtil = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
(function (global){
|
||||
@@ -46067,6 +46138,7 @@ window.Entropy = new (function() {
|
||||
var showPubKey = true;
|
||||
var showPrivKey = true;
|
||||
var showQr = false;
|
||||
var litecoinUseLtub = false;
|
||||
|
||||
var entropyChangeTimeoutEvent = null;
|
||||
var phraseChangeTimeoutEvent = null;
|
||||
@@ -46096,6 +46168,8 @@ window.Entropy = new (function() {
|
||||
DOM.generate = $(".generate");
|
||||
DOM.seed = $(".seed");
|
||||
DOM.rootKey = $(".root-key");
|
||||
DOM.litecoinLtubContainer = $(".litecoin-ltub-container");
|
||||
DOM.litecoinUseLtub = $(".litecoin-use-ltub");
|
||||
DOM.extendedPrivKey = $(".extended-priv-key");
|
||||
DOM.extendedPubKey = $(".extended-pub-key");
|
||||
DOM.bip32tab = $("#bip32-tab");
|
||||
@@ -46123,6 +46197,7 @@ window.Entropy = new (function() {
|
||||
DOM.bip49change = $("#bip49 .change");
|
||||
DOM.generatedStrength = $(".generate-container .strength");
|
||||
DOM.hardenedAddresses = $(".hardened-addresses");
|
||||
DOM.useP2wpkhNestedInP2sh = $(".p2wpkh-nested-in-p2sh");
|
||||
DOM.addresses = $(".addresses");
|
||||
DOM.rowsToAdd = $(".rows-to-add");
|
||||
DOM.more = $(".more");
|
||||
@@ -46151,6 +46226,7 @@ window.Entropy = new (function() {
|
||||
DOM.generate.on("click", generateClicked);
|
||||
DOM.more.on("click", showMore);
|
||||
DOM.rootKey.on("input", delayedRootKeyChanged);
|
||||
DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
|
||||
DOM.bip32path.on("input", calcForDerivationPath);
|
||||
DOM.bip44account.on("input", calcForDerivationPath);
|
||||
DOM.bip44change.on("input", calcForDerivationPath);
|
||||
@@ -46158,6 +46234,7 @@ window.Entropy = new (function() {
|
||||
DOM.bip49change.on("input", calcForDerivationPath);
|
||||
DOM.tab.on("shown.bs.tab", calcForDerivationPath);
|
||||
DOM.hardenedAddresses.on("change", calcForDerivationPath);
|
||||
DOM.useP2wpkhNestedInP2sh.on("change", calcForDerivationPath);
|
||||
DOM.indexToggle.on("click", toggleIndexes);
|
||||
DOM.addressToggle.on("click", toggleAddresses);
|
||||
DOM.publicKeyToggle.on("click", togglePublicKeys);
|
||||
@@ -46176,14 +46253,15 @@ window.Entropy = new (function() {
|
||||
function networkChanged(e) {
|
||||
clearDerivedKeys();
|
||||
clearAddressesList();
|
||||
DOM.litecoinLtubContainer.addClass("hidden");
|
||||
var networkIndex = e.target.value;
|
||||
var network = networks[networkIndex];
|
||||
network.onSelect();
|
||||
if (network.bip49available) {
|
||||
showBip49();
|
||||
if (network.p2wpkhNestedInP2shAvailable) {
|
||||
showP2wpkhNestedInP2shAvailable();
|
||||
}
|
||||
else {
|
||||
hideBip49();
|
||||
showP2wpkhNestedInP2shUnavailable();
|
||||
}
|
||||
if (seed != null) {
|
||||
phraseChanged();
|
||||
@@ -46228,6 +46306,10 @@ window.Entropy = new (function() {
|
||||
|
||||
function delayedPhraseChanged() {
|
||||
hideValidationError();
|
||||
seed = null;
|
||||
bip32RootKey = null;
|
||||
bip32ExtendedKey = null;
|
||||
clearAddressesList();
|
||||
showPending();
|
||||
if (phraseChangeTimeoutEvent != null) {
|
||||
clearTimeout(phraseChangeTimeoutEvent);
|
||||
@@ -46237,7 +46319,6 @@ window.Entropy = new (function() {
|
||||
|
||||
function phraseChanged() {
|
||||
showPending();
|
||||
hideValidationError();
|
||||
setMnemonicLanguage();
|
||||
// Get the mnemonic phrase
|
||||
var phrase = DOM.phrase.val();
|
||||
@@ -46250,7 +46331,6 @@ window.Entropy = new (function() {
|
||||
var passphrase = DOM.passphrase.val();
|
||||
calcBip32RootKeyFromSeed(phrase, passphrase);
|
||||
calcForDerivationPath();
|
||||
hidePending();
|
||||
}
|
||||
|
||||
function delayedEntropyChanged() {
|
||||
@@ -46313,7 +46393,6 @@ window.Entropy = new (function() {
|
||||
function rootKeyChanged() {
|
||||
showPending();
|
||||
hideValidationError();
|
||||
// Validate the root key TODO
|
||||
var rootKeyBase58 = DOM.rootKey.val();
|
||||
var errorText = validateRootKey(rootKeyBase58);
|
||||
if (errorText) {
|
||||
@@ -46325,11 +46404,21 @@ window.Entropy = new (function() {
|
||||
calcForDerivationPath();
|
||||
}
|
||||
|
||||
function litecoinUseLtubChanged() {
|
||||
litecoinUseLtub = DOM.litecoinUseLtub.prop("checked");
|
||||
if (litecoinUseLtub) {
|
||||
network = bitcoinjs.bitcoin.networks.litecoinLtub;
|
||||
}
|
||||
else {
|
||||
network = bitcoinjs.bitcoin.networks.litecoin;
|
||||
}
|
||||
phraseChanged();
|
||||
}
|
||||
|
||||
function calcForDerivationPath() {
|
||||
showPending();
|
||||
clearDerivedKeys();
|
||||
clearAddressesList();
|
||||
hideValidationError();
|
||||
showPending();
|
||||
// Don't show bip49 if it's selected but network doesn't support it
|
||||
if (bip49TabSelected() && !networkHasBip49()) {
|
||||
return;
|
||||
@@ -46349,7 +46438,6 @@ window.Entropy = new (function() {
|
||||
displayBip49Info();
|
||||
}
|
||||
displayBip32Info();
|
||||
hidePending();
|
||||
}
|
||||
|
||||
function generateClicked() {
|
||||
@@ -46497,7 +46585,7 @@ window.Entropy = new (function() {
|
||||
|
||||
function validateRootKey(rootKeyBase58) {
|
||||
try {
|
||||
bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58);
|
||||
bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
|
||||
}
|
||||
catch (e) {
|
||||
return "Invalid root key";
|
||||
@@ -46585,7 +46673,9 @@ window.Entropy = new (function() {
|
||||
return "No root key";
|
||||
}
|
||||
// Check no hardened derivation path when using xpub keys
|
||||
var hardened = path.indexOf("'") > -1;
|
||||
var hardenedPath = path.indexOf("'") > -1;
|
||||
var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked");
|
||||
var hardened = hardenedPath || hardenedAddresses;
|
||||
var isXpubkey = bip32RootKey.isNeutered();
|
||||
if (hardened && isXpubkey) {
|
||||
return "Hardened derivation path is invalid with xpub key";
|
||||
@@ -46656,23 +46746,25 @@ window.Entropy = new (function() {
|
||||
for (var i=0; i<rows.length; i++) {
|
||||
rows[i].shouldGenerate = false;
|
||||
}
|
||||
hidePending();
|
||||
}
|
||||
|
||||
for (var i=0; i<total; i++) {
|
||||
var index = i + start;
|
||||
rows.push(new TableRow(index));
|
||||
var isLast = i == total - 1;
|
||||
rows.push(new TableRow(index, isLast));
|
||||
}
|
||||
|
||||
})());
|
||||
}
|
||||
|
||||
function TableRow(index) {
|
||||
function TableRow(index, isLast) {
|
||||
|
||||
var self = this;
|
||||
this.shouldGenerate = true;
|
||||
var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
|
||||
var isBip49 = bip49TabSelected();
|
||||
var bip49available = networkHasBip49();
|
||||
var isP2wpkhNestedInP2sh = bip49TabSelected() || (bip32TabSelected() && useP2wpkhNestedInP2sh());
|
||||
var p2wpkhNestedInP2shAvailable = networkHasBip49();
|
||||
|
||||
function init() {
|
||||
calculateValues();
|
||||
@@ -46717,8 +46809,8 @@ window.Entropy = new (function() {
|
||||
address = convertRippleAdrr(address);
|
||||
}
|
||||
// BIP49 addresses are different
|
||||
if (isBip49) {
|
||||
if (!bip49available) {
|
||||
if (isP2wpkhNestedInP2sh) {
|
||||
if (!p2wpkhNestedInP2shAvailable) {
|
||||
return;
|
||||
}
|
||||
var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
|
||||
@@ -46728,6 +46820,9 @@ window.Entropy = new (function() {
|
||||
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
|
||||
}
|
||||
addAddressToList(indexText, address, pubkey, privkey);
|
||||
if (isLast) {
|
||||
hidePending();
|
||||
}
|
||||
}, 50)
|
||||
}
|
||||
|
||||
@@ -46871,6 +46966,9 @@ window.Entropy = new (function() {
|
||||
var option = $("<option>");
|
||||
option.attr("value", i);
|
||||
option.text(network.name);
|
||||
if (network.name == "BTC - Bitcoin") {
|
||||
option.prop("selected", true);
|
||||
}
|
||||
DOM.phraseNetwork.append(option);
|
||||
}
|
||||
}
|
||||
@@ -47192,8 +47290,12 @@ window.Entropy = new (function() {
|
||||
return DOM.bip32tab.hasClass("active");
|
||||
}
|
||||
|
||||
function useP2wpkhNestedInP2sh() {
|
||||
return DOM.useP2wpkhNestedInP2sh.prop("checked");
|
||||
}
|
||||
|
||||
function networkHasBip49() {
|
||||
return networks[DOM.network.val()].bip49available;
|
||||
return networks[DOM.network.val()].p2wpkhNestedInP2shAvailable;
|
||||
}
|
||||
|
||||
function bip49TabSelected() {
|
||||
@@ -47205,20 +47307,31 @@ window.Entropy = new (function() {
|
||||
DOM.bip49coin.val(coinValue);
|
||||
}
|
||||
|
||||
function showBip49() {
|
||||
function showP2wpkhNestedInP2shAvailable() {
|
||||
DOM.bip49unavailable.addClass("hidden");
|
||||
DOM.bip49available.removeClass("hidden");
|
||||
DOM.useP2wpkhNestedInP2sh.prop("disabled", false);
|
||||
}
|
||||
|
||||
function hideBip49() {
|
||||
function showP2wpkhNestedInP2shUnavailable() {
|
||||
DOM.bip49available.addClass("hidden");
|
||||
DOM.bip49unavailable.removeClass("hidden");
|
||||
DOM.useP2wpkhNestedInP2sh.prop("disabled", true);
|
||||
DOM.useP2wpkhNestedInP2sh.prop("checked", false);
|
||||
}
|
||||
|
||||
var networks = [
|
||||
{
|
||||
name: "BCH - Bitcoin Cash",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(145);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BTC - Bitcoin",
|
||||
bip49available: true,
|
||||
p2wpkhNestedInP2shAvailable: true,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(0);
|
||||
@@ -47226,7 +47339,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "BTC - Bitcoin Testnet",
|
||||
bip49available: true,
|
||||
p2wpkhNestedInP2shAvailable: true,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.testnet;
|
||||
setHdCoin(1);
|
||||
@@ -47234,7 +47347,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "CLAM - Clams",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.clam;
|
||||
setHdCoin(23);
|
||||
@@ -47242,7 +47355,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "CRW - Crown",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.crown;
|
||||
setHdCoin(72);
|
||||
@@ -47250,7 +47363,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "DASH - Dash",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.dash;
|
||||
setHdCoin(5);
|
||||
@@ -47258,7 +47371,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "DASH - Dash Testnet",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.dashtn;
|
||||
setHdCoin(1);
|
||||
@@ -47266,7 +47379,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "DOGE - Dogecoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.dogecoin;
|
||||
setHdCoin(3);
|
||||
@@ -47274,7 +47387,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "ETH - Ethereum",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(60);
|
||||
@@ -47282,7 +47395,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "GAME - GameCredits",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.game;
|
||||
setHdCoin(101);
|
||||
@@ -47290,7 +47403,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "JBS - Jumbucks",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.jumbucks;
|
||||
setHdCoin(26);
|
||||
@@ -47298,23 +47411,49 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "LTC - Litecoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.litecoin;
|
||||
setHdCoin(2);
|
||||
DOM.litecoinLtubContainer.removeClass("hidden");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MAZA - Maza",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.maza;
|
||||
setHdCoin(13);
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "NMC - Namecoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.namecoin;
|
||||
setHdCoin(7);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PIVX - PIVX",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.pivx;
|
||||
setHdCoin(119);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PIVX - PIVX Testnet",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.pivxtestnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PPC - Peercoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.peercoin;
|
||||
setHdCoin(6);
|
||||
@@ -47322,7 +47461,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "SDC - ShadowCash",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.shadow;
|
||||
setHdCoin(35);
|
||||
@@ -47330,7 +47469,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "SDC - ShadowCash Testnet",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.shadowtn;
|
||||
setHdCoin(1);
|
||||
@@ -47338,7 +47477,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "SLM - Slimcoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.slimcoin;
|
||||
setHdCoin(63);
|
||||
@@ -47346,7 +47485,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "SLM - Slimcoin Testnet",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.slimcointn;
|
||||
setHdCoin(111);
|
||||
@@ -47354,7 +47493,7 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "VIA - Viacoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.viacoin;
|
||||
setHdCoin(14);
|
||||
@@ -47362,15 +47501,23 @@ window.Entropy = new (function() {
|
||||
},
|
||||
{
|
||||
name: "VIA - Viacoin Testnet",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.viacointestnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "XMY - Myriadcoin",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.myriadcoin;
|
||||
setHdCoin(90);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "XRP - Ripple",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(144);
|
||||
|
||||
27
changelog.md
27
changelog.md
@@ -1,3 +1,30 @@
|
||||
# 0.2.5
|
||||
|
||||
* Rename variables for clarity between BIP49 and P2WPKH Nested In P2SH
|
||||
* Fix bug for validation of root key when using non-bitcoin networks
|
||||
* Add option to use P2WPKH Nested In P2SH addresses on BIP32 tab
|
||||
|
||||
# 0.2.4
|
||||
|
||||
* Show error when using xpub with hardened addresses
|
||||
* Allow switching litecoin prefixes between xprv and Ltpv
|
||||
|
||||
# 0.2.3
|
||||
|
||||
* Add maza coin
|
||||
|
||||
# 0.2.2
|
||||
|
||||
* Improve showing feedback for pending calculations
|
||||
* Bugfix: Clear old seed when mnemonic is changed
|
||||
* Add PIVX network
|
||||
|
||||
# 0.2.1
|
||||
|
||||
* BTC is the default coin
|
||||
* Add myriadcoin
|
||||
* Add Bitcon Cash
|
||||
|
||||
# 0.2.0
|
||||
|
||||
* BitcoinJS library upgrded to v3.1.1
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Once all code changes for this version have been committed, a release can be
|
||||
created with the following steps:
|
||||
|
||||
1. Run tests and ensure all tests pass
|
||||
1. Set the version in index.html
|
||||
1. Update changelog
|
||||
1. Run `python compile.py`
|
||||
@@ -15,3 +16,6 @@ created with the following steps:
|
||||
1. include the signed release notes as text for the release
|
||||
1. attach the bip39-standalone.html file
|
||||
1. Add a new post to twitter from @bip39tool with the version, link and hash
|
||||
1. Publish to any hosted locations (eg iancoleman.github.io/bip39)
|
||||
1. Download the file from the release and confirm it hashes to the expected value
|
||||
1. Confirm the signature as posted to the release notes.
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
<div class="container">
|
||||
|
||||
<h1 class="text-center">Mnemonic Code Converter</h1>
|
||||
<p class="version">v0.2.0</p>
|
||||
<p class="version">v0.2.5</p>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@@ -266,6 +266,15 @@
|
||||
<textarea id="root-key" class="root-key form-control" data-show-qr></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group litecoin-ltub-container hidden">
|
||||
<label for="litecoin-use-ltub" class="col-sm-2 control-label" data-translate>Prefixes</label>
|
||||
<div class="col-sm-10 checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="litecoin-use-ltub" class="litecoin-use-ltub">
|
||||
Use <code>Ltpv / Ltub</code> instead of <code>xprv / xpub</code>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -399,6 +408,13 @@
|
||||
<span data-translate>Use hardened addresses</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2"></div>
|
||||
<label class="col-sm-10">
|
||||
<input class="p2wpkh-nested-in-p2sh" type="checkbox">
|
||||
<span data-translate>Use SegWit addresses (ie P2WPKH Nested In P2SH)</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="core-path" class="col-sm-2 control-label" data-translate>Bitcoin Core</label>
|
||||
<div class="col-sm-10">
|
||||
|
||||
@@ -9649,6 +9649,16 @@ module.exports = {
|
||||
wif: 0xef
|
||||
},
|
||||
litecoin: {
|
||||
messagePrefix: '\x19Litecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x30,
|
||||
scriptHash: 0x32,
|
||||
wif: 0xb0
|
||||
},
|
||||
litecoinLtub: {
|
||||
messagePrefix: '\x19Litecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x019da462,
|
||||
@@ -14827,4 +14837,4 @@ module.exports = {
|
||||
|
||||
}).call(this,require("buffer").Buffer)
|
||||
},{"bs58check":80,"buffer":4}]},{},[33])(33)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,6 +53,17 @@ bitcoinjs.bitcoin.networks.dash = {
|
||||
wif: 0xcc,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.maza = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x09,
|
||||
wif: 0xe0,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dashtn = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
@@ -184,3 +195,36 @@ bitcoinjs.bitcoin.networks.zetacoin = {
|
||||
scriptHash: 0x09,
|
||||
wif: 0xe0,
|
||||
}
|
||||
|
||||
bitcoinjs.bitcoin.networks.myriadcoin = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x00, // TODO set this correctly
|
||||
wif: 0xb2,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.pivx = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
public: 0x022d2533,
|
||||
private: 0x0221312b
|
||||
},
|
||||
pubKeyHash: 0x1e,
|
||||
scriptHash: 0x0d,
|
||||
wif: 0xd4,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.pivxtestnet = {
|
||||
messagePrefix: "unused",
|
||||
bip32: {
|
||||
public: 0x3a8061a0,
|
||||
private: 0x3a805837
|
||||
},
|
||||
pubKeyHash: 0x8b,
|
||||
scriptHash: 0x13,
|
||||
wif: 0xef,
|
||||
};
|
||||
|
||||
156
src/js/index.js
156
src/js/index.js
@@ -14,6 +14,7 @@
|
||||
var showPubKey = true;
|
||||
var showPrivKey = true;
|
||||
var showQr = false;
|
||||
var litecoinUseLtub = false;
|
||||
|
||||
var entropyChangeTimeoutEvent = null;
|
||||
var phraseChangeTimeoutEvent = null;
|
||||
@@ -43,6 +44,8 @@
|
||||
DOM.generate = $(".generate");
|
||||
DOM.seed = $(".seed");
|
||||
DOM.rootKey = $(".root-key");
|
||||
DOM.litecoinLtubContainer = $(".litecoin-ltub-container");
|
||||
DOM.litecoinUseLtub = $(".litecoin-use-ltub");
|
||||
DOM.extendedPrivKey = $(".extended-priv-key");
|
||||
DOM.extendedPubKey = $(".extended-pub-key");
|
||||
DOM.bip32tab = $("#bip32-tab");
|
||||
@@ -70,6 +73,7 @@
|
||||
DOM.bip49change = $("#bip49 .change");
|
||||
DOM.generatedStrength = $(".generate-container .strength");
|
||||
DOM.hardenedAddresses = $(".hardened-addresses");
|
||||
DOM.useP2wpkhNestedInP2sh = $(".p2wpkh-nested-in-p2sh");
|
||||
DOM.addresses = $(".addresses");
|
||||
DOM.rowsToAdd = $(".rows-to-add");
|
||||
DOM.more = $(".more");
|
||||
@@ -98,6 +102,7 @@
|
||||
DOM.generate.on("click", generateClicked);
|
||||
DOM.more.on("click", showMore);
|
||||
DOM.rootKey.on("input", delayedRootKeyChanged);
|
||||
DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
|
||||
DOM.bip32path.on("input", calcForDerivationPath);
|
||||
DOM.bip44account.on("input", calcForDerivationPath);
|
||||
DOM.bip44change.on("input", calcForDerivationPath);
|
||||
@@ -105,6 +110,7 @@
|
||||
DOM.bip49change.on("input", calcForDerivationPath);
|
||||
DOM.tab.on("shown.bs.tab", calcForDerivationPath);
|
||||
DOM.hardenedAddresses.on("change", calcForDerivationPath);
|
||||
DOM.useP2wpkhNestedInP2sh.on("change", calcForDerivationPath);
|
||||
DOM.indexToggle.on("click", toggleIndexes);
|
||||
DOM.addressToggle.on("click", toggleAddresses);
|
||||
DOM.publicKeyToggle.on("click", togglePublicKeys);
|
||||
@@ -123,14 +129,15 @@
|
||||
function networkChanged(e) {
|
||||
clearDerivedKeys();
|
||||
clearAddressesList();
|
||||
DOM.litecoinLtubContainer.addClass("hidden");
|
||||
var networkIndex = e.target.value;
|
||||
var network = networks[networkIndex];
|
||||
network.onSelect();
|
||||
if (network.bip49available) {
|
||||
showBip49();
|
||||
if (network.p2wpkhNestedInP2shAvailable) {
|
||||
showP2wpkhNestedInP2shAvailable();
|
||||
}
|
||||
else {
|
||||
hideBip49();
|
||||
showP2wpkhNestedInP2shUnavailable();
|
||||
}
|
||||
if (seed != null) {
|
||||
phraseChanged();
|
||||
@@ -175,6 +182,10 @@
|
||||
|
||||
function delayedPhraseChanged() {
|
||||
hideValidationError();
|
||||
seed = null;
|
||||
bip32RootKey = null;
|
||||
bip32ExtendedKey = null;
|
||||
clearAddressesList();
|
||||
showPending();
|
||||
if (phraseChangeTimeoutEvent != null) {
|
||||
clearTimeout(phraseChangeTimeoutEvent);
|
||||
@@ -184,7 +195,6 @@
|
||||
|
||||
function phraseChanged() {
|
||||
showPending();
|
||||
hideValidationError();
|
||||
setMnemonicLanguage();
|
||||
// Get the mnemonic phrase
|
||||
var phrase = DOM.phrase.val();
|
||||
@@ -197,7 +207,6 @@
|
||||
var passphrase = DOM.passphrase.val();
|
||||
calcBip32RootKeyFromSeed(phrase, passphrase);
|
||||
calcForDerivationPath();
|
||||
hidePending();
|
||||
}
|
||||
|
||||
function delayedEntropyChanged() {
|
||||
@@ -260,7 +269,6 @@
|
||||
function rootKeyChanged() {
|
||||
showPending();
|
||||
hideValidationError();
|
||||
// Validate the root key TODO
|
||||
var rootKeyBase58 = DOM.rootKey.val();
|
||||
var errorText = validateRootKey(rootKeyBase58);
|
||||
if (errorText) {
|
||||
@@ -272,11 +280,21 @@
|
||||
calcForDerivationPath();
|
||||
}
|
||||
|
||||
function litecoinUseLtubChanged() {
|
||||
litecoinUseLtub = DOM.litecoinUseLtub.prop("checked");
|
||||
if (litecoinUseLtub) {
|
||||
network = bitcoinjs.bitcoin.networks.litecoinLtub;
|
||||
}
|
||||
else {
|
||||
network = bitcoinjs.bitcoin.networks.litecoin;
|
||||
}
|
||||
phraseChanged();
|
||||
}
|
||||
|
||||
function calcForDerivationPath() {
|
||||
showPending();
|
||||
clearDerivedKeys();
|
||||
clearAddressesList();
|
||||
hideValidationError();
|
||||
showPending();
|
||||
// Don't show bip49 if it's selected but network doesn't support it
|
||||
if (bip49TabSelected() && !networkHasBip49()) {
|
||||
return;
|
||||
@@ -296,7 +314,6 @@
|
||||
displayBip49Info();
|
||||
}
|
||||
displayBip32Info();
|
||||
hidePending();
|
||||
}
|
||||
|
||||
function generateClicked() {
|
||||
@@ -444,7 +461,7 @@
|
||||
|
||||
function validateRootKey(rootKeyBase58) {
|
||||
try {
|
||||
bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58);
|
||||
bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
|
||||
}
|
||||
catch (e) {
|
||||
return "Invalid root key";
|
||||
@@ -532,7 +549,9 @@
|
||||
return "No root key";
|
||||
}
|
||||
// Check no hardened derivation path when using xpub keys
|
||||
var hardened = path.indexOf("'") > -1;
|
||||
var hardenedPath = path.indexOf("'") > -1;
|
||||
var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked");
|
||||
var hardened = hardenedPath || hardenedAddresses;
|
||||
var isXpubkey = bip32RootKey.isNeutered();
|
||||
if (hardened && isXpubkey) {
|
||||
return "Hardened derivation path is invalid with xpub key";
|
||||
@@ -603,23 +622,25 @@
|
||||
for (var i=0; i<rows.length; i++) {
|
||||
rows[i].shouldGenerate = false;
|
||||
}
|
||||
hidePending();
|
||||
}
|
||||
|
||||
for (var i=0; i<total; i++) {
|
||||
var index = i + start;
|
||||
rows.push(new TableRow(index));
|
||||
var isLast = i == total - 1;
|
||||
rows.push(new TableRow(index, isLast));
|
||||
}
|
||||
|
||||
})());
|
||||
}
|
||||
|
||||
function TableRow(index) {
|
||||
function TableRow(index, isLast) {
|
||||
|
||||
var self = this;
|
||||
this.shouldGenerate = true;
|
||||
var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
|
||||
var isBip49 = bip49TabSelected();
|
||||
var bip49available = networkHasBip49();
|
||||
var isP2wpkhNestedInP2sh = bip49TabSelected() || (bip32TabSelected() && useP2wpkhNestedInP2sh());
|
||||
var p2wpkhNestedInP2shAvailable = networkHasBip49();
|
||||
|
||||
function init() {
|
||||
calculateValues();
|
||||
@@ -664,8 +685,8 @@
|
||||
address = convertRippleAdrr(address);
|
||||
}
|
||||
// BIP49 addresses are different
|
||||
if (isBip49) {
|
||||
if (!bip49available) {
|
||||
if (isP2wpkhNestedInP2sh) {
|
||||
if (!p2wpkhNestedInP2shAvailable) {
|
||||
return;
|
||||
}
|
||||
var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
|
||||
@@ -675,6 +696,9 @@
|
||||
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
|
||||
}
|
||||
addAddressToList(indexText, address, pubkey, privkey);
|
||||
if (isLast) {
|
||||
hidePending();
|
||||
}
|
||||
}, 50)
|
||||
}
|
||||
|
||||
@@ -818,6 +842,9 @@
|
||||
var option = $("<option>");
|
||||
option.attr("value", i);
|
||||
option.text(network.name);
|
||||
if (network.name == "BTC - Bitcoin") {
|
||||
option.prop("selected", true);
|
||||
}
|
||||
DOM.phraseNetwork.append(option);
|
||||
}
|
||||
}
|
||||
@@ -1139,8 +1166,12 @@
|
||||
return DOM.bip32tab.hasClass("active");
|
||||
}
|
||||
|
||||
function useP2wpkhNestedInP2sh() {
|
||||
return DOM.useP2wpkhNestedInP2sh.prop("checked");
|
||||
}
|
||||
|
||||
function networkHasBip49() {
|
||||
return networks[DOM.network.val()].bip49available;
|
||||
return networks[DOM.network.val()].p2wpkhNestedInP2shAvailable;
|
||||
}
|
||||
|
||||
function bip49TabSelected() {
|
||||
@@ -1152,20 +1183,31 @@
|
||||
DOM.bip49coin.val(coinValue);
|
||||
}
|
||||
|
||||
function showBip49() {
|
||||
function showP2wpkhNestedInP2shAvailable() {
|
||||
DOM.bip49unavailable.addClass("hidden");
|
||||
DOM.bip49available.removeClass("hidden");
|
||||
DOM.useP2wpkhNestedInP2sh.prop("disabled", false);
|
||||
}
|
||||
|
||||
function hideBip49() {
|
||||
function showP2wpkhNestedInP2shUnavailable() {
|
||||
DOM.bip49available.addClass("hidden");
|
||||
DOM.bip49unavailable.removeClass("hidden");
|
||||
DOM.useP2wpkhNestedInP2sh.prop("disabled", true);
|
||||
DOM.useP2wpkhNestedInP2sh.prop("checked", false);
|
||||
}
|
||||
|
||||
var networks = [
|
||||
{
|
||||
name: "BCH - Bitcoin Cash",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(145);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BTC - Bitcoin",
|
||||
bip49available: true,
|
||||
p2wpkhNestedInP2shAvailable: true,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(0);
|
||||
@@ -1173,7 +1215,7 @@
|
||||
},
|
||||
{
|
||||
name: "BTC - Bitcoin Testnet",
|
||||
bip49available: true,
|
||||
p2wpkhNestedInP2shAvailable: true,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.testnet;
|
||||
setHdCoin(1);
|
||||
@@ -1181,7 +1223,7 @@
|
||||
},
|
||||
{
|
||||
name: "CLAM - Clams",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.clam;
|
||||
setHdCoin(23);
|
||||
@@ -1189,7 +1231,7 @@
|
||||
},
|
||||
{
|
||||
name: "CRW - Crown",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.crown;
|
||||
setHdCoin(72);
|
||||
@@ -1197,7 +1239,7 @@
|
||||
},
|
||||
{
|
||||
name: "DASH - Dash",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.dash;
|
||||
setHdCoin(5);
|
||||
@@ -1205,7 +1247,7 @@
|
||||
},
|
||||
{
|
||||
name: "DASH - Dash Testnet",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.dashtn;
|
||||
setHdCoin(1);
|
||||
@@ -1213,7 +1255,7 @@
|
||||
},
|
||||
{
|
||||
name: "DOGE - Dogecoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.dogecoin;
|
||||
setHdCoin(3);
|
||||
@@ -1221,7 +1263,7 @@
|
||||
},
|
||||
{
|
||||
name: "ETH - Ethereum",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(60);
|
||||
@@ -1229,7 +1271,7 @@
|
||||
},
|
||||
{
|
||||
name: "GAME - GameCredits",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.game;
|
||||
setHdCoin(101);
|
||||
@@ -1237,7 +1279,7 @@
|
||||
},
|
||||
{
|
||||
name: "JBS - Jumbucks",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.jumbucks;
|
||||
setHdCoin(26);
|
||||
@@ -1245,23 +1287,49 @@
|
||||
},
|
||||
{
|
||||
name: "LTC - Litecoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.litecoin;
|
||||
setHdCoin(2);
|
||||
DOM.litecoinLtubContainer.removeClass("hidden");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MAZA - Maza",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.maza;
|
||||
setHdCoin(13);
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "NMC - Namecoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.namecoin;
|
||||
setHdCoin(7);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PIVX - PIVX",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.pivx;
|
||||
setHdCoin(119);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PIVX - PIVX Testnet",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.pivxtestnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PPC - Peercoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.peercoin;
|
||||
setHdCoin(6);
|
||||
@@ -1269,7 +1337,7 @@
|
||||
},
|
||||
{
|
||||
name: "SDC - ShadowCash",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.shadow;
|
||||
setHdCoin(35);
|
||||
@@ -1277,7 +1345,7 @@
|
||||
},
|
||||
{
|
||||
name: "SDC - ShadowCash Testnet",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.shadowtn;
|
||||
setHdCoin(1);
|
||||
@@ -1285,7 +1353,7 @@
|
||||
},
|
||||
{
|
||||
name: "SLM - Slimcoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.slimcoin;
|
||||
setHdCoin(63);
|
||||
@@ -1293,7 +1361,7 @@
|
||||
},
|
||||
{
|
||||
name: "SLM - Slimcoin Testnet",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.slimcointn;
|
||||
setHdCoin(111);
|
||||
@@ -1301,7 +1369,7 @@
|
||||
},
|
||||
{
|
||||
name: "VIA - Viacoin",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.viacoin;
|
||||
setHdCoin(14);
|
||||
@@ -1309,15 +1377,23 @@
|
||||
},
|
||||
{
|
||||
name: "VIA - Viacoin Testnet",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.viacointestnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "XMY - Myriadcoin",
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.myriadcoin;
|
||||
setHdCoin(90);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "XRP - Ripple",
|
||||
bip49available: false,
|
||||
p2wpkhNestedInP2shAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(144);
|
||||
|
||||
306
tests.js
306
tests.js
@@ -872,6 +872,156 @@ page.open(url, function(status) {
|
||||
});
|
||||
},
|
||||
|
||||
// Network can be set to bitcoin cash
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the phrase and coin
|
||||
var expected = "1JKvb6wKtsjNoCRxpZ4DGrbniML7z5U16A";
|
||||
page.evaluate(function() {
|
||||
$(".phrase").val("abandon abandon ability");
|
||||
$(".phrase").trigger("input");
|
||||
$(".network option[selected]").removeAttr("selected");
|
||||
$(".network option").filter(function() {
|
||||
return $(this).html() == "BCH - Bitcoin Cash";
|
||||
}).prop("selected", true);
|
||||
$(".network").trigger("change");
|
||||
});
|
||||
// check the address is generated correctly
|
||||
waitForGenerate(function() {
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".address:first").text();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("Bitcoin Cash address is incorrect");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Network can be set to myriadcoin
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the phrase and coin
|
||||
var expected = "MJEswvRR46wh9BoiVj9DzKYMBkCramhoBV";
|
||||
page.evaluate(function() {
|
||||
$(".phrase").val("abandon abandon ability");
|
||||
$(".phrase").trigger("input");
|
||||
$(".network option[selected]").removeAttr("selected");
|
||||
$(".network option").filter(function() {
|
||||
return $(this).html() == "XMY - Myriadcoin";
|
||||
}).prop("selected", true);
|
||||
$(".network").trigger("change");
|
||||
});
|
||||
// check the address is generated correctly
|
||||
waitForGenerate(function() {
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".address:first").text();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("Myriadcoin address is incorrect");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Network can be set to pivx
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the phrase and coin
|
||||
var expected = "DBxgT7faCuno7jmtKuu6KWCiwqsVPqh1tS";
|
||||
page.evaluate(function() {
|
||||
$(".phrase").val("abandon abandon ability");
|
||||
$(".phrase").trigger("input");
|
||||
$(".network option[selected]").removeAttr("selected");
|
||||
$(".network option").filter(function() {
|
||||
return $(this).html() == "PIVX - PIVX";
|
||||
}).prop("selected", true);
|
||||
$(".network").trigger("change");
|
||||
});
|
||||
// check the address is generated correctly
|
||||
waitForGenerate(function() {
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".address:first").text();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("PIVX address is incorrect");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Network can be set to pivx testnet
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the phrase and coin
|
||||
var expected = "yB5U384n6dGkVE3by5y9VdvHHPwPg68fQj";
|
||||
page.evaluate(function() {
|
||||
$(".phrase").val("abandon abandon ability");
|
||||
$(".phrase").trigger("input");
|
||||
$(".network option[selected]").removeAttr("selected");
|
||||
$(".network option").filter(function() {
|
||||
return $(this).html() == "PIVX - PIVX Testnet";
|
||||
}).prop("selected", true);
|
||||
$(".network").trigger("change");
|
||||
});
|
||||
// check the address is generated correctly
|
||||
waitForGenerate(function() {
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".address:first").text();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("PIVX Testnet address is incorrect");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Network can be set to maza
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the phrase and coin
|
||||
var expected = "MGW4Bmi2NEm4PxSjgeFwhP9vg18JHoRnfw";
|
||||
page.evaluate(function() {
|
||||
$(".phrase").val("abandon abandon ability");
|
||||
$(".phrase").trigger("input");
|
||||
$(".network option[selected]").removeAttr("selected");
|
||||
$(".network option").filter(function() {
|
||||
return $(this).html() == "MAZA - Maza";
|
||||
}).prop("selected", true);
|
||||
$(".network").trigger("change");
|
||||
});
|
||||
// check the address is generated correctly
|
||||
waitForGenerate(function() {
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".address:first").text();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("Maza address is incorrect");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// BIP39 seed is set from phrase
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
@@ -4000,6 +4150,162 @@ page.open(url, function(status) {
|
||||
});
|
||||
},
|
||||
|
||||
// github issue 43
|
||||
// Cleared mnemonic and root key still allows addresses to be generated
|
||||
// https://github.com/iancoleman/bip39/issues/43
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the phrase
|
||||
page.evaluate(function() {
|
||||
$("#bip49-tab a").click();
|
||||
$(".phrase").val("abandon abandon ability");
|
||||
$(".phrase").trigger("input");
|
||||
});
|
||||
waitForGenerate(function() {
|
||||
// clear the mnemonic and root key
|
||||
page.evaluate(function() {
|
||||
$(".phrase").val("");
|
||||
$(".phrase").trigger("input");
|
||||
$(".root-key").val("");
|
||||
$(".root-key").trigger("input");
|
||||
$(".more").click();
|
||||
});
|
||||
waitForFeedback(function() {
|
||||
// check there are no addresses shown
|
||||
var addressCount = page.evaluate(function() {
|
||||
return $(".address").length;
|
||||
});
|
||||
if (addressCount != 0) {
|
||||
console.log("Clearing mnemonic should not allow addresses to be generated");
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Github issue 95
|
||||
// error trying to generate addresses from xpub with hardened derivation
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the phrase
|
||||
page.evaluate(function() {
|
||||
// Use bip32 tab with hardened addresses
|
||||
$(".hardened-addresses").prop("checked", true);
|
||||
$("#bip32-tab a").click();
|
||||
// set xpub for account 0 of bip44 for 'abandon abandon ability'
|
||||
var bip44AccountXpub = "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf";
|
||||
$("#root-key").val(bip44AccountXpub);
|
||||
$("#root-key").trigger("input");
|
||||
});
|
||||
waitForFeedback(function() {
|
||||
// check the error message shows
|
||||
var expected = "Hardened derivation path is invalid with xpub key";
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".feedback").text();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("xpub key with hardened addresses does not show feedback");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Litecoin uses xprv by default, and can optionally be set to ltpv
|
||||
// github issue 96
|
||||
// https://github.com/iancoleman/bip39/issues/96
|
||||
// Issue with extended keys on Litecoin
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the phrase and coin
|
||||
page.evaluate(function() {
|
||||
$(".phrase").val("abandon abandon ability");
|
||||
$(".network option[selected]").removeAttr("selected");
|
||||
$(".network option").filter(function() {
|
||||
return $(this).html() == "LTC - Litecoin";
|
||||
}).prop("selected", true);
|
||||
$(".network").trigger("change");
|
||||
$(".phrase").trigger("input");
|
||||
});
|
||||
// check the extended key is generated correctly
|
||||
waitForGenerate(function() {
|
||||
var expected = "xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi";
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".root-key").val();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("Litecoin root key does not default to xprv");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
// set litecoin to use ltub
|
||||
page.evaluate(function() {
|
||||
$(".addresses").empty();
|
||||
$(".litecoin-use-ltub").prop("checked", true);
|
||||
$(".litecoin-use-ltub").trigger("change");
|
||||
});
|
||||
waitForGenerate(function() {
|
||||
var expected = "Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU";
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".root-key").val();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("Litecoin root key cannot be set to use ltub");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// BIP32 tab can use P2WPKH Nested In P2SH
|
||||
// github issue 91 part 2
|
||||
// https://github.com/iancoleman/bip39/issues/91
|
||||
// generate new addresses from xpub?
|
||||
function() {
|
||||
page.open(url, function(status) {
|
||||
// set the xpub and coin and select bip32 tab with p2wpkh addresses
|
||||
page.evaluate(function() {
|
||||
// use p2wpkh addresses
|
||||
$(".p2wpkh-nested-in-p2sh").prop("checked", true);
|
||||
// use bip32 tab
|
||||
$("#bip32-tab a").click();
|
||||
// use testnet
|
||||
$(".network option[selected]").removeAttr("selected");
|
||||
$(".network option").filter(function() {
|
||||
return $(this).html() == "BTC - Bitcoin Testnet";
|
||||
}).prop("selected", true);
|
||||
$(".network").trigger("change");
|
||||
// Set root xpub to BIP49 official test vector account 0
|
||||
$(".root-key").val("tpubDD7tXK8KeQ3YY83yWq755fHY2JW8Ha8Q765tknUM5rSvjPcGWfUppDFMpQ1ScziKfW3ZNtZvAD7M3u7bSs7HofjTD3KP3YxPK7X6hwV8Rk2");
|
||||
$(".root-key").trigger("input");
|
||||
});
|
||||
// check the address is generated correctly
|
||||
waitForGenerate(function() {
|
||||
var expected = "2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2";
|
||||
var actual = page.evaluate(function() {
|
||||
return $(".address:first").text();
|
||||
});
|
||||
if (actual != expected) {
|
||||
console.log("BIP32 tab cannot generate P2WPKH Nested In P2SH addresses");
|
||||
console.log("Expected: " + expected);
|
||||
console.log("Actual: " + actual);
|
||||
fail();
|
||||
}
|
||||
next();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// If you wish to add more tests, do so here...
|
||||
|
||||
// Here is a blank test template
|
||||
|
||||
Reference in New Issue
Block a user