github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/examples/v2/rest-wallet/main.go (about) 1 package main 2 3 import ( 4 "log" 5 "os" 6 7 "github.com/bitfinexcom/bitfinex-api-go/v2/rest" 8 "github.com/davecgh/go-spew/spew" 9 ) 10 11 // Set BFX_API_KEY and BFX_API_SECRET as : 12 // 13 // export BFX_API_KEY=YOUR_API_KEY 14 // export BFX_API_SECRET=YOUR_API_SECRET 15 // 16 // you can obtain it from https://www.bitfinex.com/api 17 18 func main() { 19 key := os.Getenv("BFX_API_KEY") 20 secret := os.Getenv("BFX_API_SECRET") 21 22 c := rest.NewClient().Credentials(key, secret) 23 24 getWallets(c) 25 transfer(c) 26 depositAddress(c) 27 createDepositAddress(c) 28 withdraw(c) 29 } 30 31 func getWallets(c *rest.Client) { 32 wallets, err := c.Wallet.Wallet() 33 if err != nil { 34 log.Fatalf("getWallets %s", err) 35 } 36 37 spew.Dump(wallets) 38 } 39 40 func transfer(c *rest.Client) { 41 notfication, err := c.Wallet.Transfer("exchange", "margin", "BTC", "BTC", 0.001) 42 if err != nil { 43 log.Fatalf("transfer %s", err) 44 } 45 46 spew.Dump(notfication) 47 } 48 49 func depositAddress(c *rest.Client) { 50 notfication, err := c.Wallet.DepositAddress("exchange", "ethereum") 51 if err != nil { 52 log.Fatalf("depositAddress %s", err) 53 } 54 55 spew.Dump(notfication) 56 } 57 58 func createDepositAddress(c *rest.Client) { 59 notfication, err := c.Wallet.DepositAddress("margin", "ethereum") 60 if err != nil { 61 log.Fatalf("createDepositAddress %s", err) 62 } 63 64 spew.Dump(notfication) 65 } 66 67 func withdraw(c *rest.Client) { 68 notfication, err := c.Wallet.Withdraw("exchange", "ethereum", 0.1, "0x5B4Dbe55dE0B565db6C63405D942886140083cE8") 69 if err != nil { 70 log.Fatalf("withdraw %s", err) 71 } 72 73 spew.Dump(notfication) 74 }