Skip to content

Commit

Permalink
Merge pull request #258 from Bitcoin-com/stage
Browse files Browse the repository at this point in the history
validate slp txs
  • Loading branch information
cgcardona authored Feb 6, 2019
2 parents 7d591e3 + 02c6784 commit e6d3c19
Show file tree
Hide file tree
Showing 22 changed files with 1,418 additions and 1,476 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ start-my-infra
dist/routes/**
test-v1
nohup.out
slp-tx-db/
18 changes: 1 addition & 17 deletions dist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,6 @@ app.use("/" + v2prefix + "/" + "dataRetrieval", dataRetrievalV2.router);
app.use("/" + v2prefix + "/" + "payloadCreation", payloadCreationV2.router);
app.use("/" + v2prefix + "/" + "wormhole/transaction", wormholeV2.router);
app.use("/" + v2prefix + "/" + "slp", slpV2.router);
// Initialize wormhole/transaction/socket endpoint
var whSocketUrl = process.env.WORMHOLE_SOCKET_URL;
var whSocketPort = process.env.WORMHOLE_SOCKET_PORT;
if (whSocketUrl && whSocketPort) {
var bchsocketd = require("bchsocketd");
bchsocketd.init({
bit: {
host: whSocketUrl,
port: whSocketPort
},
socket: {
app: app,
endpoint: v2prefix + "/wormhole/transaction/socket"
}
});
}
// catch 404 and forward to error handler
app.use(function (req, res, next) {
var err = {
Expand Down Expand Up @@ -184,7 +168,7 @@ server.on("error", onError);
server.on("listening", onListening);
// Set the time before a timeout error is generated. This impacts testing and
// the handling of timeout errors. Is 10 seconds too agressive?
server.setTimeout(10000);
server.setTimeout(30 * 1000);
/**
* Normalize a port into a number, string, or false.
*/
Expand Down
54 changes: 24 additions & 30 deletions dist/public/bitcoin-com-mainnet-rest-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"Txid": {
"type": "string"
},
"SLPTxid": {
"type": "string"
},
"RawTxid": {
"type": "string"
},
Expand Down Expand Up @@ -122,6 +125,21 @@
}
}
},
"SLPTxids": {
"type": "object",
"properties": {
"txids": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SLPTxid"
},
"example": [
"88b121101d71b73599dfc7d79eead599031912b2c48298bf5c1f37f4dd743ffa",
"fb0eeaa501a6e1acb721669c62a3f70741f48ae0fd7f4b8e1d72088785c51952"
]
}
}
},
"RawTxids": {
"type": "object",
"properties": {
Expand All @@ -130,7 +148,10 @@
"items": {
"$ref": "#/components/schemas/RawTxid"
},
"example": []
"example": [
"a5f972572ee1753e2fd2457dd61ce5f40fa2f8a30173d417e49feef7542c96a1",
"5165dc531aad05d1149bb0f0d9b7bda99c73e2f05e314bcfb5b4bb9ca5e1af5e"
]
},
"verbose": {
"type": "boolean",
Expand Down Expand Up @@ -1338,7 +1359,7 @@
"openapi": "3.0.0",
"info": {
"description": "rest.bitcoin.com is the REST layer for Bitcoin.com's Cloud. More info: [developer.bitcoin.com/rest](https://developer.bitcoin.com/rest). Chatroom [geni.us/CashDev](http://geni.us/CashDev)",
"version": "2.1.0",
"version": "2.1.2",
"title": "REST",
"license": {
"name": "MIT",
Expand Down Expand Up @@ -4338,33 +4359,6 @@
}
}
},
"/slp/address/convert/{address}": {
"get": {
"tags": [
"slp"
],
"summary": "convert address to slpAddr, cashAddr and legacy",
"description": "convert address to slpAddr, cashAddr and legacy",
"operationId": "slpAddressConvert",
"parameters": [
{
"name": "address",
"in": "path",
"description": "The slp address",
"required": true,
"example": "simpleledger:qz9tzs6d5097ejpg279rg0rnlhz546q4fsnck9wh5m",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful response"
}
}
}
},
"/slp/validate": {
"post": {
"tags": [
Expand All @@ -4379,7 +4373,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Txids"
"$ref": "#/components/schemas/SLPTxids"
}
}
}
Expand Down
49 changes: 20 additions & 29 deletions dist/public/bitcoin-com-testnet-rest-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"Txid": {
"type": "string"
},
"SLPTxid": {
"type": "string"
},
"RawTxid": {
"type": "string"
},
Expand Down Expand Up @@ -122,6 +125,21 @@
}
}
},
"SLPTxids": {
"type": "object",
"properties": {
"txids": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SLPTxid"
},
"example": [
"3ea2767c91d087d14dda8faef736cd39d6c6ebbd5f7d2c7e8de0df3360436bfb",
"cce4e8eb4b3160b93ceecb0956cde405d85b42cbcb3fa1b4e9a9bedaf3476f05"
]
}
}
},
"RawTxids": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1341,7 +1359,7 @@
"openapi": "3.0.0",
"info": {
"description": "trest.bitcoin.com is the REST layer for Bitcoin.com's Cloud. More info: [developer.bitcoin.com/rest](https://developer.bitcoin.com/rest). Chatroom [geni.us/CashDev](http://geni.us/CashDev)",
"version": "2.1.0",
"version": "2.1.2",
"title": "REST",
"license": {
"name": "MIT",
Expand Down Expand Up @@ -4341,33 +4359,6 @@
}
}
},
"/slp/address/convert/{address}": {
"get": {
"tags": [
"slp"
],
"summary": "convert address to slpAddr, cashAddr and legacy",
"description": "convert address to slpAddr, cashAddr and legacy",
"operationId": "slpAddressConvert",
"parameters": [
{
"name": "address",
"in": "path",
"description": "The slp address",
"required": true,
"example": "slptest:qz35h5mfa8w2pqma2jq06lp7dnv5fxkp2shlcycvd5",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful response"
}
}
}
},
"/slp/validate": {
"post": {
"tags": [
Expand All @@ -4382,7 +4373,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Txids"
"$ref": "#/components/schemas/SLPTxids"
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ gulp.task("build", () => {
item.value
}

if (item.key === "SLPTxids") {
parsedJson.components.schemas.SLPTxids.properties.txids.example =
item.value
}

Object.keys(parsedJson.components.schemas).forEach(key => {
if (
key === item.key &&
Expand Down Expand Up @@ -196,6 +201,16 @@ gulp.task("build", () => {
fileName: "./mainnet/components.json",
edit: (parsedJson, file) => {
mainnetComponents.forEach((item, index) => {
if (item.key === "RawTxids") {
parsedJson.components.schemas.RawTxids.properties.txids.example =
item.value
}

if (item.key === "SLPTxids") {
parsedJson.components.schemas.SLPTxids.properties.txids.example =
item.value
}

Object.keys(parsedJson.components.schemas).forEach(key => {
// console.log(key, parsedJson.components.schemas[key].properties)
if (
Expand Down
Loading

0 comments on commit e6d3c19

Please sign in to comment.