github.com/jincm/wesharechain@v0.0.0-20210122032815-1537409ce26a/chain/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 presentthe 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 "message": [ 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 "Password": "apassword" 40 } 41 ``` 42 ### SignDataResponse - deny 43 44 Response to SignDataRequest 45 46 Example: 47 ```json 48 { 49 "approved": false, 50 "Password": "" 51 } 52 ``` 53 ### SignTxRequest 54 55 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. 56 57 As in any request, it's important to consider that the `meta` info also contains untrusted data. 58 59 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) 60 61 Example: 62 ```json 63 { 64 "transaction": { 65 "from": "0xDEADbEeF000000000000000000000000DeaDbeEf", 66 "to": null, 67 "gas": "0x3e8", 68 "gasPrice": "0x5", 69 "value": "0x6", 70 "nonce": "0x1", 71 "data": "0x01020304" 72 }, 73 "call_info": [ 74 { 75 "type": "Warning", 76 "message": "Something looks odd, show this message as a warning" 77 }, 78 { 79 "type": "Info", 80 "message": "User should see this aswell" 81 } 82 ], 83 "meta": { 84 "remote": "localhost:9999", 85 "local": "localhost:8545", 86 "scheme": "http", 87 "User-Agent": "Firefox 3.2", 88 "Origin": "www.malicious.ru" 89 } 90 } 91 ``` 92 ### SignDataResponse - approve 93 94 Response to SignDataRequest. This response needs to contain the `transaction`, because the UI is free to make modifications to the transaction. 95 96 Example: 97 ```json 98 { 99 "transaction": { 100 "from": "0xDEADbEeF000000000000000000000000DeaDbeEf", 101 "to": null, 102 "gas": "0x3e8", 103 "gasPrice": "0x5", 104 "value": "0x6", 105 "nonce": "0x4", 106 "data": "0x04030201" 107 }, 108 "approved": true, 109 "password": "apassword" 110 } 111 ``` 112 ### SignDataResponse - deny 113 114 Response to SignDataRequest. When denying a request, there's no need to provide the transaction in return 115 116 Example: 117 ```json 118 { 119 "approved": false, 120 "Password": "" 121 } 122 ``` 123 ### OnApproved - SignTransactionResult 124 125 SignTransactionResult is used in the call `clef` -> `OnApprovedTx(result)` 126 127 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. 128 129 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. 130 131 **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. 132 133 The `OnApproved` method cannot be responded to, it's purely informative 134 135 Example: 136 ```json 137 { 138 "raw": "0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed", 139 "tx": { 140 "nonce": "0x64", 141 "gasPrice": "0x1", 142 "gas": "0x1", 143 "to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192", 144 "value": "0x1", 145 "input": "0x", 146 "v": "0x26", 147 "r": "0x716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293", 148 "s": "0x4e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed", 149 "hash": "0x662f6d772692dd692f1b5e8baa77a9ff95bbd909362df3fc3d301aafebde5441" 150 } 151 } 152 ``` 153 ### UserInputRequest 154 155 Sent when clef needs the user to provide data. If 'password' is true, the input field should be treated accordingly (echo-free) 156 157 Example: 158 ```json 159 { 160 "prompt": "The question to ask the user", 161 "title": "The title here", 162 "isPassword": true 163 } 164 ``` 165 ### UserInputResponse 166 167 Response to SignDataRequest 168 169 Example: 170 ```json 171 { 172 "text": "The textual response from user" 173 } 174 ``` 175 ### ListRequest 176 177 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. 178 179 Example: 180 ```json 181 { 182 "accounts": [ 183 { 184 "address": "0xdeadbeef000000000000000000000000deadbeef", 185 "url": "keystore:///path/to/keyfile/a" 186 }, 187 { 188 "address": "0x1111111122222222222233333333334444444444", 189 "url": "keystore:///path/to/keyfile/b" 190 } 191 ], 192 "meta": { 193 "remote": "localhost:9999", 194 "local": "localhost:8545", 195 "scheme": "http", 196 "User-Agent": "Firefox 3.2", 197 "Origin": "www.malicious.ru" 198 } 199 } 200 ``` 201 ### UserInputResponse 202 203 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 204 205 Example: 206 ```json 207 { 208 "accounts": [ 209 { 210 "address": "0x0000000000000000000000000000000000000000", 211 "url": ".. ignored .." 212 }, 213 { 214 "address": "0xffffffffffffffffffffffffffffffffffffffff", 215 "url": "" 216 } 217 ] 218 } 219 ```