bitpay / bitcore

A full stack for bitcoin and blockchain-based applications
https://bitcore.io/
MIT License
4.83k stars 2.08k forks source link

Not connected to peer: 127.0.0.1:8332 | Chain: BTC | Network: regtest #2197

Open WesNz opened 5 years ago

WesNz commented 5 years ago

Currently i'm using the bitcore.config.json test file in the bitcore root. (below) Below is the bitcoin.conf info.

txindex=1 server=1 listen=1 irc=1 upnp=1 port=8332 rpcport=8333 dbcache=4096 rpcallowip=127.0.0.1 rpcuser=test rpcpassword=supersecretpassword


{ "bitcoreNode": { "services": { "api": { "wallets": { "allowCreationBeforeCompleteSync": true } } }, "chains": { "BTC": { "regtest": { "chainSource": "p2p", "trustedPeers": [ { "host": "127.0.0.1", "port": 8332 } ], "rpc": { "host": "127.0.0.1", "port": 8333, "username": "test", "password": "supersecretpassword" } } } } } }


info: Starting Event Service info: Starting P2P Manager warn: 2019-05-22 11:47:20.743 GMT+12 | Not connected to peer: 127.0.0.1:8332 | Chain: BTC | Network: regtest info: Starting Event Service info: Starting API Service on port 3000 info: Starting Socket Service info: Starting Event Service info: Starting API Service on port 3000 info: Starting Socket Service

ApolloMuses commented 5 years ago

+1 same problem...wondering if the bitcoin.conf is not supposed to go in the root bitcore directory

WesNz commented 5 years ago

Starting bitcoind and then Running node worked

ApolloMuses commented 5 years ago

did you have to install bitcoind separately?

WesNz commented 5 years ago

Already had it installed and blockchain downloaded. Just figured it needed to connect to the bitcoind/bitcoin core wallet rpc/port

christroutner commented 5 years ago

I'm running into this same problem. Can you expand on this @WesNz:

Starting bitcoind and then Running node worked

I've got bitcoind running in a Docker container and I can successfully make RPC calls to it. But I'm getting the same error you reported in this Issue.

How did you fix it? Your comment leads me to believe that you didn't have bitcoind running and that's why you got the error? And you fixed it by running bitcoind?

micahriggan commented 5 years ago

@christroutner do you have the p2p ports exposed on your docker container?

Bitcore-node talks to the bitcoin node over p2p, so those ports need to be exposed, and also the bitcoin node doesn't respond to getBlock p2p messages until after the bitcoin node has fully synced.

christroutner commented 5 years ago

Thanks for the fast response! I just opened issue #2198. To answer your questions:

ApolloMuses commented 5 years ago

So does this mean the v8 node requires a separate installation of the full node? Where as v4 did not?

On Wed, May 22, 2019 at 11:40 AM Chris Troutner notifications@github.com wrote:

Thanks for the fast response! I just opened issue #2198 https://github.com/bitpay/bitcore/issues/2198. To answer your questions:

-

I can communicate with the node via the RPC on port 8332. I assume that's what you mean by p2p?

The node is fully synced.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bitpay/bitcore/issues/2197?email_source=notifications&email_token=AAZ6SSOSME32XJAPB2DFVHLPWWHSRA5CNFSM4HOPSFG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV75JEI#issuecomment-494916753, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZ6SSI2UW5CBX2VAZ55XRTPWWHSRANCNFSM4HOPSFGQ .

micahriggan commented 5 years ago

Correct! Bitcore talks to a full node. The patched full node version was hard to maintain and didn't scale like we needed.

ApolloMuses commented 5 years ago

Ahh okay that clarifies a lot of confusion. Another quick question, for BCH, would v8 just need the BCH ABC full node to full or will it need the reference BTC node too?

WesNz commented 5 years ago

Correct! Bitcore talks to a full node. The patched full node version was hard to maintain and didn't scale like we needed.

WesNz commented 5 years ago

@christroutner do you have the p2p ports exposed on your docker container?

Bitcore-node talks to the bitcoin node over p2p, so those ports need to be exposed, and also the bitcoin node doesn't respond to getBlock p2p messages until after the bitcoin node has fully synced.

Trusted P2P Peer - I see this on the requirements, Is that an app?

micahriggan commented 5 years ago

@ApolloMuses Just the BCH full node. @WesNz Trusted P2P peer would be your BTC or BCH node, or someone else's who you trust

ApolloMuses commented 5 years ago

Ah okay so then in the bitcore.config.json then it should only have the BCH configurations then?

e.g.



{
  "bitcoreNode": {
    "chains": {
      "BCH": {
        "mainnet": {
          "parentChain": "p2p",
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 30008
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 30009,
            "username": "username",
            "password": "password"
          }
        }
      }
    }
  }
}

or would it require the BTC config too?
micahriggan commented 5 years ago

Just BCH in the config :)

If you wanted it to sync both BTC and BCH, then you'd have them both in chains

ApolloMuses commented 5 years ago

Ahh thanks for clearing that up! This has been driving me nuts for the last week xD. Will test this now and if its successful, I'll draft up some documentation

micahriggan commented 5 years ago

For instance, my config looks like this

    "chains": {
      "BTC": {
        "mainnet": {
          "chainSource": "p2p",
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 20000
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 20001,
            "username": "bitpaytest",
            "password": "local321"
          }
        },
        "regtest": {
          "chainSource": "p2p",
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 20004
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 20005,
            "username": "bitpaytest",
            "password": "local321"
          }
        }
      },
      "BCH": {
        "mainnet": {
          "parentChain": "BTC",
          "forkHeight": 478558,
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 30000
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 30001,
            "username": "username",
            "password": "password"
          }
        },
        "regtest": {
          "chainSource": "p2p",
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 30004
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 30005,
            "username": "username",
            "password": "password"
          }
        }
      }
    }

But I have synced BTC already, so by setting forkHeight I can prune out some data for BCH that wasn't relevant at the time of fork*

ApolloMuses commented 5 years ago

Testing this now with a bch abc node syncing. Another quick question, the old insight-ui was using port 3001, I can't seem to find the relevant info in v8? Care to shed some light?

micahriggan commented 5 years ago

If you're wanting to run insight I think you can do

npm run insight-previous

That should launch the UI and the ui should talk to your local bitcore-node

ApolloMuses commented 5 years ago

I tried that previous but only saw errors. Just to confirm the ui is served on port 8200?

Here's the error log:

> @bitpay/insight-previous@8.3.0 start /home/ubuntu/bitcore/packages/insight-previous
> npm run ionic:serve

> @bitpay/insight-previous@8.3.0 ionic:serve /home/ubuntu/bitcore/packages/insight-previous
> ionic-app-scripts serve --port 8200

[22:12:42]  ionic-app-scripts 3.2.3
[22:12:42]  watch started ...
[22:12:42]  build dev started ...
[22:12:42]  Proxy added:/api => http://localhost:3000/api
[22:12:42]  clean started ...
[22:12:42]  clean finished in 6 ms
[22:12:42]  copy started ...
[22:12:42]  deeplinks started ...
[22:12:42]  deeplinks finished in 353 ms
[22:12:42]  transpile started ...
[22:12:53]  typescript: home/ubuntu/bitcore/node_modules/@types/mocha/index.d.ts, line: 2680
            Duplicate identifier 'beforeEach'.

    L2680:  * @see https://mochajs.org/api/global.html#afterEach

[22:12:53]  typescript: home/ubuntu/bitcore/node_modules/@types/mocha/index.d.ts, line: 2698
            Duplicate identifier 'afterEach'.

    L2698:  declare var describe: Mocha.SuiteFunction;

[22:12:53]  typescript: home/ubuntu/bitcore/node_modules/@types/mocha/index.d.ts, line: 2714
            Duplicate identifier 'describe'.

    L2715:   * Pending suite.

[22:12:53]  typescript: home/ubuntu/bitcore/node_modules/@types/mocha/index.d.ts, line: 2735
            Duplicate identifier 'xdescribe'.

    L2736:   * Describes a test case.

[22:12:53]  typescript: home/ubuntu/bitcore/node_modules/@types/mocha/index.d.ts, line: 2749
            Duplicate identifier 'it'.

    L2750:   * Describes a pending test case.

[22:12:53]  typescript: home/ubuntu/bitcore/node_modules/@types/mocha/index.d.ts, line: 2770
            Duplicate identifier 'xit'.

    L2769:  // NOTE: Mocha *must not* have a direct dependency on DOM types.
    L2770:  // tslint:disable-next-line no-empty-interface
    L2771:  interface HTMLLIElement { }

[22:12:53]  typescript: node_modules/@types/jasmine/index.d.ts, line: 9
            Duplicate identifier 'describe'.

       L9:  /** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be
      L10:  declare function pending(reason?: string): void;

[22:12:53]  typescript: node_modules/@types/jasmine/index.d.ts, line: 11
            Duplicate identifier 'xdescribe'.

      L10:  declare function pending(reason?: string): void;
      L12:  declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void;

[22:12:53]  typescript: node_modules/@types/jasmine/index.d.ts, line: 13
            Duplicate identifier 'it'.

      L12:  declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void;
      L13:  declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void;

[22:12:53]  typescript: node_modules/@types/jasmine/index.d.ts, line: 15
            Duplicate identifier 'xit'.

      L15:  declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void;
      L16:  declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void;

[22:12:53]  typescript: node_modules/@types/jasmine/index.d.ts, line: 20
            Duplicate identifier 'beforeEach'.

      L19:  declare function expect(actual: any): jasmine.Matchers;
      L21:  declare function fail(e?: any): void;

[22:12:53]  typescript: node_modules/@types/jasmine/index.d.ts, line: 21
            Duplicate identifier 'afterEach'.

      L21:  declare function fail(e?: any): void;
      L22:  /** Action method that should be called when the async work is complete */

[22:12:53]  dev server running: http://localhost:8200/

[22:12:53]  Failed to open the browser: Command failed: xdg-open "http://localhost:8200" /bin/sh: 1: xdg-open: not found
[22:12:53]  copy finished in 11.53 s
(node:30782) UnhandledPromiseRejectionWarning: Error: A watch configured to watch the following paths failed to start. It likely that a file referenced does not exist: /home/ubuntu/bitcore/packages/insight-previous/src/assets/**/*, /home/ubuntu/bitcore/packages/insight-previous/src/index.html, /home/ubuntu/bitcore/packages/insight-previous/src/manifest.json, /home/ubuntu/bitcore/packages/insight-previous/src/service-worker.js, /home/ubuntu/bitcore/packages/insight-previous/node_modules/ionicons/dist/fonts/**/*, /home/ubuntu/bitcore/packages/insight-previous/node_modules/ionic-angular/fonts/**/*, /home/ubuntu/bitcore/packages/insight-previous/node_modules/ionic-angular/polyfills/polyfills.js, /home/ubuntu/bitcore/packages/insight-previous/node_modules/sw-toolbox/sw-toolbox.js
    at new BuildError (/home/ubuntu/bitcore/packages/insight-previous/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at Timeout._onTimeout (/home/ubuntu/bitcore/packages/insight-previous/node_modules/@ionic/app-scripts/dist/watch.js:71:20)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
(node:30782) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:30782) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 
micahriggan commented 5 years ago

Actually that appears to be messed up for me as well.

Try removing

    "@types/chai": "^4.1.7",
    "@types/mocha": "^5.2.6",

From the top level package.json, then npm install, then npm run insight-previous

If you get an error about bs58, cd into insight-previous and run npm install from that folder

Submitting an MR to fix this issue.

ApolloMuses commented 5 years ago

Ahh thanks! got that going.

I must be configuring something wrong, since I am still seeing this:

2019-05-22 23:10:06.558 UTC | Not connected to peer: 127.0.0.1:8333 | Chain: BTC | Network: mainnet

I've tried my config and the one you posted.

The bitcoinABC version of bitcoind is running and the bitcoin.conf is configured as follows:

txindex=1
server=1
listen=1
irc=1
upnp=1

port=20000
rpcport=20001
dbcache=4096

rpcallowip=127.0.0.1
rpcuser=someusername
rpcpassword=somepassword

Also I only see the instance of BTC on the explorer, is this normal? I'm wondering if it is until the node is synced up to date of the spilt?

micahriggan commented 5 years ago

Output indicates it's using the default config, rather than what is in your bitcore.config.json

I only put a piece of my config, so maybe the full thing will help

This is what I have in my bitcore/bitcore.config.json

{
  "bitcoreNode": {
    "services": {
      "api": {
        "wallets": {
          "allowCreationBeforeCompleteSync": true
        }
      }
    },
    "chains": {
      "BTC": {
        "mainnet": {
          "chainSource": "p2p",
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 20000
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 20001,
            "username": "bitpaytest",
            "password": "local321"
          }
        },
        "regtest": {
          "chainSource": "p2p",
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 20004
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 20005,
            "username": "bitpaytest",
            "password": "local321"
          }
        }
      },
      "BCH": {
        "mainnet": {
          "parentChain": "BTC",
          "forkHeight": 478558,
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 30000
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 30001,
            "username": "username",
            "password": "password"
          }
        },
        "regtest": {
          "chainSource": "p2p",
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 30004
            }
          ],
          "rpc": {
            "host": "127.0.0.1",
            "port": 30005,
            "username": "username",
            "password": "password"
          }
        }
      }
    }
  }
}
elboertjie commented 5 years ago

If you're wanting to run insight I think you can do

npm run insight-previous

That should launch the UI and the ui should talk to your local bitcore-node

@micahriggan Does this mean that the Insight interface will also be available in a web browser on the internet?

I wish to make the Insight explorer available to people on the internet and was wondering if there is anything additional that I would need to install to make this work. I appreciate any guidance. Thanks

ApolloMuses commented 5 years ago

@micahriggan I got it working after some experimentation, Thanks for all your help.

@elboertjie you will need to open the port 8200 for the explorer to be available and also change the package.json config for BCH or BTC depending on which you are running.

KayRuggles commented 5 years ago

I'm not sure if I'm doing this right

KayRuggles commented 5 years ago

Do you know anything about mining how to mine for Bitcoin

todipratik commented 4 years ago

Hey @micahriggan,

I have bitcore-node running. I tried to run insight and got following error on running npm start insight-previous from bitcore/packages/insight.

> @bitpay/insight-previous@8.13.0 start /home/ubuntu/bitcore/packages/insight
> npm run ionic:serve "insight-previous"

> @bitpay/insight-previous@8.13.0 ionic:serve /home/ubuntu/bitcore/packages/insight
> ionic-app-scripts serve --port 8200 "insight-previous"

[08:29:09]  ionic-app-scripts 3.2.3
[08:29:09]  watch started ...
[08:29:09]  build dev started ...
[08:29:09]  Proxy added:/api => http://localhost:3000/api
[08:29:09]  clean started ...
[08:29:09]  clean finished in 1 ms
[08:29:09]  copy started ...
[08:29:10]  deeplinks started ...
[08:29:10]  deeplinks finished in 413 ms
[08:29:10]  transpile started ...
[08:29:25]  typescript: home/ubuntu/node_modules/@types/ws/index.d.ts, line: 44
            Namespace '"url"' has no exported member 'URL'.

      L43:  addEventListener(method: 'message', cb?: (event: { data: any; type: string; target: WebSocket }) => void): void;
      L44:  addEventListener(method: 'close', cb?: (event: {
      L45:      wasClean: boolean; code: number;

[08:29:25]  typescript: home/ubuntu/node_modules/@types/ws/index.d.ts, line: 45
            Namespace '"url"' has no exported member 'URL'.

      L44:  addEventListener(method: 'close', cb?: (event: {
      L45:      wasClean: boolean; code: number;
      L46:      reason: string; target: WebSocket

[08:29:25]  typescript: home/ubuntu/node_modules/@types/ws/index.d.ts, line: 126
            Namespace '"http"' has no exported member 'OutgoingHttpHeaders'.

     L125:  host?: string;
     L126:  family?: number;
     L127:  checkServerIdentity?(servername: string, cert: CertMeta): boolean;

[08:29:25]  dev server running: http://localhost:8200/

Any idea why might have caused this to happen?

micahriggan commented 4 years ago

To me this seems like you have a node_modules in your home directory, with types that don't match the insight directory.

Check your /home/ubuntu directory and see if there's a node_modules folder in there. If so, and you don't need it, go ahead and delete that.

todipratik commented 4 years ago

Wonderful! Seems I messed up with up home directory. It works after I deleted node_modules folder.

A follow-up question: How can I run bitcore-node and insight in the background? (such that they run even after I have logged off from my remote machine) Currently, I am using npm run node from bitcore/ directory to run bitcore-node and npm start insight-previous from bitcore/packages/insight to run insight.

micahriggan commented 4 years ago

You could use PM2, or systemd to keep it running in the background, we use systemd

todipratik commented 4 years ago

For bitcore-node, I was able to run it in background using command pm2 --name "Bitcore-Node" start server.js -- start from bitcore/packages/bitcore-node/build/src. But I am not sure if this is correct way since I am running a script in build folder. However, I also found the following script but couldn't use it. https://github.com/bitpay/bitcore/blob/master/packages/bitcore-node/bitcore-node.service

For insight, I couldn't find similar script to use with pm2.