Skip to content

Commit

Permalink
Another avenue to fix the error in regards to the weird testnet/regte…
Browse files Browse the repository at this point in the history
…st bitcore confusion
  • Loading branch information
chiguireitor committed Dec 20, 2018
1 parent d4fbdd7 commit b226969
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/js/components/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ function WalletViewModel() {

// m : masterkery / 0' : first private derivation / 0 : external account / i : index
var key = self.BITCOIN_WALLET.getAddressKey(i);
var address = bitcoinjs.payments.p2wpkh({ pubkey: key.priv.publicKey.toBuffer(), network: bitcoinjs.networks[key.priv.network.alias] }).address;
var networkName = key.priv.network.alias
if (USE_TESTNET && ! USE_REGTEST) {
networkName = key.priv.network.name
}
var address = bitcoinjs.payments.p2wpkh({ pubkey: key.priv.publicKey.toBuffer(), network: bitcoinjs.networks[networkName] }).address;

//Make sure this address doesn't already exist in the wallet (sanity check)
assert(!self.getAddressObj(address), "Cannot addAddress: address already exists in wallet!");
Expand Down
4 changes: 0 additions & 4 deletions src/js/util.bitcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ var bitcoreMessage = require('bitcore-message'); // this also binds itself to bi
// this 'global' is overwritten by tests!
var NETWORK = (USE_TESTNET || USE_REGTEST) ? bitcore.Networks.testnet : bitcore.Networks.livenet;

if (USE_TESTNET && ! USE_REGTEST) {
NETWORK.alias = NETWORK.name;
}

var CWHierarchicalKey = function(passphrase, password) {
checkArgType(passphrase, "string");
if (password) {
Expand Down

0 comments on commit b226969

Please sign in to comment.