From daab55dc613a1eef22463356eba1a742cb814cb2 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Sun, 6 Aug 2017 07:58:58 +1000 Subject: [PATCH] Add BCH - Bitcoin Cash network --- src/js/index.js | 8 ++++++++ tests.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/js/index.js b/src/js/index.js index a12e442..b1876cb 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1166,6 +1166,14 @@ } var networks = [ + { + name: "BCH - Bitcoin Cash", + bip49available: false, + onSelect: function() { + network = bitcoinjs.bitcoin.networks.bitcoin; + setHdCoin(145); + }, + }, { name: "BTC - Bitcoin", bip49available: true, diff --git a/tests.js b/tests.js index b6713b0..2e2e38b 100644 --- a/tests.js +++ b/tests.js @@ -872,6 +872,36 @@ 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(); + }); +}); +}, + // BIP39 seed is set from phrase function() { page.open(url, function(status) { -- 2.41.0