Allow BitPay address format for bitcoin cash

This commit is contained in:
Ian Coleman
2017-10-31 10:35:52 +11:00
parent 0cca6e893a
commit fe8f2d140d
4 changed files with 76 additions and 1 deletions

View File

@@ -575,6 +575,16 @@
<div class="col-md-12">
<h2>Derived Addresses</h2>
<p>Note these addreses are derived from the BIP32 Extended Key</p>
</div>
<div class="col-md-12 use-bitpay-addresses-container hidden">
<div class="checkbox">
<label>
<input type="checkbox" class="use-bitpay-addresses">
<span>Use BitPay-style addresses for Bitcoin Cash (ie starting with 'C' instead of '1')</span>
</label>
</div>
</div>
<div class="col-md-12">
<table class="table table-striped">
<thead>
<th>

View File

@@ -250,3 +250,14 @@ bitcoinjs.bitcoin.networks.nubits = {
scriptHash: 0x1a,
wif: 0x96,
};
bitcoinjs.bitcoin.networks.bitcoinCashBitbpay = {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x1c,
scriptHash: 0x28,
wif: 0x80
};

View File

@@ -75,6 +75,8 @@
DOM.generatedStrength = $(".generate-container .strength");
DOM.hardenedAddresses = $(".hardened-addresses");
DOM.useP2wpkhNestedInP2sh = $(".p2wpkh-nested-in-p2sh");
DOM.useBitpayAddressesContainer = $(".use-bitpay-addresses-container");
DOM.useBitpayAddresses = $(".use-bitpay-addresses");
DOM.addresses = $(".addresses");
DOM.rowsToAdd = $(".rows-to-add");
DOM.more = $(".more");
@@ -117,6 +119,7 @@
DOM.publicKeyToggle.on("click", togglePublicKeys);
DOM.privateKeyToggle.on("click", togglePrivateKeys);
DOM.languages.on("click", languageChanged);
DOM.useBitpayAddresses.on("change", useBitpayAddressesChange);
setQrEvents(DOM.showQrEls);
disableForms();
hidePending();
@@ -131,6 +134,7 @@
clearDerivedKeys();
clearAddressesList();
DOM.litecoinLtubContainer.addClass("hidden");
DOM.useBitpayAddressesContainer.addClass("hidden");
var networkIndex = e.target.value;
var network = networks[networkIndex];
network.onSelect();
@@ -347,6 +351,11 @@
}, 50);
}
function useBitpayAddressesChange() {
setBitcoinCashNetworkValues();
phraseChanged();
}
function toggleIndexes() {
showIndex = !showIndex;
$("td.index span").toggleClass("invisible");
@@ -1207,12 +1216,26 @@
DOM.useP2wpkhNestedInP2sh.prop("checked", false);
}
function useBitpayAddresses() {
return !(DOM.useBitpayAddresses.prop("checked"));
}
function setBitcoinCashNetworkValues() {
if (useBitpayAddresses()) {
network = bitcoinjs.bitcoin.networks.bitcoin;
}
else {
network = bitcoinjs.bitcoin.networks.bitcoinCashBitbpay;
}
}
var networks = [
{
name: "BCH - Bitcoin Cash",
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
DOM.useBitpayAddressesContainer.removeClass("hidden");
setBitcoinCashNetworkValues();
setHdCoin(145);
},
},