Skip to content

Commit

Permalink
bitfinex wallet service
Browse files Browse the repository at this point in the history
  • Loading branch information
dasbd72 committed Mar 1, 2024
1 parent db8ba82 commit 0bc522d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
28 changes: 28 additions & 0 deletions bitfinex/wallet_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package bitfinex

import (
"context"
"encoding/json"
"net/http"
)

type (
GetWalletsResponse [][]interface{}
)

func (c *Client) GetWalletStatus(ctx context.Context, opts ...RequestOption) (*GetWalletsResponse, error) {
res, err := c.CallAPI(ctx, Request_builder{
Method: http.MethodPost,
Endpoint: "/auth/r/wallets",
SecType: SecTypePrivate,
}.Build(), opts...)
if err != nil {
return nil, err
}
data := &GetWalletsResponse{}
err = json.Unmarshal(res, data)
if err != nil {
return nil, err
}
return data, nil
}
15 changes: 7 additions & 8 deletions cmd/ccy-cli/bitfinex.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"context"
"encoding/json"
"log"
"net/http"
"os"

"github.com/dasbd72/go-exchange-sdk/bitfinex"
Expand All @@ -18,21 +18,20 @@ func Bitfinex(cmd *cobra.Command, args []string) {
os.Getenv("BFX_API_SECRET"),
)

res, err := c.CallAPI(ctx, bitfinex.Request_builder{
Method: http.MethodPost,
Endpoint: "/auth/r/wallets",
SecType: bitfinex.SecTypePrivate,
Params: map[string]interface{}{},
}.Build())
// res, err := c.CallAPI(ctx, bitfinex.Request_builder{
// Method: http.MethodGet,
// Endpoint: "/ticker",
// SubEndpoint: "/tBTCUSD",
// SecType: bitfinex.SecTypePrivate,
// Params: map[string]interface{}{},
// }.Build())
data, err := c.GetWalletStatus(ctx)
if err != nil {
log.Fatal(err)
}
log.Println(string(res))
b, err := json.MarshalIndent(data, "", " ")
if err != nil {
log.Fatal(err)
}
log.Println(string(b))
}

0 comments on commit 0bc522d

Please sign in to comment.