github.com/dmmcquay/sia@v1.3.1-0.20180712220038-9f8d535311b9/doc/api/Consensus.md (about) 1 Consensus API 2 ============= 3 4 This document contains detailed descriptions of the consensus's API routes. For 5 an overview of the consensus' API routes, see 6 [API.md#consensus](/doc/API.md#consensus). For an overview of all API routes, 7 see [API.md](/doc/API.md) 8 9 There may be functional API calls which are not documented. These are not 10 guaranteed to be supported beyond the current release, and should not be used 11 in production. 12 13 Overview 14 -------- 15 16 The consensus set manages everything related to consensus and keeps the 17 blockchain in sync with the rest of the network. The consensus set's API 18 endpoint returns information about the state of the blockchain. 19 20 Index 21 ----- 22 23 | Route | HTTP verb | 24 | --------------------------------------------------------------------------- | --------- | 25 | [/consensus](#consensus-get) | GET | 26 | [/consensus/blocks](#consensusblocks-get) | GET | 27 | [/consensus/validate/transactionset](#consensusvalidatetransactionset-post) | POST | 28 29 #### /consensus [GET] 30 31 returns information about the consensus set, such as the current block height. 32 33 ###### JSON Response 34 ```javascript 35 { 36 // True if the consensus set is synced with the network, i.e. it has downloaded the entire blockchain. 37 "synced": true, 38 39 // Number of blocks preceding the current block. 40 "height": 62248, 41 42 // Hash of the current block. 43 "currentblock": "00000000000008a84884ba827bdc868a17ba9c14011de33ff763bd95779a9cf1", 44 45 // An immediate child block of this block must have a hash less than this 46 // target for it to be valid. 47 "target": [0,0,0,0,0,0,11,48,125,79,116,89,136,74,42,27,5,14,10,31,23,53,226,238,202,219,5,204,38,32,59,165], 48 49 // The difficulty of the current block target. 50 "difficulty": "1234" // arbitrary-precision integer 51 } 52 ``` 53 54 #### /consensus/blocks [GET] 55 56 Returns the block for a given id or height. 57 58 ###### Query String Parameters 59 One of the following parameters can be specified. 60 ``` 61 // BlockID of the requested block. 62 id 63 64 // BlockHeight of the requested block. 65 height 66 67 ``` 68 69 ###### Response 70 The JSON formatted block or a standard error response. 71 ``` 72 { 73 "height": 20032, 74 "id": "00000000000033b9eb57fa63a51adeea857e70f6415ebbfe5df2a01f0d0477f4", 75 "minerpayouts": [ 76 { 77 "unlockhash": "c199cd180e19ef7597bcf4beecdd4f211e121d085e24432959c42bdf9030e32b9583e1c2727c", 78 "value": "279978000000000000000000000000" 79 } 80 ], 81 "nonce": [4,12,219,7,0,0,0,0], 82 "parentid": "0000000000009615e8db750eb1226aa5e629bfa7badbfe0b79607ec8b918a44c", 83 "timestamp": 1444516982, 84 "transactions": [ 85 { 86 // ... 87 }, 88 { 89 "arbitrarydata": [], 90 "filecontractrevisions": [], 91 "filecontracts": [], 92 "id": "3c98ec79b990461f353c22bb06bcfb10e702f529ad7d27a43c4448273553d90a", 93 "minerfees": [], 94 "siacoininputs": [ 95 { 96 "parentid": "24cbeb9df7eb2d81d0025168fc94bd179909d834f49576e65b51feceaf957a64", 97 "unlockconditions": { 98 "publickeys": [ 99 { 100 "algorithm": "ed25519", 101 "key": "QET8w7WRbGfcnnpKd1nuQfE3DuNUUq9plyoxwQYDK4U=" 102 } 103 ], 104 "signaturesrequired": 1, 105 "timelock": 0 106 } 107 } 108 ], 109 "siacoinoutputs": [ 110 { 111 "id": "1f9da81e23522f79590ac67ac0b668828c52b341cbf04df4959bb7040c072f29", 112 "unlockhash": "d54f500f6c1774d518538dbe87114fe6f7e6c76b5bc8373a890b12ce4b8909a336106a4cd6db", 113 "value": "1010000000000000000000000000" 114 }, 115 { 116 "id": "14978a4c54f5ebd910ea41537de014f8423574c13d132e8713fab5af09ec08ca", 117 "unlockhash": "48a56b19bd0be4f24190640acbd0bed9669ea9c18823da2645ec1ad9652f10b06c5d4210f971", 118 "value": "5780000000000000000000000000" 119 } 120 ], 121 "siafundinputs": [], 122 "siafundoutputs": [], 123 "storageproofs": [], 124 "transactionsignatures": [ 125 { 126 "coveredfields": { 127 "arbitrarydata": [], 128 "filecontractrevisions": [], 129 "filecontracts": [], 130 "minerfees": [], 131 "siacoininputs": [], 132 "siacoinoutputs": [], 133 "siafundinputs": [], 134 "siafundoutputs": [], 135 "storageproofs": [], 136 "transactionsignatures": [], 137 "wholetransaction": true 138 }, 139 "parentid": "24cbeb9df7eb2d81d0025168fc94bd179909d834f49576e65b51feceaf957a64", 140 "publickeyindex": 0, 141 "signature": "pByLGMlvezIZWVZmHQs/ynGETETNbxcOY/kr6uivYgqZqCcKTJ0JkWhcFaKJU+3DEA7JAloLRNZe3PTklD3tCQ==", 142 "timelock": 0 143 } 144 ] 145 }, 146 { 147 // ... 148 } 149 ] 150 } 151 ``` 152 153 #### /consensus/validate/transactionset [POST] 154 155 validates a set of transactions using the current utxo set. 156 157 ###### Request Body Bytes 158 159 Since transactions may be large, the transaction set is supplied in the POST 160 body, encoded in JSON format. 161 162 ###### Response 163 standard success or error response. See 164 [#standard-responses](#standard-responses).