{"action":"created","issue":{"url":"https://api.github.com/repos/turtlecoin/turtlecoin/issues/603","repository_url":"https://api.github.com/repos/turtlecoin/turtlecoin","labels_url":"https://api.github.com/repos/turtlecoin/turtlecoin/issues/603/labels{/name}","comments_url":"https://api.github.com/repos/turtlecoin/turtlecoin/issues/603/comments","events_url":"https://api.github.com/repos/turtlecoin/turtlecoin/issues/603/events","html_url":"https://github.com/turtlecoin/turtlecoin/issues/603","id":379456421,"node_id":"MDU6SXNzdWUzNzk0NTY0MjE=","number":603,"title":"Error in JSON serialization in multiple RPC methods","user":{"login":"brandonlehmann","id":20562132,"node_id":"MDQ6VXNlcjIwNTYyMTMy","avatar_url":"https://avatars2.githubusercontent.com/u/20562132?v=4","gravatar_id":"","url":"https://api.github.com/users/brandonlehmann","html_url":"https://github.com/brandonlehmann","followers_url":"https://api.github.com/users/brandonlehmann/followers","following_url":"https://api.github.com/users/brandonlehmann/following{/other_user}","gists_url":"https://api.github.com/users/brandonlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/brandonlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandonlehmann/subscriptions","organizations_url":"https://api.github.com/users/brandonlehmann/orgs","repos_url":"https://api.github.com/users/brandonlehmann/repos","events_url":"https://api.github.com/users/brandonlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/brandonlehmann/received_events","type":"User","site_admin":false},"labels":[{"id":797689428,"node_id":"MDU6TGFiZWw3OTc2ODk0Mjg=","url":"https://api.github.com/repos/turtlecoin/turtlecoin/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-10T20:02:43Z","updated_at":"2018-11-10T20:05:27Z","closed_at":null,"author_association":"COLLABORATOR","body":"### System Information\r\n\r\n**Operating System**: All (Windows, Linux, Mac)\r\n**OS Version**: All\r\n**CPU Make, Model, & Speed**: All\r\n**Amount of RAM**: Any\r\n**Hard Drive Type**: N/A\r\n**Hard Drive Size**: N/A\r\n**Volume Type**: N/A\r\n\r\n### TurtleCoin Build Information\r\n\r\n**Version:** All builds\r\n**Binary Source:** All builds\r\n\r\n### Issue Report\r\n\r\n**Binary Reported:** TurtleCoind & turtle-service\r\n\r\n#### Expected Behavior\r\n\r\nTransaction details via the RPC return valid values for their type.\r\n\r\n#### Current Behavior\r\n\r\nWhen examining the transaction details of the following transactions:\r\n\r\n```\r\nb01a22c8d729acd78adb23a1f1ac1ca2c2b071ab55f38aeb01ba6949a07c3502\r\nec54aeb57a15cf1387f15c3af6c52bb7ae5808ac4348421713a740e77bc2222f\r\nf8f1229b41b0ef04b33e3e74557f0ed66ba8fcb54657b01c0dd64679c9247dff\r\n```\r\n\r\nThe transaction details return a negative value (`-2`) for for the `unlock_time`. `unlock_time` is specified as a `uint64_t` which is an unsigned value and thus should not return a negative value. This is an error in the serialization to JSON of the value as the blockchain data holds the correct value (`18446744073709551614`).\r\n\r\nThis issue very likely exists in `turtle-service` as well; however, as the transactions above are not **mine** they do not show up in my wallet and thus I cannot confirm. As this is a serialization error, the error likely exists across the project.\r\n\r\n#### Impact\r\n\r\nThe node (daemon) handles the correct value of the `unlock_time` appropriately; however, as a result of the serialization error, wallets *may* not recognize the `unlock_time` of the transaction properly. While this would *normally* be an issue, the correct values (`18446744073709551614`) are interpreted by the network according to the rules as outlined in §3.4 of [CNS004: Cryptonote Transactions](https://cryptonote.org/cns/cns004.txt)\r\n\r\n```\r\n   Creating a transaction, the sender specifies the unlock_time. If this\r\n   value is less than CRYPTONOTE_MAX_BLOCK_NUMBER (500000000), then it\r\n   is interpreted as the block height at which the funds are unlocked.\r\n   Otherwise, the value is interpreted as the UNIX timestamp.\r\n\r\n   unlock_time is used as a way to temporarily lock the funds.\r\n   Precisely, each output can only be spent (or referenced by an input,\r\n   even if it is not really spent) after the unlock_time elapses. Until\r\n   then these funds are considered locked and non-spendable.\r\n```\r\n\r\nGiven that the value (`18446744073709551614`) exceeds [CRYPTONOTE_MAX_BLOCK_NUMBER](https://github.com/turtlecoin/turtlecoin/blob/aa0314217efc4c66481f0cf8b6caa21f6ddfb49b/src/config/CryptoNoteConfig.h#L21) this value is interpreted as a unix timestamp. The result is that these transactions will unlock on or around:\r\n\r\n`12/04/292277026596 @ 3:30pm (UTC)`\r\n\r\nYeah, you read that right, in the year two hundred ninety-two billion, two hundred seventy-seven million, twenty-six thousand, five hundred ninety-six 👋 \r\n\r\n##### Screen Shots\r\n\r\nSample data shortened for brevity:\r\n\r\n```javascript\r\n{\r\n  \"status\": \"OK\",\r\n  \"transactions\": [\r\n    {\r\n      \"blockHash\": \"b412b7d72fe08bfe8d8e983cc728c6f3d219429c98d12e6643de89bb6d03d2de\",\r\n      \"blockIndex\": 88269,\r\n      \"extra\": {},\r\n      \"fee\": 10,\r\n      \"hash\": \"b01a22c8d729acd78adb23a1f1ac1ca2c2b071ab55f38aeb01ba6949a07c3502\",\r\n      \"inBlockchain\": true,\r\n      \"inputs\": [],\r\n      \"mixin\": 5,\r\n      \"outputs\": [],\r\n      \"paymentId\": \"cad826dac837aa45954bd48e66173f0cf6ff653e42055855b88ccb34d074324a\",\r\n      \"signatures\": [],\r\n      \"signaturesSize\": 1,\r\n      \"size\": 550,\r\n      \"timestamp\": 1515531707,\r\n      \"totalInputsAmount\": 1000,\r\n      \"totalOutputsAmount\": 990,\r\n      \"unlockTime\": -2\r\n    },\r\n    {\r\n      \"blockHash\": \"62de62dbae8fa7edd11de66b668071fc2f2ed065000ec655c3f239fd06e891ec\",\r\n      \"blockIndex\": 93405,\r\n      \"extra\": {},\r\n      \"fee\": 100,\r\n      \"hash\": \"ec54aeb57a15cf1387f15c3af6c52bb7ae5808ac4348421713a740e77bc2222f\",\r\n      \"inBlockchain\": true,\r\n      \"inputs\": [],\r\n      \"mixin\": 1,\r\n      \"outputs\": [],\r\n      \"paymentId\": \"ca33a08ece81f33535711936f2b215712b4afa2ea73a473157a8082522eee73d\",\r\n      \"signatures\": [],\r\n      \"signaturesSize\": 1,\r\n      \"size\": 362,\r\n      \"timestamp\": 1515691191,\r\n      \"totalInputsAmount\": 1000000,\r\n      \"totalOutputsAmount\": 999900,\r\n      \"unlockTime\": -2\r\n    },\r\n    {\r\n      \"blockHash\": \"bb67b6ff2e919749854a192728285cbf475c3a1189fa122dde61388df3b7ad2d\",\r\n      \"blockIndex\": 93481,\r\n      \"extra\": {},\r\n      \"fee\": 100,\r\n      \"hash\": \"f8f1229b41b0ef04b33e3e74557f0ed66ba8fcb54657b01c0dd64679c9247dff\",\r\n      \"inBlockchain\": true,\r\n      \"inputs\": [],\r\n      \"mixin\": 1,\r\n      \"outputs\": [],\r\n      \"paymentId\": \"6d4ca8733a47606c00d0dd3082b9f7bcd6cfff4b3e2e5dd8a0b6aca6b4747ace\",\r\n      \"signatures\": [],\r\n      \"signaturesSize\": 1,\r\n      \"size\": 326,\r\n      \"timestamp\": 1515693654,\r\n      \"totalInputsAmount\": 100000,\r\n      \"totalOutputsAmount\": 99900,\r\n      \"unlockTime\": -2\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n#### Steps to Reproduce\r\n\r\n1. Request transaction details via one of the following methods for the above transaction hashes:\r\na. **f_transaction_json**\r\nb. **queryblockslite**\r\nc. **get_block_details_by_height**\r\nd. **get_blocks_details_by_heights**\r\ne. **get_blocks_details_by_hashes**\r\nf. **get_blocks_hashes_by_timestamps**\r\ng. **get_transaction_details_by_hashes**\r\n2. Send a transaction with a very large `unlock_time` value and examine the outputs of the following RPC commands:\r\na. **get_pool_changes**\r\nb. **get_pool_changes_lite**\r\n\r\n#### Possible Solution\r\n\r\n1. Replace the serialization library used for RPC services with a library that can properly serialize the `uint64_t` value.\r\n2. Extend and/or repair the current serialization library such that it properly encodes a `uint64_t` value\r\n\r\n@zpalmtree can provide a link to the area of the serialization library which is likely the cause for this issue.\r\n\r\nThis issue is being opened for tracking and full disclosure purposes.\r\n"},"comment":{"url":"https://api.github.com/repos/turtlecoin/turtlecoin/issues/comments/437617120","html_url":"https://github.com/turtlecoin/turtlecoin/issues/603#issuecomment-437617120","issue_url":"https://api.github.com/repos/turtlecoin/turtlecoin/issues/603","id":437617120,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzYxNzEyMA==","user":{"login":"brandonlehmann","id":20562132,"node_id":"MDQ6VXNlcjIwNTYyMTMy","avatar_url":"https://avatars2.githubusercontent.com/u/20562132?v=4","gravatar_id":"","url":"https://api.github.com/users/brandonlehmann","html_url":"https://github.com/brandonlehmann","followers_url":"https://api.github.com/users/brandonlehmann/followers","following_url":"https://api.github.com/users/brandonlehmann/following{/other_user}","gists_url":"https://api.github.com/users/brandonlehmann/gists{/gist_id}","starred_url":"https://api.github.com/users/brandonlehmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandonlehmann/subscriptions","organizations_url":"https://api.github.com/users/brandonlehmann/orgs","repos_url":"https://api.github.com/users/brandonlehmann/repos","events_url":"https://api.github.com/users/brandonlehmann/events{/privacy}","received_events_url":"https://api.github.com/users/brandonlehmann/received_events","type":"User","site_admin":false},"created_at":"2018-11-10T20:05:27Z","updated_at":"2018-11-10T20:05:27Z","author_association":"COLLABORATOR","body":"Thanks @zpalmtree "}}
{"actor":{"display_login":"brandonlehmann"}}