diff --git a/docker-compose-test.yml b/docker-compose-test.yml index c629574c..63bcd5ac 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -70,6 +70,22 @@ services: depends_on: - postgres + token-server: + build: + context: . + dockerfile: ./token-server/Dockerfile + environment: + PROCESSOR_URL: http://mercurylayer-enclave-sgx-1:18080" + API_KEY: aaaaa + FEE: 10000 + UNIT: BTC + DELAY: 3600 + CONNECTION_STRING: postgres://postgres:pgpassword@postgres:5432/postgres + ports: + - "8001:8001" + depends_on: + - postgres + alice: image: lightninglabs/lndinit:v0.1.21-beta-lnd-v0.18.0-beta container_name: mercurylayer-alice-1 diff --git a/token-server/src/endpoints/token.rs b/token-server/src/endpoints/token.rs index 1cb8d62b..95f5a61f 100644 --- a/token-server/src/endpoints/token.rs +++ b/token-server/src/endpoints/token.rs @@ -147,6 +147,18 @@ pub async fn token_gen(token_server: &State) -> status::Custom")] +pub async fn token_accept(token_server: &State, token_id: String) -> status::Custom> { + + set_tnc_accepted(&token_server.pool, &token_id).await; + + let response_body = json!({ + "accepted": true, + }); + + return status::Custom(Status::Ok, Json(response_body)); +} + #[get("/token/token_verify/")] pub async fn token_verify(token_server: &State, token_id: String) -> status::Custom> { @@ -291,3 +303,20 @@ pub async fn set_token_confirmed(pool: &sqlx::PgPool, token_id: &str) { transaction.commit().await.unwrap(); } + +pub async fn set_tnc_accepted(pool: &sqlx::PgPool, token_id: &str) { + + let mut transaction = pool.begin().await.unwrap(); + + let query = "UPDATE tokens \ + SET accepted = true \ + WHERE token_id = $1"; + + let _ = sqlx::query(query) + .bind(token_id) + .execute(&mut *transaction) + .await + .unwrap(); + + transaction.commit().await.unwrap(); +} diff --git a/token-server/src/main.rs b/token-server/src/main.rs index fca9dd92..c603d8b9 100644 --- a/token-server/src/main.rs +++ b/token-server/src/main.rs @@ -36,6 +36,7 @@ async fn main() { endpoints::token::token_init, endpoints::token::token_verify, endpoints::token::token_gen, + endpoints::token::token_accept, ]) .register("/", catchers![ not_found,