- else {
- if (network == bitcoinjs.bitcoin.networks.bitcoinBip49) {
- network = bitcoinjs.bitcoin.networks.bitcoin;
- }
- else if (network == bitcoinjs.bitcoin.networks.testnetBip49) {
- network = bitcoinjs.bitcoin.networks.testnet;
- }
- else if (network == bitcoinjs.bitcoin.networks.litecoinBip49) {
- network = bitcoinjs.bitcoin.networks.litecoin;
+ // 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);
+ }
+
+ function uint8ArrayToHex(a) {
+ var s = ""
+ for (var i=0; i<a.length; i++) {
+ var h = a[i].toString(16);
+ while (h.length < 2) {
+ h = "0" + h;