| 1 | // Copyright (c) 2016-2022, The Monero Project |
| 2 | // |
| 3 | // All rights reserved. |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without modification, are |
| 6 | // permitted provided that the following conditions are met: |
| 7 | // |
| 8 | // 1. Redistributions of source code must retain the above copyright notice, this list of |
| 9 | // conditions and the following disclaimer. |
| 10 | // |
| 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list |
| 12 | // of conditions and the following disclaimer in the documentation and/or other |
| 13 | // materials provided with the distribution. |
| 14 | // |
| 15 | // 3. Neither the name of the copyright holder nor the names of its contributors may be |
| 16 | // used to endorse or promote products derived from this software without specific |
| 17 | // prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 20 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 22 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
| 27 | // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | |
| 29 | #include "daemon_messages.h" |
| 30 | #include "serialization/json_object.h" |
| 31 | |
| 32 | namespace cryptonote |
| 33 | { |
| 34 | |
| 35 | namespace rpc |
| 36 | { |
| 37 | void GetHeight::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 38 | {} |
| 39 | |
| 40 | void GetHeight::Request::fromJson(const rapidjson::Value& val) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | void GetHeight::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 45 | { |
| 46 | INSERT_INTO_JSON_OBJECT(dest, height, height); |
| 47 | } |
| 48 | |
| 49 | void GetHeight::Response::fromJson(const rapidjson::Value& val) |
| 50 | { |
| 51 | if (!val.IsObject()) |
| 52 | { |
| 53 | throw json::WRONG_TYPE("json object"); |
| 54 | } |
| 55 | |
| 56 | GET_FROM_JSON_OBJECT(val, height, height); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | void GetBlocksFast::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 61 | { |
| 62 | INSERT_INTO_JSON_OBJECT(dest, block_ids, block_ids); |
| 63 | INSERT_INTO_JSON_OBJECT(dest, start_height, start_height); |
| 64 | INSERT_INTO_JSON_OBJECT(dest, prune, prune); |
| 65 | } |
| 66 | |
| 67 | void GetBlocksFast::Request::fromJson(const rapidjson::Value& val) |
| 68 | { |
| 69 | if (!val.IsObject()) |
| 70 | { |
| 71 | throw json::WRONG_TYPE("json object"); |
| 72 | } |
| 73 | |
| 74 | GET_FROM_JSON_OBJECT(val, block_ids, block_ids); |
| 75 | GET_FROM_JSON_OBJECT(val, start_height, start_height); |
| 76 | GET_FROM_JSON_OBJECT(val, prune, prune); |
| 77 | } |
| 78 | |
| 79 | void GetBlocksFast::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 80 | { |
| 81 | INSERT_INTO_JSON_OBJECT(dest, blocks, blocks); |
| 82 | INSERT_INTO_JSON_OBJECT(dest, start_height, start_height); |
| 83 | INSERT_INTO_JSON_OBJECT(dest, current_height, current_height); |
| 84 | INSERT_INTO_JSON_OBJECT(dest, output_indices, output_indices); |
| 85 | } |
| 86 | |
| 87 | void GetBlocksFast::Response::fromJson(const rapidjson::Value& val) |
| 88 | { |
| 89 | if (!val.IsObject()) |
| 90 | { |
| 91 | throw json::WRONG_TYPE("json object"); |
| 92 | } |
| 93 | |
| 94 | GET_FROM_JSON_OBJECT(val, blocks, blocks); |
| 95 | GET_FROM_JSON_OBJECT(val, start_height, start_height); |
| 96 | GET_FROM_JSON_OBJECT(val, current_height, current_height); |
| 97 | GET_FROM_JSON_OBJECT(val, output_indices, output_indices); |
| 98 | } |
| 99 | |
| 100 | |
| 101 | void GetHashesFast::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 102 | { |
| 103 | INSERT_INTO_JSON_OBJECT(dest, known_hashes, known_hashes); |
| 104 | INSERT_INTO_JSON_OBJECT(dest, start_height, start_height); |
| 105 | } |
| 106 | |
| 107 | void GetHashesFast::Request::fromJson(const rapidjson::Value& val) |
| 108 | { |
| 109 | if (!val.IsObject()) |
| 110 | { |
| 111 | throw json::WRONG_TYPE("json object"); |
| 112 | } |
| 113 | |
| 114 | GET_FROM_JSON_OBJECT(val, known_hashes, known_hashes); |
| 115 | GET_FROM_JSON_OBJECT(val, start_height, start_height); |
| 116 | } |
| 117 | |
| 118 | void GetHashesFast::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 119 | { |
| 120 | INSERT_INTO_JSON_OBJECT(dest, hashes, hashes); |
| 121 | INSERT_INTO_JSON_OBJECT(dest, start_height, start_height); |
| 122 | INSERT_INTO_JSON_OBJECT(dest, current_height, current_height); |
| 123 | |
| 124 | } |
| 125 | |
| 126 | void GetHashesFast::Response::fromJson(const rapidjson::Value& val) |
| 127 | { |
| 128 | if (!val.IsObject()) |
| 129 | { |
| 130 | throw json::WRONG_TYPE("json object"); |
| 131 | } |
| 132 | |
| 133 | GET_FROM_JSON_OBJECT(val, hashes, hashes); |
| 134 | GET_FROM_JSON_OBJECT(val, start_height, start_height); |
| 135 | GET_FROM_JSON_OBJECT(val, current_height, current_height); |
| 136 | } |
| 137 | |
| 138 | |
| 139 | void GetTransactions::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 140 | { |
| 141 | INSERT_INTO_JSON_OBJECT(dest, tx_hashes, tx_hashes); |
| 142 | } |
| 143 | |
| 144 | void GetTransactions::Request::fromJson(const rapidjson::Value& val) |
| 145 | { |
| 146 | if (!val.IsObject()) |
| 147 | { |
| 148 | throw json::WRONG_TYPE("json object"); |
| 149 | } |
| 150 | |
| 151 | GET_FROM_JSON_OBJECT(val, tx_hashes, tx_hashes); |
| 152 | } |
| 153 | |
| 154 | void GetTransactions::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 155 | { |
| 156 | INSERT_INTO_JSON_OBJECT(dest, txs, txs); |
| 157 | INSERT_INTO_JSON_OBJECT(dest, missed_hashes, missed_hashes); |
| 158 | } |
| 159 | |
| 160 | void GetTransactions::Response::fromJson(const rapidjson::Value& val) |
| 161 | { |
| 162 | if (!val.IsObject()) |
| 163 | { |
| 164 | throw json::WRONG_TYPE("json object"); |
| 165 | } |
| 166 | |
| 167 | GET_FROM_JSON_OBJECT(val, txs, txs); |
| 168 | GET_FROM_JSON_OBJECT(val, missed_hashes, missed_hashes); |
| 169 | } |
| 170 | |
| 171 | |
| 172 | void KeyImagesSpent::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 173 | { |
| 174 | INSERT_INTO_JSON_OBJECT(dest, key_images, key_images); |
| 175 | } |
| 176 | |
| 177 | void KeyImagesSpent::Request::fromJson(const rapidjson::Value& val) |
| 178 | { |
| 179 | if (!val.IsObject()) |
| 180 | { |
| 181 | throw json::WRONG_TYPE("json object"); |
| 182 | } |
| 183 | |
| 184 | GET_FROM_JSON_OBJECT(val, key_images, key_images); |
| 185 | } |
| 186 | |
| 187 | void KeyImagesSpent::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 188 | { |
| 189 | INSERT_INTO_JSON_OBJECT(dest, spent_status, spent_status); |
| 190 | } |
| 191 | |
| 192 | void KeyImagesSpent::Response::fromJson(const rapidjson::Value& val) |
| 193 | { |
| 194 | if (!val.IsObject()) |
| 195 | { |
| 196 | throw json::WRONG_TYPE("json object"); |
| 197 | } |
| 198 | |
| 199 | GET_FROM_JSON_OBJECT(val, spent_status, spent_status); |
| 200 | } |
| 201 | |
| 202 | |
| 203 | void GetTxGlobalOutputIndices::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 204 | { |
| 205 | INSERT_INTO_JSON_OBJECT(dest, tx_hash, tx_hash); |
| 206 | } |
| 207 | |
| 208 | void GetTxGlobalOutputIndices::Request::fromJson(const rapidjson::Value& val) |
| 209 | { |
| 210 | if (!val.IsObject()) |
| 211 | { |
| 212 | throw json::WRONG_TYPE("json object"); |
| 213 | } |
| 214 | |
| 215 | GET_FROM_JSON_OBJECT(val, tx_hash, tx_hash); |
| 216 | } |
| 217 | |
| 218 | void GetTxGlobalOutputIndices::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 219 | { |
| 220 | INSERT_INTO_JSON_OBJECT(dest, output_indices, output_indices); |
| 221 | } |
| 222 | |
| 223 | void GetTxGlobalOutputIndices::Response::fromJson(const rapidjson::Value& val) |
| 224 | { |
| 225 | if (!val.IsObject()) |
| 226 | { |
| 227 | throw json::WRONG_TYPE("json object"); |
| 228 | } |
| 229 | |
| 230 | GET_FROM_JSON_OBJECT(val, output_indices, output_indices); |
| 231 | } |
| 232 | |
| 233 | void SendRawTx::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 234 | { |
| 235 | INSERT_INTO_JSON_OBJECT(dest, tx, tx); |
| 236 | INSERT_INTO_JSON_OBJECT(dest, relay, relay); |
| 237 | } |
| 238 | |
| 239 | void SendRawTx::Request::fromJson(const rapidjson::Value& val) |
| 240 | { |
| 241 | if (!val.IsObject()) |
| 242 | { |
| 243 | throw json::WRONG_TYPE("json object"); |
| 244 | } |
| 245 | |
| 246 | GET_FROM_JSON_OBJECT(val, tx, tx); |
| 247 | GET_FROM_JSON_OBJECT(val, relay, relay); |
| 248 | } |
| 249 | |
| 250 | void SendRawTx::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 251 | { |
| 252 | INSERT_INTO_JSON_OBJECT(dest, relayed, relayed); |
| 253 | } |
| 254 | |
| 255 | |
| 256 | void SendRawTx::Response::fromJson(const rapidjson::Value& val) |
| 257 | { |
| 258 | if (!val.IsObject()) |
| 259 | { |
| 260 | throw json::WRONG_TYPE("json object"); |
| 261 | } |
| 262 | |
| 263 | GET_FROM_JSON_OBJECT(val, relayed, relayed); |
| 264 | } |
| 265 | |
| 266 | void SendRawTxHex::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 267 | { |
| 268 | INSERT_INTO_JSON_OBJECT(dest, tx_as_hex, tx_as_hex); |
| 269 | INSERT_INTO_JSON_OBJECT(dest, relay, relay); |
| 270 | } |
| 271 | |
| 272 | void SendRawTxHex::Request::fromJson(const rapidjson::Value& val) |
| 273 | { |
| 274 | if (!val.IsObject()) |
| 275 | { |
| 276 | throw json::WRONG_TYPE("json object"); |
| 277 | } |
| 278 | |
| 279 | GET_FROM_JSON_OBJECT(val, tx_as_hex, tx_as_hex); |
| 280 | GET_FROM_JSON_OBJECT(val, relay, relay); |
| 281 | } |
| 282 | |
| 283 | void StartMining::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 284 | { |
| 285 | INSERT_INTO_JSON_OBJECT(dest, miner_address, miner_address); |
| 286 | INSERT_INTO_JSON_OBJECT(dest, threads_count, threads_count); |
| 287 | INSERT_INTO_JSON_OBJECT(dest, do_background_mining, do_background_mining); |
| 288 | INSERT_INTO_JSON_OBJECT(dest, ignore_battery, ignore_battery); |
| 289 | } |
| 290 | |
| 291 | void StartMining::Request::fromJson(const rapidjson::Value& val) |
| 292 | { |
| 293 | if (!val.IsObject()) |
| 294 | { |
| 295 | throw json::WRONG_TYPE("json object"); |
| 296 | } |
| 297 | |
| 298 | GET_FROM_JSON_OBJECT(val, miner_address, miner_address); |
| 299 | GET_FROM_JSON_OBJECT(val, threads_count, threads_count); |
| 300 | GET_FROM_JSON_OBJECT(val, do_background_mining, do_background_mining); |
| 301 | GET_FROM_JSON_OBJECT(val, ignore_battery, ignore_battery); |
| 302 | } |
| 303 | |
| 304 | void StartMining::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 305 | {} |
| 306 | |
| 307 | void StartMining::Response::fromJson(const rapidjson::Value& val) |
| 308 | { |
| 309 | } |
| 310 | |
| 311 | |
| 312 | void StopMining::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 313 | {} |
| 314 | |
| 315 | void StopMining::Request::fromJson(const rapidjson::Value& val) |
| 316 | { |
| 317 | } |
| 318 | |
| 319 | void StopMining::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 320 | {} |
| 321 | |
| 322 | void StopMining::Response::fromJson(const rapidjson::Value& val) |
| 323 | { |
| 324 | } |
| 325 | |
| 326 | |
| 327 | void MiningStatus::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 328 | {} |
| 329 | |
| 330 | void MiningStatus::Request::fromJson(const rapidjson::Value& val) |
| 331 | { |
| 332 | } |
| 333 | |
| 334 | void MiningStatus::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 335 | { |
| 336 | INSERT_INTO_JSON_OBJECT(dest, active, active); |
| 337 | INSERT_INTO_JSON_OBJECT(dest, speed, speed); |
| 338 | INSERT_INTO_JSON_OBJECT(dest, threads_count, threads_count); |
| 339 | INSERT_INTO_JSON_OBJECT(dest, address, address); |
| 340 | INSERT_INTO_JSON_OBJECT(dest, is_background_mining_enabled, is_background_mining_enabled); |
| 341 | } |
| 342 | |
| 343 | void MiningStatus::Response::fromJson(const rapidjson::Value& val) |
| 344 | { |
| 345 | if (!val.IsObject()) |
| 346 | { |
| 347 | throw json::WRONG_TYPE("json object"); |
| 348 | } |
| 349 | |
| 350 | GET_FROM_JSON_OBJECT(val, active, active); |
| 351 | GET_FROM_JSON_OBJECT(val, speed, speed); |
| 352 | GET_FROM_JSON_OBJECT(val, threads_count, threads_count); |
| 353 | GET_FROM_JSON_OBJECT(val, address, address); |
| 354 | GET_FROM_JSON_OBJECT(val, is_background_mining_enabled, is_background_mining_enabled); |
| 355 | } |
| 356 | |
| 357 | |
| 358 | void GetInfo::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 359 | {} |
| 360 | |
| 361 | void GetInfo::Request::fromJson(const rapidjson::Value& val) |
| 362 | { |
| 363 | } |
| 364 | |
| 365 | void GetInfo::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 366 | { |
| 367 | INSERT_INTO_JSON_OBJECT(dest, info, info); |
| 368 | } |
| 369 | |
| 370 | void GetInfo::Response::fromJson(const rapidjson::Value& val) |
| 371 | { |
| 372 | if (!val.IsObject()) |
| 373 | { |
| 374 | throw json::WRONG_TYPE("json object"); |
| 375 | } |
| 376 | |
| 377 | GET_FROM_JSON_OBJECT(val, info, info); |
| 378 | } |
| 379 | |
| 380 | |
| 381 | void SaveBC::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 382 | {} |
| 383 | |
| 384 | void SaveBC::Request::fromJson(const rapidjson::Value& val) |
| 385 | { |
| 386 | } |
| 387 | |
| 388 | void SaveBC::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 389 | {} |
| 390 | |
| 391 | void SaveBC::Response::fromJson(const rapidjson::Value& val) |
| 392 | { |
| 393 | } |
| 394 | |
| 395 | |
| 396 | void GetBlockHash::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 397 | { |
| 398 | INSERT_INTO_JSON_OBJECT(dest, height, height); |
| 399 | } |
| 400 | |
| 401 | void GetBlockHash::Request::fromJson(const rapidjson::Value& val) |
| 402 | { |
| 403 | if (!val.IsObject()) |
| 404 | { |
| 405 | throw json::WRONG_TYPE("json object"); |
| 406 | } |
| 407 | |
| 408 | GET_FROM_JSON_OBJECT(val, height, height); |
| 409 | } |
| 410 | |
| 411 | void GetBlockHash::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 412 | { |
| 413 | INSERT_INTO_JSON_OBJECT(dest, hash, hash); |
| 414 | } |
| 415 | |
| 416 | void GetBlockHash::Response::fromJson(const rapidjson::Value& val) |
| 417 | { |
| 418 | if (!val.IsObject()) |
| 419 | { |
| 420 | throw json::WRONG_TYPE("json object"); |
| 421 | } |
| 422 | |
| 423 | GET_FROM_JSON_OBJECT(val, hash, hash); |
| 424 | } |
| 425 | |
| 426 | |
| 427 | void GetLastBlockHeader::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 428 | {} |
| 429 | |
| 430 | void GetLastBlockHeader::Request::fromJson(const rapidjson::Value& val) |
| 431 | { |
| 432 | } |
| 433 | |
| 434 | void GetLastBlockHeader::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 435 | { |
| 436 | INSERT_INTO_JSON_OBJECT(dest, header, header); |
| 437 | } |
| 438 | |
| 439 | void GetLastBlockHeader::Response::fromJson(const rapidjson::Value& val) |
| 440 | { |
| 441 | if (!val.IsObject()) |
| 442 | { |
| 443 | throw json::WRONG_TYPE("json object"); |
| 444 | } |
| 445 | |
| 446 | GET_FROM_JSON_OBJECT(val, header, header); |
| 447 | } |
| 448 | |
| 449 | |
| 450 | void GetBlockHeaderByHash::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 451 | { |
| 452 | INSERT_INTO_JSON_OBJECT(dest, hash, hash); |
| 453 | } |
| 454 | |
| 455 | void GetBlockHeaderByHash::Request::fromJson(const rapidjson::Value& val) |
| 456 | { |
| 457 | if (!val.IsObject()) |
| 458 | { |
| 459 | throw json::WRONG_TYPE("json object"); |
| 460 | } |
| 461 | |
| 462 | GET_FROM_JSON_OBJECT(val, hash, hash); |
| 463 | } |
| 464 | |
| 465 | void GetBlockHeaderByHash::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 466 | { |
| 467 | INSERT_INTO_JSON_OBJECT(dest, header, header); |
| 468 | } |
| 469 | |
| 470 | void GetBlockHeaderByHash::Response::fromJson(const rapidjson::Value& val) |
| 471 | { |
| 472 | if (!val.IsObject()) |
| 473 | { |
| 474 | throw json::WRONG_TYPE("json object"); |
| 475 | } |
| 476 | |
| 477 | GET_FROM_JSON_OBJECT(val, header, header); |
| 478 | } |
| 479 | |
| 480 | |
| 481 | void GetBlockHeaderByHeight::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 482 | { |
| 483 | INSERT_INTO_JSON_OBJECT(dest, height, height); |
| 484 | } |
| 485 | |
| 486 | void GetBlockHeaderByHeight::Request::fromJson(const rapidjson::Value& val) |
| 487 | { |
| 488 | if (!val.IsObject()) |
| 489 | { |
| 490 | throw json::WRONG_TYPE("json object"); |
| 491 | } |
| 492 | |
| 493 | GET_FROM_JSON_OBJECT(val, height, height); |
| 494 | } |
| 495 | |
| 496 | void GetBlockHeaderByHeight::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 497 | { |
| 498 | INSERT_INTO_JSON_OBJECT(dest, header, header); |
| 499 | } |
| 500 | |
| 501 | void GetBlockHeaderByHeight::Response::fromJson(const rapidjson::Value& val) |
| 502 | { |
| 503 | if (!val.IsObject()) |
| 504 | { |
| 505 | throw json::WRONG_TYPE("json object"); |
| 506 | } |
| 507 | |
| 508 | GET_FROM_JSON_OBJECT(val, header, header); |
| 509 | } |
| 510 | |
| 511 | |
| 512 | void GetBlockHeadersByHeight::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 513 | { |
| 514 | INSERT_INTO_JSON_OBJECT(dest, heights, heights); |
| 515 | } |
| 516 | |
| 517 | void GetBlockHeadersByHeight::Request::fromJson(const rapidjson::Value& val) |
| 518 | { |
| 519 | if (!val.IsObject()) |
| 520 | { |
| 521 | throw json::WRONG_TYPE("json object"); |
| 522 | } |
| 523 | |
| 524 | GET_FROM_JSON_OBJECT(val, heights, heights); |
| 525 | } |
| 526 | |
| 527 | void GetBlockHeadersByHeight::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 528 | { |
| 529 | INSERT_INTO_JSON_OBJECT(dest, headers, headers); |
| 530 | } |
| 531 | |
| 532 | void GetBlockHeadersByHeight::Response::fromJson(const rapidjson::Value& val) |
| 533 | { |
| 534 | if (!val.IsObject()) |
| 535 | { |
| 536 | throw json::WRONG_TYPE("json object"); |
| 537 | } |
| 538 | |
| 539 | GET_FROM_JSON_OBJECT(val, headers, headers); |
| 540 | } |
| 541 | |
| 542 | |
| 543 | void GetPeerList::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 544 | {} |
| 545 | |
| 546 | void GetPeerList::Request::fromJson(const rapidjson::Value& val) |
| 547 | { |
| 548 | } |
| 549 | |
| 550 | void GetPeerList::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 551 | { |
| 552 | INSERT_INTO_JSON_OBJECT(dest, white_list, white_list); |
| 553 | INSERT_INTO_JSON_OBJECT(dest, gray_list, gray_list); |
| 554 | } |
| 555 | |
| 556 | void GetPeerList::Response::fromJson(const rapidjson::Value& val) |
| 557 | { |
| 558 | if (!val.IsObject()) |
| 559 | { |
| 560 | throw json::WRONG_TYPE("json object"); |
| 561 | } |
| 562 | |
| 563 | GET_FROM_JSON_OBJECT(val, white_list, white_list); |
| 564 | GET_FROM_JSON_OBJECT(val, gray_list, gray_list); |
| 565 | } |
| 566 | |
| 567 | |
| 568 | void SetLogLevel::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 569 | { |
| 570 | INSERT_INTO_JSON_OBJECT(dest, level, level); |
| 571 | } |
| 572 | |
| 573 | void SetLogLevel::Request::fromJson(const rapidjson::Value& val) |
| 574 | { |
| 575 | if (!val.IsObject()) |
| 576 | { |
| 577 | throw json::WRONG_TYPE("json object"); |
| 578 | } |
| 579 | |
| 580 | GET_FROM_JSON_OBJECT(val, level, level); |
| 581 | } |
| 582 | |
| 583 | void SetLogLevel::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 584 | {} |
| 585 | |
| 586 | void SetLogLevel::Response::fromJson(const rapidjson::Value& val) |
| 587 | { |
| 588 | } |
| 589 | |
| 590 | |
| 591 | void GetTransactionPool::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 592 | {} |
| 593 | |
| 594 | void GetTransactionPool::Request::fromJson(const rapidjson::Value& val) |
| 595 | { |
| 596 | } |
| 597 | |
| 598 | void GetTransactionPool::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 599 | { |
| 600 | INSERT_INTO_JSON_OBJECT(dest, transactions, transactions); |
| 601 | INSERT_INTO_JSON_OBJECT(dest, key_images, key_images); |
| 602 | } |
| 603 | |
| 604 | void GetTransactionPool::Response::fromJson(const rapidjson::Value& val) |
| 605 | { |
| 606 | if (!val.IsObject()) |
| 607 | { |
| 608 | throw json::WRONG_TYPE("json object"); |
| 609 | } |
| 610 | |
| 611 | GET_FROM_JSON_OBJECT(val, transactions, transactions); |
| 612 | GET_FROM_JSON_OBJECT(val, key_images, key_images); |
| 613 | } |
| 614 | |
| 615 | |
| 616 | void HardForkInfo::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 617 | { |
| 618 | INSERT_INTO_JSON_OBJECT(dest, version, version); |
| 619 | } |
| 620 | |
| 621 | void HardForkInfo::Request::fromJson(const rapidjson::Value& val) |
| 622 | { |
| 623 | if (!val.IsObject()) |
| 624 | { |
| 625 | throw json::WRONG_TYPE("json object"); |
| 626 | } |
| 627 | |
| 628 | GET_FROM_JSON_OBJECT(val, version, version); |
| 629 | } |
| 630 | |
| 631 | void HardForkInfo::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 632 | { |
| 633 | INSERT_INTO_JSON_OBJECT(dest, info, info); |
| 634 | } |
| 635 | |
| 636 | void HardForkInfo::Response::fromJson(const rapidjson::Value& val) |
| 637 | { |
| 638 | if (!val.IsObject()) |
| 639 | { |
| 640 | throw json::WRONG_TYPE("json object"); |
| 641 | } |
| 642 | |
| 643 | GET_FROM_JSON_OBJECT(val, info, info); |
| 644 | } |
| 645 | |
| 646 | |
| 647 | void GetOutputHistogram::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 648 | { |
| 649 | INSERT_INTO_JSON_OBJECT(dest, amounts, amounts); |
| 650 | INSERT_INTO_JSON_OBJECT(dest, min_count, min_count); |
| 651 | INSERT_INTO_JSON_OBJECT(dest, max_count, max_count); |
| 652 | INSERT_INTO_JSON_OBJECT(dest, unlocked, unlocked); |
| 653 | INSERT_INTO_JSON_OBJECT(dest, recent_cutoff, recent_cutoff); |
| 654 | } |
| 655 | |
| 656 | void GetOutputHistogram::Request::fromJson(const rapidjson::Value& val) |
| 657 | { |
| 658 | if (!val.IsObject()) |
| 659 | { |
| 660 | throw json::WRONG_TYPE("json object"); |
| 661 | } |
| 662 | |
| 663 | GET_FROM_JSON_OBJECT(val, amounts, amounts); |
| 664 | GET_FROM_JSON_OBJECT(val, min_count, min_count); |
| 665 | GET_FROM_JSON_OBJECT(val, max_count, max_count); |
| 666 | GET_FROM_JSON_OBJECT(val, unlocked, unlocked); |
| 667 | GET_FROM_JSON_OBJECT(val, recent_cutoff, recent_cutoff); |
| 668 | } |
| 669 | |
| 670 | void GetOutputHistogram::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 671 | { |
| 672 | INSERT_INTO_JSON_OBJECT(dest, histogram, histogram); |
| 673 | } |
| 674 | |
| 675 | void GetOutputHistogram::Response::fromJson(const rapidjson::Value& val) |
| 676 | { |
| 677 | if (!val.IsObject()) |
| 678 | { |
| 679 | throw json::WRONG_TYPE("json object"); |
| 680 | } |
| 681 | |
| 682 | GET_FROM_JSON_OBJECT(val, histogram, histogram); |
| 683 | } |
| 684 | |
| 685 | |
| 686 | void GetOutputKeys::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 687 | { |
| 688 | INSERT_INTO_JSON_OBJECT(dest, outputs, outputs); |
| 689 | } |
| 690 | |
| 691 | void GetOutputKeys::Request::fromJson(const rapidjson::Value& val) |
| 692 | { |
| 693 | if (!val.IsObject()) |
| 694 | { |
| 695 | throw json::WRONG_TYPE("json object"); |
| 696 | } |
| 697 | |
| 698 | GET_FROM_JSON_OBJECT(val, outputs, outputs); |
| 699 | } |
| 700 | |
| 701 | void GetOutputKeys::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 702 | { |
| 703 | INSERT_INTO_JSON_OBJECT(dest, keys, keys); |
| 704 | } |
| 705 | |
| 706 | void GetOutputKeys::Response::fromJson(const rapidjson::Value& val) |
| 707 | { |
| 708 | if (!val.IsObject()) |
| 709 | { |
| 710 | throw json::WRONG_TYPE("json object"); |
| 711 | } |
| 712 | |
| 713 | GET_FROM_JSON_OBJECT(val, keys, keys); |
| 714 | } |
| 715 | |
| 716 | |
| 717 | void GetRPCVersion::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 718 | {} |
| 719 | |
| 720 | void GetRPCVersion::Request::fromJson(const rapidjson::Value& val) |
| 721 | { |
| 722 | } |
| 723 | |
| 724 | void GetRPCVersion::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 725 | { |
| 726 | INSERT_INTO_JSON_OBJECT(dest, version, version); |
| 727 | } |
| 728 | |
| 729 | void GetRPCVersion::Response::fromJson(const rapidjson::Value& val) |
| 730 | { |
| 731 | if (!val.IsObject()) |
| 732 | { |
| 733 | throw json::WRONG_TYPE("json object"); |
| 734 | } |
| 735 | |
| 736 | GET_FROM_JSON_OBJECT(val, version, version); |
| 737 | } |
| 738 | |
| 739 | void GetFeeEstimate::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 740 | { |
| 741 | INSERT_INTO_JSON_OBJECT(dest, num_grace_blocks, num_grace_blocks); |
| 742 | } |
| 743 | |
| 744 | void GetFeeEstimate::Request::fromJson(const rapidjson::Value& val) |
| 745 | { |
| 746 | if (!val.IsObject()) |
| 747 | { |
| 748 | throw json::WRONG_TYPE("json object"); |
| 749 | } |
| 750 | |
| 751 | GET_FROM_JSON_OBJECT(val, num_grace_blocks, num_grace_blocks); |
| 752 | } |
| 753 | |
| 754 | void GetFeeEstimate::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 755 | { |
| 756 | INSERT_INTO_JSON_OBJECT(dest, fees, fees); |
| 757 | INSERT_INTO_JSON_OBJECT(dest, estimated_base_fee, estimated_base_fee); |
| 758 | INSERT_INTO_JSON_OBJECT(dest, fee_mask, fee_mask); |
| 759 | INSERT_INTO_JSON_OBJECT(dest, size_scale, size_scale); |
| 760 | INSERT_INTO_JSON_OBJECT(dest, hard_fork_version, hard_fork_version); |
| 761 | } |
| 762 | |
| 763 | void GetFeeEstimate::Response::fromJson(const rapidjson::Value& val) |
| 764 | { |
| 765 | if (!val.IsObject()) |
| 766 | { |
| 767 | throw json::WRONG_TYPE("json object"); |
| 768 | } |
| 769 | |
| 770 | GET_FROM_JSON_OBJECT(val, fees, fees); |
| 771 | GET_FROM_JSON_OBJECT(val, estimated_base_fee, estimated_base_fee); |
| 772 | GET_FROM_JSON_OBJECT(val, fee_mask, fee_mask); |
| 773 | GET_FROM_JSON_OBJECT(val, size_scale, size_scale); |
| 774 | GET_FROM_JSON_OBJECT(val, hard_fork_version, hard_fork_version); |
| 775 | } |
| 776 | |
| 777 | void GetOutputDistribution::Request::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 778 | { |
| 779 | INSERT_INTO_JSON_OBJECT(dest, amounts, amounts); |
| 780 | INSERT_INTO_JSON_OBJECT(dest, from_height, from_height); |
| 781 | INSERT_INTO_JSON_OBJECT(dest, to_height, to_height); |
| 782 | INSERT_INTO_JSON_OBJECT(dest, cumulative, cumulative); |
| 783 | } |
| 784 | |
| 785 | void GetOutputDistribution::Request::fromJson(const rapidjson::Value& val) |
| 786 | { |
| 787 | if (!val.IsObject()) |
| 788 | { |
| 789 | throw json::WRONG_TYPE("json object"); |
| 790 | } |
| 791 | |
| 792 | GET_FROM_JSON_OBJECT(val, amounts, amounts); |
| 793 | GET_FROM_JSON_OBJECT(val, from_height, from_height); |
| 794 | GET_FROM_JSON_OBJECT(val, to_height, to_height); |
| 795 | GET_FROM_JSON_OBJECT(val, cumulative, cumulative); |
| 796 | } |
| 797 | |
| 798 | void GetOutputDistribution::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const |
| 799 | { |
| 800 | INSERT_INTO_JSON_OBJECT(dest, status, status); |
| 801 | INSERT_INTO_JSON_OBJECT(dest, distributions, distributions); |
| 802 | } |
| 803 | |
| 804 | void GetOutputDistribution::Response::fromJson(const rapidjson::Value& val) |
| 805 | { |
| 806 | if (!val.IsObject()) |
| 807 | { |
| 808 | throw json::WRONG_TYPE("json object"); |
| 809 | } |
| 810 | |
| 811 | GET_FROM_JSON_OBJECT(val, status, status); |
| 812 | GET_FROM_JSON_OBJECT(val, distributions, distributions); |
| 813 | } |
| 814 | |
| 815 | } // namespace rpc |
| 816 | |
| 817 | } // namespace cryptonote |