decred.org/dcrdex@v1.0.5/docs/wiki/Client-control-API.mediawiki (about)

     1  ==Bison Wallet (bisonw) ==
     2  
     3  ==RPC==
     4  
     5  Bison Wallet (bisonw) can be controlled via its remote procedure call (RPC) interface.
     6  
     7  ==HTTPS==
     8  
     9  All HTTP requests sent to the RPC server must contain basic auth with a
    10  user:password pair that the client's RPC interface will accept.
    11  
    12  Communication is done using [https://golang.org/pkg/crypto/tls/ tls].
    13  
    14  Requests must be constructed as specified in [https://github.com/decred/dcrdex/blob/master/spec/comm.mediawiki/#Message_Protocol Message Protocol]
    15  
    16  ===Payload===
    17  
    18  All requests use the same payload structure. All individual arguments are strings.
    19  Return values vary.
    20  
    21  <code>payload</code>
    22  {|
    23  ! field !! type   !! description
    24  |-
    25  | PWArgs  || &#91;string&#93; || An array of password arguments. Can be null.
    26  |-
    27  | args    || &#91;string&#93; || An array of arguments. Can be null.
    28  |}
    29  
    30  Arguments in arrays are positional and must be placed in the order they appear
    31  here. If an argument is optional, but a placeholder is needed, an empty
    32  string "" can be used. Arguments have a pseudo-type. For example,
    33  if boolean, the argument must be the string representation of a truthy value. i.e.
    34  "true" or "1"
    35  
    36  Returns will come with an error if there was a problem. If arguments could not
    37  be parsed, a help message for that specific route/command is returned.
    38  
    39  
    40  ===Help===
    41  
    42  Print a help message.
    43  
    44  '''Request route:''' <code>help</code>
    45  
    46  <code>args</code>
    47  {|
    48  ! name !! pseudo-type !! description
    49  |-
    50  | cmd || string  || Optional. The command to print help for.
    51  |-
    52  | includePasswords || bool || Optional. Default is false. Whether to include password arguments in the returned help. Passwords are hidden when using bwctl.
    53  |}
    54  
    55  '''Response'''
    56  
    57  The response will contain a help message based on the arguments.
    58  
    59  <code>payload</code>
    60  {|
    61  ! type !! description
    62  |-
    63  | string ||  The help message for command.
    64  |}
    65  
    66  
    67  ===Version===
    68  
    69  Print the Bison Wallet rpcserver version. Accepts no arguments
    70  
    71  '''Request route:''' <code>version</code>
    72  
    73  '''Response'''
    74  
    75  The response will contain the semver as a string. i.e. "1.0.0"
    76  
    77  <code>payload</code>
    78  {|
    79  ! type !! description
    80  |-
    81  | string || The Bison Wallet rpcserver version.
    82  |}
    83  
    84  
    85  ===Init===
    86  
    87  Initialize the client with a password.
    88  
    89  '''Request route:''' <code>init</code>
    90  
    91  <code>PWArgs</code>
    92  {|
    93  ! name !! type !! description
    94  |-
    95  | appPass || string  || The Bison Wallet password.
    96  |}
    97  
    98  '''Response'''
    99  
   100  The response will contain a message.
   101  
   102  <code>payload</code>
   103  {|
   104  ! type !! description
   105  |-
   106  | string || The message "app initialized".
   107  |}
   108  
   109  
   110  ===Get Fee===
   111  
   112  Print a help message.
   113  
   114  '''Request route:''' <code>getfee</code>
   115  
   116  <code>args</code>
   117  {|
   118  ! name !! pseudo-type !! description
   119  |-
   120  | dex || string  || The DEX address for which the registration fee should be retrieved.
   121  |-
   122  | cert || string || Optional. The TLS certificate path.
   123  |}
   124  
   125  '''Response'''
   126  
   127  The response will contain the fee.
   128  
   129  <code>payload</code>
   130  {|
   131  ! type !! description
   132  |-
   133  | object || The getFee result.
   134  |}
   135  
   136  '''JSON GetFeeResult object'''
   137  
   138  {|
   139  ! field   !! type   !! description
   140  |-
   141  | fee      || int   || The DEX registration fee.
   142  |}
   143  
   144  
   145  ===New Wallet===
   146  
   147  Connect to a new wallet.
   148  
   149  '''Request route:''' <code>newwallet</code>
   150  
   151  <code>PWArgs</code>
   152  {|
   153  ! name !! type !! description
   154  |-
   155  | appPass || string  || The Bison Wallet password.
   156  |-
   157  | walletPass || string  || The wallet's password. The client will encrypt and store this.
   158  |}
   159  
   160  <code>args</code>
   161  {|
   162  ! name !! pseudo-type !! description
   163  |-
   164  | cmd || string  || Optional. The command to print help for.
   165  |-
   166  | assetID  || int || The asset's BIP-44 registered coin index. e.g. 42 for DCR. See [https://github.com/satoshilabs/slips/blob/master/slip-0044.md slip0044]
   167  |-
   168  | path     || string  || Optional. Text from a configuration file.
   169  |-
   170  | settings || object  || Optional. A JSON-encoded string->string mapping of additional configuration settings. These settings take precedence over any settings parsed from file. e.g. '{"account":"default"}' for Decred accounts, and '{"walletname":""}' for the default Bitcoin wallet where bitcoind's listwallets RPC gives possible walletnames.
   171  |}
   172  
   173  '''Response'''
   174  
   175  The response will contain a message.
   176  
   177  <code>payload</code>
   178  {|
   179  ! type !! description
   180  |-
   181  | string ||  The message "&#91;coin symbol&#93; wallet created and unlocked".
   182  |}
   183  
   184  
   185  ===Open Wallet===
   186  
   187  Unlock an existing wallet for one year.
   188  
   189  '''Request route:''' <code>openwallet</code>
   190  
   191  <code>PWArgs</code>
   192  {|
   193  ! name !! type !! description
   194  |-
   195  | appPass || string  || The Bison Wallet password.
   196  |}
   197  
   198  <code>args</code>
   199  {|
   200  ! name !! pseudo-type !! description
   201  |-
   202  | assetID  || int || The asset's BIP-44 registered coin index. e.g. 42 for DCR. See [https://github.com/satoshilabs/slips/blob/master/slip-0044.md slip0044]
   203  |}
   204  
   205  '''Response'''
   206  
   207  The response will contain a message.
   208  
   209  <code>payload</code>
   210  {|
   211  ! type !! description
   212  |-
   213  | string ||  The message "&#91;coin symbol&#93; wallet unlocked".
   214  |}
   215  
   216  
   217  ===Close Wallet===
   218  
   219  Lock an existing wallet.
   220  
   221  '''Request route:''' <code>lockwallet</code>
   222  
   223  <code>args</code>
   224  {|
   225  ! name !! pseudo-type !! description
   226  |-
   227  | assetID  || int || The asset's BIP-44 registered coin index. e.g. 42 for DCR. See [https://github.com/satoshilabs/slips/blob/master/slip-0044.md slip0044]
   228  |}
   229  
   230  '''Response'''
   231  
   232  The response will contain a message.
   233  
   234  <code>payload</code>
   235  {|
   236  ! type !! description
   237  |-
   238  | string ||  The message "&#91;coin symbol&#93; wallet locked".
   239  |}
   240  
   241  
   242  ===Wallets===
   243  
   244  Get information about all wallets registered with the client. Accepts no arguments.
   245  
   246  '''Request route:''' <code>wallets</code>
   247  
   248  '''Response'''
   249  
   250  The response will contain an array of information for each wallet.
   251  
   252  <code>payload</code>
   253  {|
   254  ! type !! description
   255  |-
   256  | &#91;object&#93; || A list of '''WalletInfo''' objects (described below).
   257  |}
   258  
   259  '''JSON WalletInfo object'''
   260  
   261  {|
   262  ! field   !! type   !! description
   263  |-
   264  | symbol  || string || The coin symbol.
   265  |-
   266  | assetID || int    || The asset's BIP-44 registered coin index. e.g. 42 for DCR. See [https://github.com/satoshilabs/slips/blob/master/slip-0044.md slip0044]
   267  |-
   268  | open    || bool   || Whether the wallet is unlocked.
   269  |-
   270  | running || bool   || Whether the wallet is running.
   271  |-
   272  | updated || int    || Unix time of last balance update. Seconds since 00:00:00 Jan 1 1970.
   273  |-
   274  | balance || object || A Balance object (described below).
   275  |-
   276  | address || string || A wallet address.
   277  |-
   278  | feerate || int    || The fee rate.
   279  |-
   280  | units   || string || Unit of measure for amounts.
   281  |}
   282  
   283  '''JSON Balance object'''
   284  
   285  {|
   286  ! field   !! type   !! description
   287  |-
   288  | available || int || The balance available for funding orders case.
   289  |-
   290  | immature  || int || Balance that requires confirmations before use.
   291  |-
   292  | locked    || int || The total locked balance.
   293  |-
   294  | stamp     || string || Time stamp.
   295  |}
   296  
   297  
   298  ===Register===
   299  
   300  Register for a DEX. An OK response does not mean that registration is complete.
   301  Registration is complete after the fee transaction has been confirmed.
   302  
   303  '''Request route:''' <code>register</code>
   304  
   305  <code>PWArgs</code>
   306  {|
   307  ! name !! type !! description
   308  |-
   309  | appPass || string  || The Bison Wallet password.
   310  |}
   311  
   312  <code>args</code>
   313  {|
   314  ! name !! pseudo-type !! description
   315  |-
   316  | addr || string  || The DEX address to register for.
   317  |-
   318  | fee  || int  || The DEX fee.
   319  |-
   320  | cert || string  || Optional. The TLS certificate.
   321  |}
   322  
   323  '''Response'''
   324  
   325  The response will contain a RegisterResult object.
   326  
   327  <code>payload</code>
   328  {|
   329  ! type !! description
   330  |-
   331  | object ||  The RegisterResult (described below).
   332  |}
   333  
   334  '''JSON RegisterResult object'''
   335  
   336  {|
   337  ! field   !! type   !! description
   338  |-
   339  | feeID       || string || The fee transaction's ID and output index.
   340  |-
   341  | reqConfirms || int || The number of confirmations required to start trading.
   342  |}
   343  
   344  
   345  ===Exchanges===
   346  
   347  Detailed information about known exchanges and markets. Arguments not accepted.
   348  
   349  '''Request route:''' <code>exchanges</code>
   350  
   351  '''Response'''
   352  
   353  The response will contain an Exchanges object.
   354  
   355  <code>payload</code>
   356  {|
   357  ! type !! description
   358  |-
   359  | object ||  An Exchanges object (described below).
   360  |}
   361  
   362  '''JSON Exchanges object'''
   363  
   364  {|
   365  ! field   !! type   !! description
   366  |-
   367  | &#91;DEX host&#93; || object || Repeating. An Exchange object (described below)
   368  |}
   369  
   370  '''JSON Exchange object'''
   371  
   372  {|
   373  ! field   !! type   !! description
   374  |-
   375  | markets       || object || A Markets object (described below).
   376  |-
   377  | assets        || object || An Assets object (described below).
   378  |-
   379  | confsrequired || int || The number of confirmations needed for the registration fee payment.
   380  |-
   381  | confs         || int || The current number of confirmations for the registration fee payment. This is only present during the registration process.
   382  |}
   383  
   384  '''JSON Markets object'''
   385  
   386  {|
   387  ! field   !! type   !! description
   388  |-
   389  | &#91;assetSymbol-assetSymbol&#93; || object || Repeating. A Market object (described below)
   390  |}
   391  
   392  '''JSON Market object'''
   393  
   394  {|
   395  ! field   !! type   !! description
   396  |-
   397  | baseid      || int || The base asset ID.
   398  |-
   399  | basesymbol  || string || The base ticker symbol.
   400  |-
   401  | quoteid     || int || The quote asset ID.
   402  |-
   403  | quotesymbol || string || The quote asset ID symbol,
   404  |-
   405  | epochlen    || int || Duration of a epoch in milliseconds.
   406  |-
   407  | startepoch  || int || Time of start of the last epoch in milliseconds since 00:00:00 Jan 1 1970.
   408  |-
   409  | buybuffer   || float || The minimum order size for a market buy order.
   410  |}
   411  
   412  '''JSON Assets object'''
   413  
   414  {|
   415  ! field   !! type   !! description
   416  |-
   417  | &#91;assetID&#93; || object || Repeating. An Asset object (described below)
   418  |}
   419  
   420  '''JSON Asset object'''
   421  
   422  {|
   423  ! field   !! type   !! description
   424  |-
   425  | symbol       || string || The asset's coin symbol.
   426  |-
   427  | lotSize      || int || The amount of units of a coin in one lot.
   428  |-
   429  | rateStep     || int || the price rate increment in atoms.
   430  |-
   431  | feeRate      || int || The transaction fee in atoms per byte.
   432  |-
   433  | swapSize     || int || The size of a swap transaction in bytes.
   434  |-
   435  | swapSizeBase || int || The size of a swap transaction minus inputs in bytes.
   436  |-
   437  | swapConf     || int || The number of confirmations needed to confirm trade transactions.
   438  |}
   439  
   440  
   441  ===Login===
   442  
   443  Attempt to login to all registered DEX servers.
   444  
   445  '''Request route:''' <code>login</code>
   446  
   447  <code>PWArgs</code>
   448  {|
   449  ! name !! type !! description
   450  |-
   451  | appPass || string  || The Bison Wallet password.
   452  |}
   453  
   454  '''Response'''
   455  
   456  The response will contain a LoginResult.
   457  
   458  <code>payload</code>
   459  {|
   460  ! type !! description
   461  |-
   462  | object ||  The LoginResult (described below).
   463  |}
   464  
   465  '''JSON LoginResult object'''
   466  
   467  {|
   468  ! field   !! type   !! description
   469  |-
   470  | notification || &#91;object&#93; || A list of Notification objects (described below).
   471  |-
   472  | dexes        || &#91;object&#93; || A list of Dex objects (described below).
   473  |}
   474  
   475  '''JSON Notification object'''
   476  
   477  {|
   478  ! field   !! type   !! description
   479  |-
   480  | type     || string || The notification type.
   481  |-
   482  | subject  || string || A clarification of type.
   483  |-
   484  | details  || string || The notification details.
   485  |-
   486  | severity || int || The importance of the notification on a scale of 0 through 5.
   487  |-
   488  | stamp    || int || Unix time of the notification. Seconds since 00:00:00 Jan 1 1970.
   489  |-
   490  | acked    || bool || Whether the notification was acknowledged.
   491  |-
   492  | id       || string || A unique hex ID.
   493  |}
   494  
   495  '''JSON DEX object'''
   496  
   497  {|
   498  ! field   !! type   !! description
   499  |-
   500  | host     || string || The DEX address.
   501  |-
   502  | acctID   || string || A unique hex ID.
   503  |-
   504  | authed   || bool || If successfully authenticated with the DEX.
   505  |-
   506  | autherr  || string || Omitted if authed. If not authed, the reason.
   507  |-
   508  | tradeIDs || &#91;string&#93; || An array of active trade IDs.
   509  |}
   510  
   511  
   512  ===Trade===
   513  
   514  Make an order to buy or sell an asset.
   515  
   516  '''Request route:''' <code>trade</code>
   517  
   518  <code>PWArgs</code>
   519  {|
   520  ! name !! type !! description
   521  |-
   522  | appPass || string  || The Bison Wallet password.
   523  |}
   524  
   525  <code>args</code>
   526  {|
   527  ! name !! pseudo-type !! description
   528  |-
   529  | host      || string || The DEX to trade on.
   530  |-
   531  | isLimit   || bool || Whether the order is a limit order.
   532  |-
   533  | sell      || bool || Whether the order is selling.
   534  |-
   535  | base      || int || The BIP-44 coin index for the market's base asset.
   536  |-
   537  | quote     || int || The BIP-44 coin index for the market's quote asset.
   538  |-
   539  | qty       || int || The number of units to buy/sell. Must be a multiple of the lot size.
   540  |-
   541  | rate      || int || The atoms quote asset to pay/accept per unit base asset. e.g. 156000 satoshi/DCR for the DCR(base)_BTC(quote).
   542  |-
   543  | immediate || bool || Require immediate match. Do not book the order.
   544  |}
   545  
   546  '''Response'''
   547  
   548  The response will contain an OrderDetails.
   549  
   550  <code>payload</code>
   551  {|
   552  ! type !! description
   553  |-
   554  | object ||  An OrderDetails object (describled below).
   555  |}
   556  
   557  '''JSON OrderDetails object'''
   558  
   559  {|
   560  ! field   !! type   !! description
   561  |-
   562  | orderid || string || The order's unique hex identifier.
   563  |-
   564  | sig     || string || The DEX's signature of the order information.
   565  |-
   566  | stamp   || int || The time the order was signed in milliseconds since 00:00:00 Jan 1 1970.
   567  |}
   568  
   569  
   570  ===Cancel===
   571  
   572  Cancel an order.
   573  
   574  '''Request route:''' <code>cancel</code>
   575  
   576  <code>PWArgs</code>
   577  {|
   578  ! name !! type !! description
   579  |-
   580  | appPass || string  || The Bison Wallet password.
   581  |}
   582  
   583  <code>args</code>
   584  {|
   585  ! name !! pseudo-type !! description
   586  |-
   587  | orderID || string  || The hex ID of the order to cancel.
   588  |}
   589  
   590  '''Response'''
   591  
   592  The response will contain a message.
   593  
   594  <code>payload</code>
   595  {|
   596  ! type !! description
   597  |-
   598  | string ||  The message "canceled order &#91;order ID&#93;".
   599  |}
   600  
   601  
   602  ===Withdraw===
   603  
   604  Withdraw value from an exchange wallet to address.
   605  
   606  '''Request route:''' <code>withdraw</code>
   607  
   608  <code>PWArgs</code>
   609  {|
   610  ! name !! type !! description
   611  |-
   612  | appPass || string  || The Bison Wallet password.
   613  |}
   614  
   615  <code>args</code>
   616  {|
   617  ! name !! pseudo-type !! description
   618  |-
   619  | assetID || int || The asset's BIP-44 registered coin index. Used to identify which wallet to withdraw from. e.g. 42 for DCR. See [https://github.com/satoshilabs/slips/blob/master/slip-0044.md slip0044]
   620  |-
   621  | value   || int || The amount to withdraw in units of the asset's smallest denomination (e.g. satoshis, atoms, etc.)
   622  |-
   623  | address || string || The address to which withdrawn funds are sent.
   624  |}
   625  
   626  '''Response'''
   627  
   628  The response will contain coin ID of the withdraw transaction.
   629  
   630  <code>payload</code>
   631  {|
   632  ! type !! description
   633  |-
   634  | string ||  "&#91;coin ID&#93;".
   635  |}
   636  
   637  
   638  ===Logout===
   639  
   640  Logout of Bison Wallet. Accepts no arguments.
   641  
   642  '''Request route:''' <code>logout</code>
   643  
   644  '''Response'''
   645  
   646  The response will contain a message.
   647  
   648  <code>payload</code>
   649  {|
   650  ! type !! description
   651  |-
   652  | string || The message "goodbye"
   653  |}
   654  
   655  
   656  ===Order Book===
   657  
   658  Retrieve all orders for a market.
   659  
   660  '''Request route:''' <code>orderbook</code>
   661  
   662  <code>args</code>
   663  {|
   664  ! name !! pseudo-type !! description
   665  |-
   666  | host    || string || The DEX to retrieve the order book from.
   667  |-
   668  | base    || int || The BIP-44 coin index for the market's base asset.
   669  |-
   670  | quote   || int || The BIP-44 coin index for the market's quote asset.
   671  |-
   672  | nOrders || int || Optional. Default is 0, which returns all orders. The number of orders from the top of buys and sells to return. Epoch orders are not truncated.
   673  |}
   674  
   675  '''Response'''
   676  
   677  The response will contain an OrderBook object.
   678  
   679  <code>payload</code>
   680  {|
   681  ! type !! description
   682  |-
   683  | object ||  An OrderBook object (described below).
   684  |}
   685  
   686  '''JSON OrderBook object'''
   687  
   688  {|
   689  ! field   !! type   !! description
   690  |-
   691  | sells || &#91;object&#93; || An array of booked MiniOrder objects (described below).
   692  |-
   693  | buys  || &#91;object&#93; || An array of booked buy MiniOrder objects.
   694  |-
   695  | epoch || &#91;object&#93; || An array of epoch MiniOrder objects. Epoch orders include all kinds of orders, even those that cannot or may not be booked. They are not truncated.
   696  |}
   697  
   698  '''JSON MiniOrder object'''
   699  
   700  {|
   701  ! field   !! type   !! description
   702  |-
   703  | qty   || float || The number of coins base asset being bought or sold.
   704  |-
   705  | rate  || float || The coins quote asset to accept per coin base asset.
   706  |-
   707  | sell  || bool || Whether this order is a sell order.
   708  |-
   709  | token || string || The first 8 bytes of the order id, coded in hex.
   710  |-
   711  | epoch || int || Only present for epoch orders. The order's epoch.
   712  |}
   713  
   714  
   715  ===My Orders===
   716  
   717  Fetch all active and recently executed orders belonging to the user.
   718  
   719  '''Request route:''' <code>myorders</code>
   720  
   721  <code>args</code>
   722  {|
   723  ! name !! pseudo-type !! description
   724  |-
   725  | host  || string || Optional. The DEX to show orders from.
   726  |-
   727  | base  || int || Optional. The BIP-44 coin index for the market's base asset.
   728  |-
   729  | quote || int || Optional. The BIP-44 coin index for the market's quote asset.
   730  |}
   731  
   732  '''Response'''
   733  
   734  The response will contain a list of Order objects.
   735  
   736  <code>payload</code>
   737  {|
   738  ! type !! description
   739  |-
   740  | &#91;object&#93; ||  A list of Order objects (described below).
   741  |}
   742  
   743  '''JSON Order object'''
   744  
   745  {|
   746  ! field   !! type   !! description
   747  |-
   748  | host       || string || The DEX address.
   749  |-
   750  | marketName || string || The market's name. e.g. "DCR_BTC".
   751  |-
   752  | baseID     || int || The market's base asset BIP-44 coin index. e.g. 42 for DCR.
   753  |-
   754  | quoteID    || int || The market's quote asset BIP-44 coin index. e.g. 0 for BTC.
   755  |-
   756  | id         || string || The order's unique hex ID.
   757  |-
   758  | type       || string || The type of order. "limit", "market", or "cancel".
   759  |-
   760  | sell       || string || Whether this order is selling.
   761  |-
   762  | stamp      || int || Time the order was made in milliseconds since 00:00:00 Jan 1 1970.
   763  |-
   764  | age        || string || The time that this order has been active in human readable form.
   765  |-
   766  | rate       || int || The exchange rate limit. Limit orders only. Units: quote asset per unit base asset.
   767  |-
   768  | quantity   || int || The amount being traded.
   769  |-
   770  | filled     || int || The order quantity that has matched.
   771  |-
   772  | settled    || int || The sum quantity of all completed matches.
   773  |-
   774  | status     || string || The status of the order. "epoch", "booked", "executed", "canceled", or "revoked".
   775  |-
   776  | cancelling || bool || Whether this order is in the process of cancelling.
   777  |-
   778  | canceled   || bool || Whether this order has been canceled.
   779  |-
   780  | tif        || string || "immediate" if this limit order will only match for one epoch. "standing" if the order can continue matching until filled or cancelled.
   781  |}
   782  
   783  ==WebSocket==
   784  
   785  A connection to the WebSocket server can be made through the RPC server. The
   786  websocket server server allows for notifications from a market and other long
   787  running operations.
   788  
   789  Connect by providing proper credentials and a valid header when visiting
   790  "wss://&#91;RPC Server Address&#93;/ws".
   791  
   792  ==Examples==
   793  
   794  An example of setting up both an https and wss connection to the RPC server can
   795  be found [https://github.com/decred/dcrdex/blob/master/docs/examples/rpcclient here]