Compare commits

...

12 Commits
0.2.2 ... 0.2.5

Author SHA1 Message Date
Ian Coleman
0a8d06d03e Release v0.2.5 2017-09-01 12:35:42 +10:00
Ian Coleman
88311463c7 Allow P2WPKH nested in P2SH addresses on BIP32 tab 2017-09-01 12:28:27 +10:00
Ian Coleman
cd7c8327b1 Validate root key correctly for alternate networks 2017-09-01 12:27:03 +10:00
Ian Coleman
0cda44d5f6 Rename bip49 to p2wpkhNestedInP2sh where suitable 2017-09-01 12:25:45 +10:00
Ian Coleman
7258b102c1 Add confirmation steps to the release process 2017-08-28 10:03:21 +10:00
Ian Coleman
8d18f379fd Release v0.2.4 2017-08-28 09:48:48 +10:00
Ian Coleman
3abab9b087 Add a checkbox to switch litecoin key prefixes 2017-08-28 09:45:38 +10:00
Ian Coleman
b18eb97ae3 Show error when using xpub with hardened addresses 2017-08-24 09:37:21 +10:00
Ian Coleman
88ea3e40ee Release v0.2.3 2017-08-23 09:45:09 +10:00
Ian Coleman
8a9f391376 Test for Maza network 2017-08-23 09:41:53 +10:00
iancoleman
e40acc3ab0 Merge pull request #92 from jonspock/master
Add maza coin, update PIVX in bip39-standalone.html
2017-08-23 09:30:43 +10:00
Jon Spock
56ad960105 Add maza coin 2017-08-21 17:13:44 -07:00
8 changed files with 393 additions and 78 deletions

View File

@@ -118,7 +118,7 @@
<div class="container">
<h1 class="text-center">Mnemonic Code Converter</h1>
<p class="version">v0.2.2</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: {
@@ -46100,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;
@@ -46129,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");
@@ -46156,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");
@@ -46184,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);
@@ -46191,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);
@@ -46209,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();
@@ -46348,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) {
@@ -46360,6 +46404,17 @@ 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() {
clearDerivedKeys();
clearAddressesList();
@@ -46530,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";
@@ -46618,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";
@@ -46706,8 +46763,8 @@ window.Entropy = new (function() {
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();
@@ -46752,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());
@@ -47233,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() {
@@ -47246,20 +47307,23 @@ 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",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(145);
@@ -47267,7 +47331,7 @@ window.Entropy = new (function() {
},
{
name: "BTC - Bitcoin",
bip49available: true,
p2wpkhNestedInP2shAvailable: true,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(0);
@@ -47275,7 +47339,7 @@ window.Entropy = new (function() {
},
{
name: "BTC - Bitcoin Testnet",
bip49available: true,
p2wpkhNestedInP2shAvailable: true,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.testnet;
setHdCoin(1);
@@ -47283,7 +47347,7 @@ window.Entropy = new (function() {
},
{
name: "CLAM - Clams",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.clam;
setHdCoin(23);
@@ -47291,7 +47355,7 @@ window.Entropy = new (function() {
},
{
name: "CRW - Crown",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.crown;
setHdCoin(72);
@@ -47299,7 +47363,7 @@ window.Entropy = new (function() {
},
{
name: "DASH - Dash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dash;
setHdCoin(5);
@@ -47307,7 +47371,7 @@ window.Entropy = new (function() {
},
{
name: "DASH - Dash Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dashtn;
setHdCoin(1);
@@ -47315,7 +47379,7 @@ window.Entropy = new (function() {
},
{
name: "DOGE - Dogecoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dogecoin;
setHdCoin(3);
@@ -47323,7 +47387,7 @@ window.Entropy = new (function() {
},
{
name: "ETH - Ethereum",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(60);
@@ -47331,7 +47395,7 @@ window.Entropy = new (function() {
},
{
name: "GAME - GameCredits",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.game;
setHdCoin(101);
@@ -47339,7 +47403,7 @@ window.Entropy = new (function() {
},
{
name: "JBS - Jumbucks",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.jumbucks;
setHdCoin(26);
@@ -47347,15 +47411,25 @@ 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);
@@ -47363,7 +47437,7 @@ window.Entropy = new (function() {
},
{
name: "PIVX - PIVX",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.pivx;
setHdCoin(119);
@@ -47371,7 +47445,7 @@ window.Entropy = new (function() {
},
{
name: "PIVX - PIVX Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.pivxtestnet;
setHdCoin(1);
@@ -47379,7 +47453,7 @@ window.Entropy = new (function() {
},
{
name: "PPC - Peercoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.peercoin;
setHdCoin(6);
@@ -47387,7 +47461,7 @@ window.Entropy = new (function() {
},
{
name: "SDC - ShadowCash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.shadow;
setHdCoin(35);
@@ -47395,7 +47469,7 @@ window.Entropy = new (function() {
},
{
name: "SDC - ShadowCash Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.shadowtn;
setHdCoin(1);
@@ -47403,7 +47477,7 @@ window.Entropy = new (function() {
},
{
name: "SLM - Slimcoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.slimcoin;
setHdCoin(63);
@@ -47411,7 +47485,7 @@ window.Entropy = new (function() {
},
{
name: "SLM - Slimcoin Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.slimcointn;
setHdCoin(111);
@@ -47419,7 +47493,7 @@ window.Entropy = new (function() {
},
{
name: "VIA - Viacoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.viacoin;
setHdCoin(14);
@@ -47427,7 +47501,7 @@ window.Entropy = new (function() {
},
{
name: "VIA - Viacoin Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.viacointestnet;
setHdCoin(1);
@@ -47435,7 +47509,7 @@ window.Entropy = new (function() {
},
{
name: "XMY - Myriadcoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.myriadcoin;
setHdCoin(90);
@@ -47443,7 +47517,7 @@ window.Entropy = new (function() {
},
{
name: "XRP - Ripple",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(144);

View File

@@ -1,3 +1,18 @@
# 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

View File

@@ -17,3 +17,5 @@ created with the following steps:
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.

View File

@@ -114,7 +114,7 @@
<div class="container">
<h1 class="text-center">Mnemonic Code Converter</h1>
<p class="version">v0.2.2</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">

View File

@@ -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)
});
});

View File

@@ -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: {

View File

@@ -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();
@@ -262,7 +269,6 @@
function rootKeyChanged() {
showPending();
hideValidationError();
// Validate the root key TODO
var rootKeyBase58 = DOM.rootKey.val();
var errorText = validateRootKey(rootKeyBase58);
if (errorText) {
@@ -274,6 +280,17 @@
calcForDerivationPath();
}
function litecoinUseLtubChanged() {
litecoinUseLtub = DOM.litecoinUseLtub.prop("checked");
if (litecoinUseLtub) {
network = bitcoinjs.bitcoin.networks.litecoinLtub;
}
else {
network = bitcoinjs.bitcoin.networks.litecoin;
}
phraseChanged();
}
function calcForDerivationPath() {
clearDerivedKeys();
clearAddressesList();
@@ -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";
@@ -620,8 +639,8 @@
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();
@@ -666,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());
@@ -1147,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() {
@@ -1160,20 +1183,23 @@
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",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(145);
@@ -1181,7 +1207,7 @@
},
{
name: "BTC - Bitcoin",
bip49available: true,
p2wpkhNestedInP2shAvailable: true,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(0);
@@ -1189,7 +1215,7 @@
},
{
name: "BTC - Bitcoin Testnet",
bip49available: true,
p2wpkhNestedInP2shAvailable: true,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.testnet;
setHdCoin(1);
@@ -1197,7 +1223,7 @@
},
{
name: "CLAM - Clams",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.clam;
setHdCoin(23);
@@ -1205,7 +1231,7 @@
},
{
name: "CRW - Crown",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.crown;
setHdCoin(72);
@@ -1213,7 +1239,7 @@
},
{
name: "DASH - Dash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dash;
setHdCoin(5);
@@ -1221,7 +1247,7 @@
},
{
name: "DASH - Dash Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dashtn;
setHdCoin(1);
@@ -1229,7 +1255,7 @@
},
{
name: "DOGE - Dogecoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dogecoin;
setHdCoin(3);
@@ -1237,7 +1263,7 @@
},
{
name: "ETH - Ethereum",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(60);
@@ -1245,7 +1271,7 @@
},
{
name: "GAME - GameCredits",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.game;
setHdCoin(101);
@@ -1253,7 +1279,7 @@
},
{
name: "JBS - Jumbucks",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.jumbucks;
setHdCoin(26);
@@ -1261,15 +1287,25 @@
},
{
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);
@@ -1277,7 +1313,7 @@
},
{
name: "PIVX - PIVX",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.pivx;
setHdCoin(119);
@@ -1285,7 +1321,7 @@
},
{
name: "PIVX - PIVX Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.pivxtestnet;
setHdCoin(1);
@@ -1293,7 +1329,7 @@
},
{
name: "PPC - Peercoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.peercoin;
setHdCoin(6);
@@ -1301,7 +1337,7 @@
},
{
name: "SDC - ShadowCash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.shadow;
setHdCoin(35);
@@ -1309,7 +1345,7 @@
},
{
name: "SDC - ShadowCash Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.shadowtn;
setHdCoin(1);
@@ -1317,7 +1353,7 @@
},
{
name: "SLM - Slimcoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.slimcoin;
setHdCoin(63);
@@ -1325,7 +1361,7 @@
},
{
name: "SLM - Slimcoin Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.slimcointn;
setHdCoin(111);
@@ -1333,7 +1369,7 @@
},
{
name: "VIA - Viacoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.viacoin;
setHdCoin(14);
@@ -1341,7 +1377,7 @@
},
{
name: "VIA - Viacoin Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.viacointestnet;
setHdCoin(1);
@@ -1349,7 +1385,7 @@
},
{
name: "XMY - Myriadcoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.myriadcoin;
setHdCoin(90);
@@ -1357,7 +1393,7 @@
},
{
name: "XRP - Ripple",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(144);

151
tests.js
View File

@@ -992,6 +992,36 @@ page.open(url, function(status) {
});
},
// 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) {
@@ -4155,6 +4185,127 @@ page.open(url, function(status) {
});
},
// 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