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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Testnet #771

Closed
lzhuor opened this issue Jul 12, 2018 · 7 comments
Closed

Add Support for Testnet #771

lzhuor opened this issue Jul 12, 2018 · 7 comments
Assignees
Labels
enhancement An enhancement for an existing feature

Comments

@lzhuor
Copy link
Contributor

lzhuor commented Jul 12, 2018

馃悰 Bug Report 馃悰

Description

Hi team, I'm trying to connect to testnet from localhost:8080. However, I am getting below error during login:

hdnode.js:78 Uncaught Error: Invalid network version
    at Function.HDNode.fromBase58 (hdnode.js:78)
    at accountCons (HDAccount.js:124)
    at fromJS (HDAccount.js:130)
    at args.(anonymous function) (webpack:////Users/zhuoranli/IdeaProjects/public/blockchain-wallet-v4-frontend/node_modules/ramda/es/addIndex.js?:40:27)
    at _map (_map.js:8)
    at map (map.js:64)
    at eval (_dispatchable.js:42)
    at f2 (_curry2.js:30)
    at eval (addIndex.js:44)
    at eval (_curryN.js:38)

The development.js config is :

module.exports = {
  ROOT_URL: 'https://testnet.blockchain.info',
  API_DOMAIN: 'https://api-testnet.blockchain.info',
  WEB_SOCKET_URL: 'wss://ws.blockchain.info/testnet3/inv',
  WALLET_HELPER_DOMAIN: 'https://wallet-helper.blockchain.info'
}

Could you please advise what can I do to connect to testnet via local environment? Do you mind providing a guide on how could developers start using testnet for development in local?

Thank you and greatly appreciate it!

Expected Behavior

I should be able to login

Reproduction Steps

yarn start:dev with above development.js

Screenshots/Logs

image

Additional Information

NIL

@plondon plondon self-assigned this Jul 13, 2018
@plondon
Copy link
Contributor

plondon commented Jul 13, 2018

Hi at @lzhuor thank you so much for using the wallet and contributing an issue!

The v4 wallet does not yet support testnet, we've looked into it a little bit but have not had sufficient time to fully implement it. I believe the crux of the issue is here: https://github.com/blockchain/blockchain-wallet-v4-frontend/blame/development/packages/blockchain-wallet-v4/src/types/Wrapper.js#L157. Where the wallet is created but the network is not passed in.

We have some more work to do around network configurations, but this is definitely on the todo list! In the meantime, if its a testnet wallet you need you can use https://testnet.blockchain.info/wallet/#/login.

Actually, you may be able to create a testnet wallet there and then use it with the v4 config you have, since it may just be the creation of the wallet that is incorrect.

Best
Phil

@plondon plondon changed the title testnet doesn't work with local dev environment Add Support for Testnet Jul 13, 2018
@plondon plondon added the enhancement An enhancement for an existing feature label Jul 13, 2018
@lzhuor
Copy link
Contributor Author

lzhuor commented Jul 13, 2018

Thank you @plondon!

The workaround works for me. I will take a look at the code snippet to understand the root cause.

Btw, this react + redux (and saga) front-end project is awesome. I learned quite a few good points such as using monorepo, using ramda, using lense etc. Lesson learned.

@schnogz schnogz added the help wanted Help is desired by developer(s) label Jul 17, 2018
@lzhuor
Copy link
Contributor Author

lzhuor commented Jul 23, 2018

Hi folks, I tried to fix the above problem in #803.

After the fix, in debug mode, I can see network is passed all the way down. However, I am getting below error after wallet creation:
image

The error was thrown from kvStore/index.js during calling GET https://api-testnet.blockchain.info/metadata/1CH6gsibWwGqTTZYZ6cEuMKMTwJL1Wvfsq

const fetchKVStore = kv => {
    let setKvFromResponse = curry((currentKv, res) => {
      if (res === null) return set(KV.value, null, currentKv)
      let setFromResponse = compose(
        set(KV.magicHash, prop('compute_new_magic_hash', res)),
        set(KV.value, KV.extractResponse(kv.encKeyBuffer, res))
      )
      return setFromResponse(currentKv)
    })

    return request('GET', kv.address)
      .map(KV.verifyResponse(kv.address))
      .chain(eitherToTask)
      .map(setKvFromResponse(kv))
      .rejectedMap(e => {
        console.error(
          `Failed to fetch metadata entry ${kv.typeId} at ${kv.address}:`,
          e
        )
        return new Error('METADATA_FETCH_FAILED')
      })
  }

Do you have an idea about the cause? Thank you for your time! 鉂わ笍

@plondon
Copy link
Contributor

plondon commented Jul 23, 2018

@lzhuor first of all, thank you so so much for your contribution. I or someone on the team will surely find time this week to make a more comprehensive review. For now to ensure you're not stuck I noticed that https://api-testnet.blockchain.info/metadata/**1CH6gsibWwGqTTZYZ6cEuMKMTwJL1Wvfsq** is not a testnet address. metadata will check this and fail because of that most likely.

@plondon
Copy link
Contributor

plondon commented Jul 23, 2018

Compare the response to curl 'https://api-testnet.blockchain.info/metadata/mp3jyzMgYJhnmCuTsXpRbh78YZo1jajA6S' -H 'pragma: no-cache' -H 'origin: https://testnet.blockchain.info' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' -H 'content-type: application/json' -H 'accept: */*' -H 'cache-control: no-cache' -H 'authority: api-testnet.blockchain.info' -H 'referer: https://testnet.blockchain.info/wallet/' -H 'dnt: 1' --compressed

@lzhuor
Copy link
Contributor Author

lzhuor commented Jul 24, 2018

Thank you @plondon ! I will continue from above hint.

@plondon plondon removed the help wanted Help is desired by developer(s) label Aug 15, 2018
@plondon
Copy link
Contributor

plondon commented Aug 15, 2018

Bitcoin testnet wallet available here: #874

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

No branches or pull requests

3 participants