decred.org/dcrdex@v1.0.5/client/webserver/types.go (about)

     1  // This code is available on the terms of the project LICENSE.md file,
     2  // also available online at https://blueoakcouncil.org/license/1.0.0.
     3  
     4  package webserver
     5  
     6  import (
     7  	"decred.org/dcrdex/client/core"
     8  	"decred.org/dcrdex/client/db"
     9  	"decred.org/dcrdex/dex"
    10  	"decred.org/dcrdex/dex/encode"
    11  )
    12  
    13  // standardResponse is a basic API response when no data needs to be returned.
    14  type standardResponse struct {
    15  	OK   bool   `json:"ok"`
    16  	Msg  string `json:"msg,omitempty"`
    17  	Code *int   `json:"code,omitempty"`
    18  }
    19  
    20  // simpleAck is a plain standardResponse with "ok" = true.
    21  func simpleAck() *standardResponse {
    22  	return &standardResponse{
    23  		OK: true,
    24  	}
    25  }
    26  
    27  // The loginForm is sent by the client to log in to a DEX.
    28  type loginForm struct {
    29  	Pass encode.PassBytes `json:"pass"`
    30  }
    31  
    32  // addDexForm is used to connect a DEX without creating an account.
    33  type addDexForm struct {
    34  	Addr  string           `json:"addr"`
    35  	Cert  string           `json:"cert"`
    36  	AppPW encode.PassBytes `json:"appPW"`
    37  }
    38  
    39  // registrationForm is used to register a new DEX account.
    40  type registrationForm struct {
    41  	Addr     string           `json:"addr"`
    42  	Cert     string           `json:"cert"`
    43  	Password encode.PassBytes `json:"pass"`
    44  	Fee      uint64           `json:"fee"`
    45  	AssetID  *uint32          `json:"asset,omitempty"` // prevent omission using BTC
    46  }
    47  
    48  type bondsFeeBufferForm struct {
    49  	AssetID uint32 `json:"assetID"`
    50  }
    51  
    52  // postBondForm is used to post a new bond for an existing DEX account.
    53  type postBondForm struct {
    54  	Addr         string           `json:"addr"`
    55  	Cert         string           `json:"cert"` // may be empty for adding bond to existing account
    56  	Password     encode.PassBytes `json:"pass"`
    57  	Bond         uint64           `json:"bond"`
    58  	AssetID      *uint32          `json:"asset,omitempty"` // prevent omission using BTC
    59  	LockTime     uint64           `json:"lockTime"`
    60  	Maintain     *bool            `json:"maintain,omitempty"`
    61  	MaxBondedAmt *uint64          `json:"maxBondedAmt,omitempty"`
    62  	FeeBuffer    *uint64          `json:"feeBuffer,omitempty"`
    63  }
    64  
    65  type registrationTxFeeForm struct {
    66  	Addr    string  `json:"addr"`
    67  	Cert    string  `json:"cert"`
    68  	AssetID *uint32 `json:"asset,omitempty"`
    69  }
    70  
    71  type sendTxFeeForm struct {
    72  	Addr        string  `json:"addr"`
    73  	Value       uint64  `json:"value"`
    74  	Subtract    bool    `json:"subtract"`
    75  	MaxWithdraw bool    `json:"maxWithdraw"`
    76  	AssetID     *uint32 `json:"assetID,omitempty"`
    77  }
    78  
    79  type walletConfig struct {
    80  	AssetID    uint32 `json:"assetID"`
    81  	WalletType string `json:"walletType"`
    82  	// These are only used if the Decred wallet does not already exist. In that
    83  	// case, these parameters will be used to create the wallet.
    84  	Config map[string]string `json:"config"`
    85  }
    86  
    87  // newWalletForm is information necessary to create a new wallet.
    88  type newWalletForm struct {
    89  	walletConfig
    90  	Pass       encode.PassBytes `json:"pass"`
    91  	AppPW      encode.PassBytes `json:"appPass"`
    92  	ParentForm *walletConfig    `json:"parentForm"`
    93  }
    94  
    95  // openWalletForm is information necessary to open a wallet.
    96  type openWalletForm struct {
    97  	AssetID uint32           `json:"assetID"`
    98  	Pass    encode.PassBytes `json:"pass"` // Application password.
    99  }
   100  
   101  // walletStatusForm is information necessary to change a wallet's status.
   102  type walletStatusForm struct {
   103  	AssetID uint32 `json:"assetID"`
   104  	Disable bool   `json:"disable"`
   105  }
   106  
   107  type tradeForm struct {
   108  	Pass  encode.PassBytes `json:"pw"`
   109  	Order *core.TradeForm  `json:"order"`
   110  }
   111  
   112  type cancelForm struct {
   113  	OrderID dex.Bytes `json:"orderID"`
   114  }
   115  
   116  // sendForm is sent to initiate either send tx.
   117  type sendForm struct {
   118  	AssetID  uint32           `json:"assetID"`
   119  	Value    uint64           `json:"value"`
   120  	Address  string           `json:"address"`
   121  	Subtract bool             `json:"subtract"`
   122  	Pass     encode.PassBytes `json:"pw"`
   123  }
   124  
   125  type accountExportForm struct {
   126  	Pass encode.PassBytes `json:"pw"`
   127  	Host string           `json:"host"`
   128  }
   129  
   130  type accountImportForm struct {
   131  	Pass    encode.PassBytes `json:"pw"`
   132  	Account *core.Account    `json:"account"`
   133  	Bonds   []*db.Bond       `json:"bonds"`
   134  }
   135  
   136  type updateAccountStatusForm struct {
   137  	Pass    encode.PassBytes `json:"pw"`
   138  	Host    string           `json:"host"`
   139  	Disable bool             `json:"disable"`
   140  }
   141  
   142  type deleteRecordsForm struct {
   143  	OlderThanMs       int64 `json:"olderThanMs"`
   144  	SaveOrdersToFile  bool  `json:"saveOrdersToFile"`
   145  	SaveMatchesToFile bool  `json:"saveMatchesToFile"`
   146  }
   147  
   148  type buildInfoResponse struct {
   149  	OK       bool   `json:"ok"`
   150  	Version  string `json:"version"`
   151  	Revision string `json:"revision"`
   152  }