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

client: register dex account #140

Merged
merged 15 commits into from
Jan 24, 2020
Merged

client: register dex account #140

merged 15 commits into from
Jan 24, 2020

Conversation

buck54321
Copy link
Member

@buck54321 buck54321 commented Jan 19, 2020

Adds ability to register new DEX account through the web interface.

  • core.Core gets a CreateWallet method so that the fee-paying Decred exchange wallet can be created.
  • core.Core also get a Register method, that walks through the registration process with the server. This includes negotiation of config and notifyfee routes.
  • Adds notifications to core and web UI.

Testing with live simnet server

This PR can be tested against a live instance of dcrdex on simnet with the following (possibly incomplete) steps.

Configure server

Server requires PostgreSQL installed and running. Create a user named dcrdex

psql -U postgres -c "CREATE USER dcrdex;"

and then create a DEX database

psql -U postgres -c "CREATE DATABASE dcrdex OWNER dcrdex;"

The server must be configured to point to the simnet testing harness nodes for Decred and Bitcoin. You'll need to create two configuration files.

btc/simnet.conf

rpcuser=user
rpcpassword=pass
rpcport=20556

dcr/simnet.conf

rpcuser=user
rpcpass=pass
rpccert=/home/user/dextest/dcr/alpha/rpc.cert
rpclisten=127.0.0.1:19570

Replace user in the rpccert entry with your user name. dextest will be created in your home directory, if it doesn't already exist.

Update or create ~/.dcrdex/markets.json so it is minimally

{
    "markets": [
        {
            "base": "DCR_simnet",
            "quote": "BTC_simnet",
            "epochDuration": 60000,
            "marketBuyBuffer": 1.2
        }
    ],
    "assets": {
        "DCR_simnet": {
            "bip44symbol": "dcr",
            "network": "simnet",
            "lotSize": 100000000,
            "rateStep": 100000000,
            "feeRate": 10,
            "swapConf": 1,
            "fundConf": 1,
            "configPath": "/path/to/dcr/simnet.conf"
        },
        "BTC_simnet": {
            "bip44symbol": "btc",
            "network": "simnet",
            "lotSize": 100000,
            "rateStep": 100000,
            "feeRate": 100,
            "swapConf": 1,
            "fundConf": 1,
            "configPath": "/path/to/btc/simnet.conf"
        }
    }
}

Update the configPath entries to point to the config files you just made.

Finally, update or create the actual server configuration file at ~/.dcrdex/dcrdex.conf with the simnet harness alpha wallet's extended public key.

regfeexpub=spubVWHTkHRefqHptAnBdNcDJMnT9w7wBPGtyv5Ji6hHsHGGXyLhgq21SakpXmjEAAQFjcwm14bgXGa23ETaskUTxgm4cqi2qbKLkaY1YdCHmtz
regfeeconfirms=1

Configure Decred wallet

Create the wallet configuration file.

dcr/simnet-w.conf NOTE: Reference ~/dextest/dcr/alpha/w-alpha.conf generated by the dcr harness.

username=user
password=pass
rpccert=/home/user/dextest/dcr/alpha/rpc.cert
rpclisten=127.0.0.1:19567

Update the cafile path with your system user name.

You'll need to tell the wallet where to find the server's TLS certificate. You do that by creating a certs.json file in the .dexclient directory.

~/.dexc/certs.json (was ~/.dexclient/certs.json)

{
	"https://127.0.0.1:7232": "/home/user/.dcrdex/rpc.cert"
}

updating the .dcrdex path as necessary.

Build web assets

You must have npm installed.

Go to dcrdex/client/webserver/site/ and run npm install, and then npm run build.

Run the harnesses

In a new terminal, run harness.sh in dcrdex/dex/testing/dcr.

In yet another terminal, run harness.sh in dcrdex/dex/testing/btc.

The harnesses can be killed later by running ./quit in the tmux terminals that are opened.

Run the server and client

In yet another terminal, run go build; ./dcrdex --simnet --debuglevel=trace from the dcrdex repo directory.

In yet another terminal, run go build; ./dexc --simnet --notui --web --log trace from the dcrdex/client/cmd/dexc directory.

Register

Go to http://127.0.0.1:5758 in a browser on the same system. Complete the registration form with the following fields

DEX Address: https://127.0.0.1:7232
Create DEX Password: anything you want
Decred Wallet Config Filepath.: /path/to/simnet-w.conf
Decred Wallet Account Name: default
Decred Wallet Password: 123

Submit the form. If everything goes correctly, you should be sent to the markets page, which will show the single DCR-BTC market, but no order book data to show obviously

You should also have a notification. Click on the bell to read it.

The registration process is actually waiting on a confirmation. Go to the Decred tmux simnet harness and run ./alpha generate 1. Back in your web browser, you should see another notification now confirming completion of the registration process.

* tested on Chrome and Firefox

@buck54321 buck54321 changed the title Register client: register dex account Jan 19, 2020
client/asset/interface.go Show resolved Hide resolved
client/asset/interface.go Outdated Show resolved Hide resolved
client/core/types.go Show resolved Hide resolved
client/db/bolt/db.go Show resolved Hide resolved
dex/encrypt/snacl.go Outdated Show resolved Hide resolved
server/cmd/dcrdex/config.go Outdated Show resolved Hide resolved
server/coinwaiter/coinwaiter.go Show resolved Hide resolved
server/dex/dex.go Outdated Show resolved Hide resolved
@chappjc
Copy link
Member

chappjc commented Jan 20, 2020

Nice, easy PR test instructions, thanks! I ran into the no cookie panic issue again though

cookie, err = r.Cookie(darkModeCK)
switch err {
// Dark mode is the default
case nil:
darkMode = true
case http.ErrNoCookie:
darkMode = cookie.Value == "1"
default:
log.Errorf("Cookie dcrdataDarkBG retrieval error: %v", err)
}

Looks like the nil and http.ErrNoCookie cases are swapped.

client/cmd/dexc/go.mod Outdated Show resolved Hide resolved
client/asset/dcr/dcr.go Outdated Show resolved Hide resolved
@chappjc
Copy link
Member

chappjc commented Jan 20, 2020

Despite being in draft I just had to test this, with the great instructions and all. :)

Anyway, to summarize our Matrix discussions from this morning, I was able to get it all working as described despite a couple failed attempts. One issue that was likely creating a problem was with the {dcr,btc}/harness.sh files were sending commands to the active session:window instead of explicitly specifying which one. This seems to be a problem with the two harness.sh scripts running simultaneously. Other than that, it was just dark mode cookie panic and extra replace statement I mentioned in my comments above.

dex/msgjson/types.go Outdated Show resolved Hide resolved
dex/encrypt/snacl.go Outdated Show resolved Hide resolved
@buck54321 buck54321 marked this pull request as ready for review January 23, 2020 01:37
client/asset/driver.go Outdated Show resolved Hide resolved
Copy link
Member

@dnldd dnldd left a comment

Choose a reason for hiding this comment

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

Looks good.

client/core/types.go Show resolved Hide resolved
client/core/types.go Outdated Show resolved Hide resolved
server/cmd/dcrdex/config.go Outdated Show resolved Hide resolved
server/coinwaiter/coinwaiter.go Outdated Show resolved Hide resolved
Comment on lines +28 to 30
// txWaitExpiration is the longest the Swapper will wait for a coin waiter.
// This could be thought of as the maximum allowable backend latency.
txWaitExpiration = time.Minute
Copy link
Member

Choose a reason for hiding this comment

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

Seems very similar to broacast timeout. Would the same value be appropriate here, or maybe a multiple of it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The similarities are superficial, really. Network latency vs. community conduct. Linking the value to the broadcast timeout doesn't reflect its purpose very well, IMO. Could be an operator-set variable though.

Copy link
Member

Choose a reason for hiding this comment

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

Let's make an issue then to track this. I think this PR is g2g.

@chappjc chappjc merged commit 8340160 into decred:master Jan 24, 2020
@buck54321 buck54321 mentioned this pull request Jan 29, 2020
@buck54321 buck54321 mentioned this pull request Feb 13, 2020
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.

3 participants