mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
exchanges/engine: Add multichain deposit/withdrawal support (#794)
* Add exchange multichain support * Start tidying up * Add multichain transfer support for Bitfinex and fix poloniex bug * Add Coinbene multichain support * Start adjusting the deposit address manager * Fix deposit tests and further enhancements * Cleanup * Add bypass flag, expand tests plus error coverage for Huobi Adjust helpers * Address nitterinos * BFX wd changes * Address nitterinos * Minor fixes rebasing on master * Fix BFX acceptableMethods test * Add some TO-DOs for 2 tests WRT races * Fix acceptableMethods test round 2 * Address nitterinos
This commit is contained in:
@@ -2592,7 +2592,7 @@ func getCryptocurrencyDepositAddresses(c *cli.Context) error {
|
||||
var getCryptocurrencyDepositAddressCommand = &cli.Command{
|
||||
Name: "getcryptocurrencydepositaddress",
|
||||
Usage: "gets the cryptocurrency deposit address for an exchange and cryptocurrency",
|
||||
ArgsUsage: "<exchange> <cryptocurrency>",
|
||||
ArgsUsage: "<exchange> <cryptocurrency> <chain> <bypass>",
|
||||
Action: getCryptocurrencyDepositAddress,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
@@ -2603,12 +2603,102 @@ var getCryptocurrencyDepositAddressCommand = &cli.Command{
|
||||
Name: "cryptocurrency",
|
||||
Usage: "the cryptocurrency to get the deposit address for",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "chain",
|
||||
Usage: "the chain to use for the deposit",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "bypass",
|
||||
Usage: "whether to bypass the deposit address manager cache if enabled",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func getCryptocurrencyDepositAddress(c *cli.Context) error {
|
||||
if c.NArg() == 0 && c.NumFlags() == 0 {
|
||||
return cli.ShowCommandHelp(c, "getcryptocurrencydepositaddresses")
|
||||
return cli.ShowCommandHelp(c, "getcryptocurrencydepositaddress")
|
||||
}
|
||||
|
||||
var exchangeName string
|
||||
var cryptocurrency string
|
||||
|
||||
if c.IsSet("exchange") {
|
||||
exchangeName = c.String("exchange")
|
||||
} else {
|
||||
exchangeName = c.Args().First()
|
||||
}
|
||||
|
||||
if c.IsSet("cryptocurrency") {
|
||||
cryptocurrency = c.String("cryptocurrency")
|
||||
} else if c.Args().Get(1) != "" {
|
||||
cryptocurrency = c.Args().Get(1)
|
||||
}
|
||||
|
||||
if cryptocurrency == "" {
|
||||
return errors.New("cryptocurrency must be set")
|
||||
}
|
||||
|
||||
var chain string
|
||||
if c.IsSet("chain") {
|
||||
chain = c.String("chain")
|
||||
} else if c.Args().Get(2) != "" {
|
||||
chain = c.Args().Get(2)
|
||||
}
|
||||
|
||||
var bypass bool
|
||||
if c.IsSet("bypass") {
|
||||
bypass = c.Bool("bypass")
|
||||
} else if c.Args().Get(3) != "" {
|
||||
b, err := strconv.ParseBool(c.Args().Get(3))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bypass = b
|
||||
}
|
||||
|
||||
conn, cancel, err := setupClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closeConn(conn, cancel)
|
||||
|
||||
client := gctrpc.NewGoCryptoTraderClient(conn)
|
||||
result, err := client.GetCryptocurrencyDepositAddress(c.Context,
|
||||
&gctrpc.GetCryptocurrencyDepositAddressRequest{
|
||||
Exchange: exchangeName,
|
||||
Cryptocurrency: cryptocurrency,
|
||||
Chain: chain,
|
||||
Bypass: bypass,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jsonOutput(result)
|
||||
return nil
|
||||
}
|
||||
|
||||
var getAvailableTransferChainsCommand = &cli.Command{
|
||||
Name: "getavailabletransferchains",
|
||||
Usage: "gets the available transfer chains (deposits and withdrawals) for the desired exchange and cryptocurrency",
|
||||
ArgsUsage: "<exchange> <cryptocurrency>",
|
||||
Action: getAvailableTransferChains,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "exchange",
|
||||
Usage: "the exchange to get the available transfer chains",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "cryptocurrency",
|
||||
Usage: "the cryptocurrency to get the available transfer chains for",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func getAvailableTransferChains(c *cli.Context) error {
|
||||
if c.NArg() == 0 && c.NumFlags() == 0 {
|
||||
return cli.ShowCommandHelp(c, "getavailabletransferchains")
|
||||
}
|
||||
|
||||
var exchangeName string
|
||||
@@ -2637,8 +2727,8 @@ func getCryptocurrencyDepositAddress(c *cli.Context) error {
|
||||
defer closeConn(conn, cancel)
|
||||
|
||||
client := gctrpc.NewGoCryptoTraderClient(conn)
|
||||
result, err := client.GetCryptocurrencyDepositAddress(c.Context,
|
||||
&gctrpc.GetCryptocurrencyDepositAddressRequest{
|
||||
result, err := client.GetAvailableTransferChains(c.Context,
|
||||
&gctrpc.GetAvailableTransferChainsRequest{
|
||||
Exchange: exchangeName,
|
||||
Cryptocurrency: cryptocurrency,
|
||||
},
|
||||
@@ -2654,7 +2744,7 @@ func getCryptocurrencyDepositAddress(c *cli.Context) error {
|
||||
var withdrawCryptocurrencyFundsCommand = &cli.Command{
|
||||
Name: "withdrawcryptofunds",
|
||||
Usage: "withdraws cryptocurrency funds from the desired exchange",
|
||||
ArgsUsage: "<exchange> <currency> <amount> <address> <addresstag> <fee> <description>",
|
||||
ArgsUsage: "<exchange> <currency> <amount> <address> <addresstag> <fee> <description> <chain>",
|
||||
Action: withdrawCryptocurrencyFunds,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
@@ -2685,6 +2775,10 @@ var withdrawCryptocurrencyFundsCommand = &cli.Command{
|
||||
Name: "description",
|
||||
Usage: "description to submit with request",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "chain",
|
||||
Usage: "chain to use for the withdrawal",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2693,7 +2787,7 @@ func withdrawCryptocurrencyFunds(c *cli.Context) error {
|
||||
return cli.ShowCommandHelp(c, "withdrawcryptofunds")
|
||||
}
|
||||
|
||||
var exchange, cur, address, addressTag, description string
|
||||
var exchange, cur, address, addressTag, chain, description string
|
||||
var amount, fee float64
|
||||
|
||||
if c.IsSet("exchange") {
|
||||
@@ -2744,6 +2838,12 @@ func withdrawCryptocurrencyFunds(c *cli.Context) error {
|
||||
description = c.Args().Get(6)
|
||||
}
|
||||
|
||||
if c.IsSet("chain") {
|
||||
chain = c.String("chain")
|
||||
} else if c.Args().Get(7) != "" {
|
||||
chain = c.Args().Get(7)
|
||||
}
|
||||
|
||||
conn, cancel, err := setupClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -2761,6 +2861,7 @@ func withdrawCryptocurrencyFunds(c *cli.Context) error {
|
||||
Amount: amount,
|
||||
Fee: fee,
|
||||
Description: description,
|
||||
Chain: chain,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -143,6 +143,7 @@ func main() {
|
||||
removeEventCommand,
|
||||
getCryptocurrencyDepositAddressesCommand,
|
||||
getCryptocurrencyDepositAddressCommand,
|
||||
getAvailableTransferChainsCommand,
|
||||
withdrawCryptocurrencyFundsCommand,
|
||||
withdrawFiatFundsCommand,
|
||||
withdrawalRequestCommand,
|
||||
|
||||
Reference in New Issue
Block a user