gogo-tattoo / teller

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

teller

Setup project

Prerequisites

  • Have go1.8+ installed
  • Have GOPATH env set
  • Have btcd started
  • Have skycoin node started

Summary of setup for development without btcd or skycoind

# generate btc_addresses.json file
cd cmd/tool
go run tool.go -json newbtcaddress <seed> <num> > /tmp/btc_addresses.json

# Run proxy, a pubkey will be printed to stdout, copy it
cd ../proxy
go run proxy.go

# In a new terminal, run teller in dummy mode, provide pubkey from proxy stdout, point addresses to addr file
cd ../teller
go run teller.go -proxy-pubkey=<proxy pubkey> -dummy -btc-addrs=/tmp/btc_addresses.json

Proxy API is available on localhost:7071. API has two methods, /bind and /status, with one query arg skyaddr, e.g.:

wget http://localhost:7071/bind?skyaddr=<skycoin addr>

Start teller-proxy

cd cmd/proxy/
go run proxy.go

once the proxy start, will show a pubkey in the log.

18:28:49 proxy.go:33: Pubkey: 03583bf0a6cbe7048023be5475aca693e192b4b5570bcc883c50f7d96f0a996eda

Start teller

install the skycoin-cli

cd cmd/teller
./install-skycoin-cli.sh

add pregenearted bitcoin deposit address list in btc_addresses.json.

{
    "btc_addresses": [
        "1PZ63K3G4gZP6A6E2TTbBwxT5bFQGL2TLB",
        "14FG8vQnmK6B7YbLSr6uC5wfGY78JFNCYg",
        "17mMWfVWq3pSwz7BixNmfce5nxaD73gRjh",
        "1Bmp9Kv9vcbjNKfdxCrmL1Ve5n7gvkDoNp"
    ]
}

use tool to pregenerate bitcoin address list:

cd cmd/tool
go run tool.go -json newbtcaddress $seed $num

example:

go run tool.go -json newbtcaddress 12323 3

2Q5sR1EgTWesxX9853AnNpbBS1grEY1JXn3
2Q8y3vVAqY8Q3paxS7Fz4biy1RUTY5XQuzb
216WfF5EcvpVk6ypSRP3Lg9BxqpUrgBJBco

generate json file example:

go run tool.go -json newbtcaddress 12323 3 > new_btc_addresses.json

teller's config is managed in config.json, need to set the wallet_path in skynode field to an absolute path of skycoin wallet file, and set up the btcd config in btc_rpc field, including server address, username, password and absolute path to the cert file.

config.json:

{
    "proxy_address": "127.0.0.1:7070",
    "reconnect_time": 5,
    "dial_timeout": 5,
    "ping_timeout": 5,
    "pong_timeout": 10,
    "exchange_rate": 500,
    "skynode": {
        "rpc_address": "127.0.0.1:6430",
        "wallet_path": "absolute path to the wallet file"
    },
    "btc_scan": {
        "check_period": 20,
        "deposit_buffer_size": 1024
    },
    "btc_rpc": {
        "server": "127.0.0.1:8334",
        "user": "",
        "pass": "",
        "cert": "absolute path to rpc cert file"
    },
    "sky_sender": {
        "request_buffer_size": 1024
    }
}

run teller service

go run teller.go -proxy-pubkey=$the_pubkey_of_proxy

Service apis

The http apis service is provided by the proxy and serve on port 7071.

Bind

Method: GET
URI: /bind
Args: skyaddr

example:

curl http://localhost:7071/bind?skyaddr=t5apgjk4LvV9PQareTPzWkE88o1G5A55FW

response:

{
    "btc_address": "1Bmp9Kv9vcbjNKfdxCrmL1Ve5n7gvkDoNp"
}

Status

Method: GET
URI: /status
Args: skyaddr

example:

curl http://localhost:7071/status?skyaddr=t5apgjk4LvV9PQareTPzWkE88o1G5A55FW

response:

{
    "statuses": [
        {
            "seq": 1,
            "update_at": 1501137828,
            "status": "done"
        },
        {
            "seq": 2,
            "update_at": 1501128062,
            "status": "waiting_deposit"
        },
        {
            "seq": 3,
            "update_at": 1501128063,
            "status": "waiting_deposit"
        },
    ]
}

About


Languages

Language:Go 91.1%Language:JavaScript 7.7%Language:HTML 1.1%Language:Shell 0.1%Language:CSS 0.0%