Skip to content

Commit

Permalink
Feat/142 provide spendable reveal and reclaim paths (#32)
Browse files Browse the repository at this point in the history
* Move the reveal/reclaim pubkeys server side.

* Chore: docs

* Chore: docs

* bug - deployment issue with the btc_node env var..

* Aligned unwrap with wrap by altering the flow to be op_drop only.
  • Loading branch information
radicleart committed May 30, 2023
1 parent 47ca1ee commit 1700199
Show file tree
Hide file tree
Showing 22 changed files with 552 additions and 148 deletions.
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ the application.
To run the docker containers locally;

```bash
./build.sh
build -t mijoco/bridge_api sbtc-bridge-api
```

Note the build.sh tags and pushes the containers to mijoco docker hub. This will change for mainnet
Expand All @@ -32,8 +32,20 @@ deployment.
Alternatively, no docker hub, use docker compose directly..

```bash
docker-compose build
docker-compose up -d
docker rm -f bridge_api_staging
source /home/bob/.profile;
docker run -d -t -i --name bridge_api_staging -p 3010:3010 \
-e TARGET_ENV='linode-staging' \
-e btcSchnorrReveal=${BTC_SCHNORR_KEY_REVEAL} \
-e btcSchnorrReclaim=${BTC_SCHNORR_KEY_RECLAIM} \
-e btcRpcUser=${BTC_RPC_USER} \
-e btcRpcPwd=${BTC_RPC_PWD} \
-e btcNode=${BTC_NODE} \
-e mongoDbUrl=${MONGO_SBTC_URL} \
-e mongoDbName=${MONGO_SBTC_DBNAME} \
-e mongoUser=${MONGO_SBTC_USER} \
-e mongoPwd=${MONGO_SBTC_PWD} \
mijoco/bridge_api
```

## Swagger API Docs
Expand All @@ -45,16 +57,10 @@ See https://testnet.stx.eco/bridge-api/docs/#/
Deployment builds, tags and pushes the images and then uses ssh to log on to remote server
and then pulls the images from docker hub;

```bash
docker-compose -f docker-compose.yml pull
docker-compose -f docker-compose.yml up -d
```

This is automated using the deploy script;

```bash
./deploy.sh // for testnet
./deploy.sh prod // for mainnet
./deploy-linode.sh
```

Note: requires docker hub access and ssh key registered on server. This will change when deployment
Expand All @@ -68,6 +74,7 @@ The sBTC Wallet is a taproot wallet with addresses (most recent first);
- tb1pf74xr0x574farj55t4hhfvv0vpc9mpgerasawmf5zk9suauckugqdppqe8

## Production Deployment

Note: `docker-compose.yml` is used for production deployment.

- Local build and push of docker images
Expand Down
5 changes: 4 additions & 1 deletion deploy-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export DOCKER_CMD='docker'

$DOCKER_CMD build -t mijoco/bridge_api sbtc-bridge-api
$DOCKER_CMD tag mijoco/bridge_api mijoco/bridge_api
#$DOCKER_CMD push mijoco/bridge_api:latest
$DOCKER_CMD push mijoco/bridge_api:latest

printf "\nConnecting to $SERVER.\n\n"

Expand All @@ -18,6 +18,9 @@ docker rm -f bridge_api
#source ~/.profile;
docker run -d -t -i --name bridge_api -p 3010:3010 \
-e TARGET_ENV='development' \
-e btcSchnorrReveal=${BTC_SCHNORR_KEY_REVEAL} \
-e btcSchnorrReclaim=${BTC_SCHNORR_KEY_RECLAIM} \
-e btcRpcUser=${BTC_RPC_USER} \
-e btcRpcUser=${BTC_RPC_USER} \
-e btcRpcPwd=${BTC_RPC_PWD} \
-e btcNode=${BTC_NODE} \
Expand Down
4 changes: 4 additions & 0 deletions deploy-linode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ ssh -i ~/.ssh/id_rsa -p $PORT bob@$SERVER "
source /home/bob/.profile;
docker run -d -t -i --name bridge_api_staging -p 3010:3010 \
-e TARGET_ENV='linode-staging' \
-e btcSchnorrReveal=${BTC_SCHNORR_KEY_REVEAL} \
-e btcSchnorrReclaim=${BTC_SCHNORR_KEY_RECLAIM} \
-e btcRpcUser=${BTC_RPC_USER} \
-e btcRpcPwd=${BTC_RPC_PWD} \
-e btcNode=${BTC_NODE} \
Expand All @@ -46,6 +48,8 @@ docker rm -f bridge_api_production
source /home/bob/.profile;
docker run -d -t -i --name bridge_api_production -p 3020:3010 \
-e TARGET_ENV='production' \
-e btcSchnorrReveal=${BTC_SCHNORR_KEY_REVEAL} \
-e btcSchnorrReclaim=${BTC_SCHNORR_KEY_RECLAIM} \
-e btcRpcUser=${BTC_RPC_USER} \
-e btcRpcPwd=${BTC_RPC_PWD} \
-e btcNode=${BTC_NODE} \
Expand Down
1 change: 1 addition & 0 deletions sbtc-bridge-api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules

# local env files
.env
.env.*

# Log files
npm-debug.log*
Expand Down
26 changes: 26 additions & 0 deletions sbtc-bridge-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# sbtc-bridge-api

![ci](https://github.com/Trust-Machines/sbtc-bridge-api)

## Introduction

Node Server for sBTC Bridge.

[sbtc.world](https://sbtc.world).

## Build

```bash
npm install
npm run build
```

## Test

```bash
npm run test
```

## Deploy

To be integrated with Google Cloud. Currently builds to Linode via ssh and rsync.
95 changes: 49 additions & 46 deletions sbtc-bridge-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions sbtc-bridge-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"concurrently": "^7.6.0",
"dotenv": "^16.0.3",
"eslint": "^8.34.0",
"nodemon": "^2.0.20",
"ts-node": "^10.9.1",
Expand All @@ -53,7 +52,8 @@
"vitest-fetch-mock": "^0.2.2"
},
"dependencies": {
"@noble/secp256k1": "^1.7.1",
"@noble/curves": "^1.0.0",
"@noble/secp256k1": "^2.0.0",
"@scure/base": "^1.1.1",
"@scure/bip32": "^1.1.0",
"@scure/btc-signer": "^0.5.0",
Expand All @@ -71,7 +71,7 @@
"morgan": "^1.10.0",
"node-cron": "^3.0.2",
"node-fetch": "^2.6.9",
"sbtc-bridge-lib": "^1.0.11",
"sbtc-bridge-lib": "^1.0.12",
"swagger-ui-express": "^4.6.2",
"tsoa": "^5.1.1",
"uninstall": "^0.0.0"
Expand Down
42 changes: 42 additions & 0 deletions sbtc-bridge-api/public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@
"requestBodies": {},
"responses": {},
"schemas": {
"KeySet": {
"properties": {
"deposits": {
"properties": {
"reclaimPubKey": {
"type": "string"
},
"revealPubKey": {
"type": "string"
}
},
"required": [
"reclaimPubKey",
"revealPubKey"
],
"type": "object"
}
},
"required": [
"deposits"
],
"type": "object"
},
"FeeEstimateResponse": {
"properties": {
"feeInfo": {
Expand Down Expand Up @@ -185,6 +208,25 @@
},
"openapi": "3.0.0",
"paths": {
"/bridge-api/{network}/v1/btc/tx/keys": {
"get": {
"operationId": "GetKeys",
"responses": {
"200": {
"description": "Ok",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/KeySet"
}
}
}
}
},
"security": [],
"parameters": []
}
},
"/bridge-api/{network}/v1/btc/tx/{txid}": {
"get": {
"operationId": "FetchRawTransaction",
Expand Down

0 comments on commit 1700199

Please sign in to comment.