github.com/jimmyx0x/go-ethereum@v1.10.28/cmd/clef/datatypes.md (about)

     1  ## UI Client interface
     2  
     3  These data types are defined in the channel between clef and the UI
     4  ### SignDataRequest
     5  
     6  SignDataRequest contains information about a pending request to sign some data. The data to be signed can be of various types, defined by content-type. Clef has done most of the work in canonicalizing and making sense of the data, and it's up to the UI to present the user with the contents of the `message`
     7  
     8  Example:
     9  ```json
    10  {
    11    "content_type": "text/plain",
    12    "address": "0xDEADbEeF000000000000000000000000DeaDbeEf",
    13    "raw_data": "GUV0aGVyZXVtIFNpZ25lZCBNZXNzYWdlOgoxMWhlbGxvIHdvcmxk",
    14    "messages": [
    15      {
    16        "name": "message",
    17        "value": "\u0019Ethereum Signed Message:\n11hello world",
    18        "type": "text/plain"
    19      }
    20    ],
    21    "hash": "0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68",
    22    "meta": {
    23      "remote": "localhost:9999",
    24      "local": "localhost:8545",
    25      "scheme": "http",
    26      "User-Agent": "Firefox 3.2",
    27      "Origin": "www.malicious.ru"
    28    }
    29  }
    30  ```
    31  ### SignDataResponse - approve
    32  
    33  Response to SignDataRequest
    34  
    35  Example:
    36  ```json
    37  {
    38    "approved": true
    39  }
    40  ```
    41  ### SignDataResponse - deny
    42  
    43  Response to SignDataRequest
    44  
    45  Example:
    46  ```json
    47  {
    48    "approved": false
    49  }
    50  ```
    51  ### SignTxRequest
    52  
    53  SignTxRequest contains information about a pending request to sign a transaction. Aside from the transaction itself, there is also a `call_info`-struct. That struct contains messages of various types, that the user should be informed of.
    54  
    55  As in any request, it's important to consider that the `meta` info also contains untrusted data.
    56  
    57  The `transaction` (on input into clef) can have either `data` or `input` -- if both are set, they must be identical, otherwise an error is generated. However, Clef will always use `data` when passing this struct on (if Clef does otherwise, please file a ticket)
    58  
    59  Example:
    60  ```json
    61  {
    62    "transaction": {
    63      "from": "0xDEADbEeF000000000000000000000000DeaDbeEf",
    64      "to": null,
    65      "gas": "0x3e8",
    66      "gasPrice": "0x5",
    67      "value": "0x6",
    68      "nonce": "0x1",
    69      "data": "0x01020304"
    70    },
    71    "call_info": [
    72      {
    73        "type": "Warning",
    74        "message": "Something looks odd, show this message as a warning"
    75      },
    76      {
    77        "type": "Info",
    78        "message": "User should see this aswell"
    79      }
    80    ],
    81    "meta": {
    82      "remote": "localhost:9999",
    83      "local": "localhost:8545",
    84      "scheme": "http",
    85      "User-Agent": "Firefox 3.2",
    86      "Origin": "www.malicious.ru"
    87    }
    88  }
    89  ```
    90  ### SignTxResponse - approve
    91  
    92  Response to request to sign a transaction. This response needs to contain the `transaction`, because the UI is free to make modifications to the transaction.
    93  
    94  Example:
    95  ```json
    96  {
    97    "transaction": {
    98      "from": "0xDEADbEeF000000000000000000000000DeaDbeEf",
    99      "to": null,
   100      "gas": "0x3e8",
   101      "gasPrice": "0x5",
   102      "value": "0x6",
   103      "nonce": "0x4",
   104      "data": "0x04030201"
   105    },
   106    "approved": true
   107  }
   108  ```
   109  ### SignTxResponse - deny
   110  
   111  Response to SignTxRequest. When denying a request, there's no need to provide the transaction in return
   112  
   113  Example:
   114  ```json
   115  {
   116    "transaction": {
   117      "from": "0x",
   118      "to": null,
   119      "gas": "0x0",
   120      "gasPrice": "0x0",
   121      "value": "0x0",
   122      "nonce": "0x0",
   123      "data": null
   124    },
   125    "approved": false
   126  }
   127  ```
   128  ### OnApproved - SignTransactionResult
   129  
   130  SignTransactionResult is used in the call `clef` -> `OnApprovedTx(result)`
   131  
   132  This occurs _after_ successful completion of the entire signing procedure, but right before the signed transaction is passed to the external caller. This method (and data) can be used by the UI to signal to the user that the transaction was signed, but it is primarily useful for ruleset implementations.
   133  
   134  A ruleset that implements a rate limitation needs to know what transactions are sent out to the external interface. By hooking into this methods, the ruleset can maintain track of that count.
   135  
   136  **OBS:** Note that if an attacker can restore your `clef` data to a previous point in time (e.g through a backup), the attacker can reset such windows, even if he/she is unable to decrypt the content.
   137  
   138  The `OnApproved` method cannot be responded to, it's purely informative
   139  
   140  Example:
   141  ```json
   142  {
   143    "raw": "0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed",
   144    "tx": {
   145      "nonce": "0x64",
   146      "gasPrice": "0x1",
   147      "gas": "0x1",
   148      "to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192",
   149      "value": "0x1",
   150      "input": "0x",
   151      "v": "0x26",
   152      "r": "0x716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293",
   153      "s": "0x4e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed",
   154      "hash": "0x662f6d772692dd692f1b5e8baa77a9ff95bbd909362df3fc3d301aafebde5441"
   155    }
   156  }
   157  ```
   158  ### UserInputRequest
   159  
   160  Sent when clef needs the user to provide data. If 'password' is true, the input field should be treated accordingly (echo-free)
   161  
   162  Example:
   163  ```json
   164  {
   165    "prompt": "The question to ask the user",
   166    "title": "The title here",
   167    "isPassword": true
   168  }
   169  ```
   170  ### UserInputResponse
   171  
   172  Response to UserInputRequest
   173  
   174  Example:
   175  ```json
   176  {
   177    "text": "The textual response from user"
   178  }
   179  ```
   180  ### ListRequest
   181  
   182  Sent when a request has been made to list addresses. The UI is provided with the full `account`s, including local directory names. Note: this information is not passed back to the external caller, who only sees the `address`es.
   183  
   184  Example:
   185  ```json
   186  {
   187    "accounts": [
   188      {
   189        "address": "0xdeadbeef000000000000000000000000deadbeef",
   190        "url": "keystore:///path/to/keyfile/a"
   191      },
   192      {
   193        "address": "0x1111111122222222222233333333334444444444",
   194        "url": "keystore:///path/to/keyfile/b"
   195      }
   196    ],
   197    "meta": {
   198      "remote": "localhost:9999",
   199      "local": "localhost:8545",
   200      "scheme": "http",
   201      "User-Agent": "Firefox 3.2",
   202      "Origin": "www.malicious.ru"
   203    }
   204  }
   205  ```
   206  ### ListResponse
   207  
   208  Response to list request. The response contains a list of all addresses to show to the caller. Note: the UI is free to respond with any address the caller, regardless of whether it exists or not
   209  
   210  Example:
   211  ```json
   212  {
   213    "accounts": [
   214      {
   215        "address": "0x0000000000000000000000000000000000000000",
   216        "url": ".. ignored .."
   217      },
   218      {
   219        "address": "0xffffffffffffffffffffffffffffffffffffffff",
   220        "url": ""
   221      }
   222    ]
   223  }
   224  ```