@vigcoin/webapi v0.1.1
Web Api for vigcoin
Setup
Webapi is tested on ubuntu 16.04. Other Linux platform can easily adapte to use vigcoin webapi.
Before running webapi, here are some bash steps you should follow:
sudo apt-get install gcc
curl https://sh.rustup.rs -sSf | sh -s -- -y
source "$HOME/.cargo/env"
curl -o- https://raw.githubusercontent.com/calidion/chinese-noder-the-easy-way/master/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
config npm (For Chinese)
If you are in China and find it very slow to install npm packages. The following instruction will be helpful.
Create a file
touch ~/.npmrc
with the following content.
registry=https://registry.npm.taobao.org/
You can add the following optional content when necessary:
disturl=https://npm.taobao.org/dist
chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
operadriver_cdnurl=http://cdn.npm.taobao.org/dist/operadriver
phantomjs_cdnurl=http://cdn.npm.taobao.org/dist/phantomjs
fse_binary_host_mirror=https://npm.taobao.org/mirrors/fsevents
sass_binary_site=http://cdn.npm.taobao.org/dist/node-sass
electron_mirror=http://cdn.npm.taobao.org/dist/electron/
Run Web API server
platform: ubuntu 18.04/16.04
Run with ts-node
git clone --depth 1 https://github.com/vigcoin/webapi.git
cd webapi && npm install
npm install -g ts-node
ts-node src/main.ts
default port is 8080, use
PORT=8081 ts-node src/main.ts
to change port number
Run with pm2
git clone --depth 1 https://github.com/vigcoin/webapi.git
cd webapi && npm install
npm install -g pm2 && pm2 install typescript
pm2 start src/main.ts
Web APIs
Wallet API
Create Wallet
- url
/wallet/create
- Parameters
None
- Response JSON
address: Address for the wallet spend: Private key for spending. view: Private key for viewing.
{
"code": 0,
"data": {
"address": "BFrj6s15vg47Za5ipA46m8CjV59nsEeeNSSozZzs9WEo759Prf3zXke4caP22RESH5Yj2GJubQ6WPCDBR78MX3myNaHsWME",
"spend": "32e4e5f72797c2fc0e2dda4e80e61bd0093934a305af08c9d3b942715844aa08",
"view": "95a27c683df6a73bfc238d78fc55f414c699735d60fad4e3a999806763cb340d"
},
"message": "成功!",
"name": "Success"
}
Open Wallet
- url
/wallet/open
- Parameters
Parameter Name | Type | Optional |
---|---|---|
file | File | N |
password | String | Y |
- Response JSON
address: Address for the wallet spend: Private key for spending. view: Private key for viewing.
{
"code": 0,
"data": {
"address": "BFrj6s15vg47Za5ipA46m8CjV59nsEeeNSSozZzs9WEo759Prf3zXke4caP22RESH5Yj2GJubQ6WPCDBR78MX3myNaHsWME",
"keys": {
"spend": "32e4e5f72797c2fc0e2dda4e80e61bd0093934a305af08c9d3b942715844aa08",
"view": "95a27c683df6a73bfc238d78fc55f414c699735d60fad4e3a999806763cb340d"
}
},
"message": "成功!",
"name": "Success"
}
Refine Wallet
Old vigcoin saves cache in wallet file. New vigcoin wallet will use no cache in wallet file.
cache files will be separated from wallet.
- url
/wallet/refine
- Parameters
Parameter Name | Type | Optional |
---|---|---|
file | File | N |
password | String | Y |
- Response File
will retrun an file which is in a vigcoin wallet format
or
return status 500 if wrong.
Generate Wallet from Keys
- url
/wallet/export
- Parameters
Parameter Name | Type | Optional |
---|---|---|
spend | String | N |
view | String | N |
spend/view are spend and view private keys.
- Response File
will retrun an file which is in a vigcoin wallet format
or
return status 500 if wrong.