github.com/trezor/blockbook@v0.4.1-0.20240328132726-e9a08582ee2c/server/ws_types.go (about)

     1  package server
     2  
     3  import "encoding/json"
     4  
     5  type WsReq struct {
     6  	ID     string          `json:"id"`
     7  	Method string          `json:"method" ts_type:"'getAccountInfo' | 'getInfo' | 'getBlockHash'| 'getBlock' | 'getAccountUtxo' | 'getBalanceHistory' | 'getTransaction' | 'getTransactionSpecific' | 'estimateFee' | 'sendTransaction' | 'subscribeNewBlock' | 'unsubscribeNewBlock' | 'subscribeNewTransaction' | 'unsubscribeNewTransaction' | 'subscribeAddresses' | 'unsubscribeAddresses' | 'subscribeFiatRates' | 'unsubscribeFiatRates' | 'ping' | 'getCurrentFiatRates' | 'getFiatRatesForTimestamps' | 'getFiatRatesTickersList' | 'getMempoolFilters'"`
     8  	Params json.RawMessage `json:"params" ts_type:"any"`
     9  }
    10  
    11  type WsRes struct {
    12  	ID   string      `json:"id"`
    13  	Data interface{} `json:"data"`
    14  }
    15  
    16  type WsAccountInfoReq struct {
    17  	Descriptor        string `json:"descriptor"`
    18  	Details           string `json:"details,omitempty" ts_type:"'basic' | 'tokens' | 'tokenBalances' | 'txids' | 'txslight' | 'txs'"`
    19  	Tokens            string `json:"tokens,omitempty" ts_type:"'derived' | 'used' | 'nonzero'"`
    20  	PageSize          int    `json:"pageSize,omitempty"`
    21  	Page              int    `json:"page,omitempty"`
    22  	FromHeight        int    `json:"from,omitempty"`
    23  	ToHeight          int    `json:"to,omitempty"`
    24  	ContractFilter    string `json:"contractFilter,omitempty"`
    25  	SecondaryCurrency string `json:"secondaryCurrency,omitempty"`
    26  	Gap               int    `json:"gap,omitempty"`
    27  }
    28  
    29  type WsBackendInfo struct {
    30  	Version          string      `json:"version,omitempty"`
    31  	Subversion       string      `json:"subversion,omitempty"`
    32  	ConsensusVersion string      `json:"consensus_version,omitempty"`
    33  	Consensus        interface{} `json:"consensus,omitempty"`
    34  }
    35  
    36  type WsInfoRes struct {
    37  	Name       string        `json:"name"`
    38  	Shortcut   string        `json:"shortcut"`
    39  	Decimals   int           `json:"decimals"`
    40  	Version    string        `json:"version"`
    41  	BestHeight int           `json:"bestHeight"`
    42  	BestHash   string        `json:"bestHash"`
    43  	Block0Hash string        `json:"block0Hash"`
    44  	Testnet    bool          `json:"testnet"`
    45  	Backend    WsBackendInfo `json:"backend"`
    46  }
    47  
    48  type WsBlockHashReq struct {
    49  	Height int `json:"height"`
    50  }
    51  
    52  type WsBlockHashRes struct {
    53  	Hash string `json:"hash"`
    54  }
    55  
    56  type WsBlockReq struct {
    57  	Id       string `json:"id"`
    58  	PageSize int    `json:"pageSize,omitempty"`
    59  	Page     int    `json:"page,omitempty"`
    60  }
    61  
    62  type WsAccountUtxoReq struct {
    63  	Descriptor string `json:"descriptor"`
    64  }
    65  
    66  type WsBalanceHistoryReq struct {
    67  	Descriptor string   `json:"descriptor"`
    68  	From       int64    `json:"from,omitempty"`
    69  	To         int64    `json:"to,omitempty"`
    70  	Currencies []string `json:"currencies,omitempty"`
    71  	Gap        int      `json:"gap,omitempty"`
    72  	GroupBy    uint32   `json:"groupBy,omitempty"`
    73  }
    74  
    75  type WsTransactionReq struct {
    76  	Txid string `json:"txid"`
    77  }
    78  
    79  type WsMempoolFiltersReq struct {
    80  	ScriptType    string `json:"scriptType"`
    81  	FromTimestamp uint32 `json:"fromTimestamp"`
    82  	ParamM        uint64 `json:"M,omitempty"`
    83  }
    84  
    85  type WsBlockFilterReq struct {
    86  	ScriptType string `json:"scriptType"`
    87  	BlockHash  string `json:"blockHash"`
    88  	ParamM     uint64 `json:"M,omitempty"`
    89  }
    90  
    91  type WsBlockFiltersBatchReq struct {
    92  	ScriptType string `json:"scriptType"`
    93  	BlockHash  string `json:"bestKnownBlockHash"`
    94  	PageSize   int    `json:"pageSize,omitempty"`
    95  	ParamM     uint64 `json:"M,omitempty"`
    96  }
    97  
    98  type WsTransactionSpecificReq struct {
    99  	Txid string `json:"txid"`
   100  }
   101  
   102  type WsEstimateFeeReq struct {
   103  	Blocks   []int                  `json:"blocks,omitempty"`
   104  	Specific map[string]interface{} `json:"specific,omitempty" ts_type:"{conservative?: boolean;txsize?: number;from?: string;to?: string;data?: string;value?: string;}"`
   105  }
   106  
   107  type WsEstimateFeeRes struct {
   108  	FeePerTx   string `json:"feePerTx,omitempty"`
   109  	FeePerUnit string `json:"feePerUnit,omitempty"`
   110  	FeeLimit   string `json:"feeLimit,omitempty"`
   111  }
   112  
   113  type WsSendTransactionReq struct {
   114  	Hex string `json:"hex"`
   115  }
   116  
   117  type WsSubscribeAddressesReq struct {
   118  	Addresses []string `json:"addresses"`
   119  }
   120  type WsSubscribeFiatRatesReq struct {
   121  	Currency string   `json:"currency,omitempty"`
   122  	Tokens   []string `json:"tokens,omitempty"`
   123  }
   124  
   125  type WsCurrentFiatRatesReq struct {
   126  	Currencies []string `json:"currencies,omitempty"`
   127  	Token      string   `json:"token,omitempty"`
   128  }
   129  
   130  type WsFiatRatesForTimestampsReq struct {
   131  	Timestamps []int64  `json:"timestamps"`
   132  	Currencies []string `json:"currencies,omitempty"`
   133  	Token      string   `json:"token,omitempty"`
   134  }
   135  
   136  type WsFiatRatesTickersListReq struct {
   137  	Timestamp int64  `json:"timestamp,omitempty"`
   138  	Token     string `json:"token,omitempty"`
   139  }