+ function adjustNetworkForSegwit() {
+ // If segwit is selected the xpub/xprv prefixes need to be adjusted
+ // to avoid accidentally importing BIP49 xpub to BIP44 watch only
+ // wallet.
+ // See https://github.com/iancoleman/bip39/issues/125
+ var segwitNetworks = null;
+ // if a segwit network is alread selected, need to use base network to
+ // look up new parameters
+ if ("baseNetwork" in network) {
+ network = bitcoinjs.bitcoin.networks[network.baseNetwork];
+ }
+ // choose the right segwit params
+ if (p2wpkhSelected() && "p2wpkh" in network) {
+ network = network.p2wpkh;
+ }
+ else if (p2wpkhInP2shSelected() && "p2wpkhInP2sh" in network) {
+ network = network.p2wpkhInP2sh;
+ }
+ }
+
+ function lastIndexInTable() {
+ var pathText = DOM.addresses.find(".index").last().text();
+ var pathBits = pathText.split("/");
+ var lastBit = pathBits[pathBits.length-1];
+ var lastBitClean = lastBit.replace("'", "");
+ return parseInt(lastBitClean);