broxus / ever-wallet-api

Self-hosted wallet management service
Apache License 2.0
22 stars 20 forks source link

Callback documentation & event status #17

Closed evd0kim closed 3 weeks ago

evd0kim commented 7 months ago
  1. Documentation in README.md does not correspond to actual endpoints in Swagger
  2. Service returns {'error_message': None, 'status': 'Ok'} on the submitted event, but it (actually they) keeps appearing in the list of events

If /mark should somehow let the service know that the event was processed, then this is a bug. If events should be provided on every /events call then disregard this report besides documentation issues.

evd0kim commented 3 weeks ago

Also closing as not confirmed.

If somebody has issues with processing events please use these scripts as examples for debugging.

Getting event:

#!/usr/bin/env bash

host=http://0.0.0.0:8080
secret=
api_key=

function timestamp_ms {
  date +%s000
}

function create_signature() {
  stringToSign="$1"
  echo -en "$stringToSign" | openssl sha256 -hmac "$secret" -binary | base64
}

uri="/ton/v3/events/id/712150b7-16b0-4002-b961-cbd164a5ac64"
timestamp=$(timestamp_ms)
stringToSign="$timestamp$uri"
signature=$(create_signature "$stringToSign")

curl --location --request GET "$host$uri" \
  --header 'Content-Type: application/json' \
  --header "api-key: $api_key" \
  --header "timestamp: $timestamp" \
  --header "sign: $signature" | jq

Marking event as processed:

!/usr/bin/env bash

host=http://0.0.0.0:8080
secret=
api_key=

function timestamp_ms {
  date +%s000
}

function create_signature() {
  stringToSign="$1"
  echo -en "$stringToSign" | openssl sha256 -hmac "$secret" -binary | base64
}

uri="/ton/v3/events/mark"

body='{"id": ""}'
body=$(echo "$body" | jq --indent 4 -r --arg id "712150b7-16b0-4002-b961-cbd164a5ac64" '.id = $id')

timestamp=$(timestamp_ms)
stringToSign="$timestamp$uri$body"
signature=$(create_signature "$stringToSign")

echo $stringToSign
echo $signature

curl --location --request POST "$host$uri" \
  --header 'Content-Type: application/json' \
  --header "api-key: $api_key" \
  --header "timestamp: $timestamp" \
  --header "sign: $signature" \
  --data-raw "$body" | jq