diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2016-12-19 13:54:51 +1100 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2016-12-19 13:55:21 +1100 |
commit | ba3cb9ecae2667e98af71f5b38a862ba604e8e1c (patch) | |
tree | 380d24d03b7a3e6c7e02592901a62d605b2df61e /tests.js | |
parent | 52da415f0385a6a89070498d14259aed980f989b (diff) | |
download | BIP39-ba3cb9ecae2667e98af71f5b38a862ba604e8e1c.tar.gz BIP39-ba3cb9ecae2667e98af71f5b38a862ba604e8e1c.tar.zst BIP39-ba3cb9ecae2667e98af71f5b38a862ba604e8e1c.zip |
xpub key can be used as bip32 root key
Diffstat (limited to 'tests.js')
-rw-r--r-- | tests.js | 103 |
1 files changed, 103 insertions, 0 deletions
@@ -3138,6 +3138,109 @@ page.open(url, function(status) { | |||
3138 | }); | 3138 | }); |
3139 | }, | 3139 | }, |
3140 | 3140 | ||
3141 | // github issue 40 | ||
3142 | // BIP32 root key can be set as an xpub | ||
3143 | function() { | ||
3144 | page.open(url, function(status) { | ||
3145 | // set the phrase | ||
3146 | page.evaluate(function() { | ||
3147 | // set xpub for account 0 of bip44 for 'abandon abandon ability' | ||
3148 | var bip44AccountXpub = "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf"; | ||
3149 | $("#root-key").val(bip44AccountXpub); | ||
3150 | $("#root-key").trigger("input"); | ||
3151 | }); | ||
3152 | waitForFeedback(function() { | ||
3153 | page.evaluate(function() { | ||
3154 | // Use bip32 tab | ||
3155 | $("#bip32-tab a").click(); | ||
3156 | }); | ||
3157 | waitForGenerate(function() { | ||
3158 | page.evaluate(function() { | ||
3159 | // derive external addresses for this xpub | ||
3160 | var firstAccountDerivationPath = "m/0"; | ||
3161 | $("#bip32-path").val(firstAccountDerivationPath); | ||
3162 | $("#bip32-path").trigger("input"); | ||
3163 | }); | ||
3164 | waitForGenerate(function() { | ||
3165 | // check the addresses are generated | ||
3166 | var expected = "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug"; | ||
3167 | var actual = page.evaluate(function() { | ||
3168 | return $(".address:first").text(); | ||
3169 | }); | ||
3170 | if (actual != expected) { | ||
3171 | console.log("xpub key does not generate addresses in table"); | ||
3172 | console.log("Expected: " + expected); | ||
3173 | console.log("Actual: " + actual); | ||
3174 | fail(); | ||
3175 | } | ||
3176 | // check the xprv key is not set | ||
3177 | var expected = "NA"; | ||
3178 | var actual = page.evaluate(function() { | ||
3179 | return $(".extended-priv-key").val(); | ||
3180 | }); | ||
3181 | if (actual != expected) { | ||
3182 | console.log("xpub key as root shows derived bip32 xprv key"); | ||
3183 | console.log("Expected: " + expected); | ||
3184 | console.log("Actual: " + actual); | ||
3185 | fail(); | ||
3186 | } | ||
3187 | // check the private key is not set | ||
3188 | var expected = "NA"; | ||
3189 | var actual = page.evaluate(function() { | ||
3190 | return $(".privkey:first").text(); | ||
3191 | }); | ||
3192 | if (actual != expected) { | ||
3193 | console.log("xpub key generates private key in addresses table"); | ||
3194 | console.log("Expected: " + expected); | ||
3195 | console.log("Actual: " + actual); | ||
3196 | fail(); | ||
3197 | } | ||
3198 | next(); | ||
3199 | }); | ||
3200 | }); | ||
3201 | }); | ||
3202 | }); | ||
3203 | }, | ||
3204 | |||
3205 | // github issue 40 | ||
3206 | // xpub for bip32 root key will not work with hardened derivation paths | ||
3207 | function() { | ||
3208 | page.open(url, function(status) { | ||
3209 | // set the phrase | ||
3210 | page.evaluate(function() { | ||
3211 | // set xpub for account 0 of bip44 for 'abandon abandon ability' | ||
3212 | var bip44AccountXpub = "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf"; | ||
3213 | $("#root-key").val(bip44AccountXpub); | ||
3214 | $("#root-key").trigger("input"); | ||
3215 | }); | ||
3216 | waitForFeedback(function() { | ||
3217 | // Check feedback is correct | ||
3218 | var expected = "Hardened derivation path is invalid with xpub key"; | ||
3219 | var actual = page.evaluate(function() { | ||
3220 | return $(".feedback").text(); | ||
3221 | }); | ||
3222 | if (actual != expected) { | ||
3223 | console.log("xpub key with hardened derivation path does not show feedback"); | ||
3224 | console.log("Expected: " + expected); | ||
3225 | console.log("Actual: " + actual); | ||
3226 | fail(); | ||
3227 | } | ||
3228 | // Check no addresses are shown | ||
3229 | var expected = 0; | ||
3230 | var actual = page.evaluate(function() { | ||
3231 | return $(".addresses tr").length; | ||
3232 | }); | ||
3233 | if (actual != expected) { | ||
3234 | console.log("addresses still show after setting xpub key with hardened derivation path"); | ||
3235 | console.log("Expected: " + expected); | ||
3236 | console.log("Actual: " + actual); | ||
3237 | fail(); | ||
3238 | } | ||
3239 | next(); | ||
3240 | }); | ||
3241 | }); | ||
3242 | }, | ||
3243 | |||
3141 | 3244 | ||
3142 | // If you wish to add more tests, do so here... | 3245 | // If you wish to add more tests, do so here... |
3143 | 3246 | ||