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

How to add a new coin to peatio with microkube #111

Open
champmine opened this issue May 15, 2019 · 19 comments
Open

How to add a new coin to peatio with microkube #111

champmine opened this issue May 15, 2019 · 19 comments

Comments

@champmine
Copy link

Hi,

what are the files that need to be edited to add a new coin to peatio (running in the microkube framework)?
I have peatio local repo already, just want to know which files to change for a new coin.

Thanks!

@msembinelli
Copy link

msembinelli commented May 15, 2019

You can either add coins manually from the admin panel (www.app.local/admin when running locally), or edit the templates/config/peatio/seed/currencies.yml.erb template. You will also need to add the coins to the wallets and market files. When editing the templates you will need to re-run the rake commands to stop and start the project.

The templates are the key with microkube. When you run the rake commands, it uses the templates to regenerate the config.yml files, so you must make the changes there or else they will be overwritten.

@champmine
Copy link
Author

Thanks, that is fine, but how can one make sure that deposits arrive in the wallets? Is there an example / howto for adding new coins to microkube/peatio?

@msembinelli
Copy link

With the ethereum geth node, you have to let it fully sync before you will see deposits in the user wallet on the site. You must spin up the cryptonode service with rake service:cryptonodes[start]. The syncing could take anywhere from 2-4 days depending on your host hardware and internet connection.

@champmine
Copy link
Author

Thanks very much, yes, the geth node will eventually come up
Is there some documentation how to set up bitcoind, dashd, etc. with microkube?
It would be really nice of the developers to come around and make the entrance hurdle less high than it currently is

@msembinelli
Copy link

msembinelli commented May 18, 2019

Trust me, its been a struggle getting this exchange stood up. It is especially hard if you're not experienced with docker. It really does take a decent time investment just to understand how everything works together. I understand the frustration, which is why I've been active on the microkube repo trying to help answer questions. A good place to find answers is actually the telegram channel for peatio, but even then it might take awhile for someone to respond. The community is more knowledgable on peatio 1.9 (and workbench), while very few have moved on to peatio 2.0.xx (and microkube).

It seems the community around this project likes to act very much like gatekeepers, which isn't fun for noobies like us. But this is free software after all, so we can't have any expectation of support.

That being said, I think i'm comfortable enough now where I understand most of the configuration and customization available in microkube.

Adding Bitcoind

Adding any new blockchain to peatio/microkube will require us to run a full node. There are many dockerized full nodes on dockerhub, most notably: https://hub.docker.com/r/kylemanna/bitcoind

The first thing you will have to do in microkube is add a new cryptonode service to cryptonodes.yaml.erb

version: '3.6'

services:
  geth:
    image: ethereum/client-go:stable
    restart: always
    command: |
      --syncmode=full
      --rinkeby
      --rpc
      --rpcaddr=0.0.0.0
      --rpcport=8545
      --port=30303
      --rpcapi="db,personal,eth,net,web3"
      --rpccorsdomain="*"
      --rpcvhosts="*"
    volumes:
      - ../data/geth:/root/.ethereum/
    expose:
      - "8545"
      - "30303"
    labels:
      traefik.enable: true
      traefik.frontend.rule: 'Host: eth.<%= @config['app']['domain'] %>'
      traefik.port: 8545
  bitcoind:
    image: kylemanna/bitcoind:latest
    restart: always
    command: |
      -printtoconsole
      -testnet=1
      -rest
      -rpcallowip=0.0.0.0/0
      -rpcpassword=changeme
      -rpcport=18333
      -rpcuser=testuser
      -server
    volumes:
      - ../data/bitcoin:/root/.bitcoin/
    expose:
      - "18333"
    labels:
      traefik.enable: true
      traefik.frontend.rule: 'Host: btc.<%= @config['app']['domain'] %>'
      traefik.port: 18333

By the way, the above is untested, just as an example. It might take some fiddling to get this right. The best way is to try getting the container running and check its logs by using the docker logs command.
Note: I am still unsure at this point whether you use bitcoind or bitcoin as the service name used when referenced by peatios backend implementation. You might have to play with this.

Once you have a working bitcoind node, the next thing to do is to tell peatio about it. First shut down everything as the peatio database only gets seeded with the new configuration when you use the rake commands to render the config files. This configuration for adding new blockchains is in the seed file named blockchains.yml.erb.

- key:               eth-rinkeby
  name:              Ethereum Rinkeby
  client:            ethereum               # API client name.
  server:            http://geth:8545       # Public Ethereum node endpoint. IMPORTANT: full syncmode.
  height:            2500000                # Initial block number from which sync will be started.
  min_confirmations: 6                      # Minimal confirmations needed for withdraw and deposit confirmation.
  explorer:
    address:         https://rinkeby.etherscan.io/address/#{address}
    transaction:     https://rinkeby.etherscan.io/tx/#{txid}
  status:            active

- key:               eth-mainet
  name:              Ethereum Mainet
  client:            ethereum               # API client name.
  server:            http://geth:8545       # Public Ethereum node endpoint. IMPORTANT: full syncmode.
  height:            5000000                # Initial block number from which sync will be started.
  min_confirmations: 6                      # Minimal confirmations needed for withdraw and deposit confirmation.
  explorer:
    address:         https://etherscan.io/address/#{address}
    transaction:     https://etherscan.io/tx/#{txid}
  status:            disabled

- key:               btc-testnet
  name:              Bitcoin Testnet
  client:            bitcoin                   # API client name.
  server:            http://bitcoin:18333       # Public Ethereum node endpoint. IMPORTANT: full syncmode.
  height:            1516996                # Initial block number from which sync will be started.
  min_confirmations: 6                      # Minimal confirmations needed for withdraw and deposit confirmation.
  explorer:
    address:         https://live.blockcypher.com/btc-testnet/address/#{address}
    transaction:     https://live.blockcypher.com/btc-testnet/tx/#{txid}
  status:            enabled

From there you will also have to edit the currencies.yml.erb, markets.yml.erb, and wallets.yml.erb to add bitcoin. Use the other existing entries as reference, and use the proper bitcoin client URI's and blockchain key's for it to work properly. When you spin everything back up of course you will have to wait for full sync. You can also verify that the currencies, blockchains, wallets, and markets have been properly added in the UI through the admin panel at www.app.local/admin. You will need to sign in as the seeded admin user to see this panel.

There are many more settings I didn't mention above but this should put you on the right path. I also believe that peatio 1.9 workbench might help you with configurations as far as the bitcoin node goes.

EDIT: by default, running rake service:all[start] will NOT start the cryptonodes service, which is where you add new full nodes for various blockchain/coin support. You will have to also run rake service:cryptonodes[start]. Additionally, you will also need to start the blockchain daemons rake service:daemons[start]. This starts the service that will connect to the bitcoin node and will start processing blocks looking for deposits and withdrawals starting at the block height specified in the blockchains.yml.erb file. This will also take time, but you can monitor the process with the docker logs command on the blockchain daemon service,

Hope this helps!

Matt

@champmine
Copy link
Author

Matt - thanks, very good info indeed, I am making progress a little bit. Have you managed to integrate any monero-like coins using cryptonote variants?

@msembinelli
Copy link

Unfortunately no, as my current project is focussed on ERC20 token variants. I'm sure the rubykube community would appreciate a pull request if you figure it out though!

@btczo
Copy link

btczo commented Sep 11, 2019

@msembinelli is the best, others spit half bake info

@Guillerbr
Copy link

Is there a tutorial to do the complete setup of wallets in openware version?
I would like to learn about this and make a tutorial, since in the openware documentation this is not available, and this is the main point of the process. Help me create a tutorial to make this easier.

@asadhayat1068
Copy link

Trust me, its been a struggle getting this exchange stood up. It is especially hard if you're not experienced with docker. It really does take a decent time investment just to understand how everything works together. I understand the frustration, which is why I've been active on the microkube repo trying to help answer questions. A good place to find answers is actually the telegram channel for peatio, but even then it might take awhile for someone to respond. The community is more knowledgable on peatio 1.9 (and workbench), while very few have moved on to peatio 2.0.xx (and microkube).

It seems the community around this project likes to act very much like gatekeepers, which isn't fun for noobies like us. Double that with the fact that anyone from the rubykube organization has incentive not to help devs like us, as they are trying to funnel business to their paid enterprise consulting and development services. But this is free software after all, so we can't have any expectation of support.

That being said, I think i'm comfortable enough now where I understand most of the configuration and customization available in microkube.

Adding Bitcoind

Adding any new blockchain to peatio/microkube will require us to run a full node. There are many dockerized full nodes on dockerhub, most notably: https://hub.docker.com/r/kylemanna/bitcoind

The first thing you will have to do in microkube is add a new cryptonode service to cryptonodes.yaml.erb

version: '3.6'

services:
  geth:
    image: ethereum/client-go:stable
    restart: always
    command: |
      --syncmode=full
      --rinkeby
      --rpc
      --rpcaddr=0.0.0.0
      --rpcport=8545
      --port=30303
      --rpcapi="db,personal,eth,net,web3"
      --rpccorsdomain="*"
      --rpcvhosts="*"
    volumes:
      - ../data/geth:/root/.ethereum/
    expose:
      - "8545"
      - "30303"
    labels:
      traefik.enable: true
      traefik.frontend.rule: 'Host: eth.<%= @config['app']['domain'] %>'
      traefik.port: 8545
  bitcoind:
    image: kylemanna/bitcoind:latest
    restart: always
    command: |
      -printtoconsole
      -testnet=1
      -rest
      -rpcallowip=0.0.0.0/0
      -rpcpassword=changeme
      -rpcport=18333
      -rpcuser=testuser
      -server
    volumes:
      - ../data/bitcoin:/root/.bitcoin/
    expose:
      - "18333"
    labels:
      traefik.enable: true
      traefik.frontend.rule: 'Host: btc.<%= @config['app']['domain'] %>'
      traefik.port: 18333

By the way, the above is untested, just as an example. It might take some fiddling to get this right. The best way is to try getting the container running and check its logs by using the docker logs command.
Note: I am still unsure at this point whether you use bitcoind or bitcoin as the service name used when referenced by peatios backend implementation. You might have to play with this.

Once you have a working bitcoind node, the next thing to do is to tell peatio about it. First shut down everything as the peatio database only gets seeded with the new configuration when you use the rake commands to render the config files. This configuration for adding new blockchains is in the seed file named blockchains.yml.erb.

- key:               eth-rinkeby
  name:              Ethereum Rinkeby
  client:            ethereum               # API client name.
  server:            http://geth:8545       # Public Ethereum node endpoint. IMPORTANT: full syncmode.
  height:            2500000                # Initial block number from which sync will be started.
  min_confirmations: 6                      # Minimal confirmations needed for withdraw and deposit confirmation.
  explorer:
    address:         https://rinkeby.etherscan.io/address/#{address}
    transaction:     https://rinkeby.etherscan.io/tx/#{txid}
  status:            active

- key:               eth-mainet
  name:              Ethereum Mainet
  client:            ethereum               # API client name.
  server:            http://geth:8545       # Public Ethereum node endpoint. IMPORTANT: full syncmode.
  height:            5000000                # Initial block number from which sync will be started.
  min_confirmations: 6                      # Minimal confirmations needed for withdraw and deposit confirmation.
  explorer:
    address:         https://etherscan.io/address/#{address}
    transaction:     https://etherscan.io/tx/#{txid}
  status:            disabled

- key:               btc-testnet
  name:              Bitcoin Testnet
  client:            bitcoin                   # API client name.
  server:            http://bitcoin:18333       # Public Ethereum node endpoint. IMPORTANT: full syncmode.
  height:            1516996                # Initial block number from which sync will be started.
  min_confirmations: 6                      # Minimal confirmations needed for withdraw and deposit confirmation.
  explorer:
    address:         https://live.blockcypher.com/btc-testnet/address/#{address}
    transaction:     https://live.blockcypher.com/btc-testnet/tx/#{txid}
  status:            enabled

From there you will also have to edit the currencies.yml.erb, markets.yml.erb, and wallets.yml.erb to add bitcoin. Use the other existing entries as reference, and use the proper bitcoin client URI's and blockchain key's for it to work properly. When you spin everything back up of course you will have to wait for full sync. You can also verify that the currencies, blockchains, wallets, and markets have been properly added in the UI through the admin panel at www.app.local/admin. You will need to sign in as the seeded admin user to see this panel.

There are many more settings I didn't mention above but this should put you on the right path. I also believe that peatio 1.9 workbench might help you with configurations as far as the bitcoin node goes.

EDIT: by default, running rake service:all[start] will NOT start the cryptonodes service, which is where you add new full nodes for various blockchain/coin support. You will have to also run rake service:cryptonodes[start]. Additionally, you will also need to start the blockchain daemons rake service:daemons[start]. This starts the service that will connect to the bitcoin node and will start processing blocks looking for deposits and withdrawals starting at the block height specified in the blockchains.yml.erb file. This will also take time, but you can monitor the process with the docker logs command on the blockchain daemon service,

Hope this helps!

Matt

I ran the exchange successfully. Firstly i had problem with generating deposit address for users but managed to solve it.
Now the problem is when it send some funds to the generated address, it does not credit the account. I am guessing that my walletnotify flag is not working...

I am running my bitcoind in host operating system, my walletnotify flag is something like,

walletnotify=docker exec opendax_rabbitmq_1 rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"%s", "currency":"btc"}'
When i run docker exec opendax_rabbitmq_1 rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"%s", "currency":"btc"}' manually, i get
Message published but NOT routed.

Can anyone help me with this?

@interbiznw
Copy link

I am having this same issue

Now the problem is when it send some funds to the generated address, it does not credit the account. I am guessing that my walletnotify flag is not working...

@interbiznw
Copy link

@asadhayat1068 did you figure it out?

@asadhayat1068
Copy link

@interbiznw yes i am getting balance in my wallet now, but don't know how.
And when i send more coins, its not coming to my exchange wallet.

@champmine
Copy link
Author

@msembinelli Matt, can you outline the process of adding ERC20 tokens to peatio? I have eth working ok

@msembinelli
Copy link

@champmine I am no longer working with peatio so I'm not sure. If you got eth working I'm sure you're 90% of the way there.

@champmine
Copy link
Author

champmine commented Mar 2, 2020

@msembinelli Matt, what are you working with now?

@andreireiand
Copy link

Did you guys manage to get orderflow into the system?

@andreireiand
Copy link

@champmine I am no longer working with peatio so I'm not sure. If you got eth working I'm sure you're 90% of the way there.

How was your experience/feedback w/ peatio? I find peatio a nice "learning" env. nonetheless not too fit for prod - what do you think, and more importantly what's more "prod ready" than this?

@CowboyKen
Copy link

Anyone have any luck with NEO, ADA, and IOTA?

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

No branches or pull requests

9 participants