Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add testnet support #803

Closed
wants to merge 10 commits into from

Conversation

lzhuor
Copy link
Contributor

@lzhuor lzhuor commented Jul 23, 2018

WORK IN PROGRESS, PLEASE DO NOT MERGE.

TODO

  • Fix kvstore entries
  • Fix send
  • Fix add wallet account
  • Disable other currencies?

Description

Added logic to check Node.js environment in config/index.js so Bitcoin Network and Bitcoin Cash Network can be derived from NODE_ENV

Change Type

  • Feature
    Added testnet support

  • Bug Fix

  1. The var network is assigned with settings.NETWORK_BITCOIN but we are using NETWORK as the name in config/index.js so its value is always undefined. Renamed NETWORK as NETWORK_BITCOIN
  2. Passing network as a param in actions.auth.register() function

Testing Steps

  1. Run yarn start:testnet
  2. Should successfully create a wallet

Code Checklist

  • Code compiles successfully (verified via yarn start)
  • No lint issues exist (verified via yarn lint)
  • New and existing unit tests pass (verified via yarn test)
  • README.md and other documentation is updated as needed

@lzhuor lzhuor mentioned this pull request Jul 23, 2018
@schnogz schnogz added the don't merge yet Code should not be merged label Jul 23, 2018
NETWORK_ETHEREUM: 1,
NETWORK_BCH: BitcoinCash.networks.bitcoin
NETWORK_BCH: BitcoinCash.networks[isTestnet ? 'testnet' : 'bitcoin']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick. We're trying to use currency codes instead of currency names. Can you change to NETWORK_BTC?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@plondon plondon Jul 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed we are hardcoding Bitcoin.networks.bitcoin in a few places, which will need to be replaced by settings config. For example: http://github.com/blockchain/blockchain-wallet-v4-frontend/blob/e6b67ab820bb6e262dfb2f89ac3f3389d1c1fcb6/packages/blockchain-wallet-v4/src/types/HDWallet.js#L88

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plondon Thank you!

  1. I will address the naming.
  2. Good catch! I caught that TODO as well and has addressed it in local.
  3. Great! I will search for these hardcoding reference

@plondon plondon self-assigned this Jul 24, 2018
@@ -1,13 +1,15 @@
import Bitcoin from 'bitcoinjs-lib'
import BitcoinCash from 'bitcoinforksjs-lib'

const isTestnet = process.NODE_ENV === 'testnet'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct is process.env.NODE_ENV, also this doesn't seem to work even if it's correct

Copy link
Contributor Author

@lzhuor lzhuor Jul 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologize for my late night stupidness. This will not work because process.env.NODE_ENV will not be known by the client. I will address it.

- Fixed config/index.js by renaming 'NETWORK' to 'NETWORK_BITCOIN'
- Setting network config conditionally by checking environment
- Passing network from onSubmit function of Register component
- Fixed a few linting issues
- Rebased development branch
- Rebased development branch
@@ -1,13 +1,15 @@
import Bitcoin from 'bitcoinjs-lib'
import BitcoinCash from 'bitcoinforksjs-lib'

const isTestnet = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better way to do this is to determine the network through wallet-options. https://github.com/blockchain/wallet-options/blob/master/prod/wallet-options-v4.json#L30. So I will probably end up removing NETWORK related things from this config

@plondon
Copy link
Contributor

plondon commented Aug 8, 2018

@lzhuor thanks for starting this off. I put a bit more work in but there are still a few todos before we can merge it.

Sending works, but only if you override the isValidAddress check here: https://github.com/lzhuor/blockchain-wallet-v4-frontend/blob/fix/testnet_support/packages/blockchain-wallet-v4/src/utils/btc.js#L16. We need to pass the network to this function.

@lzhuor
Copy link
Contributor Author

lzhuor commented Aug 9, 2018

@plondon Thank you for your patience! I was drenched in my personal stuff in the past week. Looking into it now!

@plondon
Copy link
Contributor

plondon commented Aug 9, 2018

@lzhuor apology unnecessary, really appreciate your contribution!

@plondon plondon added this to the 4.3.x milestone Aug 9, 2018
@plondon plondon removed the don't merge yet Code should not be merged label Aug 15, 2018
@plondon
Copy link
Contributor

plondon commented Aug 15, 2018

Not sure why the build failed but moving this to another PR

@plondon plondon closed this Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants