Withdraw additional functionality (validation/submission/tracking) (#409)

* reworked request struct and exchange response started work on validation system

* removed import cycle until work around

* Added intial withdraw support via CLI added

* Added Crypto command to gctcli

* moved var declartion to single line

* Test updates for binance and anx

* All exchange tests have been updated test coverage added to validate

* First pass at adding withdrawl select from database

* started adding basic lru cache system

* Added basic LRU cache including Add Get Remove Contains ContainsOrAdd Clear

* wording changes on comments

* removed exported var's in strut as they are not required

* Added README

* README updates

* corrected ID on commands

* rm line :D

* merged in origin/cache

* linter fixes (gofmt)

* Added basic cache lookup to events

* swapped to mutex over rwmutex updated comments

* unexported getNewest & getOldest

* unexported getNewest & getOldest

* Updated comments and cited references in source

* updated comments

* WIP

* Migrated exchange WithdrawFiat wrapper to new struct response

* Migrated exchange WithdrawFiat wrapper to new struct response

* started work on bank management

* Added exchange level banking details back with migration to banking package

* Removed broken tests for now

* Added validation to bank accounts

* removed duplicate bank details from withdraw struct

* Test coverage increased

* gofmt

* merged upstream/master with clean up

* First pass at adding command line linking to gctcli

* added validation for crypto address, added gctcli support to retreive previous withdrawal requests

* general cleanup

* general cleanup

* reordered imports

* Increased test coverage moved to database sublogger

* Pass incorrect currency no longer return error from c.CheckBankAccountConfig

* remove TestMain() for now as other tests in this package will need to be reworked

* Happy little race car

* Reverted to upstream tests

* Added test covarege for validation method, corrected response on cli protobuf

* query clean up and removal of duplicated code

* cleaned up queries into singlem ethod increased test coverage

* Migrated international fund withdraw to new exchange response and added cache size override

* Migrated international fund withdraw to new exchange response and added cache size override

* Extended gctcli commands

* lowered default cache to 25

* small code clean up

* added get by date method

* add returned error

* cli commands cleaing return error on nil results to fix out of bounds

* merged write & read helpers into one for test coverage and increased engine/withdraw test coverage

* gofmt

* Added test coverage for valid ID

* removed unused param

* converted to use timestamp package from protobuf

* gofmt

* use built in RFC3339 timestamp

* remove setting of CreatedAt & UpdatedAt and allow ORm to take care of it

* also use ptype on byid

* code flow improvements

* remove inverse conditional check and linters run

* removed test data

* removed comment

* removed comment

* also write failures to database for auditing

* converted to use default time for start & end

* Default to time.Now() minus 30 days

* Default to time.Now() minus 30 days

* small code clean up

* fixed missing semicolon on migrations, code clean up

* updated sqlite migrations

* Added additonal check for exchange level bank account if global is not found

* case sensativity fix for currency names

* use correct compare

* test coverage fixed

* removed space

* return pointer to banking.Account

* return pointer to banking.Account

* added else check back to validate()

* Added empty string as default to migration over NULL due to retrivial of data
This commit is contained in:
Andrew
2020-02-26 15:45:13 +11:00
committed by GitHub
parent def3cdf226
commit b26ec86d43
122 changed files with 18066 additions and 2029 deletions

View File

@@ -502,16 +502,7 @@
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/gctrpcGetAccountInfoResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of gctrpcGetAccountInfoResponse"
"$ref": "#/x-stream-definitions/gctrpcGetAccountInfoResponse"
}
}
},
@@ -709,16 +700,7 @@
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/gctrpcOrderbookResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of gctrpcOrderbookResponse"
"$ref": "#/x-stream-definitions/gctrpcOrderbookResponse"
}
}
},
@@ -833,16 +815,7 @@
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/gctrpcTickerResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of gctrpcTickerResponse"
"$ref": "#/x-stream-definitions/gctrpcTickerResponse"
}
}
},
@@ -1062,16 +1035,7 @@
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/gctrpcOrderbookResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of gctrpcOrderbookResponse"
"$ref": "#/x-stream-definitions/gctrpcOrderbookResponse"
}
}
},
@@ -1251,16 +1215,7 @@
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/gctrpcTickerResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of gctrpcTickerResponse"
"$ref": "#/x-stream-definitions/gctrpcTickerResponse"
}
}
},
@@ -1457,14 +1412,14 @@
]
}
},
"/v1/withdrawcryptofunds": {
"/v1/withdrawaleventbydate": {
"post": {
"operationId": "WithdrawCryptocurrencyFunds",
"operationId": "WithdrawalEventsByDate",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcWithdrawResponse"
"$ref": "#/definitions/gctrpcWithdrawalEventsByExchangeResponse"
}
}
},
@@ -1474,7 +1429,33 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/gctrpcWithdrawCurrencyRequest"
"$ref": "#/definitions/gctrpcWithdrawalEventsByDateRequest"
}
}
],
"tags": [
"GoCryptoTrader"
]
}
},
"/v1/withdrawaleventbyid": {
"post": {
"operationId": "WithdrawalEventsByExchange",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcWithdrawalEventsByExchangeResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/gctrpcWithdrawalEventsByExchangeRequest"
}
}
],
@@ -1500,7 +1481,33 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/gctrpcWithdrawCurrencyRequest"
"$ref": "#/definitions/gctrpcWithdrawFiatRequest"
}
}
],
"tags": [
"GoCryptoTrader"
]
}
},
"/v1/withdrawithdrawcryptofundswfiatfunds": {
"post": {
"operationId": "WithdrawCryptocurrencyFunds",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcWithdrawResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/gctrpcWithdrawCryptoRequest"
}
}
],
@@ -1602,6 +1609,13 @@
"balance": {
"type": "number",
"format": "double"
},
"supported_exchanges": {
"type": "string"
},
"cold_storage": {
"type": "boolean",
"format": "boolean"
}
}
},
@@ -1758,6 +1772,21 @@
}
}
},
"gctrpcCryptoWithdrawalEvent": {
"type": "object",
"properties": {
"address": {
"type": "string"
},
"address_tag": {
"type": "string"
},
"fee": {
"type": "number",
"format": "double"
}
}
},
"gctrpcCurrencyPair": {
"type": "object",
"properties": {
@@ -1786,6 +1815,29 @@
}
}
},
"gctrpcFiatWithdrawalEvent": {
"type": "object",
"properties": {
"bank_name": {
"type": "string"
},
"account_name": {
"type": "string"
},
"account_number": {
"type": "string"
},
"bsb": {
"type": "string"
},
"swift": {
"type": "string"
},
"iban": {
"type": "string"
}
}
},
"gctrpcForexProvider": {
"type": "object",
"properties": {
@@ -2809,61 +2861,51 @@
}
}
},
"gctrpcWithdrawCurrencyRequest": {
"gctrpcWithdrawCryptoRequest": {
"type": "object",
"properties": {
"exchange": {
"type": "string"
},
"description": {
"type": "string"
},
"one_time_password": {
"type": "string"
},
"account_id": {
"type": "string"
},
"pin": {
"type": "string",
"format": "int64"
},
"trade_password": {
"type": "string"
},
"currency": {
"type": "string"
},
"address": {
"type": "string"
},
"address_tag": {
"type": "string"
},
"currency": {
"type": "string"
},
"amount": {
"type": "number",
"format": "double"
},
"fee_amount": {
"fee": {
"type": "number",
"format": "double"
},
"bank_name": {
"description": {
"type": "string"
}
}
},
"gctrpcWithdrawFiatRequest": {
"type": "object",
"properties": {
"exchange": {
"type": "string"
},
"bank_address": {
"currency": {
"type": "string"
},
"bank_city": {
"amount": {
"type": "number",
"format": "double"
},
"description": {
"type": "string"
},
"bank_country": {
"type": "string"
},
"swife_code": {
"type": "string"
},
"wire_currency": {
"bank_account_id": {
"type": "string"
}
}
@@ -2871,7 +2913,131 @@
"gctrpcWithdrawResponse": {
"type": "object",
"properties": {
"result": {
"id": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"gctrpcWithdrawalEventByIDRequest": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
"gctrpcWithdrawalEventByIDResponse": {
"type": "object",
"properties": {
"event": {
"$ref": "#/definitions/gctrpcWithdrawalEventResponse"
}
}
},
"gctrpcWithdrawalEventResponse": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"exchange": {
"$ref": "#/definitions/gctrpcWithdrawlExchangeEvent"
},
"request": {
"$ref": "#/definitions/gctrpcWithdrawalRequestEvent"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
}
},
"gctrpcWithdrawalEventsByDateRequest": {
"type": "object",
"properties": {
"exchange": {
"type": "string"
},
"start": {
"type": "string"
},
"end": {
"type": "string"
},
"limit": {
"type": "integer",
"format": "int32"
}
}
},
"gctrpcWithdrawalEventsByExchangeRequest": {
"type": "object",
"properties": {
"exchange": {
"type": "string"
},
"id": {
"type": "string"
},
"limit": {
"type": "integer",
"format": "int32"
}
}
},
"gctrpcWithdrawalEventsByExchangeResponse": {
"type": "object",
"properties": {
"event": {
"type": "array",
"items": {
"$ref": "#/definitions/gctrpcWithdrawalEventResponse"
}
}
}
},
"gctrpcWithdrawalRequestEvent": {
"type": "object",
"properties": {
"currency": {
"type": "string"
},
"description": {
"type": "string"
},
"amount": {
"type": "number",
"format": "double"
},
"type": {
"type": "integer",
"format": "int32"
},
"fiat": {
"$ref": "#/definitions/gctrpcFiatWithdrawalEvent"
},
"crypto": {
"$ref": "#/definitions/gctrpcCryptoWithdrawalEvent"
}
}
},
"gctrpcWithdrawlExchangeEvent": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"type": "string"
}
}
@@ -2913,5 +3079,43 @@
}
}
}
},
"x-stream-definitions": {
"gctrpcGetAccountInfoResponse": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/gctrpcGetAccountInfoResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of gctrpcGetAccountInfoResponse"
},
"gctrpcOrderbookResponse": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/gctrpcOrderbookResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of gctrpcOrderbookResponse"
},
"gctrpcTickerResponse": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/gctrpcTickerResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of gctrpcTickerResponse"
}
}
}