mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-17 07:52:16 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f128bd58c4 | ||
|
|
0eda54f5a7 | ||
|
|
ed6d9d3905 | ||
|
|
47b64d3ee1 | ||
|
|
bc33f5ee53 | ||
|
|
c0df01895d |
@@ -118,7 +118,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<h1 class="text-center">Mnemonic Code Converter</h1>
|
<h1 class="text-center">Mnemonic Code Converter</h1>
|
||||||
<p class="version">v0.2.1</p>
|
<p class="version">v0.2.2</p>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
@@ -22302,6 +22302,28 @@ bitcoinjs.bitcoin.networks.myriadcoin = {
|
|||||||
scriptHash: 0x00, // TODO set this correctly
|
scriptHash: 0x00, // TODO set this correctly
|
||||||
wif: 0xb2,
|
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>
|
||||||
<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){
|
<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){
|
(function (global){
|
||||||
@@ -46239,6 +46261,10 @@ window.Entropy = new (function() {
|
|||||||
|
|
||||||
function delayedPhraseChanged() {
|
function delayedPhraseChanged() {
|
||||||
hideValidationError();
|
hideValidationError();
|
||||||
|
seed = null;
|
||||||
|
bip32RootKey = null;
|
||||||
|
bip32ExtendedKey = null;
|
||||||
|
clearAddressesList();
|
||||||
showPending();
|
showPending();
|
||||||
if (phraseChangeTimeoutEvent != null) {
|
if (phraseChangeTimeoutEvent != null) {
|
||||||
clearTimeout(phraseChangeTimeoutEvent);
|
clearTimeout(phraseChangeTimeoutEvent);
|
||||||
@@ -46248,7 +46274,6 @@ window.Entropy = new (function() {
|
|||||||
|
|
||||||
function phraseChanged() {
|
function phraseChanged() {
|
||||||
showPending();
|
showPending();
|
||||||
hideValidationError();
|
|
||||||
setMnemonicLanguage();
|
setMnemonicLanguage();
|
||||||
// Get the mnemonic phrase
|
// Get the mnemonic phrase
|
||||||
var phrase = DOM.phrase.val();
|
var phrase = DOM.phrase.val();
|
||||||
@@ -46261,7 +46286,6 @@ window.Entropy = new (function() {
|
|||||||
var passphrase = DOM.passphrase.val();
|
var passphrase = DOM.passphrase.val();
|
||||||
calcBip32RootKeyFromSeed(phrase, passphrase);
|
calcBip32RootKeyFromSeed(phrase, passphrase);
|
||||||
calcForDerivationPath();
|
calcForDerivationPath();
|
||||||
hidePending();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delayedEntropyChanged() {
|
function delayedEntropyChanged() {
|
||||||
@@ -46337,10 +46361,9 @@ window.Entropy = new (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function calcForDerivationPath() {
|
function calcForDerivationPath() {
|
||||||
showPending();
|
|
||||||
clearDerivedKeys();
|
clearDerivedKeys();
|
||||||
clearAddressesList();
|
clearAddressesList();
|
||||||
hideValidationError();
|
showPending();
|
||||||
// Don't show bip49 if it's selected but network doesn't support it
|
// Don't show bip49 if it's selected but network doesn't support it
|
||||||
if (bip49TabSelected() && !networkHasBip49()) {
|
if (bip49TabSelected() && !networkHasBip49()) {
|
||||||
return;
|
return;
|
||||||
@@ -46360,7 +46383,6 @@ window.Entropy = new (function() {
|
|||||||
displayBip49Info();
|
displayBip49Info();
|
||||||
}
|
}
|
||||||
displayBip32Info();
|
displayBip32Info();
|
||||||
hidePending();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateClicked() {
|
function generateClicked() {
|
||||||
@@ -46667,17 +46689,19 @@ window.Entropy = new (function() {
|
|||||||
for (var i=0; i<rows.length; i++) {
|
for (var i=0; i<rows.length; i++) {
|
||||||
rows[i].shouldGenerate = false;
|
rows[i].shouldGenerate = false;
|
||||||
}
|
}
|
||||||
|
hidePending();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i=0; i<total; i++) {
|
for (var i=0; i<total; i++) {
|
||||||
var index = i + start;
|
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;
|
var self = this;
|
||||||
this.shouldGenerate = true;
|
this.shouldGenerate = true;
|
||||||
@@ -46739,6 +46763,9 @@ window.Entropy = new (function() {
|
|||||||
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
|
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
|
||||||
}
|
}
|
||||||
addAddressToList(indexText, address, pubkey, privkey);
|
addAddressToList(indexText, address, pubkey, privkey);
|
||||||
|
if (isLast) {
|
||||||
|
hidePending();
|
||||||
|
}
|
||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47334,6 +47361,22 @@ window.Entropy = new (function() {
|
|||||||
setHdCoin(7);
|
setHdCoin(7);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "PIVX - PIVX",
|
||||||
|
bip49available: false,
|
||||||
|
onSelect: function() {
|
||||||
|
network = bitcoinjs.bitcoin.networks.pivx;
|
||||||
|
setHdCoin(119);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "PIVX - PIVX Testnet",
|
||||||
|
bip49available: false,
|
||||||
|
onSelect: function() {
|
||||||
|
network = bitcoinjs.bitcoin.networks.pivxtestnet;
|
||||||
|
setHdCoin(1);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "PPC - Peercoin",
|
name: "PPC - Peercoin",
|
||||||
bip49available: false,
|
bip49available: false,
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
# 0.2.2
|
||||||
|
|
||||||
|
* Improve showing feedback for pending calculations
|
||||||
|
* Bugfix: Clear old seed when mnemonic is changed
|
||||||
|
* Add PIVX network
|
||||||
|
|
||||||
# 0.2.1
|
# 0.2.1
|
||||||
|
|
||||||
* BTC is the default coin
|
* BTC is the default coin
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<h1 class="text-center">Mnemonic Code Converter</h1>
|
<h1 class="text-center">Mnemonic Code Converter</h1>
|
||||||
<p class="version">v0.2.1</p>
|
<p class="version">v0.2.2</p>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|||||||
@@ -195,3 +195,25 @@ bitcoinjs.bitcoin.networks.myriadcoin = {
|
|||||||
scriptHash: 0x00, // TODO set this correctly
|
scriptHash: 0x00, // TODO set this correctly
|
||||||
wif: 0xb2,
|
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,
|
||||||
|
};
|
||||||
|
|||||||
@@ -175,6 +175,10 @@
|
|||||||
|
|
||||||
function delayedPhraseChanged() {
|
function delayedPhraseChanged() {
|
||||||
hideValidationError();
|
hideValidationError();
|
||||||
|
seed = null;
|
||||||
|
bip32RootKey = null;
|
||||||
|
bip32ExtendedKey = null;
|
||||||
|
clearAddressesList();
|
||||||
showPending();
|
showPending();
|
||||||
if (phraseChangeTimeoutEvent != null) {
|
if (phraseChangeTimeoutEvent != null) {
|
||||||
clearTimeout(phraseChangeTimeoutEvent);
|
clearTimeout(phraseChangeTimeoutEvent);
|
||||||
@@ -184,7 +188,6 @@
|
|||||||
|
|
||||||
function phraseChanged() {
|
function phraseChanged() {
|
||||||
showPending();
|
showPending();
|
||||||
hideValidationError();
|
|
||||||
setMnemonicLanguage();
|
setMnemonicLanguage();
|
||||||
// Get the mnemonic phrase
|
// Get the mnemonic phrase
|
||||||
var phrase = DOM.phrase.val();
|
var phrase = DOM.phrase.val();
|
||||||
@@ -197,7 +200,6 @@
|
|||||||
var passphrase = DOM.passphrase.val();
|
var passphrase = DOM.passphrase.val();
|
||||||
calcBip32RootKeyFromSeed(phrase, passphrase);
|
calcBip32RootKeyFromSeed(phrase, passphrase);
|
||||||
calcForDerivationPath();
|
calcForDerivationPath();
|
||||||
hidePending();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delayedEntropyChanged() {
|
function delayedEntropyChanged() {
|
||||||
@@ -273,10 +275,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function calcForDerivationPath() {
|
function calcForDerivationPath() {
|
||||||
showPending();
|
|
||||||
clearDerivedKeys();
|
clearDerivedKeys();
|
||||||
clearAddressesList();
|
clearAddressesList();
|
||||||
hideValidationError();
|
showPending();
|
||||||
// Don't show bip49 if it's selected but network doesn't support it
|
// Don't show bip49 if it's selected but network doesn't support it
|
||||||
if (bip49TabSelected() && !networkHasBip49()) {
|
if (bip49TabSelected() && !networkHasBip49()) {
|
||||||
return;
|
return;
|
||||||
@@ -296,7 +297,6 @@
|
|||||||
displayBip49Info();
|
displayBip49Info();
|
||||||
}
|
}
|
||||||
displayBip32Info();
|
displayBip32Info();
|
||||||
hidePending();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateClicked() {
|
function generateClicked() {
|
||||||
@@ -603,17 +603,19 @@
|
|||||||
for (var i=0; i<rows.length; i++) {
|
for (var i=0; i<rows.length; i++) {
|
||||||
rows[i].shouldGenerate = false;
|
rows[i].shouldGenerate = false;
|
||||||
}
|
}
|
||||||
|
hidePending();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i=0; i<total; i++) {
|
for (var i=0; i<total; i++) {
|
||||||
var index = i + start;
|
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;
|
var self = this;
|
||||||
this.shouldGenerate = true;
|
this.shouldGenerate = true;
|
||||||
@@ -675,6 +677,9 @@
|
|||||||
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
|
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
|
||||||
}
|
}
|
||||||
addAddressToList(indexText, address, pubkey, privkey);
|
addAddressToList(indexText, address, pubkey, privkey);
|
||||||
|
if (isLast) {
|
||||||
|
hidePending();
|
||||||
|
}
|
||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1270,6 +1275,22 @@
|
|||||||
setHdCoin(7);
|
setHdCoin(7);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "PIVX - PIVX",
|
||||||
|
bip49available: false,
|
||||||
|
onSelect: function() {
|
||||||
|
network = bitcoinjs.bitcoin.networks.pivx;
|
||||||
|
setHdCoin(119);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "PIVX - PIVX Testnet",
|
||||||
|
bip49available: false,
|
||||||
|
onSelect: function() {
|
||||||
|
network = bitcoinjs.bitcoin.networks.pivxtestnet;
|
||||||
|
setHdCoin(1);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "PPC - Peercoin",
|
name: "PPC - Peercoin",
|
||||||
bip49available: false,
|
bip49available: false,
|
||||||
|
|||||||
95
tests.js
95
tests.js
@@ -932,6 +932,66 @@ page.open(url, function(status) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// BIP39 seed is set from phrase
|
// BIP39 seed is set from phrase
|
||||||
function() {
|
function() {
|
||||||
page.open(url, function(status) {
|
page.open(url, function(status) {
|
||||||
@@ -4060,6 +4120,41 @@ 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// If you wish to add more tests, do so here...
|
// If you wish to add more tests, do so here...
|
||||||
|
|
||||||
// Here is a blank test template
|
// Here is a blank test template
|
||||||
|
|||||||
Reference in New Issue
Block a user