gitlab.com/SiaPrime/SiaPrime@v1.4.1/doc/api/index.html.md (about) 1 --- 2 title: Sia API Documentation 3 4 language_tabs: # must be one of https://git.io/vQNgJ 5 - go 6 7 toc_footers: 8 - <a href='https://sia.tech'>The Official Sia Website 9 - <a href='https://gitlab.com/NebulousLabs/Sia'>Sia on GitLab</a> 10 11 search: true 12 --- 13 14 # Introduction 15 16 ## Welcome to the Sia Storage Platform API! 17 > Example GET curl call 18 19 ```go 20 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/wallet/transactions?startheight=1&endheight=250" 21 ``` 22 23 > Example POST curl call with data 24 25 ```go 26 curl -A "Sia-Agent" -u "":<apipassword> --data "amount=123&destination=abcd" "localhost:9980/wallet/siacoins" 27 ``` 28 29 > Example POST curl call without data or authentication 30 31 ```go 32 curl -A "Sia-Agent" -X POST "localhost:9980/gateway/connect/123.456.789.0:9981" 33 ``` 34 35 Sia uses semantic versioning and is backwards compatible to version v1.0.0. 36 37 API calls return either JSON or no content. Success is indicated by 2xx HTTP status codes, while errors are indicated by 4xx and 5xx HTTP status codes. If an endpoint does not specify its expected status code refer to [standard responses](#Standard-Responses). 38 39 There may be functional API calls which are not documented. These are not guaranteed to be supported beyond the current release, and should not be used in production. 40 41 **Notes:** 42 43 - Requests must set their User-Agent string to contain the substring "Sia-Agent". 44 - By default, siad listens on "localhost:9980". This can be changed using the `--api-addr` flag when running siad. 45 - **Do not bind or expose the API to a non-loopback address unless you are aware of the possible dangers.** 46 47 ## Documentation Standards 48 49 The following details the documentation standards for the API endpoints. 50 - Endpoints should follow the structure of: 51 - Parameters 52 - Response 53 - Each endpoint should have a corresponding curl example 54 - All non-standard responses should have a JSON Response example 55 with units 56 - There should be detailed descriptions of all JSON response fields 57 - There should be detailed descriptions of all query string parameters 58 - Query String Parameters should be separated into **REQUIRED** and **OPTIONAL** sections 59 - Detailed descriptions should be structured as "**field** | units" 60 61 Contributors should follow these standards when submitting updates to the API documentation. If you find API endpoints that do not adhere to these documentation standards please let the Sia team know by submitting an issue [here](https://gitlab.com/NebulousLabs/Sia/issues) 62 63 # Standard Responses 64 65 ## Success 66 The standard response indicating the request was successfully processed is HTTP status code `204 No Content`. If the request was successfully processed and the server responded with JSON the HTTP status code is `200 OK`. Specific endpoints may specify other 2xx status codes on success. 67 68 ## Error 69 70 ```go 71 { 72 "message": String 73 74 // There may be additional fields depending on the specific error. 75 } 76 ``` 77 78 The standard error response indicating the request failed for any reason, is a 4xx or 5xx HTTP status code with an error JSON object describing the error. 79 80 # Authentication 81 > Example POST curl call with Authentication 82 83 ```go 84 curl -A "Sia-Agent" --user "":<apipassword> --data "amount=123&destination=abcd" "localhost:9980/wallet/siacoins" 85 ``` 86 87 API authentication is enabled by default, using a password stored in a flat file. The location of this file is: 88 89 - Linux: `$HOME/.sia/apipassword` 90 - MacOS: `$HOME/Library/Application Support/Sia/apipassword` 91 - Windows: `%LOCALAPPDATA%\Sia\apipassword` 92 93 94 Note that the file contains a trailing newline, which must be trimmed before 95 use. 96 97 Authentication is HTTP Basic Authentication as described in [RFC 2617](https://tools.ietf.org/html/rfc2617), however, the username is the empty string. The flag does not enforce authentication on all API endpoints. Only endpoints that expose sensitive information or modify state require authentication. 98 99 For example, if the API password is "foobar" the request header should include 100 101 `Authorization: Basic OmZvb2Jhcg==` 102 103 And for a curl call the following would be included 104 105 `--user "":<apipassword>` 106 107 Authentication can be disabled by passing the `--authenticate-api=false` flag to siad. You can change the password by modifying the password file, setting the `SIA_API_PASSWORD` environment variable, or passing the `--temp-password` flag to siad. 108 109 # Units 110 111 Unless otherwise noted, all parameters should be identified in their smallest possible unit. For example, size should always be specified in bytes and Siacoins should always be specified in hastings. JSON values returned by the API will also use the smallest possible unit, unless otherwise noted. 112 113 If a number is returned as a string in JSON, it should be treated as an arbitrary-precision number (bignum), and it should be parsed with your language's corresponding bignum library. Currency values are the most common example where this is necessary. 114 115 # Consensus 116 117 The consensus set manages everything related to consensus and keeps the blockchain in sync with the rest of the network. The consensus set's API endpoint returns information about the state of the blockchain. 118 119 ## /consensus [GET] 120 > curl example 121 122 ```go 123 curl -A "Sia-Agent" "localhost:9980/consensus" 124 ``` 125 126 Returns information about the consensus set, such as the current block height. 127 Also returns the set of constants in use in the consensus code. 128 129 ### JSON Response 130 > JSON Response Example 131 132 ```go 133 { 134 "synced": true, // boolean 135 "height": 62248, // blockheight 136 "currentblock": "00000000000008a84884ba827bdc868a17ba9c14011de33ff763bd95779a9cf1", // hash 137 "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], // hash 138 "difficulty": "1234" // arbitrary-precision integer 139 140 "blockfrequency": 600, // seconds per block 141 "blocksizelimit": 2000000, // bytes 142 "extremefuturethreshold": 10800, // seconds 143 "futurethreshold": 10800, // seconds 144 "genesistimestamp": 1257894000, // Unix time 145 "maturitydelay": 144, // blocks 146 "mediantimestampwindow": 11, // blocks 147 "siafundcount": "10000", // siafund 148 "siafundportion": "39/1000", // fraction 149 150 "initialcoinbase": 300000, // Siacoins (see note in Daemon.md) 151 "minimumcoinbase": 30000, // Siacoins (see note in Daemon.md) 152 153 "roottarget": [0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], // hash 154 "rootdepth": [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], // hash 155 156 "siacoinprecision": "1000000000000000000000000" // hastings per siacoin 157 } 158 ``` 159 **synced** | boolean 160 True if the consensus set is synced with the network, e.g. it has downloaded the entire blockchain. 161 162 **height** | blockheight 163 Number of blocks preceding the current block. 164 165 **currentblock** | hash 166 Hash of the current block. 167 168 **target** | hash 169 An immediate child block of this block must have a hash less than this target for it to be valid. 170 171 **difficulty** | arbitrary-precision integer 172 The difficulty of the current block target. 173 174 **blockfrequency** | blocks / second 175 Target for how frequently new blocks should be mined. 176 177 **blocksizelimit** | bytes 178 Maximum size, in bytes, of a block. Blocks larger than this will be rejected by peers. 179 180 **extremefuturethreshold** | seconds 181 Farthest a block's timestamp can be in the future before the block is rejected outright. 182 183 **futurethreshold** | seconds 184 How far in the future a block can be without being rejected. A block further into the future will not be accepted immediately, but the daemon will attempt to accept the block as soon as it is valid. 185 186 **genesistimestamp** | unix timestamp 187 Timestamp of the genesis block. 188 189 **maturitydelay** | number of blocks 190 Number of children a block must have before it is considered "mature." 191 192 **mediantimestampwindow** | number of blocks 193 Duration of the window used to adjust the difficulty. 194 195 **siafundcount** | siafunds 196 Total number of siafunds. 197 198 **siafundportion** | fraction 199 Fraction of each file contract payout given to siafund holders. 200 201 **initialcoinbase** | siacoin 202 Number of coins given to the miner of the first block. Note that elsewhere in the API currency is typically returned in hastings and as a bignum. This is not the case here. 203 204 **minimumcoinbase** | siacoin 205 Minimum number of coins paid out to the miner of a block (the coinbase decreases with each block). Note that elsewhere in the API currency is typically returned in hastings and as a bignum. This is not the case here. 206 207 **roottarget** | hash 208 Initial target. 209 210 **rootdepth** | hash 211 Initial depth. 212 213 **siacoinprecision** | hastings per siacoin 214 Number of Hastings in one Siacoin. 215 216 ## /consensus/blocks [GET] 217 > curl example 218 219 ```go 220 curl -A "Sia-Agent" "localhost:9980/consensus/blocks?height=20032" 221 ``` 222 ```go 223 curl -A "Sia-Agent" "localhost:9980/consensus/blocks?id=00000000000033b9eb57fa63a51adeea857e70f6415ebbfe5df2a01f0d0477f4" 224 ``` 225 226 Returns the block for a given id or height. 227 228 ### Query String Parameters 229 #### REQUIRED 230 One of the following parameters must be specified. 231 232 **id** | blockID 233 BlockID of the requested block. 234 235 **height** | blockheight 236 BlockHeight of the requested block. 237 238 ### JSON Response 239 > JSON Response Example 240 241 ```go 242 { 243 "height": 20032, 244 "id": "00000000000033b9eb57fa63a51adeea857e70f6415ebbfe5df2a01f0d0477f4", 245 "minerpayouts": [ 246 { 247 "unlockhash": "c199cd180e19ef7597bcf4beecdd4f211e121d085e24432959c42bdf9030e32b9583e1c2727c", 248 "value": "279978000000000000000000000000" 249 } 250 ], 251 "nonce": [4,12,219,7,0,0,0,0], 252 "parentid": "0000000000009615e8db750eb1226aa5e629bfa7badbfe0b79607ec8b918a44c", 253 "timestamp": 1444516982, 254 "transactions": [ 255 { 256 // ... 257 } 258 { 259 "arbitrarydata": [], 260 "filecontractrevisions": [], 261 "filecontracts": [], 262 "minerfees": [], 263 "siacoininputs": [ 264 { 265 "parentid": "24cbeb9df7eb2d81d0025168fc94bd179909d834f49576e65b51feceaf957a64", 266 "unlockconditions": { 267 "publickeys": [ 268 { 269 "algorithm": "ed25519", 270 "key": "QET8w7WRbGfcnnpKd1nuQfE3DuNUUq9plyoxwQYDK4U=" 271 } 272 ], 273 "signaturesrequired": 1, 274 "timelock": 0 275 } 276 } 277 ], 278 "siacoinoutputs": [ 279 { 280 "unlockhash": "d54f500f6c1774d518538dbe87114fe6f7e6c76b5bc8373a890b12ce4b8909a336106a4cd6db", 281 "value": "1010000000000000000000000000" 282 }, 283 { 284 "unlockhash": "48a56b19bd0be4f24190640acbd0bed9669ea9c18823da2645ec1ad9652f10b06c5d4210f971", 285 "value": "5780000000000000000000000000" 286 } 287 ], 288 "siafundinputs": [], 289 "siafundoutputs": [], 290 "storageproofs": [], 291 "transactionsignatures": [ 292 { 293 "coveredfields": { 294 "arbitrarydata": [], 295 "filecontractrevisions": [], 296 "filecontracts": [], 297 "minerfees": [], 298 "siacoininputs": [], 299 "siacoinoutputs": [], 300 "siafundinputs": [], 301 "siafundoutputs": [], 302 "storageproofs": [], 303 "transactionsignatures": [], 304 "wholetransaction": true 305 }, 306 "parentid": "24cbeb9df7eb2d81d0025168fc94bd179909d834f49576e65b51feceaf957a64", 307 "publickeyindex": 0, 308 "signature": "pByLGMlvezIZWVZmHQs/ynGETETNbxcOY/kr6uivYgqZqCcKTJ0JkWhcFaKJU+3DEA7JAloLRNZe3PTklD3tCQ==", 309 "timelock": 0 310 } 311 ] 312 }, 313 { 314 // ... 315 } 316 ] 317 } 318 ``` 319 320 ## /consensus/validate/transactionset [POST] 321 > curl example 322 323 ```go 324 curl -A "Sia-Agent" --data "[JSON-encoded-txnset]" "localhost:9980/validate/transactionset" 325 ``` 326 327 validates a set of transactions using the current utxo set. 328 329 ### Request Body Bytes 330 331 Since transactions may be large, the transaction set is supplied in the POST body, encoded in JSON format. 332 333 ### Response 334 335 standard success or error response. See [standard responses](#standard-responses). 336 337 # Daemon 338 339 The daemon is responsible for starting and stopping the modules which make up the rest of Sia. 340 341 <<<<<<< HEAD 342 ## /daemon/constants [GET] 343 > curl example 344 345 ```go 346 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/daemon/constants" 347 ``` 348 349 Returns the some of the constants that the Sia daemon uses. 350 351 ### JSON Response 352 > JSON Response Example 353 354 ```go 355 { 356 "blockfrequency":600, // blockheight 357 "blocksizelimit":2000000, // uint64 358 "extremefuturethreshold":18000, // timestamp 359 "futurethreshold":10800, // timestamp 360 "genesistimestamp":1433600000, // timestamp 361 "maturitydelay":144, // blockheight 362 "mediantimestampwindow":11, // uint64 363 "siafundcount":"10000", // uint64 364 "siafundportion":"39/1000", // big.Rat 365 "targetwindow":1000, // blockheight 366 367 "initialcoinbase":300000, // uint64 368 "minimumcoinbase":30000, // uint64 369 370 "roottarget": // target 371 [0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 372 "rootdepth": // target 373 [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], 374 375 "allowance": // allowance 376 { 377 "funds":"55000000000000000000000000000", // currency 378 "hosts":50, // uint64 379 "period":12096, // blockheight 380 "renewwindow":4032, // blockheight 381 "expectedstorage":1000000000000, // uint64 382 "expectedupload":2, // uint64 383 "expecteddownload":1, // uint64 384 "expectedredundancy":3 // uint64 385 }, 386 387 "maxtargetadjustmentup":"5/2", // big.Rat 388 "maxtargetadjustmentdown":"2/5", // big.Rat 389 390 "siacoinprecision":"1000000000000000000000000" // currency 391 } 392 ``` 393 **blockfrequency** | blockheight 394 BlockFrequency is the desired number of seconds that should elapse, on average, between successive Blocks. 395 396 **blocksizelimit** | uint64 397 BlockSizeLimit is the maximum size of a binary-encoded Block that is permitted by the consensus rules. 398 399 **extremefuturethreshold** | timestamp 400 ExtremeFutureThreshold is a temporal limit beyond which Blocks are discarded by the consensus rules. When incoming Blocks are processed, their Timestamp is allowed to exceed the processor's current time by a small amount. But if the Timestamp is further into the future than ExtremeFutureThreshold, the Block is immediately discarded. 401 402 **futurethreshold** | timestamp 403 FutureThreshold is a temporal limit beyond which Blocks are discarded by the consensus rules. When incoming Blocks are processed, their Timestamp is allowed to exceed the processor's current time by no more than FutureThreshold. If the excess duration is larger than FutureThreshold, but smaller than ExtremeFutureThreshold, the Block may be held in memory until the Block's Timestamp exceeds the current time by less than FutureThreshold. 404 405 **genesistimestamp** | timestamp 406 GenesisBlock is the first block of the block chain 407 408 **maturitydelay** | blockheight 409 MaturityDelay specifies the number of blocks that a maturity-required output is required to be on hold before it can be spent on the blockchain. Outputs are maturity-required if they are highly likely to be altered or invalidated in the event of a small reorg. One example is the block reward, as a small reorg may invalidate the block reward. Another example is a siafund payout, as a tiny reorg may change the value of the payout, and thus invalidate any transactions spending the payout. File contract payouts also are subject to a maturity delay. 410 411 **mediantimestampwindow** | uint64 412 MedianTimestampWindow tells us how many blocks to look back when calculating the median timestamp over the previous n blocks. The timestamp of a block is not allowed to be less than or equal to the median timestamp of the previous n blocks, where for Sia this number is typically 11. 413 414 **siafundcount** | currency 415 SiafundCount is the total number of Siafunds in existence. 416 417 **siafundportion** | big.Rat 418 SiafundPortion is the percentage of siacoins that is taxed from FileContracts. 419 420 **targetwindow** | blockheight 421 TargetWindow is the number of blocks to look backwards when determining how much time has passed vs. how many blocks have been created. It's only used in the old, broken difficulty adjustment algorithm. 422 423 **initialcoinbase** | uint64 424 InitialCoinbase is the coinbase reward of the Genesis block. 425 426 **minimumcoinbase** | uint64 427 MinimumCoinbase is the minimum coinbase reward for a block. The coinbase decreases in each block after the Genesis block, but it will not decrease past MinimumCoinbase. 428 429 **roottarget** | target 430 RootTarget is the target for the genesis block - basically how much work needs to be done in order to mine the first block. The difficulty adjustment algorithm takes over from there. 431 432 **rootdepth** | target 433 RootDepth is the cumulative target of all blocks. The root depth is essentially the maximum possible target, there have been no blocks yet, so there is no cumulated difficulty yet. 434 435 **defaultallowance** | allowance 436 DefaultAllowance is the set of default allowance settings that will be used when allowances are not set or not fully set 437 438 **maxtargetadjustmentup** | big.Rat 439 MaxTargetAdjustmentUp restrict how much the block difficulty is allowed to change in a single step, which is important to limit the effect of difficulty raising and lowering attacks. 440 441 **maxtargetadjustmentdown** | big.Rat 442 MaxTargetAdjustmentDown restrict how much the block difficulty is allowed to change in a single step, which is important to limit the effect of difficulty raising and lowering attacks. 443 444 **siacoinprecision** | currency 445 SiacoinPrecision is the number of base units in a siacoin. The Sia network has a very large number of base units. We call 10^24 of these a siacoin. 446 447 ## /daemon/settings [GET] 448 > curl example 449 450 ```go 451 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/daemon/settings" 452 ``` 453 Returns the settings for the daemon 454 455 ### JSON Response 456 > JSON Response Example 457 458 ```go 459 { 460 "maxdownloadspeed": 0, // bytes per second 461 "maxuploadspeed": 0 // bytes per second 462 } 463 ``` 464 465 **maxdownloadspeed** | bytes per second 466 Is the maximum download speed that the daemon can reach. 0 means there is no limit set. 467 468 **maxuploadspeed** | bytes per second 469 Is the maximum upload speed that the daemon can reach. 0 means there is no limit set. 470 471 ## /daemon/settings [POST] 472 > curl example 473 474 ```go 475 curl -A "Sia-Agent" -u "":<apipassword> --data "maxdownloadspeed=1000000&maxuploadspeed=20000" "localhost:9980/daemon/settings" 476 ``` 477 478 Modify settings that control the daemon's behavior. 479 480 ### Query String Parameters 481 #### OPTIONAL 482 **maxdownloadspeed** | bytes per second 483 Max download speed permitted in bytes per second 484 485 **maxuploadspeed** | bytes per second 486 Max upload speed permitted in bytes per second 487 488 ### Response 489 standard success or error response. See [standard responses](#standard-responses). 490 491 ======= 492 >>>>>>> siaprime/master 493 ## /daemon/stop [GET] 494 > curl example 495 496 ```go 497 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/daemon/stop" 498 ``` 499 500 Cleanly shuts down the daemon. This may take a few seconds. 501 502 ### Response 503 standard success or error response. See [standard responses](#standard-responses). 504 505 <<<<<<< HEAD 506 ## /daemon/update [GET] 507 > curl example 508 509 ```go 510 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/daemon/update" 511 ``` 512 Returns the the status of any updates available for the daemon 513 514 ### JSON Response 515 > JSON Response Example 516 517 ```go 518 { 519 "available": false, // boolean 520 "version": "1.4.0" // string 521 } 522 ``` 523 524 **available** | boolean 525 Available indicates whether or not there is an update available for the daemon. 526 527 **version** | string 528 Version is the version of the latest release. 529 530 ## /daemon/update [POST] 531 > curl example 532 533 ```go 534 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/daemon/update" 535 ``` 536 Updates the daemon to the latest available version release. 537 538 ### Response 539 standard success or error response. See [standard responses](#standard-responses). 540 541 ======= 542 >>>>>>> siaprime/master 543 ## /daemon/version [GET] 544 > curl example 545 546 ```go 547 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/daemon/version" 548 ``` 549 550 Returns the version of the Sia daemon currently running. 551 552 ### JSON Response 553 > JSON Response Example 554 555 ```go 556 { 557 "version": "1.3.7" // string 558 } 559 ``` 560 **version** | string 561 This is the version number that is visible to its peers on the network. 562 563 # Gateway 564 565 The gateway maintains a peer to peer connection to the network and provides a method for calling RPCs on connected peers. The gateway's API endpoints expose methods for viewing the connected peers, manually connecting to peers, and manually disconnecting from peers. The gateway may connect or disconnect from peers on its own. 566 567 ## /gateway [GET] 568 > curl example 569 570 ```go 571 curl -A "Sia-Agent" "localhost:9980/gateway" 572 ``` 573 574 returns information about the gateway, including the list of connected peers. 575 576 ### JSON Response 577 > JSON Response Example 578 579 ```go 580 { 581 "netaddress":"333.333.333.333:9981", // string 582 "peers":[ 583 { 584 <<<<<<< HEAD 585 "inbound": false, // boolean 586 ======= 587 "inbound": alse, // boolean 588 >>>>>>> siaprime/master 589 "local": false, // boolean 590 "netaddress": "222.222.222.222:9981", // string 591 "version": "1.0.0", // string 592 }, 593 ], 594 "maxdownloadspeed": 1234, // bytes per second 595 "maxuploadspeed": 1234, // bytes per second 596 } 597 ``` 598 **netaddress** | string 599 netaddress is the network address of the gateway as seen by the rest of the network. The address consists of the external IP address and the port Sia is listening on. It represents a `modules.NetAddress`. 600 601 **peers** | array 602 peers is an array of peers the gateway is connected to. It represents an array of `modules.Peer`s. 603 604 **inbound** | boolean 605 inbound is true when the peer initiated the connection. This field is exposed as outbound peers are generally trusted more than inbound peers, as inbound peers are easily manipulated by an adversary. 606 607 **local** | boolean 608 local is true if the peer's IP address belongs to a local address range such as 192.168.x.x or 127.x.x.x 609 610 **netaddress** | string 611 netaddress is the address of the peer. It represents a `modules.NetAddress`. 612 613 **version** | string 614 version is the version number of the peer. 615 616 **maxdownloadspeed** | bytes per second 617 Max download speed permitted in bytes per second 618 619 **maxuploadspeed** | bytes per second 620 Max upload speed permitted in bytes per second 621 622 ## /gateway [POST] 623 > curl example 624 625 ```go 626 curl -A "Sia-Agent" -u "":<apipassword> --data "maxdownloadspeed=1000000&maxuploadspeed=20000" "localhost:9980/gateway" 627 ``` 628 629 Modify settings that control the gateway's behavior. 630 631 ### Query String Parameters 632 #### OPTIONAL 633 **maxdownloadspeed** | bytes per second 634 Max download speed permitted in bytes per second 635 636 **maxuploadspeed** | bytes per second 637 Max upload speed permitted in bytes per second 638 639 ### Response 640 641 standard success or error response. See [standard responses](#standard-responses). 642 643 ## /gateway/connect/:*netaddress* [POST] 644 > curl example 645 646 ```go 647 curl -A "Sia-Agent" -X POST "localhost:9980/gateway/connect/123.456.789.0:9981" 648 ``` 649 650 connects the gateway to a peer. The peer is added to the node list if it is not already present. The node list is the list of all nodes the gateway knows about, but is not necessarily connected to. 651 652 ### Path Parameters 653 #### REQUIRED 654 netaddress is the address of the peer to connect to. It should be a reachable ip address and port number, of the form `IP:port`. IPV6 addresses must be enclosed in square brackets. 655 656 **netaddress** | string 657 Example IPV4 address: 123.456.789.0:123 658 Example IPV6 address: [123::456]:789 659 660 ### Response 661 standard success or error response. See [standard responses](#Standard-Responses). 662 663 ## /gateway/disconnect/:*netaddress* [POST] 664 > curl example 665 666 ```go 667 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/gateway/disconnect/123.456.789.0:9981" 668 ``` 669 670 disconnects the gateway from a peer. The peer remains in the node list. Disconnecting from a peer does not prevent the gateway from automatically connecting to the peer in the future. 671 672 ### Path Parameters 673 #### REQUIRED 674 netaddress is the address of the peer to connect to. It should be a reachable ip address and port number, of the form `IP:port`. IPV6 addresses must be enclosed in square brackets. 675 676 **netaddress** | string 677 Example IPV4 address: 123.456.789.0:123 678 Example IPV6 address: [123::456]:789 679 680 ### Response 681 standard success or error response. See [standard responses](#standard-responses). 682 683 # Host 684 685 The host provides storage from local disks to the network. The host negotiates file contracts with remote renters to earn money for storing other users' files. The host's endpoints expose methods for viewing and modifying host settings, announcing to the network, and managing how files are stored on disk. 686 687 ## /host [GET] 688 > curl example 689 690 ```go 691 curl -A "Sia-Agent" "localhost:9980/host" 692 ``` 693 694 fetches status information about the host. 695 696 ### JSON Response 697 > JSON Response Example 698 699 ```go 700 { 701 "externalsettings": { 702 "acceptingcontracts": true, // boolean 703 "maxdownloadbatchsize": 17825792, // bytes 704 "maxduration": 25920, // blocks 705 "maxrevisebatchsize": 17825792, // bytes 706 "netaddress": "123.456.789.0:9982", // string 707 "remainingstorage": 35000000000, // bytes 708 "sectorsize": 4194304, // bytes 709 "totalstorage": 35000000000, // bytes 710 "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", // hash 711 "windowsize": 144, // blocks 712 713 "collateral": "57870370370", // hastings / byte / block 714 "maxcollateral": "100000000000000000000000000000", // hastings 715 716 "contractprice": "30000000000000000000000000", // hastings 717 "downloadbandwidthprice": "250000000000000", // hastings / byte 718 "storageprice": "231481481481", // hastings / byte / block 719 "uploadbandwidthprice": "100000000000000", // hastings / byte 720 721 "revisionnumber": 0, // int 722 "version": "1.0.0" // string 723 }, 724 725 "financialmetrics": { 726 "contractcount": 2, // int 727 "contractcompensation": "123", // hastings 728 "potentialcontractcompensation": "123", // hastings 729 730 "lockedstoragecollateral": "123", // hastings 731 "lostrevenue": "123", // hastings 732 "loststoragecollateral": "123", // hastings 733 "potentialstoragerevenue": "123", // hastings 734 "riskedstoragecollateral": "123", // hastings 735 "storagerevenue": "123", // hastings 736 "transactionfeeexpenses": "123", // hastings 737 738 "downloadbandwidthrevenue": "123", // hastings 739 "potentialdownloadbandwidthrevenue": "123", // hastings 740 "potentialuploadbandwidthrevenue": "123", // hastings 741 "uploadbandwidthrevenue": "123" // hastings 742 }, 743 744 "internalsettings": { 745 "acceptingcontracts": true, // boolean 746 "maxdownloadbatchsize": 17825792, // bytes 747 "maxduration": 25920, // blocks 748 "maxrevisebatchsize": 17825792, // bytes 749 "netaddress": "123.456.789.0:9982", // string 750 "windowsize": 144, // blocks 751 <<<<<<< HEAD 752 753 "collateral": "57870370370", // hastings / byte / block 754 "collateralbudget": "2000000000000000000000000000000", // hastings 755 "maxcollateral": "100000000000000000000000000000", // hastings 756 757 "minbaserpcprice": "123", //hastings 758 "mincontractprice": "30000000000000000000000000", // hastings 759 "mindownloadbandwidthprice": "250000000000000", // hastings / byte 760 "minsectoraccessprice": "123", //hastings 761 ======= 762 763 "collateral": "57870370370", // hastings / byte / block 764 "collateralbudget": "2000000000000000000000000000000", // hastings 765 "maxcollateral": "100000000000000000000000000000", // hastings 766 767 "mincontractprice": "30000000000000000000000000", // hastings 768 "mindownloadbandwidthprice": "250000000000000", // hastings / byte 769 >>>>>>> siaprime/master 770 "minstorageprice": "231481481481", // hastings / byte / block 771 "minuploadbandwidthprice": "100000000000000" // hastings / byte 772 }, 773 774 "networkmetrics": { 775 "downloadcalls": 0, // int 776 "errorcalls": 1, // int 777 "formcontractcalls": 2, // int 778 "renewcalls": 3, // int 779 "revisecalls": 4, // int 780 "settingscalls": 5, // int 781 "unrecognizedcalls": 6 // int 782 }, 783 784 "connectabilitystatus": "checking", // string 785 "workingstatus": "checking" // string 786 } 787 ``` 788 #### externalsettings 789 The settings that get displayed to untrusted nodes querying the host's status. 790 791 **acceptingcontracts** | boolean 792 Whether or not the host is accepting new contracts. 793 794 **maxdownloadbatchsize** | bytes 795 The maximum size of a single download request from a renter. Each download request has multiple round trips of communication that exchange money. Larger batch sizes mean fewer round trips, but more financial risk for the host - the renter can get a free batch when downloading by refusing to provide a signature. 796 797 **maxduration** | blocks 798 The maximum duration that a host will allow for a file contract. The host commits to keeping files for the full duration under the threat of facing a large penalty for losing or dropping data before the duration is complete. The storage proof window of an incoming file contract must end before the current height + maxduration. 799 800 **maxrevisebatchsize** | bytes 801 The maximum size of a single batch of file contract revisions. The renter can perform DoS attacks on the host by uploading a batch of data then refusing to provide a signature to pay for the data. The host can reduce this exposure by limiting the batch size. Larger batch sizes allow for higher throughput as there is significant communication overhead associated with performing a batch upload. 802 803 **netaddress** | string 804 The IP address or hostname (including port) that the host should be contacted at. 805 806 **remainingstorage** | bytes 807 The amount of unused storage capacity on the host in bytes. It should be noted that the host can lie. 808 809 **sectorsize** | bytes 810 The smallest amount of data in bytes that can be uploaded or downloaded when performing calls to the host. 811 812 **totalstorage** | bytes 813 The total amount of storage capacity on the host. It should be noted that the host can lie. 814 815 **unlockhash** | hash 816 The unlock hash is the address at which the host can be paid when forming file contracts. 817 818 **windowsize** | blocks 819 The storage proof window is the number of blocks that the host has to get a storage proof onto the blockchain. The window size is the minimum size of window that the host will accept in a file contract. 820 821 **collateral** | hastings / byte / block 822 The maximum amount of money that the host will put up as collateral for storage that is contracted by the renter. 823 824 **maxcollateral** | hastings 825 The maximum amount of collateral that the host will put into a single file contract. 826 827 **contractprice** | hastings 828 The price that a renter has to pay to create a contract with the host. The payment is intended to cover transaction fees for the file contract revision and the storage proof that the host will be submitting to the blockchain. 829 830 **downloadbandwidthprice** | hastings / byte 831 The price that a renter has to pay when downloading data from the host. 832 833 **storageprice** | hastings / byte / block 834 The price that a renter has to pay to store files with the host. 835 836 **uploadbandwidthprice** | hastings / byte 837 The price that a renter has to pay when uploading data to the host. 838 839 **revisionnumber** | int 840 The revision number indicates to the renter what iteration of settings the host is currently at. Settings are generally signed. If the renter has multiple conflicting copies of settings from the host, the renter can expect the one with the higher revision number to be more recent. 841 842 **version** | string 843 The version of external settings being used. This field helps coordinate updates while preserving compatibility with older nodes. 844 845 #### financialmetrics 846 The financial status of the host. 847 848 **contractcount** | int 849 Number of open file contracts. 850 851 **contractcompensation** | hastings 852 The amount of money that renters have given to the host to pay for file contracts. The host is required to submit a file contract revision and a storage proof for every file contract that gets created, and the renter pays for the miner fees on these objects. 853 854 **potentialcontractcompensation** | hastings 855 The amount of money that renters have given to the host to pay for file contracts which have not been confirmed yet. The potential compensation becomes compensation after the storage proof is submitted. 856 857 **lockedstoragecollateral** | hastings 858 The amount of storage collateral which the host has tied up in file contracts. The host has to commit collateral to a file contract even if there is no storage, but the locked collateral will be returned even if the host does not submit a storage proof - the collateral is not at risk, it is merely set aside so that it can be put at risk later. 859 860 **lostrevenue** | hastings 861 The amount of revenue, including storage revenue and bandwidth revenue, that has been lost due to failed file contracts and failed storage proofs. 862 863 **loststoragecollateral** | hastings 864 The amount of collateral that was put up to protect data which has been lost due to failed file contracts and missed storage proofs. 865 866 **potentialstoragerevenue** | hastings 867 The amount of revenue that the host stands to earn if all storage proofs are submitted corectly and in time. 868 869 **riskedstoragecollateral** | hastings 870 The amount of money that the host has risked on file contracts. If the host starts missing storage proofs, the host can forfeit up to this many coins. In the event of a missed storage proof, locked storage collateral gets returned, but risked storage collateral does not get returned. 871 872 **storagerevenue** | hastings 873 The amount of money that the host has earned from storing data. This money has been locked down by successful storage proofs. 874 875 **transactionfeeexpenses** | hastings 876 The amount of money that the host has spent on transaction fees when submitting host announcements, file contract revisions, and storage proofs. 877 878 **downloadbandwidthrevenue** | hastings 879 The amount of money that the host has made from renters downloading their files. This money has been locked in by successsful storage proofs. 880 881 **potentialdownloadbandwidthrevenue** | hastings 882 The amount of money that the host stands to make from renters that downloaded their files. The host will only realize this revenue if the host successfully submits storage proofs for the related file contracts. 883 884 **potentialuploadbandwidthrevenue** | hastings 885 The amount of money that the host stands to make from renters that uploaded files. The host will only realize this revenue if the host successfully submits storage proofs for the related file contracts. 886 887 **uploadbandwidthrevenue** | hastings 888 The amount of money that the host has made from renters uploading their files. This money has been locked in by successful storage proofs. 889 890 #### internalsettings 891 The settings of the host. Most interactions between the user and the host occur by changing the internal settings. 892 893 **acceptingcontracts** | boolean 894 When set to true, the host will accept new file contracts if the terms are reasonable. When set to false, the host will not accept new file contracts at all. 895 896 **maxdownloadbatchsize** | bytes 897 The maximum size of a single download request from a renter. Each download request has multiple round trips of communication that exchange money. Larger batch sizes mean fewer round trips, but more financial risk for the host - the renter can get a free batch when downloading by refusing to provide a signature. 898 899 **maxduration** | blocks 900 The maximum duration of a file contract that the host will accept. The storage proof window must end before the current height + maxduration. 901 902 **maxrevisebatchsize** | bytes 903 The maximum size of a single batch of file contract revisions. The renter can perform DoS attacks on the host by uploading a batch of data then refusing to provide a signature to pay for the data. The host can reduce this exposure by limiting the batch size. Larger batch sizes allow for higher throughput as there is significant communication overhead associated with performing a batch upload. 904 905 **netaddress** | string 906 The IP address or hostname (including port) that the host should be contacted at. If left blank, the host will automatically figure out its ip address and use that. If given, the host will use the address given. 907 908 **windowsize** | blocks 909 The storage proof window is the number of blocks that the host has to get a storage proof onto the blockchain. The window size is the minimum size of window that the host will accept in a file contract. 910 911 **collateral** | hastings / byte / block 912 The maximum amount of money that the host will put up as collateral per byte per block of storage that is contracted by the renter. 913 914 **collateralbudget** | hastings 915 The total amount of money that the host will allocate to collateral across all file contracts. 916 917 **maxcollateral** | hastings 918 The maximum amount of collateral that the host will put into a 919 <<<<<<< HEAD 920 single file contract. 921 922 **minbaserpcprice** | hastings 923 The minimum price that the host will demand from a renter for interacting with 924 the host. This is charged for every interaction a renter has with a host to pay 925 for resources consumed during the interaction. It is added to the 926 `mindownloadbandwidthprice` and `minuploadbandwidthprice` when uploading or 927 downloading files from the host. 928 ======= 929 single file contract. 930 >>>>>>> siaprime/master 931 932 **mincontractprice** | hastings 933 The minimum price that the host will demand from a renter when forming a contract. Typically this price is to cover transaction fees on the file contract revision and storage proof, but can also be used if the host has a low amount of collateral. The price is a minimum because the host may automatically adjust the price upwards in times of high demand. 934 935 **mindownloadbandwidthprice** | hastings / byte 936 <<<<<<< HEAD 937 The minimum price that the host will demand from a renter when the renter is downloading data. If the host is saturated, the host may increase the price from the minimum. 938 939 **minsectoraccessprice** | hastings 940 The minimum price that the host will demand from a renter for accessing a sector 941 of data on disk. Since the host has to read at least a full 4MB sector from disk 942 regardless of how much the renter intends to download this is charged to pay for 943 the physical disk resources the host uses. It is multiplied by the number of 944 sectors read then added to the `mindownloadbandwidthprice` when downloading a 945 file. 946 ======= 947 The minimum price that the host will demand from a renter when the renter is downloading data. If the host is saturated, the host may increase the price from the minimum. 948 >>>>>>> siaprime/master 949 950 **minstorageprice** | hastings / byte / block 951 The minimum price that the host will demand when storing data for extended periods of time. If the host is low on space, the price of storage may be set higher than the minimum. 952 953 **minuploadbandwidthprice** | hastings / byte 954 The minimum price that the host will demand from a renter when the renter is uploading data. If the host is saturated, the host may increase the price from the minimum. 955 956 #### networkmetrics 957 Information about the network, specifically various ways in which renters have contacted the host. 958 959 **downloadcalls** | int 960 The number of times that a renter has attempted to download something from the host. 961 962 **errorcalls** | int 963 The number of calls that have resulted in errors. A small number of errors are expected, but a large number of errors indicate either buggy software or malicious network activity. Usually buggy software. 964 965 **formcontractcalls** | int 966 The number of times that a renter has tried to form a contract with the host. 967 968 **renewcalls** | int 969 The number of times that a renter has tried to renew a contract with the host. 970 971 **revisecalls** | int 972 The number of times that the renter has tried to revise a contract with the host. 973 974 **settingscalls** | int 975 The number of times that a renter has queried the host for the host's settings. The settings include the price of bandwidth, which is a price that can adjust every few minutes. This value is usually very high compared to the others. 976 977 **unrecognizedcalls** | int 978 The number of times that a renter has attempted to use an unrecognized call. Larger numbers typically indicate buggy software. 979 980 **connectabilitystatus** | string 981 connectabilitystatus is one of "checking", "connectable", or "not connectable", and indicates if the host can connect to itself on its configured NetAddress. 982 983 **workingstatus** | string 984 workingstatus is one of "checking", "working", or "not working" and indicates if the host is being actively used by renters. 985 986 ## /host [POST] 987 > curl example 988 989 ```go 990 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/host?acceptingcontracts=true&maxduration=12096&windowsize=1008" 991 ``` 992 993 Configures hosting parameters. All parameters are optional; unspecified parameters will be left unchanged. 994 995 ### Query String Parameters 996 #### OPTIONAL 997 **acceptingcontracts** | boolean 998 When set to true, the host will accept new file contracts if the terms are reasonable. When set to false, the host will not accept new file contracts at all. 999 1000 **maxdownloadbatchsize** | bytes 1001 The maximum size of a single download request from a renter. Each download request has multiple round trips of communication that exchange money. Larger batch sizes mean fewer round trips, but more financial risk for the host - the renter can get a free batch when downloading by refusing to provide a signature. 1002 1003 **maxduration** | blocks 1004 The maximum duration of a file contract that the host will accept. The storage proof window must end before the current height + maxduration. 1005 1006 **maxrevisebatchsize** | bytes 1007 The maximum size of a single batch of file contract revisions. The renter can perform DoS attacks on the host by uploading a batch of data then refusing to provide a signature to pay for the data. The host can reduce this exposure by limiting the batch size. Larger batch sizes allow for higher throughput as there is significant communication overhead associated with performing a batch upload. 1008 1009 **netaddress** | string 1010 The IP address or hostname (including port) that the host should be contacted at. If left blank, the host will automatically figure out its ip address and use that. If given, the host will use the address given. 1011 1012 **windowsize** | blocks 1013 // The storage proof window is the number of blocks that the host has to get a storage proof onto the blockchain. The window size is the minimum size of window that the host will accept in a file contract. 1014 1015 **collateral** | hastings / byte / block 1016 The maximum amount of money that the host will put up as collateral per byte per block of storage that is contracted by the renter. 1017 1018 **collateralbudget** | hastings 1019 The total amount of money that the host will allocate to collateral across all file contracts. 1020 1021 **maxcollateral** | hastings 1022 The maximum amount of collateral that the host will put into a single file contract. 1023 1024 <<<<<<< HEAD 1025 **minbaserpcprice** | hastings 1026 The minimum price that the host will demand from a renter for interacting with 1027 the host. This is charged for every interaction a renter has with a host to pay 1028 for resources consumed during the interaction. It is added to the 1029 `mindownloadbandwidthprice` and `minuploadbandwidthprice` when uploading or 1030 downloading files from the host. 1031 1032 **mincontractprice** | hastings 1033 The minimum price that the host will demand from a renter when forming a contract. Typically this price is to cover transaction fees on the file contract revision and storage proof, but can also be used if the host has a low amount of collateral. The price is a minimum because the host may automatically adjust the price upwards in times of high demand. 1034 1035 **minsectoraccessprice** | hastings 1036 The minimum price that the host will demand from a renter for accessing a sector 1037 of data on disk. Since the host has to read at least a full 4MB sector from disk 1038 regardless of how much the renter intends to download this is charged to pay for 1039 the physical disk resources the host uses. It is multiplied by the number of 1040 sectors read then added to the `mindownloadbandwidthprice` when downloading a 1041 file. 1042 1043 ======= 1044 **mincontractprice** | hastings 1045 The minimum price that the host will demand from a renter when forming a contract. Typically this price is to cover transaction fees on the file contract revision and storage proof, but can also be used if the host has a low amount of collateral. The price is a minimum because the host may automatically adjust the price upwards in times of high demand. 1046 1047 >>>>>>> siaprime/master 1048 **mindownloadbandwidthprice** | hastings / byte 1049 The minimum price that the host will demand from a renter when the renter is downloading data. If the host is saturated, the host may increase the price from the minimum. 1050 1051 **minstorageprice** | hastings / byte / block 1052 The minimum price that the host will demand when storing data for extended periods of time. If the host is low on space, the price of storage may be set higher than the minimum. 1053 1054 **minuploadbandwidthprice** | hastings / byte 1055 The minimum price that the host will demand from a renter when the renter is uploading data. If the host is saturated, the host may increase the price from the minimum. 1056 1057 ### Response 1058 1059 standard success or error response. See [standard responses](#standard-responses). 1060 1061 ## /host/announce [POST] 1062 > curl example 1063 1064 ```go 1065 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/host/announce" 1066 ``` 1067 1068 Announce the host to the network as a source of storage. Generally only needs to be called once. 1069 1070 Note that even after the host has been announced, it will not accept new contracts unless configured to do so. To configure the host to accept contracts, see [/host](## /host [POST]). 1071 1072 ### Query String Parameters 1073 #### OPTIONAL 1074 **netaddress string** | string 1075 The address to be announced. If no address is provided, the automatically discovered address will be used instead. 1076 1077 ### Response 1078 1079 standard success or error response. See [standard responses](#Standard-Responses). 1080 1081 ## /host/contracts [GET] 1082 > curl example 1083 1084 ```go 1085 curl -A "Sia-Agent" "localhost:9980/host/contracts" 1086 ``` 1087 1088 1089 Get contract information from the host database. This call will return all storage obligations on the host. Its up to the caller to filter the contracts based on their needs. 1090 1091 ### JSON Response 1092 > JSON Response Example 1093 1094 ```go 1095 { 1096 "contracts": [ 1097 { 1098 "contractcost": "1234", // hastings 1099 "datasize": 500000, // bytes 1100 "lockedcollateral": "1234", // hastings 1101 "obligationid": "fff48010dcbbd6ba7ffd41bc4b25a3634ee58bbf688d2f06b7d5a0c837304e13", // hash 1102 "potentialdownloadrevenue": "1234", // hastings 1103 "potentialstoragerevenue": "1234", // hastings 1104 "potentialuploadrevenue": "1234", // hastings 1105 "riskedcollateral": "1234", // hastings 1106 "sectorrootscount": 2, // int 1107 "transactionfeesadded": "1234", // hastings 1108 "expirationheight": 123456, // blocks 1109 "negotiationheight": 123456, // blocks 1110 "proofdeadline": 123456, // blocks 1111 "obligationstatus": "obligationFailed", // string 1112 "originconfirmed": true, // boolean 1113 "proofconfirmed": true, // boolean 1114 "proofconstructed": true, // boolean 1115 "revisionconfirmed": false, // boolean 1116 "revisionconstructed": false, // boolean 1117 } 1118 ] 1119 } 1120 ``` 1121 **contractcost** | hastings 1122 Amount in hastings to cover the transaction fees for this storage obligation. 1123 1124 **datasize** | bytes 1125 Size of the data that is protected by the contract. 1126 1127 **lockedcollateral** | hastings 1128 Amount that is locked as collateral for this storage obligation. 1129 1130 **obligationid** | hash 1131 Id of the storageobligation, which is defined by the file contract id of the file contract that governs the storage obligation. 1132 1133 **potentialdownloadrevenue** | hastings 1134 Potential revenue for downloaded data that the host will reveive upon successful completion of the obligation. 1135 1136 **potentialstoragerevenue** | hastings 1137 Potential revenue for storage of data that the host will reveive upon successful completion of the obligation. 1138 1139 **potentialuploadrevenue** | hastings 1140 Potential revenue for uploaded data that the host will reveive upon successful completion of the obligation. 1141 1142 **riskedcollateral** | hastings 1143 Amount that the host might lose if the submission of the storage proof is not successful. 1144 1145 **sectorrootscount** | int 1146 Number of sector roots. 1147 1148 **transactionfeesadded** | hastings 1149 Amount for transaction fees that the host added to the storage obligation. 1150 1151 **expirationheight** | blockheight 1152 Expiration height is the height at which the storage obligation expires. 1153 1154 **negotiationheight** | blockheight 1155 Negotion height is the height at which the storage obligation was negotiated. 1156 1157 **proofdeadline** | blockheight 1158 The proof deadline is the height by which the storage proof must be submitted. 1159 1160 **obligationstatus** | string 1161 Status of the storage obligation. There are 4 different statuses: 1162 - `obligationFailed`: the storage obligation failed, potential revenues and risked collateral are lost 1163 - `obligationRejected`: the storage obligation was never started, no revenues gained or lost 1164 - `obligationSucceeded`: the storage obligation was completed, revenues were gained 1165 - `obligationUnresolved`: the storage obligation has an uninitialized value. When the **proofdeadline** is in the past this might be a stale obligation. 1166 1167 **originconfirmed** | hash 1168 Origin confirmed indicates whether the file contract was seen on the blockchain for this storage obligation. 1169 1170 **proofconfirmed** | boolean 1171 Proof confirmed indicates whether there was a storage proof seen on the blockchain for this storage obligation. 1172 1173 **proofconstructed** | boolean 1174 The host has constructed a storage proof 1175 1176 **revisionconfirmed** | boolean 1177 Revision confirmed indicates whether there was a file contract revision seen on the blockchain for this storage obligation. 1178 1179 **revisionconstructed** | boolean 1180 Revision constructed indicates whether there was a file contract revision constructed for this storage obligation. 1181 1182 ## /host/storage [GET] 1183 > curl example 1184 1185 ```go 1186 curl -A "Sia-Agent" "localhost:9980/host/storage" 1187 ``` 1188 1189 Gets a list of folders tracked by the host's storage manager. 1190 1191 ### JSON Response 1192 > JSON Response Example 1193 1194 ```go 1195 { 1196 "folders": [ 1197 { 1198 "path": "/home/foo/bar", // string 1199 "capacity": 50000000000, // bytes 1200 "capacityremaining": 100000, // bytes 1201 1202 "failedreads": 0, // int 1203 "failedwrites": 1, // int 1204 "successfulreads": 2, // int 1205 "successfulwrites": 3, // int 1206 } 1207 ] 1208 } 1209 ``` 1210 **path** | string 1211 Absolute path to the storage folder on the local filesystem. 1212 1213 **capacity** | bytes 1214 Maximum capacity of the storage folder in bytes. The host will not store more than this many bytes in the folder. This capacity is not checked against the drive's remaining capacity. Therefore, you must manually ensure the disk has sufficient capacity for the folder at all times. Otherwise you risk losing renter's data and failing storage proofs. 1215 1216 **capacityremaining** | bytes 1217 Unused capacity of the storage folder in bytes. 1218 1219 **failedreads, failedwrites** | int 1220 Number of failed disk read & write operations. A large number of failed reads or writes indicates a problem with the filesystem or drive's hardware. 1221 1222 **successfulreads, successfulwrites** | int 1223 Number of successful read & write operations. 1224 1225 ## /host/storage/folders/add [POST] 1226 > curl example 1227 1228 ```go 1229 curl -A "Sia-Agent" -u "":<apipassword> --data "path=foo/bar&size=1000000000000" "localhost:9980/host/storage/add" 1230 ``` 1231 1232 adds a storage folder to the manager. The manager may not check that there is enough space available on-disk to support as much storage as requested 1233 1234 ### Query String Parameters 1235 #### REQUIRED 1236 **path** | string 1237 Local path on disk to the storage folder to add. 1238 1239 **size** | bytes 1240 Initial capacity of the storage folder. This value isn't validated so it is possible to set the capacity of the storage folder greater than the capacity of the disk. Do not do this. 1241 1242 ### Response 1243 1244 standard success or error response. See [standard responses](#standard-responses). 1245 1246 ## /host/storage/folders/remove [POST] 1247 > curl example 1248 1249 ```go 1250 curl -A "Sia-Agent" -u "":<apipassword> --data "path=foo/bar&force=false" "localhost:9980/host/storage/remove" 1251 ``` 1252 1253 Remove a storage folder from the manager. All sotrage on the folder will be moved to other stoarge folders, meaning that no data will be lost. If the manager is unable to save data, an error will be returned and the operation will be stopped. 1254 1255 ### Query String Parameters 1256 #### REQUIRED 1257 **path** | string 1258 Local path on disk to the storage folder to removed. 1259 1260 #### OPTIONAL 1261 **force** | boolean 1262 If `force` is true, the storage folder will be removed even if the data in the storage folder cannot be moved to other storage folders, typically because they don't have sufficient capacity. If `force` is true and the data cannot be moved, data will be lost. 1263 1264 ### Response 1265 1266 standard success or error response. See [standard responses](#standard-responses). 1267 1268 ## /host/storage/folders/resize [POST] 1269 > curl example 1270 1271 ```go 1272 curl -A "Sia-Agent" -u "":<apipassword> --data "path=foo/bar&newsize=1000000000000" "localhost:9980/host/storage/resize" 1273 ``` 1274 1275 Grows or shrinks a storage file in the manager. The manager may not check that there is enough space on-disk to support growing the storasge folder, but should gracefully handle running out of space unexpectedly. When shrinking a storage folder, any data in the folder that neeeds to be moved will be placed into other storage folders, meaning that no data will be lost. If the manager is unable to migrate the data, an error will be returned and the operation will be stopped. 1276 1277 ### Query String Parameters 1278 #### REQUIRED 1279 **path** | string 1280 Local path on disk to the storage folder to resize. 1281 1282 **newsize** | bytes 1283 Desired new size of the storage folder. This will be the new capacity of the storage folder. 1284 1285 ### Response 1286 1287 standard success or error response. See [standard responses](#standard-responses). 1288 1289 ## /host/storage/sectors/delete/:*merkleroot* [POST] 1290 > curl example 1291 1292 ```go 1293 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/host/storage/sectors/delete/[merkleroot]" 1294 ``` 1295 1296 Deletes a sector, meaning that the manager will be unable to upload that sector and be unable to provide a storage proof on that sector. This endpoint is for removing the data entirely, and will remove instances of the sector appearing at all heights. The primary purpose is to comply with legal requests to remove data. 1297 1298 ### Path Parameters 1299 #### REQUIRED 1300 **merkleroot** | merkleroot 1301 Merkleroot of the sector to delete. 1302 1303 ### Response 1304 1305 standard success or error response. See [standard responses](#standard-responses). 1306 1307 ## /host/estimatescore [GET] 1308 > curl example 1309 1310 ```go 1311 curl -A "Sia-Agent" "localhost:9980/host/estimatescore" 1312 ``` 1313 1314 Returns the estimated HostDB score of the host using its current settings, combined with the provided settings. 1315 1316 ### Query String Parameters 1317 #### OPTIONAL 1318 See [host internal settings](#internalsettings) 1319 - acceptingcontracts 1320 - maxdownloadbatchsize 1321 - maxduration 1322 - maxrevisebatchsize 1323 - netaddress 1324 - windowsize 1325 - collateral 1326 - collateralbudget 1327 - maxcollateral 1328 - mincontractprice 1329 - mindownloadbandwidthprice 1330 - minstorageprice 1331 - minuploadbandwidthprice 1332 1333 ### JSON Response 1334 > JSON Response Example 1335 1336 ```go 1337 { 1338 "estimatedscore": "123456786786786786786786786742133", // big int 1339 "conversionrate": 95 // float64 1340 } 1341 ``` 1342 **estimatedscore** | big int 1343 estimatedscore is the estimated HostDB score of the host given the settings passed to estimatescore. 1344 1345 **conversionrate** | float64 1346 conversionrate is the likelihood given the settings passed to estimatescore that the host will be selected by renters forming contracts. 1347 1348 # Host DB 1349 1350 The hostdb maintains a database of all hosts known to the network. The database identifies hosts by their public key and keeps track of metrics such as price. 1351 1352 ## /hostdb [GET] 1353 > curl example 1354 1355 ```go 1356 curl -A "Sia-Agent" "localhost:9980/hostdb" 1357 ``` 1358 1359 Shows some general information about the state of the hostdb. 1360 1361 ### JSON Response 1362 > JSON Response Example 1363 1364 ```go 1365 { 1366 "initialscancomplete": false // boolean 1367 } 1368 ``` 1369 **initialscancomplete** | boolean 1370 indicates if all known hosts have been scanned at least once. 1371 1372 ## /hostdb/active [GET] 1373 > curl example 1374 1375 ```go 1376 curl -A "Sia-Agent" "localhost:9980/hostdb/active" 1377 ``` 1378 1379 lists all of the active hosts known to the renter, sorted by preference. 1380 1381 ### Query String Parameters 1382 #### OPTIONAL 1383 **numhosts** | int 1384 Number of hosts to return. The actual number of hosts returned may be less if there are insufficient active hosts. Optional, the default is all active hosts. 1385 1386 ### JSON Response 1387 > JSON Response Example 1388 1389 ```go 1390 { 1391 "hosts": [ 1392 { 1393 "acceptingcontracts": true, // boolean 1394 "maxdownloadbatchsize": 17825792, // bytes 1395 "maxduration": 25920, // blocks 1396 "maxrevisebatchsize": 17825792, // bytes 1397 "netaddress": "123.456.789.0:9982" // string 1398 "remainingstorage": 35000000000, // bytes 1399 "sectorsize": 4194304, // bytes 1400 "totalstorage": 35000000000, // bytes 1401 "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", // hash 1402 "windowsize": 144, // blocks 1403 "collateral": "20000000000" // hastings / byte / block 1404 "maxcollateral": "1000000000000000000000000000" // hastings 1405 "contractprice": "1000000000000000000000000" // hastings 1406 "downloadbandwidthprice": "35000000000000" // hastings / byte 1407 "storageprice": "14000000000" // hastings / byte / block 1408 "uploadbandwidthprice": "3000000000000" // hastings / byte 1409 "revisionnumber": 12733798, // int 1410 "version": "1.3.4" // string 1411 "firstseen": 160000, // blocks 1412 "historicdowntime": 0, // nanoseconds 1413 "historicuptime": 41634520900246576, // nanoseconds 1414 "scanhistory": [ 1415 { 1416 "success": true, // boolean 1417 "timestamp": "2018-09-23T08:00:00.000000000+04:00" // unix timestamp 1418 }, 1419 { 1420 "success": true, // boolean 1421 "timestamp": "2018-09-23T06:00:00.000000000+04:00" // unix timestamp 1422 }, 1423 { 1424 "success": true, // boolean// boolean 1425 "timestamp": "2018-09-23T04:00:00.000000000+04:00" // unix timestamp 1426 } 1427 ], 1428 "historicfailedinteractions": 0, // int 1429 "historicsuccessfulinteractions": 5, // int 1430 "recentfailedinteractions": 0, // int 1431 "recentsuccessfulinteractions": 0, // int 1432 "lasthistoricupdate": 174900, // blocks 1433 "ipnets": [ 1434 "1.2.3.0", // string 1435 "2.1.3.0" // string 1436 ], 1437 "lastipnetchange": "2015-01-01T08:00:00.000000000+04:00", // unix timestamp 1438 "publickey": { 1439 "algorithm": "ed25519", // string 1440 "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU=" // string 1441 }, 1442 "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", // string 1443 "filtered": false, // boolean 1444 } 1445 ] 1446 } 1447 ``` 1448 1449 #### hosts 1450 **acceptingcontracts** | boolean 1451 true if the host is accepting new contracts. 1452 1453 **maxdownloadbatchsize** | bytes 1454 Maximum number of bytes that the host will allow to be requested by a single download request. 1455 1456 **maxduration** | blocks 1457 Maximum duration in blocks that a host will allow for a file contract. The host commits to keeping files for the full duration under the threat of facing a large penalty for losing or dropping data before the duration is complete. The storage proof window of an incoming file contract must end before the current height + maxduration. 1458 1459 There is a block approximately every 10 minutes. e.g. 1 day = 144 blocks 1460 1461 **maxrevisebatchsize** | bytes 1462 Maximum size in bytes of a single batch of file contract revisions. Larger batch sizes allow for higher throughput as there is significant communication overhead associated with performing a batch upload. 1463 1464 **netaddress** | sting 1465 Remote address of the host. It can be an IPv4, IPv6, or hostname, along with the port. IPv6 addresses are enclosed in square brackets. 1466 1467 **remainingstorage** | bytes 1468 Unused storage capacity the host claims it has. 1469 1470 **sectorsize** | bytes 1471 Smallest amount of data in bytes that can be uploaded or downloaded to or from the host. 1472 1473 **totalstorage** | bytes 1474 Total amount of storage capacity the host claims it has. 1475 1476 **unlockhash** | hash 1477 Address at which the host can be paid when forming file contracts. 1478 1479 **windowsize** | blocks 1480 A storage proof window is the number of blocks that the host has to get a storage proof onto the blockchain. The window size is the minimum size of window that the host will accept in a file contract. 1481 1482 **collateral** | hastings / byte / block 1483 The maximum amount of money that the host will put up as collateral for storage that is contracted by the renter. 1484 1485 **maxcollateral** | hastings 1486 The maximum amount of collateral that the host will put into a single file contract. 1487 1488 **contractprice** | hastings 1489 The price that a renter has to pay to create a contract with the host. The payment is intended to cover transaction fees for the file contract revision and the storage proof that the host will be submitting to the blockchain. 1490 1491 **downloadbandwidthprice** | hastings / byte 1492 The price that a renter has to pay when downloading data from the host. 1493 1494 **storageprice** | hastings / byte / block 1495 The price that a renter has to pay to store files with the host. 1496 1497 **uploadbandwidthprice** | hastings / byte 1498 The price that a renter has to pay when uploading data to the host. 1499 1500 **revisionnumber** | int 1501 The revision number indicates to the renter what iteration of settings the host is currently at. Settings are generally signed. If the renter has multiple conflicting copies of settings from the host, the renter can expect the one with the higher revision number to be more recent. 1502 1503 **version** | string 1504 The version of the host. 1505 1506 **firstseen** | blocks 1507 Firstseen is the last block height at which this host was announced. 1508 1509 **historicdowntime** | nanoseconds 1510 Total amount of time the host has been offline. 1511 1512 **historicuptime** | nanoseconds 1513 Total amount of time the host has been online. 1514 1515 **scanhistory** 1516 Measurements that have been taken on the host. The most recent measurements are kept in full detail. 1517 1518 **historicfailedinteractions** | int 1519 Number of historic failed interactions with the host. 1520 1521 **historicsuccessfulinteractions** | int 1522 Number of historic successful interactions with the host. 1523 1524 **recentfailedinteractions** | int 1525 Number of recent failed interactions with the host. 1526 1527 **recentsuccessfulinteractions** | int 1528 Number of recent successful interactions with the host. 1529 1530 **lasthistoricupdate** | blocks 1531 The last time that the interactions within scanhistory have been compressed into the historic ones. 1532 1533 **ipnets** 1534 List of IP subnet masks used by the host. For IPv4 the /24 and for IPv6 the /54 subnet mask is used. A host can have either one IPv4 or one IPv6 subnet or one of each. E.g. these lists are valid: [ "IPv4" ], [ "IPv6" ] or [ "IPv4", "IPv6" ]. The following lists are invalid: [ "IPv4", "IPv4" ], [ "IPv4", "IPv6", "IPv6" ]. Hosts with an invalid list are ignored. 1535 1536 **lastipnetchange** | date 1537 The last time the list of IP subnet masks was updated. When equal subnet masks are found for different hosts, the host that occupies the subnet mask for a longer time is preferred. 1538 1539 **publickey** 1540 Public key used to identify and verify hosts. 1541 1542 **algorithm** | string 1543 Algorithm used for signing and verification. Typically "ed25519". 1544 1545 **key** | hash 1546 Key used to verify signed host messages. 1547 1548 **publickeystring** | string 1549 The string representation of the full public key, used when calling /hostdb/hosts. 1550 1551 **filtered** | boolean 1552 Indicates if the host is currently being filtered from the HostDB 1553 1554 ## /hostdb/all [GET] 1555 > curl example 1556 1557 ```go 1558 curl -A "Sia-Agent" "localhost:9980/hostdb/all" 1559 ``` 1560 1561 Lists all of the hosts known to the renter. Hosts are not guaranteed to be in any particular order, and the order may change in subsequent calls. 1562 1563 ### JSON Response 1564 <<<<<<< HEAD 1565 Response is the same as [`/hostdb/active`](#hosts) 1566 ======= 1567 Repsonse is the same as [`/hostdb/active`](#hosts) 1568 >>>>>>> siaprime/master 1569 1570 ## /hostdb/hosts/:*pubkey* [GET] 1571 > curl example 1572 1573 ```go 1574 curl -A "Sia-Agent" "localhost:9980/hostdb/hosts/ed25519:8a95848bc71e9689e2f753c82c35dc47a1d62867f77c0113ebb6fa5b51723215" 1575 ``` 1576 1577 fetches detailed information about a particular host, including metrics regarding the score of the host within the database. It should be noted that each renter uses different metrics for selecting hosts, and that a good score on in one hostdb does not mean that the host will be successful on the network overall. 1578 1579 ### Path Parameters 1580 > curl example 1581 1582 ```go 1583 curl -A "Sia-Agent" "localhost:9980/hostdb/hosts/<pubkey>" 1584 ``` 1585 #### REQUIRED 1586 **pubkey** 1587 The public key of the host. Each public key identifies a single host. 1588 1589 Example Pubkey: ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef 1590 1591 ### JSON Response 1592 > JSON Response Example 1593 1594 ```go 1595 { 1596 "entry": { 1597 // same as hosts 1598 }, 1599 "scorebreakdown": { 1600 "score": 1, // big int 1601 "conversionrate": 9.12345, // float64 1602 "ageadjustment": 0.1234, // float64 1603 "burnadjustment": 0.1234, // float64 1604 "collateraladjustment": 23.456, // float64 1605 <<<<<<< HEAD 1606 "durationadjustment": 1, // float64 1607 ======= 1608 >>>>>>> siaprime/master 1609 "interactionadjustment": 0.1234, // float64 1610 "priceadjustment": 0.1234, // float64 1611 "storageremainingadjustment": 0.1234, // float64 1612 "uptimeadjustment": 0.1234, // float64 1613 "versionadjustment": 0.1234, // float64 1614 } 1615 } 1616 ``` 1617 Response is the same as [`/hostdb/active`](#hosts) with the additional of the **scorebreakdown** 1618 1619 **scorebreakdown** 1620 A set of scores as determined by the renter. Generally, the host's final score is all of the values multiplied together. Modified renters may have additional criteria that they use to judge a host, or may ignore certin criteia. In general, these fields should only be used as a loose guide for the score of a host, as every renter sees the world differently and uses different metrics to evaluate hosts. 1621 1622 **score** | big int 1623 The overall score for the host. Scores are entriely relative, and are consistent only within the current hostdb. Between different machines, different configurations, and different versions the absolute scores for a given host can be off by many orders of magnitude. When displaying to a human, some form of normalization with respect to the other hosts (for example, divide all scores by the median score of the hosts) is recommended. 1624 1625 **conversionrate** | float64 1626 conversionrate is the likelihood that the host will be selected by renters forming contracts. 1627 1628 **ageadjustment** | float64 1629 The multiplier that gets applied to the host based on how long it has been a host. Older hosts typically have a lower penalty. 1630 1631 **burnadjustment** | float64 1632 The multiplier that gets applied to the host based on how much proof-of-burn the host has performed. More burn causes a linear increase in score. 1633 1634 **collateraladjustment** | float64 1635 The multiplier that gets applied to a host based on how much collateral the host is offering. More collateral is typically better, though above a point it can be detrimental. 1636 1637 <<<<<<< HEAD 1638 **durationadjustment** | float64 1639 The multiplier that gets applied to a host based on the max duration it accepts for file contracts. Typically '1' for hosts with an acceptable max duration, and '0' for hosts that have a max duration which is not long enough. 1640 1641 ======= 1642 >>>>>>> siaprime/master 1643 **interactionadjustment** | float64 1644 The multipler that gets applied to a host based on previous interactions with the host. A high ratio of successful interactions will improve this hosts score, and a high ratio of failed interactions will hurt this hosts score. This adjustment helps account for hosts that are on unstable connections, don't keep their wallets unlocked, ran out of funds, etc. 1645 1646 **pricesmultiplier** | float64 1647 The multiplier that gets applied to a host based on the host's price. Lower prices are almost always better. Below a certain, very low price, there is no advantage. 1648 1649 **storageremainingadjustment** | float64 1650 The multiplier that gets applied to a host based on how much storage is remaining for the host. More storage remaining is better, to a point. 1651 1652 **uptimeadjustment** | float64 1653 The multiplier that gets applied to a host based on the uptime percentage of the host. The penalty increases extremely quickly as uptime drops below 90%. 1654 1655 **versionadjustment** | float64 1656 The multiplier that gets applied to a host based on the version of Sia that they are running. Versions get penalties if there are known bugs, scaling limitations, performance limitations, etc. Generally, the most recent version is always the one with the highest score. 1657 1658 <<<<<<< HEAD 1659 ## /hostdb/filtermode [GET] 1660 > curl example 1661 1662 ```go 1663 curl -A "Sia-Agent" --user "":<apipassword> "localhost:9980/hostdb/filtermode" 1664 ``` 1665 Returns the current filter mode of the hostDB and any filtered hosts. 1666 1667 ### JSON Response 1668 > JSON Response Example 1669 1670 ```go 1671 { 1672 "filtermode": "blacklist", // string 1673 "hosts": 1674 [ 1675 "ed25519:122218260fb74b20a8be3000ad56a931f7461ea990a6dc5676c31bdf65fc668f" // string 1676 ] 1677 } 1678 1679 ``` 1680 **filtermode** | string 1681 Can be either whitelist, blacklist, or disable. 1682 1683 **hosts** | array of strings 1684 Comma separated pubkeys. 1685 1686 ======= 1687 >>>>>>> siaprime/master 1688 ## /hostdb/filtermode [POST] 1689 > curl example 1690 1691 ```go 1692 curl -A "Sia-Agent" --user "":<apipassword> --data '{"filtermode" : "whitelist","hosts" : ["ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef","ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef","ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"]}' "localhost:9980/hostdb/filtermode" 1693 ``` 1694 ```go 1695 curl -A "Sia-Agent" --user "":<apipassword> --data '{"filtermode" : "disable"}' "localhost:9980/hostdb/filtermode" 1696 ``` 1697 <<<<<<< HEAD 1698 Lets you enable and disable a filter mode for the hostdb. Currently the two modes supported are `blacklist` mode and `whitelist` mode. In `blacklist` mode, any hosts you identify as being on the `blacklist` will not be used to form contracts. In `whitelist` mode, only the hosts identified as being on the `whitelist` will be used to form contracts. In both modes, hosts that you are blacklisted will be filtered from your hostdb. To enable either mode, set `filtermode` to the desired mode and submit a list of host pubkeys as the corresponding `blacklist` or `whitelist`. To disable either list, the `host` field can be left blank (e.g. empty slice) and the `filtermode` should be set to `disable`. 1699 ======= 1700 Lets you enable and disable a filter mode for the hostdb. Currenlty the two modes supported are `blacklist` mode and `whitelist` mode. In `blacklist` mode, any hosts you identify as being on the `blacklist` will not be used to form contracts. In `whitelist` mode, only the hosts identified as being on the `whitelist` will be used to form contracts. In both modes, hosts that you are blacklisted will be filtered from your hostdb. To enable either mode, set `filtermode` to the desired mode and submit a list of host pubkeys as the corresponding `blacklist` or `whitelist`. To disable either list, the `host` field can be left blank (e.g. empty slice) and the `filtermode` should be set to `disable`. 1701 >>>>>>> siaprime/master 1702 1703 **NOTE:** Enabling and disabling a filter mode can result in changes with your current contracts with can result in an increase in contract fee spending. For example, if `blacklist` mode is enabled, any hosts that you currently have contracts with that are also on the provide list of `hosts` will have their contracts replaced with non-blacklisted hosts. When `whitelist` mode is enabled, contracts will be replaced until there are only contracts with whitelisted hosts. Even disabling a filter mode can result in a change in contracts if there are better scoring hosts in your hostdb that were previously being filtered out. 1704 1705 ### Query String Parameters 1706 #### REQUIRED 1707 **filtermode** | string 1708 Can be either whitelist, blacklist, or disable. 1709 1710 <<<<<<< HEAD 1711 **hosts** | array of string 1712 ======= 1713 **hosts** | array of string 1714 >>>>>>> siaprime/master 1715 Comma separated pubkeys. 1716 1717 ### Response 1718 1719 standard success or error response. See [standard responses](#standard-responses). 1720 1721 # Miner 1722 1723 The miner provides endpoints for getting headers for work and submitting solved headers to the network. The miner also provides endpoints for controlling a basic CPU mining implementation. 1724 1725 ## /miner [GET] 1726 > curl example 1727 1728 ```go 1729 curl -A "Sia-Agent" "localhost:9980/miner" 1730 ``` 1731 returns the status of the miner. 1732 1733 ### JSON Response 1734 > JSON Response Example 1735 1736 ```go 1737 { 1738 "blocksmined": 9001, // int 1739 "cpuhashrate": 1337, // hashes / second 1740 "cpumining": false, // boolean 1741 "staleblocksmined": 0, // int 1742 } 1743 ``` 1744 **blocksmined** | int 1745 Number of mined blocks. This value is remembered after restarting. 1746 1747 **cpuhashrate** | hashes / second 1748 How fast the cpu is hashing, in hashes per second. 1749 1750 **cpumining** | boolean 1751 true if the cpu miner is active. 1752 1753 **staleblocksmined** | int 1754 Number of mined blocks that are stale, indicating that they are not included in the current longest chain, likely because some other block at the same height had its chain extended first. 1755 1756 1757 ## /miner/start [GET] 1758 > curl example 1759 1760 ```go 1761 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/miner/start" 1762 ``` 1763 1764 Starts a single threaded CPU miner. Does nothing if the CPU miner is already running. 1765 1766 ### Response 1767 1768 standard success or error response. See [standard responses](#standard-responses). 1769 1770 ## /miner/stop [GET] 1771 > curl example 1772 1773 ```go 1774 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/miner/stop" 1775 ``` 1776 1777 stops the cpu miner. Does nothing if the cpu miner is not running. 1778 1779 ### Response 1780 1781 standard success or error response. See [standard responses](#standard-responses). 1782 1783 ## /miner/header [GET] 1784 > curl example 1785 1786 ```go 1787 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/miner/header" 1788 ``` 1789 1790 provides a block header that is ready to be grinded on for work. 1791 1792 ### Byte Response 1793 For efficiency the header for work is returned as a raw byte encoding of the header, rather than encoded to JSON. 1794 1795 Blocks are mined by repeatedly changing the nonce of the header, hashing the header's bytes, and comparing the resulting hash to the target. The block with that nonce is valid if the hash is less than the target. If none of the 2^64 possible nonces result in a header with a hash less than the target, call /miner/header [GET] again to get a new block header with a different merkle root. The above process can then be repeated for the new block header. 1796 1797 The other fields can generally be ignored. The parent block ID field is the hash of the parent block's header. Modifying this field will result in an orphan block. The timestamp is the time at which the block was mined and is set by the Sia Daemon. Modifying this field can result in invalid block. The merkle root is the merkle root of a merkle tree consisting of the timestamp, the miner outputs (one leaf per payout), and the transactions (one leaf per transaction). Modifying this field will result in an invalid block. 1798 1799 Field | Byte range within response | Byte range within header 1800 -------------- | -------------- | -------------- 1801 target | [0-32) 1802 header | [32-112) 1803 parent block ID | [32-64) | [0-32) 1804 nonce | [64-72) | [32-40) 1805 timestamp | [72-80) | [40-48) 1806 merkle root | [80-112) | [48-80) 1807 1808 ## /miner/header [POST] 1809 > curl example 1810 1811 ```go 1812 curl -A "Sia-Agent" -data "<byte-encoded-header>" -u "":<apipassword> "localhost:9980/miner" 1813 ``` 1814 1815 submits a header that has passed the POW. 1816 1817 ### Byte Response 1818 For efficiency headers are submitted as raw byte encodings of the header in the body of the request, rather than as a query string parameter or path parameter. The request body should contain only the 80 bytes of the encoded header. The encoding is the same encoding used in `/miner/header [GET]` endpoint. 1819 1820 Blocks are mined by repeatedly changing the nonce of the header, hashing the header's bytes, and comparing the resulting hash to the target. The block with that nonce is valid if the hash is less than the target. If none of the 2^64 possible nonces result in a header with a hash less than the target, call /miner/header [GET] again to get a new block header with a different merkle root. The above process can then be repeated for the new block header. 1821 1822 The other fields can generally be ignored. The parent block ID field is the hash of the parent block's header. Modifying this field will result in an orphan block. The timestamp is the time at which the block was mined and is set by the Sia Daemon. Modifying this field can result in invalid block. The merkle root is the merkle root of a merkle tree consisting of the timestamp, the miner outputs (one leaf per payout), and the transactions (one leaf per transaction). Modifying this field will result in an invalid block. 1823 1824 Field | Byte range within response | Byte range within header 1825 -------------- | -------------- | -------------- 1826 target | [0-32) 1827 header | [32-112) 1828 parent block ID | [32-64) | [0-32) 1829 nonce | [64-72) | [32-40) 1830 timestamp | [72-80) | [40-48) 1831 merkle root | [80-112) | [48-80) 1832 1833 # Renter 1834 1835 The renter manages the user's files on the network. The renter's API endpoints expose methods for managing files on the network and managing the renter's allocated funds. 1836 1837 ## /renter [GET] 1838 > curl example 1839 1840 ```go 1841 curl -A "Sia-Agent" "localhost:9980/renter" 1842 ``` 1843 1844 Returns the current settings along with metrics on the renter's spending. 1845 1846 ### JSON Response 1847 > JSON Response Example 1848 1849 ```go 1850 { 1851 "settings": { 1852 "allowance": { 1853 <<<<<<< HEAD 1854 "funds": "1234", // hastings 1855 "hosts": 24, // int 1856 "period": 6048, // blocks 1857 "renewwindow": 3024 // blocks 1858 "expectedstorage": 1000000000000, // uint64 1859 "expectedupload": 2, // uint64 1860 "expecteddownload": 1, // uint64 1861 "expectedredundancy": 3 // uint64 1862 ======= 1863 "funds": "1234", // hastings 1864 "hosts": 24, // int 1865 "period": 6048, // blocks 1866 "renewwindow": 3024 // blocks 1867 >>>>>>> siaprime/master 1868 }, 1869 "maxuploadspeed": 1234, // BPS 1870 "maxdownloadspeed": 1234, // BPS 1871 "streamcachesize": 4 // int 1872 }, 1873 "financialmetrics": { 1874 "contractfees": "1234", // hastings 1875 "contractspending": "1234", // hastings (deprecated, now totalallocated) 1876 "downloadspending": "5678", // hastings 1877 "storagespending": "1234", // hastings 1878 "totalallocated": "1234", // hastings 1879 "uploadspending": "5678", // hastings 1880 "unspent": "1234" // hastings 1881 }, 1882 "currentperiod": 200 // blockheight 1883 } 1884 ``` 1885 #### settings 1886 Settings that control the behavior of the renter. 1887 1888 #### allowance 1889 Allowance dictates how much the renter is allowed to spend in a given period. Note that funds are spent on both storage and bandwidth. 1890 1891 **funds** | hastings 1892 <<<<<<< HEAD 1893 Funds determines the number of siacoins that the renter will spend when forming 1894 contracts with hosts. The renter will not allocate more than this amount of 1895 siacoins into the set of contracts each billing period. If the renter spends all 1896 of the funds but then needs to form new contracts, the renter will wait until 1897 either until the user increase the allowance funds, or until a new billing 1898 period is reached. If there are not enough funds to repair all files, then files 1899 may be at risk of getting lost. 1900 1901 **hosts** | int 1902 Hosts sets the number of hosts that will be used to form the allowance. Sia 1903 gains most of its resiliancy from having a large number of hosts. More hosts 1904 will mean both more robustness and higher speeds when using the network, however 1905 will also result in more memory consumption and higher blockchain fees. It is 1906 recommended that the default number of hosts be treated as a minimum, and that 1907 double the default number of default hosts be treated as a maximum. 1908 1909 **period** | blocks 1910 The period is equivalent to the billing cycle length. The renter will not spend 1911 more than the full balance of its funds every billing period. When the billing 1912 period is over, the contracts will be renewed and the spending will be reset. 1913 1914 **renewwindow** | blocks 1915 The renew window is how long the user has to renew their contracts. At the end 1916 of the period, all of the contracts expire. The contracts need to be renewewd 1917 before they expire, otherwise the user will lose all of their files. The renew 1918 window is the window of time at the end of the period during which the renter 1919 will renew the users contracts. For example, if the renew window is 1 week long, 1920 then during the final week of each period the user will renew their contracts. 1921 If the user is offline for that whole week, the user's data will be lost. 1922 1923 Each billing period begins at the beginning of the renew window for the previous 1924 period. For example, if the period is 12 weeks long and the renew window is 4 1925 weeks long, then the first billing period technically begins at -4 weeks, or 4 1926 weeks before the allowance is created. And the second billing period begins at 1927 week 8, or 8 weeks after the allowance is created. The third billing period will 1928 begin at week 20. 1929 1930 **expectedstorage** | bytes 1931 Expected storage is the amount of storage that the user expects to keep on the 1932 Sia network. This value is important to calibrate the spending habits of siad. 1933 Because Sia is decentralized, there is no easy way for siad to know what the 1934 real world cost of storage is, nor what the real world price of a siacoin is. To 1935 overcome this deficiency, siad depends on the user for guidance. 1936 1937 If the user has a low allowance and a high amount of expected storage, siad will 1938 more heavily prioritize cheaper hosts, and will also be more comfortable with 1939 hosts that post lower amounts of collateral. If the user has a high allowance 1940 and a low amount of expected storage, siad will prioritize hosts that post more 1941 collateral, as well as giving preference to hosts better overall traits such as 1942 uptime and age. 1943 1944 Even when the user has a large allowance and a low amount of expected storage, 1945 siad will try to optimize for saving money; siad tries to meet the users storage 1946 and bandwidth needs while spending significantly less than the overall allowance. 1947 1948 **expectedupload** | bytes 1949 Expected upload tells siad how much uploading the user expects to do each month. 1950 If this value is high, siad will more strongly prefer hosts that have a low 1951 upload bandwidth price. If this value is low, siad will focus on other metrics 1952 than upload bandwidth pricing, because even if the host charges a lot for upload 1953 bandwidth, it will not impact the total cost to the user very much. 1954 1955 The user should not consider upload bandwidth used during repairs, siad will 1956 consider repair bandwidth separately. 1957 1958 **expecteddownload** | bytes 1959 Expected download tells siad how much downloading the user expects to do each 1960 month. If this value is high, siad will more strongly prefer hosts that have a 1961 low download bandwidth price. If this value is low, siad will focus on other 1962 metrics than download bandwidth pricing, because even if the host charges a lot 1963 for downloads, it will not impact the total cost to the user very much. 1964 1965 The user should not consider download bandwidth used during repairs, siad will 1966 consider repair bandwidth separately. 1967 1968 **expectedredundancy** | bytes 1969 Expected redundancy is used in conjunction with expected storage to determine 1970 the total amount of raw storage that will be stored on hosts. If the expected 1971 storage is 1 TB and the expected redundancy is 3, then the renter will calculate 1972 that the total amount of storage in the user's contracts will be 3 TiB. 1973 1974 This value does not need to be changed from the default unless the user is 1975 manually choosing redundancy settings for their file. If different files are 1976 being given different redundancy settings, then the average of all the 1977 redundancies should be used as the value for expected redundancy, weighted by 1978 how large the files are. 1979 ======= 1980 Amount of money allocated for contracts. Funds are spent on both storage and bandwidth. 1981 1982 **hosts** | int 1983 Number of hosts that contracts will be formed with. 1984 1985 **period** | blocks 1986 Duration of contracts formed, in number of blocks. 1987 1988 **renewwindow** | blocks 1989 If the current blockheight + the renew window >= the height the contract is scheduled to end, the contract is renewed automatically. Is always nonzero. 1990 >>>>>>> siaprime/master 1991 1992 **maxuploadspeed** | bytes per second 1993 MaxUploadSpeed by default is unlimited but can be set by the user to manage bandwidth. 1994 1995 **maxdownloadspeed** | bytes per second 1996 MaxDownloadSpeed by default is unlimited but can be set by the user to manage bandwidth. 1997 1998 **streamcachesize** | int 1999 The StreamCacheSize is the number of data chunks that will be cached during streaming. 2000 2001 #### financialmetrics 2002 Metrics about how much the Renter has spent on storage, uploads, and downloads. 2003 2004 **contractfees** | hastings 2005 Amount of money spent on contract fees, transaction fees and siafund fees. 2006 2007 **contractspending** | hastings, (deprecated, now totalallocated) 2008 How much money, in hastings, the Renter has spent on file contracts, including fees. 2009 2010 **downloadspending** | hastings 2011 Amount of money spent on downloads. 2012 2013 **storagespending** | hastings 2014 Amount of money spend on storage. 2015 2016 **totalallocated** | hastings 2017 Total amount of money that the renter has put into contracts. Includes spent money and also money that will be returned to the renter. 2018 2019 **uploadspending** | hastings 2020 Amount of money spent on uploads. 2021 2022 **unspent** | hastings 2023 Amount of money in the allowance that has not been spent. 2024 2025 **currentperiod** | blockheight 2026 Height at which the current allowance period began. 2027 2028 ## /renter [POST] 2029 > curl example 2030 2031 ```go 2032 curl -A "Sia-Agent" -u "":<apipassword> --data "period=12096&renewwindow=4032&funds=1000&hosts=50" "localhost:9980/renter" 2033 ``` 2034 2035 Modify settings that control the renter's behavior. 2036 2037 <<<<<<< HEAD 2038 ### Query String Parameters 2039 ======= 2040 ### Query Response Parameters 2041 >>>>>>> siaprime/master 2042 #### OPTIONAL 2043 Any of the renter settings can be set, see fields [here](#settings) 2044 2045 **checkforipviolation** | boolean 2046 Enables or disables the check for hosts using the same ip subnets within the hostdb. It's turned on by default and causes Sia to not form contracts with hosts from the same subnet and if such contracts already exist, it will deactivate the contract which has occupied that subnet for the shorter time. 2047 2048 ### Response 2049 2050 standard success or error response. See [standard responses](#standard-responses). 2051 2052 ## /renter/contract/cancel [POST] 2053 > curl example 2054 2055 ```go 2056 curl -A "Sia-Agent" -u "":<apipassword> --data "id=bd7ef21b13fb85eda933a9ff2874ec50a1ffb4299e98210bf0dd343ae1632f80" "localhost:9980/renter/contract/cancel" 2057 ``` 2058 2059 cancels a specific contract of the Renter. 2060 2061 ### Query String Parameters 2062 #### REQUIRED 2063 **id** | hash 2064 ID of the file contract 2065 2066 ### Response 2067 2068 standard success or error response. See [standard responses](#standard-responses). 2069 2070 ## /renter/backup [POST] 2071 > curl example 2072 2073 ```go 2074 curl -A "Sia-Agent" -u "":<apipassword> --data "destination=/home/backups/01-01-1968.backup" "localhost:9980/renter/backup" 2075 ``` 2076 2077 Creates a backup of all siafiles in the renter at the specified path. 2078 2079 <<<<<<< HEAD 2080 ### Query String Parameters 2081 ======= 2082 ### Query Response Parameters 2083 >>>>>>> siaprime/master 2084 #### REQUIRED 2085 **destination** | string 2086 The path on disk where the backup will be created. Needs to be an absolute 2087 path. 2088 2089 <<<<<<< HEAD 2090 #### OPTIONAL 2091 **remote** | boolean 2092 flag indicating if the backup should be stored on hosts. If true, 2093 **destination** is interpreted as the backup's name, not its path. 2094 2095 ======= 2096 >>>>>>> siaprime/master 2097 ### Response 2098 2099 standard success or error response. See [standard responses](#standard-responses). 2100 2101 ## /renter/recoverbackup [POST] 2102 > curl example 2103 2104 ```go 2105 curl -A "Sia-Agent" -u "":<apipassword> --data "source=/home/backups/01-01-1968.backup" "localhost:9980/renter/recoverbackup" 2106 ``` 2107 2108 Recovers an existing backup from the specified path by adding all the siafiles 2109 contained within it to the renter. Should a siafile for a certain path already 2110 exist, a number will be added as a suffix. e.g. 'myfile_1.sia' 2111 2112 <<<<<<< HEAD 2113 ### Query String Parameters 2114 ======= 2115 ### Query Response Parameters 2116 >>>>>>> siaprime/master 2117 #### REQUIRED 2118 **source** | string 2119 The path on disk where the backup will be recovered from. Needs to be an 2120 absolute path. 2121 2122 <<<<<<< HEAD 2123 #### OPTIONAL 2124 **remote** | boolean 2125 flag indicating if the backup is stored on hosts. If true, **source** is 2126 interpreted as the backup's name, not its path. 2127 2128 ======= 2129 >>>>>>> siaprime/master 2130 ### Response 2131 2132 standard success or error response. See [standard responses](#standard-responses). 2133 2134 <<<<<<< HEAD 2135 ## /renter/uploadedbackups [POST] 2136 > curl example 2137 2138 ```go 2139 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/renter/uploadedbackups" 2140 ``` 2141 2142 Lists the backups that have been uploaded to hosts. 2143 2144 ### JSON Response 2145 > JSON Response Example 2146 2147 ```go 2148 [ 2149 { 2150 "name": "foo", // string 2151 "UID": "00112233445566778899aabbccddeeff", // string 2152 "creationdate": 1234567890, // Unix timestamp 2153 "size": 8192 // bytes 2154 } 2155 ] 2156 ``` 2157 **name** | string 2158 The name of the backup. 2159 2160 **UID** | string 2161 A unique identifier for the backup. 2162 2163 **creationdate** | string 2164 Unix timestamp of when the backup was created. 2165 2166 **size** 2167 Size in bytes of the backup. 2168 2169 ======= 2170 >>>>>>> siaprime/master 2171 ## /renter/contracts [GET] 2172 > curl example 2173 2174 ```go 2175 <<<<<<< HEAD 2176 curl -A "Sia-Agent" "localhost:9980/renter/contracts?disabled=true&expired=true&recoverable=false" 2177 ``` 2178 2179 Returns the renter's contracts. Active, passive, and refreshed contracts are returned by default. 2180 Active contracts are contracts that the Renter is currently using to store, upload, and download data. 2181 Passive contracts are contracts that are no longer GoodForUpload but are GoodForRenew. This means the data will continue to be available to be downloaded from. 2182 Refreshed contracts are contracts that ran out of funds and needed to be renewed so more money could be added to the contract with the host. The data reported in these contracts is duplicate data and should not be included in any accounting. 2183 Disabled contracts are contracts that are in the current period that are not being used for uploading as they were replaced instead of renewed. 2184 Expired contracts are contracts not in the current period, where no more data is being stored and excess funds have been released to the renter. 2185 Expired Refreshed contracts are contracts that were refreshed at some point in a previous period. The data reported in these contracts is duplicate data and should not be included in any accounting. 2186 Recoverable contracts are contracts which the contractor is currently trying to recover and which haven't expired yet. 2187 2188 | Type | GoodForUpload | GoodForRenew | In Current Period | Data Counted Elsewhere Already| 2189 | ----------------- | :-----------: | :----------: | :---------------: | :---------------------------: | 2190 | Active | Yes | Yes | Yes | No | 2191 | Passive | No | Yes | Yes | No | 2192 | Refreshed | No | No | Yes | Yes | 2193 | Disabled | No | No | Yes | No | 2194 | Expired | No | No | No | No | 2195 | Expired Refreshed | No | No | No | Yes | 2196 2197 **NOTE:** No spending is double counted anywhere in the contracts, only the data is double counted in the refreshed contracts. For spending totals in the current period, all spending in active, passive, refreshed, and disabled contracts should be counted. For data totals, the data in active and passive contracts is the total uploaded while the data in disabled contracts is wasted uploaded data. 2198 2199 ### Query String Parameters 2200 #### OPTIONAL 2201 **disabled** | boolean 2202 flag indicating if disabled contracts should be returned. 2203 ======= 2204 curl -A "Sia-Agent" "localhost:9980/renter/contracts?inactive=true&expired=true&recoverable=false" 2205 ``` 2206 2207 Returns the renter's contracts. Active contracts are contracts that the Renter is currently using to store, upload, and download data, and are returned by default. Inactive contracts are contracts that are in the current period but are marked as not good for renew, these contracts have the potential to become active again but currently are not storing data. Expired contracts are contracts not in the current period, where not more data is being stored and excess funds have been released to the renter. Recoverable contracts are contracts which the contractor is currently trying to recover and which haven't expired yet. 2208 2209 ### Query String Parameters 2210 #### OPTIONAL 2211 **inactive** | boolean 2212 flag indicating if inactive contracts should be returned. 2213 >>>>>>> siaprime/master 2214 2215 **expired** | boolean 2216 flag indicating if expired contracts should be returned. 2217 2218 **recoverable** | boolean 2219 flag indicating if recoverable contracts should be returned. 2220 2221 ### JSON Response 2222 > JSON Response Example 2223 2224 ```go 2225 { 2226 "activecontracts": [ 2227 { 2228 "downloadspending": "1234", // hastings 2229 "endheight": 50000, // block height 2230 "fees": "1234", // hastings 2231 "hostpublickey": { 2232 "algorithm": "ed25519", // string 2233 "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU=" // hash 2234 }, 2235 "hostversion": "1.4.0", // string 2236 "id": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", // hash 2237 "lasttransaction": {}, // transaction 2238 "netaddress": "12.34.56.78:9", // string 2239 "renterfunds": "1234", // hastings 2240 "size": 8192, // bytes 2241 "startheight": 50000, // block height 2242 "storagespending": "1234", // hastings 2243 "totalcost": "1234", // hastings 2244 "uploadspending": "1234" // hastings 2245 "goodforupload": true, // boolean 2246 "goodforrenew": false, // boolean 2247 } 2248 ], 2249 <<<<<<< HEAD 2250 "passivecontracts": [], 2251 "refreshedcontracts": [], 2252 "disabledcontracts": [], 2253 "expiredcontracts": [], 2254 "expiredrefreshedcontracts": [], 2255 ======= 2256 "inactivecontracts": [], 2257 "expiredcontracts": [], 2258 >>>>>>> siaprime/master 2259 "recoverablecontracts": [], 2260 } 2261 ``` 2262 **downloadspending** | hastings 2263 Amount of contract funds that have been spent on downloads. 2264 2265 **endheight** | block height 2266 Block height that the file contract ends on. 2267 2268 **fees** | hastings 2269 Fees paid in order to form the file contract. 2270 2271 **hostpublickey** 2272 Public key of the host that the file contract is formed with. 2273 2274 **hostversion** | string 2275 The version of the host. 2276 2277 **algorithm** | string 2278 Algorithm used for signing and verification. Typically "ed25519". 2279 2280 **key** | hash 2281 Key used to verify signed host messages. 2282 2283 **id** | hash 2284 ID of the file contract. 2285 2286 **lasttransaction** | transaction 2287 A signed transaction containing the most recent contract revision. 2288 2289 **netaddress** | string 2290 Address of the host the file contract was formed with. 2291 2292 **renterfunds** | hastings 2293 Remaining funds left for the renter to spend on uploads & downloads. 2294 2295 **size** | bytes 2296 Size of the file contract, which is typically equal to the number of bytes that have been uploaded to the host. 2297 2298 **startheight** | block height 2299 Block height that the file contract began on. 2300 2301 **storagespending** | hastings 2302 Amount of contract funds that have been spent on storage. 2303 2304 **totalcost** | hastings 2305 Total cost to the wallet of forming the file contract. This includes both the fees and the funds allocated in the contract. 2306 2307 **uploadspending** | hastings 2308 Amount of contract funds that have been spent on uploads. 2309 2310 **goodforupload** | boolean 2311 Signals if contract is good for uploading data. 2312 2313 **goodforrenew** | boolean 2314 Signals if contract is good for a renewal. 2315 2316 ## /renter/dir/*siapath [GET] 2317 > curl example 2318 2319 > The root siadir path is "" so submitting the API call without an empty siapath 2320 will return the root siadir information. 2321 2322 ```go 2323 curl -A "Sia-Agent" "localhost:9980/renter/dir/" 2324 ``` 2325 ```go 2326 curl -A "Sia-Agent" "localhost:9980/renter/dir/mydir" 2327 ``` 2328 2329 retrieves the contents of a directory on the sia network 2330 2331 ### Path Parameters 2332 #### REQUIRED 2333 **siapath** | string 2334 Path to the directory on the sia netork 2335 2336 ### JSON Response 2337 > JSON Response Example 2338 2339 ```go 2340 { 2341 "directories": [ 2342 { 2343 "aggregatenumfiles": 2, // uint64 2344 "aggregatenumstuckchunks": 4, // uint64 2345 "aggregatesize": 4096, // uint64 2346 "heatlh": 1.0, // float64 2347 "lasthealtchecktime": "2018-09-23T08:00:00.000000000+04:00" // timestamp 2348 "maxhealth": 0.5, // float64 2349 "minredundancy": 2.6, // float64 2350 "mostrecentmodtime": "2018-09-23T08:00:00.000000000+04:00" // timestamp 2351 "stuckhealth": 1.0, // float64 2352 2353 "numfiles": 3, // uint64 2354 "numsubdirs": 2, // uint64 2355 "siapath": "foo/bar" // string 2356 } 2357 ], 2358 "files": [] 2359 } 2360 ``` 2361 **directories** 2362 An array of sia directories 2363 2364 **aggregatenumfiles** | uint64 2365 the total number of files in the sub directory tree 2366 2367 **aggregatenumstuckchunks** | uint64 2368 the total number of stuck chunks in the sub directory tree 2369 2370 **aggregatenumsize** | uint64 2371 2372 **health** | float64 2373 This is the worst health of any of the files or subdirectories. Health is the percent of parity pieces missing. 2374 - health = 0 is full redundancy 2375 - health <= 1 is recoverable 2376 - health > 1 needs to be repaired from disk 2377 2378 **lasthealthchecktime** | timestamp 2379 The oldest time that the health of the directory or any of its files or sub directories' health was checked. 2380 2381 **maxhealth** | float64 2382 This is the worst health when comparing stuck health vs health 2383 2384 **minredundancy** | float64 2385 the lowest redundancy of any file or directory in the sub directory tree 2386 2387 **mostrecentmodtime** | timestamp 2388 the most recent mod time of any file or directory in the sub directory tree 2389 2390 **numfiles** | uint64 2391 the number of files in the directory 2392 2393 **numsubdirs** | uint64 2394 the number of directories in the directory 2395 2396 **siapath** | string 2397 The path to the directory on the sia network 2398 2399 **files** 2400 Same response as [files](#files) 2401 2402 ## /renter/dir/*siapath [POST] 2403 > curl example 2404 2405 ```go 2406 curl -A "Sia-Agent" -u "":<apipassword> --data "action=delete" "localhost:9980/renter/dir/mydir" 2407 ``` 2408 2409 performs various functions on the renter's directories 2410 2411 ### Path Parameters 2412 #### REQUIRED 2413 **siapath** | string 2414 Location where the directory will reside in the renter on the network. The path must be non-empty, may not include any path traversal strings ("./", "../"), and may not begin with a forward-slash character. 2415 2416 ### Query String Parameters 2417 #### REQUIRED 2418 **action** | string 2419 <<<<<<< HEAD 2420 Action can be either `create`, `delete` or `rename`. 2421 - `create` will create an empty directory on the sia network 2422 - `delete` will remove a directory and its contents from the sia network 2423 - `rename` will rename a directory on the sia network 2424 2425 **newsiapath** | string 2426 The new siapath of the renamed folder. Only required for the `rename` action. 2427 ======= 2428 Action can be either `create` or `delete`. 2429 - `create` will create an empty directory on the sia network 2430 - `delete` will remove a directory and its contents from the sia network 2431 >>>>>>> siaprime/master 2432 2433 ### Response 2434 2435 standard success or error response. See [standard responses](#standard-responses). 2436 2437 ## /renter/downloads [GET] 2438 > curl example 2439 2440 ```go 2441 curl -A "Sia-Agent" "localhost:9980/renter/downloads" 2442 ``` 2443 2444 Lists all files in the download queue. 2445 2446 ### JSON Response 2447 > JSON Response Example 2448 2449 ```go 2450 { 2451 "downloads": [ 2452 { 2453 "destination": "/home/users/alice/bar.txt", // string 2454 "destinationtype": "file", // string 2455 "length": 8192, // bytes 2456 "offset": 2000, // bytes 2457 "siapath": "foo/bar.txt", // string 2458 2459 "completed": true, // boolean 2460 "endtime": "2009-11-10T23:10:00Z", // RFC 3339 time 2461 "error": "", // string 2462 "received": 8192, // bytes 2463 "starttime": "2009-11-10T23:00:00Z", // RFC 3339 time 2464 "totaldatatransfered": 10031 // bytes 2465 } 2466 ] 2467 } 2468 ``` 2469 **destination** | string 2470 Local path that the file will be downloaded to. 2471 2472 **destinationtype** | string 2473 What type of destination was used. Can be "file", indicating a download to disk, can be "buffer", indicating a download to memory, and can be "http stream", indicating that the download was streamed through the http API. 2474 2475 **length** | bytes 2476 Length of the download. If the download was a partial download, this will indicate the length of the partial download, and not the length of the full file. 2477 2478 **offset** | bytes 2479 Offset within the file of the download. For full file downloads, the offset will be '0'. For partial downloads, the offset may be anywhere within the file. offset+length will never exceed the full file size. 2480 2481 **siapath** | string 2482 Siapath given to the file when it was uploaded. 2483 2484 **completed** | oolean 2485 Whether or not the download has completed. Will be false initially, and set to true immediately as the download has been fully written out to the file, to the http stream, or to the in-memory buffer. Completed will also be set to true if there is an error that causes the download to fail. 2486 2487 **endtime** | date, RFC 3339 time 2488 Time at which the download completed. Will be zero if the download has not yet completed. 2489 2490 **error** | string 2491 Error encountered while downloading. If there was no error (yet), it will be the empty string. 2492 2493 **received** | bytes 2494 Number of bytes downloaded thus far. Will only be updated as segments of the file complete fully. This typically has a resolution of tens of megabytes. 2495 2496 **starttime** | date, RFC 3339 time 2497 Time at which the download was initiated. 2498 2499 **totaldatatransfered** | bytes 2500 <<<<<<< HEAD 2501 The total amount of data transferred when downloading the file. This will eventually include data transferred during contract + payment negotiation, as well as data from failed piece downloads. 2502 ======= 2503 The total amount of data transfered when downloading the file. This will eventually include data transferred during contract + payment negotiation, as well as data from failed piece downloads. 2504 >>>>>>> siaprime/master 2505 2506 ## /renter/downloads/clear [POST] 2507 > curl example 2508 2509 ```go 2510 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/renter/downloads/clear?before=1551398400&after=1552176000" 2511 ``` 2512 2513 Clears the download history of the renter for a range of unix time stamps. Both parameters are optional, if no parameters are provided, the entire download history will be cleared. To clear a single download, provide the timestamp for the download as both parameters. Providing only the before parameter will clear all downloads older than the timestamp. Conversely, providing only the after parameter will clear all downloads newer than the timestamp. 2514 2515 ### Query String Parameters 2516 #### OPTIONAL 2517 **before** | unix timestamp 2518 unix timestamp found in the download history 2519 2520 **after** | unix timestamp 2521 unix timestamp found in the download history 2522 2523 ### Response 2524 2525 standard success or error response. See [standard responses](#standard-responses). 2526 2527 ## /renter/prices [GET] 2528 > curl example 2529 2530 ```go 2531 curl -A "Sia-Agent" "localhost:9980/renter/prices" 2532 ``` 2533 2534 Lists the estimated prices of performing various storage and data operations. An allowance can be submitted to provide a more personalized estimate. If no allowance is submitted then the current set allowance will be used, if there is no allowance set then sane defaults will be used. Submitting an allowance is optional, but when submitting an allowance all the components of the allowance are required. The allowance used to create the estimate is returned with the estimate. 2535 2536 ### Query String Parameters 2537 ##### REQUIRED or OPTIONAL 2538 Allowance settings, see the fields [here](#allowance) 2539 2540 ### JSON Response 2541 > JSON Response Example 2542 2543 ```go 2544 { 2545 "downloadterabyte": "1234", // hastings 2546 "formcontracts": "1234", // hastings 2547 "storageterabytemonth": "1234", // hastings 2548 "uploadterabyte": "1234", // hastings 2549 "funds": "1234", // hastings 2550 "hosts": 24, // int 2551 "period": 6048, // blocks 2552 "renewwindow": 3024 // blocks 2553 } 2554 ``` 2555 **downloadterabyte** | hastings 2556 The estimated cost of downloading one terabyte of data from the network. 2557 2558 **formcontracts** | hastings 2559 The estimated cost of forming a set of contracts on the network. This cost also applies to the estimated cost of renewing the renter's set of contracts. 2560 2561 **storageterabytemonth** | hastings 2562 The estimated cost of storing one terabyte of data on the network for a month, including accounting for redundancy. 2563 2564 **uploadterabyte** | hastings 2565 The estimated cost of uploading one terabyte of data to the network, including accounting for redundancy. 2566 2567 The allowance settings used for the estimation are also returned, see the fields [here](#allowance) 2568 2569 ## /renter/files [GET] 2570 > curl example 2571 2572 ```go 2573 <<<<<<< HEAD 2574 curl -A "Sia-Agent" "localhost:9980/renter/files?cached=false" 2575 ``` 2576 2577 ### Query String Parameters 2578 #### OPTIONAL 2579 **cached** | boolean 2580 determines whether cached values should be returned or if the latest values should be computed. Cached values speed the endpoint up significantly. The default value is 'false'. 2581 2582 ======= 2583 curl -A "Sia-Agent" "localhost:9980/renter/files" 2584 ``` 2585 2586 >>>>>>> siaprime/master 2587 lists the status of all files. 2588 2589 ### JSON Response 2590 > JSON Response Example 2591 2592 ```go 2593 { 2594 "files": [ 2595 { 2596 "accesstime": 12578940002019-02-20T17:46:20.34810935+01:00, // timestamp 2597 "available": true, // boolean 2598 "changetime": 12578940002019-02-20T17:46:20.34810935+01:00, // timestamp 2599 "ciphertype": "threefish", // string 2600 "createtime": 12578940002019-02-20T17:46:20.34810935+01:00, // timestamp 2601 "expiration": 60000, // block height 2602 "filesize": 8192, // bytes 2603 "health": 0.5, // float64 2604 "localpath": "/home/foo/bar.txt", // string 2605 "maxhealth": 0.0, // float64 2606 "maxhealthpercent": 100%, // float64 2607 "modtime": 12578940002019-02-20T17:46:20.34810935+01:00, // timestamp 2608 "numstuckchunks": 0, // uint64 2609 "ondisk": true, // boolean 2610 "recoverable": true, // boolean 2611 "redundancy": 5, // float64 2612 "renewing": true, // boolean 2613 "siapath": "foo/bar.txt", // string 2614 "stuck": false, // bool 2615 "stuckhealth": 0.0, // float64 2616 "uploadedbytes": 209715200, // total bytes uploaded 2617 "uploadprogress": 100, // percent 2618 } 2619 ] 2620 } 2621 ``` 2622 #### files 2623 2624 **accesstime** | timestamp 2625 indicates the last time the siafile was accessed 2626 2627 **available** | boolean 2628 true if the file is available for download. Files may be available before they are completely uploaded. 2629 2630 **changetime** | timestamp 2631 indicates the last time the siafile metadata was updated 2632 2633 **ciphertype** | string 2634 indicates the encryption used for the siafile 2635 2636 **createtime** | timestamp 2637 indicates when the siafile was created 2638 2639 **expiration** | block height 2640 Block height at which the file ceases availability. 2641 2642 **filesize** | bytes 2643 Size of the file in bytes. 2644 2645 **health** | float64 2646 health is an indication of the amount of redundancy missing where 0 is full redundancy and >1 means the file is not available. The health of the siafile is the health of the worst unstuck chunk. 2647 2648 **localpath** | string 2649 Path to the local file on disk. 2650 2651 **maxhealth** | float64 2652 the maxhealth is either the health or the stuckhealth of the siafile, whichever is worst 2653 2654 **maxhealthpercent** | float64 2655 maxhealthpercent is the maxhealth converted to be out of 100% to be more easily understood 2656 2657 **modtime** | timestamp 2658 indicates the last time the siafile contents where modified 2659 2660 **numstuckchunks** | uint64 2661 indicates the number of stuck chunks in a file. A chunk is stuck if it cannot reach full redundancy 2662 2663 **ondisk** | boolean 2664 indicates if the source file is found on disk 2665 2666 **recoverable** | boolean 2667 indicates if the siafile is recoverable 2668 2669 **redundancy** | float64 2670 Average redundancy of the file on the network. Redundancy is calculated by dividing the amount of data uploaded in the file's open contracts by the size of the file. Redundancy does not necessarily correspond to availability. Specifically, a redundancy >= 1 does not indicate the file is available as there could be a chunk of the file with 0 redundancy. 2671 2672 **renewing** | boolean 2673 true if the file's contracts will be automatically renewed by the renter. 2674 2675 **siapath** | string 2676 Path to the file in the renter on the network. 2677 2678 **stuck** | bool 2679 a file is stuck if there are any stuck chunks in the file, which means the file cannot reach full redundancy 2680 2681 **stuckhealth** | float64 2682 stuckhealth is the worst health of any of the stuck chunks. 2683 2684 **uploadedbytes** | bytes 2685 Total number of bytes successfully uploaded via current file contracts. This number includes padding and rendundancy, so a file with a size of 8192 bytes might be padded to 40 MiB and, with a redundancy of 5, encoded to 200 MiB for upload. 2686 2687 **uploadprogress** | percent 2688 Percentage of the file uploaded, including redundancy. Uploading has completed when uploadprogress is 100. Files may be available for download before upload progress is 100. 2689 2690 ## /renter/file/*siapath* [GET] 2691 > curl example 2692 2693 ```go 2694 curl -A "Sia-Agent" "localhost:9980/renter/file/myfile" 2695 ``` 2696 2697 Lists the status of specified file. 2698 2699 ### Path Parameters 2700 #### REQUIRED 2701 **siapath** | string 2702 Path to the file in the renter on the network. 2703 2704 ### JSON Response 2705 Same response as [files](#files) 2706 2707 ## /renter/file/*siapath* [POST] 2708 > curl example 2709 2710 ```go 2711 curl -A "Sia-Agent" -u "":<apipassword> --data "trackingpath=/home/myfile" "localhost:9980/renter/file/myfile" 2712 ``` 2713 2714 endpoint for changing file metadata. 2715 2716 ### Path Parameters 2717 #### REQUIRED 2718 **siapath** | string 2719 SiaPath of the file on the network. The path must be non-empty, may not include any path traversal strings ("./", "../"), and may not begin with a forward-slash character. 2720 2721 ### Query String Parameters 2722 #### OPTIONAL 2723 **trackingpath** | string 2724 If provided, this parameter changes the tracking path of a file to the specified path. Useful if moving the file to a different location on disk. 2725 2726 ### Response 2727 2728 standard success or error response. See [standard responses](#standard-responses). 2729 2730 ## /renter/delete/*siapath* [POST] 2731 > curl example 2732 2733 ```go 2734 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/renter/delete/myfile" 2735 ``` 2736 2737 deletes a renter file entry. Does not delete any downloads or original files, only the entry in the renter. 2738 2739 ### Path Parameters 2740 #### REQUIRED 2741 **siapath** | string 2742 Path to the file in the renter on the network. 2743 2744 ### Response 2745 2746 standard success or error response. See [standard responses](#standard-responses). 2747 2748 ## /renter/download/*siapath* [GET] 2749 > curl example 2750 2751 ```go 2752 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/renter/download/myfile?httpresp=true" 2753 ``` 2754 2755 downloads a file to the local filesystem. The call will block until the file has been downloaded. 2756 2757 ### Path Parameters 2758 #### REQUIRED 2759 **siapath** | string 2760 Path to the file in the renter on the network. 2761 2762 ### Query String Parameters 2763 #### REQUIRED (Either one or the other) 2764 **destination** | string 2765 Location on disk that the file will be downloaded to. 2766 2767 **httpresp** | boolean 2768 If httresp is true, the data will be written to the http response. 2769 2770 #### OPTIONAL 2771 **async** | boolean 2772 <<<<<<< HEAD 2773 If async is true, the http request will be non blocking. Can't be used with 2774 httpresp. An async download will also set the 'ID' field in the http response 2775 header to a unique identifier for the async download which can be used to 2776 cancel the download with the /renter/download/cancel endpoint. 2777 ======= 2778 If async is true, the http request will be non blocking. Can't be used with: 2779 >>>>>>> siaprime/master 2780 2781 **length** | bytes 2782 Length of the requested data. Has to be <= filesize-offset. 2783 2784 **offset** | bytes 2785 Offset relative to the file start from where the download starts. 2786 2787 ### Response 2788 2789 standard success or error response. See [standard responses](#standard-responses). 2790 2791 <<<<<<< HEAD 2792 ## /renter/download/cancel [POST] 2793 > curl example 2794 2795 ```go 2796 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/renter/download/cancel?id=<downloadid>" 2797 ``` 2798 2799 cancels the download with the given id. 2800 2801 ### Query String Parameters 2802 **id** | string 2803 ID returned by the /renter/download/*siapath* endpoint when setting 2804 async=true. It is set in the http header's 'ID' field. 2805 2806 ### Response 2807 2808 standard success or error response. See [standard responses](#standard-responses). 2809 2810 ======= 2811 >>>>>>> siaprime/master 2812 ## /renter/downloadsync/*siapath* [GET] 2813 > curl example 2814 2815 ```go 2816 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/renter/downloadasync/myfile?destination=/home/myfile" 2817 ``` 2818 2819 downloads a file to the local filesystem. The call will return immediately. 2820 2821 ### Path Parameters 2822 #### REQUIRED 2823 **siapath** | string 2824 Path to the file in the renter on the network. 2825 2826 ### Query String Parameters 2827 #### REQUIRED 2828 **destination** | string 2829 Location on disk that the file will be downloaded to. 2830 2831 ### Response 2832 2833 standard success or error response. See [standard responses](#standard-responses). 2834 2835 ## /renter/recoveryscan [POST] 2836 > curl example 2837 2838 ```go 2839 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/renter/recoveryscan" 2840 ``` 2841 2842 starts a rescan of the whole blockchain to find recoverable contracts. The 2843 contractor will periodically try to recover found contracts every 10 minutes 2844 until they are recovered or expired. 2845 2846 ### Response 2847 2848 standard success or error response. See [standard responses](#standard-responses). 2849 2850 ## /renter/recoveryscan [GET] 2851 > curl example 2852 2853 ```go 2854 curl -A "Sia-Agent" "localhost:9980/renter/recoveryscan" 2855 ``` 2856 2857 Returns some information about a potentially ongoing recovery scan. 2858 2859 ### JSON Response 2860 > JSON Response Example 2861 2862 ```go 2863 { 2864 "scaninprogress": true // boolean 2865 "scannedheight" : 1000 // uint64 2866 } 2867 ``` 2868 **scaninprogress** | boolean 2869 indicates if a scan for recoverable contracts is currently in progress. 2870 2871 **scannedheight** | uint64 2872 indicates the progress of a currently ongoing scan in terms of number of blocks 2873 that have already been scanned. 2874 2875 ## /renter/rename/*siapath* [POST] 2876 > curl example 2877 2878 ```go 2879 curl -A "Sia-Agent" -u "":<apipassword> --data "newsiapath=myfile2" "localhost:9980/renter/rename/myfile" 2880 ``` 2881 2882 ### Path Parameters 2883 #### REQUIRED 2884 **siapath** | string 2885 Path to the file in the renter on the network. 2886 2887 ### Query String Parameters 2888 #### REQUIRED 2889 **newsiapath** | string 2890 New location of the file in the renter on the network. 2891 2892 ### Response 2893 2894 standard success or error response. See [standard responses](#standard-responses). 2895 2896 ## /renter/stream/*siapath* [GET] 2897 > curl example 2898 2899 > Stream the whole file. 2900 2901 ```go 2902 curl -A "Sia-Agent" "localhost:9980/renter/stream/myfile" 2903 ``` 2904 > The file can be streamed partially by using standard partial http requests which means setting the "Range" field in the http header. 2905 2906 ```go 2907 curl -A "Sia-Agent" -H "Range: bytes=0-1023" "localhost:9980/renter/stream/myfile" 2908 ``` 2909 2910 downloads a file using http streaming. This call blocks until the data is received. The streaming endpoint also uses caching internally to prevent siad from re-downloading the same chunk multiple times when only parts of a file are requested at once. This might lead to a substantial increase in ram usage and therefore it is not recommended to stream multiple files in parallel at the moment. This restriction will be removed together with the caching once partial downloads are supported in the future. If you want to stream multiple files you should increase the size of the Renter's `streamcachesize` to at least 2x the number of files you are steaming. 2911 2912 ### Path Parameters 2913 #### REQUIRED 2914 **siapath** | string 2915 Path to the file in the renter on the network. 2916 2917 ### Response 2918 2919 standard success or error response. See [standard responses](#standard-responses). 2920 2921 ## /renter/upload/*siapath* [POST] 2922 > curl example 2923 2924 ```go 2925 curl -A "Sia-Agent" -u "":<apipassword> --data "source=/home/myfile" "localhost:9980/renter/upload/myfile" 2926 ``` 2927 2928 uploads a file to the network from the local filesystem. 2929 2930 ### Path Parameters 2931 #### REQUIRED 2932 **siapath** | string 2933 Location where the file will reside in the renter on the network. The path must be non-empty, may not include any path traversal strings ("./", "../"), and may not begin with a forward-slash character. 2934 2935 ### Query String Parameters 2936 #### REQUIRED 2937 **source** | string 2938 Location on disk of the file being uploaded. 2939 2940 #### OPTIONAL 2941 **datapieces** | int 2942 The number of data pieces to use when erasure coding the file. 2943 2944 **paritypieces** | int 2945 The number of parity pieces to use when erasure coding the file. Total redundancy of the file is (datapieces+paritypieces)/datapieces. 2946 2947 <<<<<<< HEAD 2948 **force** | boolean 2949 Delete potential existing file at siapath. 2950 2951 ### Response 2952 2953 standard success or error response. See [standard responses](#standard-responses). 2954 2955 ## /renter/uploadstream/*siapath* [POST] 2956 > curl example 2957 2958 ```go 2959 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/renter/uploadstream/myfile?datapieces=10&paritypieces=20" --data-binary @myfile.dat 2960 ``` 2961 2962 uploads a file to the network using a stream. 2963 2964 ### Path Parameters 2965 #### REQUIRED 2966 **siapath** | string 2967 Location where the file will reside in the renter on the network. The path must be non-empty, may not include any path traversal strings ("./", "../"), and may not begin with a forward-slash character. 2968 2969 ### Query String Parameters 2970 #### OPTIONAL 2971 **datapieces** | int 2972 The number of data pieces to use when erasure coding the file. 2973 2974 **paritypieces** | int 2975 The number of parity pieces to use when erasure coding the file. Total redundancy of the file is (datapieces+paritypieces)/datapieces. 2976 2977 **force** 2978 Delete potential existing file at siapath. 2979 2980 **repair** 2981 Repair existing file from stream. Can't be specified together with datapieces, paritypieces and force. 2982 2983 ======= 2984 >>>>>>> siaprime/master 2985 ### Response 2986 2987 standard success or error response. See [standard responses](#standard-responses). 2988 2989 <<<<<<< HEAD 2990 ## /renter/validate/*siapath* [POST] 2991 > curl example 2992 2993 ```go 2994 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/renter/validatesiapath/isthis-aval_idsiapath" 2995 ``` 2996 2997 validates whether or not the provided siapaht is a valid siapath. SiaPaths cannot contain traversal strings or be empty. Valid characters are: 2998 2999 $, &, `, :, ;, #, %, @, <, >, =, ?, [, ], {, }, ^, |, ~, -, +, _, comma, ', " 3000 3001 ### Path Parameters 3002 #### REQUIRED 3003 **siapath** | string 3004 siapath to test. 3005 3006 ### Response 3007 standard success or error response, a successful response means a valid siapath. See [standard responses](#standard-responses). 3008 3009 ======= 3010 >>>>>>> siaprime/master 3011 # Transaction Pool 3012 3013 ## /tpool/confirmed/:id [GET] 3014 > curl example 3015 3016 ```go 3017 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/tpool/confirmed/22e8d5428abc184302697929f332fa0377ace60d405c39dd23c0327dc694fae7" 3018 ``` 3019 3020 returns whether the requested transaction has been seen on the blockchain. Note, however, that the block containing the transaction may later be invalidated by a reorg. 3021 3022 ### Path Parameters 3023 #### REQUIRED 3024 **id** | hash 3025 id of the transaction being queried 3026 3027 ### JSON Response 3028 > JSON Response Example 3029 3030 ```go 3031 { 3032 "confirmed": true // boolean 3033 } 3034 ``` 3035 **confirmed** | boolean 3036 indicates if a transaction is confirmed on the blockchain 3037 3038 ## /tpool/fee [GET] 3039 > curl example 3040 3041 ```go 3042 curl -A "Sia-Agent" "localhost:9980/tpool/fee" 3043 ``` 3044 3045 returns the minimum and maximum estimated fees expected by the transaction pool. 3046 3047 ### JSON Response 3048 > JSON Response Example 3049 3050 ```go 3051 { 3052 "minimum": "1234", // hastings / byte 3053 "maximum": "5678" // hastings / byte 3054 } 3055 ``` 3056 **minimum** | hastings / byte 3057 the minimum estimated fee 3058 3059 **maximum** | hastings / byte 3060 the maximum estimated fee 3061 3062 ## /tpool/raw/:id [GET] 3063 > curl example 3064 3065 ```go 3066 curl -A "Sia-Agent" "localhost:9980/tpool/raw/22e8d5428abc184302697929f332fa0377ace60d405c39dd23c0327dc694fae7" 3067 ``` 3068 3069 returns the ID for the requested transaction and its raw encoded parents and transaction data. 3070 3071 ### Path Parameters 3072 #### REQUIRED 3073 **id** | hash 3074 id of the transaction being queried 3075 3076 ### JSON Response 3077 > JSON Response Example 3078 3079 ```go 3080 { 3081 // id of the transaction 3082 "id": "124302d30a219d52f368ecd94bae1bfb922a3e45b6c32dd7fb5891b863808788", 3083 3084 // raw, base64 encoded transaction data 3085 "transaction": "AQAAAAAAAADBM1ca/FyURfizmSukoUQ2S0GwXMit1iNSeYgrnhXOPAAAAAAAAAAAAQAAAAAAAABlZDI1NTE5AAAAAAAAAAAAIAAAAAAAAACdfzoaJ1MBY7L0fwm7O+BoQlFkkbcab5YtULa6B9aecgEAAAAAAAAAAQAAAAAAAAAMAAAAAAAAAAM7Ljyf0IA86AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACgAAAAAAAACe0ZTbGbI4wAAAAAAAAAAAAAABAAAAAAAAAMEzVxr8XJRF+LOZK6ShRDZLQbBcyK3WI1J5iCueFc48AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAA+z4P1wc98IqKxykTSJxiVT+BVbWezIBnIBO1gRRlLq2x/A+jIc6G7/BA5YNJRbdnqPHrzsZvkCv4TKYd/XzwBA==", 3086 "parents": "AQAAAAAAAAABAAAAAAAAAJYYmFUdXXfLQ2p6EpF+tcqM9M4Pw5SLSFHdYwjMDFCjAAAAAAAAAAABAAAAAAAAAGVkMjU1MTkAAAAAAAAAAAAgAAAAAAAAAAHONvdzzjHfHBx6psAN8Z1rEVgqKPZ+K6Bsqp3FbrfjAQAAAAAAAAACAAAAAAAAAAwAAAAAAAAAAzvNDjSrme8gwAAA4w8ODnW8DxbOV/JribivvTtjJ4iHVOug0SXJc31BdSINAAAAAAAAAAPGHY4699vggx5AAAC2qBhm5vwPaBsmwAVPho/1Pd8ecce/+BGv4UimnEPzPQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAACWGJhVHV13y0NqehKRfrXKjPTOD8OUi0hR3WMIzAxQowAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAABnt64wN1qxym/CfiMgOx5fg/imVIEhY+4IiiM7gwvSx8qtqKniOx50ekrGv8B+gTKDXpmm2iJibWTI9QLZHWAY=", 3087 } 3088 ``` 3089 **id** | string 3090 id of the transaction. 3091 3092 **transaction** | string 3093 raw, base64 encoded transaction data 3094 3095 ## /tpool/raw [POST] 3096 > curl example 3097 3098 ```go 3099 curl -A "Sia-Agent" --data "<raw-encoded-tset>" "localhost:9980/tpool/raw" 3100 ``` 3101 3102 submits a raw transaction to the transaction pool, broadcasting it to the transaction pool's peers. 3103 3104 ### Query String Parameters 3105 #### REQUIRED 3106 **parents** | string 3107 JSON- or base64-encoded transaction parents 3108 3109 **transaction** | string 3110 JSON- or base64-encoded transaction 3111 3112 ### Response 3113 3114 standard success or error response. See [standard responses](#standard-responses). 3115 3116 ## /tpool/confirmed/:id [GET] 3117 > curl example 3118 3119 ```go 3120 curl -A "Sia-Agent" "localhost:9980/tpool/confirmed/9028cc285ad755b81c0cfead3710c1344044175e59cdc4ca097374fe188c9acf" 3121 ``` 3122 3123 ### Query String Parameters 3124 #### REQUIRED 3125 **id** | hash 3126 id of the transaction being queried 3127 3128 ### JSON Response 3129 > JSON Response Example 3130 3131 ```go 3132 { 3133 "confirmed": true, 3134 } 3135 ``` 3136 **confirmed** | boolean 3137 boolean that indicates if transaction was confirmed 3138 3139 # Wallet 3140 3141 ## /wallet [GET] 3142 > curl example 3143 3144 ```go 3145 curl -A "Sia-Agent" "localhost:9980/wallet" 3146 ``` 3147 3148 Returns basic information about the wallet, such as whether the wallet is locked or unlocked. 3149 3150 ### JSON Response 3151 > JSON Response Example 3152 3153 ```go 3154 { 3155 "encrypted": true, // boolean 3156 "unlocked": true, // boolean 3157 "rescanning": false, // boolean 3158 3159 "confirmedsiacoinbalance": "123456", // hastings, big int 3160 "unconfirmedoutgoingsiacoins": "0", // hastings, big int 3161 "unconfirmedincomingsiacoins": "789", // hastings, big int 3162 3163 "siafundbalance": "1", // siafunds, big int 3164 "siacoinclaimbalance": "9001", // hastings, big int 3165 3166 "dustthreshold": "1234", // hastings / byte, big int 3167 } 3168 ``` 3169 **encrypted** | boolean 3170 Indicates whether the wallet has been encrypted or not. If the wallet has not been encrypted, then no data has been generated at all, and the first time the wallet is unlocked, the password given will be used as the password for encrypting all of the data. 'encrypted' will only be set to false if the wallet has never been unlocked before (the unlocked wallet is still encryped - but the encryption key is in memory). 3171 3172 **unlocked** | boolean 3173 Indicates whether the wallet is currently locked or unlocked. Some calls become unavailable when the wallet is locked. 3174 3175 **rescanning** | boolean 3176 Indicates whether the wallet is currently rescanning the blockchain. This will be true for the duration of calls to /unlock, /seeds, /init/seed, and /sweep/seed. 3177 3178 **confirmedsiacoinbalance** | hastings, big int 3179 Number of siacoins, in hastings, available to the wallet as of the most recent block in the blockchain. 3180 3181 **unconfirmedoutgoingsiacoins** | hastings, big int 3182 Number of siacoins, in hastings, that are leaving the wallet according to the set of unconfirmed transactions. Often this number appears inflated, because outputs are frequently larger than the number of coins being sent, and there is a refund. These coins are counted as outgoing, and the refund is counted as incoming. The difference in balance can be calculated using 'unconfirmedincomingsiacoins' - 'unconfirmedoutgoingsiacoins' 3183 3184 **unconfirmedincomingsiacoins** | hastings, big int 3185 Number of siacoins, in hastings, are entering the wallet according to the set of unconfirmed transactions. This number is often inflated by outgoing siacoins, because outputs are frequently larger than the amount being sent. The refund will be included in the unconfirmed incoming siacoins balance. 3186 3187 **siafundbalance** | big int 3188 Number of siafunds available to the wallet as of the most recent block in the blockchain. 3189 3190 **siacoinclaimbalance** | hastings, big int 3191 Number of siacoins, in hastings, that can be claimed from the siafunds as of the most recent block. Because the claim balance increases every time a file contract is created, it is possible that the balance will increase before any claim transaction is confirmed. 3192 3193 **dustthreshold** | hastings / byte, big int 3194 Number of siacoins, in hastings per byte, below which a transaction output cannot be used because the wallet considers it a dust output. 3195 3196 ## /wallet/033x [POST] 3197 > curl example 3198 3199 ```go 3200 curl -A "Sia-Agent" -u "":<apipassword> --data "source=/home/legacy-wallet&encryptionpassword=mypassword" "localhost:9980/wallet/033x" 3201 ``` 3202 3203 Loads a v0.3.3.x wallet into the current wallet, harvesting all of the secret keys. All spendable addresses in the loaded wallet will become spendable from the current wallet. 3204 3205 ### Query String Parameters 3206 #### REQUIRED 3207 **source** 3208 Path on disk to the v0.3.3.x wallet to be loaded. 3209 3210 **encryptionpassword** 3211 Encryption key of the wallet. 3212 3213 ### Response 3214 3215 standard success or error response. See [standard responses](#standard-responses). 3216 3217 ## /wallet/address [GET] 3218 > curl example 3219 3220 ```go 3221 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/wallet/address" 3222 ``` 3223 3224 Gets a new address from the wallet generated by the primary seed. An error will be returned if the wallet is locked. 3225 3226 ### JSON Response 3227 > JSON Response Example 3228 3229 ```go 3230 { 3231 "address": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab" 3232 } 3233 ``` 3234 **address** | hash 3235 Wallet address that can receive siacoins or siafunds. Addresses are 76 character long hex strings. 3236 3237 ## /wallet/addresses [GET] 3238 > curl example 3239 3240 ```go 3241 curl -A "Sia-Agent" "localhost:9980/wallet/addresses" 3242 ``` 3243 3244 Fetches the list of addresses from the wallet. If the wallet has not been created or unlocked, no addresses will be returned. After the wallet is unlocked, this call will continue to return its addresses even after the wallet is locked again. 3245 3246 ### JSON Response 3247 > JSON Response Example 3248 3249 ```go 3250 { 3251 "addresses": [ 3252 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 3253 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3254 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 3255 ] 3256 } 3257 ``` 3258 **addresses** 3259 Array of wallet addresses owned by the wallet. 3260 3261 ## /wallet/seedaddrs [GET] 3262 > curl example 3263 3264 ```go 3265 curl -A "Sia-Agent" "localhost:9980/wallet/seedaddrs" 3266 ``` 3267 3268 Fetches addresses generated by the wallet in reverse order. The last address 3269 generated by the wallet will be the first returned. This also means that 3270 addresses which weren't generated using the wallet's seed can't be retrieved 3271 with this endpoint. 3272 3273 ### Query String Parameters 3274 #### OPTIONAL 3275 **count** 3276 Number of addresses that should be returned. If count is not specified or if 3277 count is bigger than the number of addresses generated by the wallet, all 3278 addresses will be returned. 3279 3280 ### JSON Response 3281 > JSON Response Example 3282 3283 ```go 3284 { 3285 "addresses": [ 3286 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 3287 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3288 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 3289 ] 3290 } 3291 ``` 3292 **addresses** 3293 Array of wallet addresses previously generated by the wallet. 3294 3295 ## /wallet/backup [GET] 3296 > curl example 3297 3298 ```go 3299 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/wallet/backup?destination=/home/wallet-settings.backup" 3300 ``` 3301 3302 Creates a backup of the wallet settings file. Though this can easily be done manually, the settings file is often in an unknown or difficult to find location. The /wallet/backup call can spare users the trouble of needing to find their wallet file. 3303 3304 ### Query String Parameters 3305 #### REQUIRED 3306 **destination** 3307 Path to the location on disk where the backup file will be saved. 3308 3309 ### Response 3310 3311 standard success or error response. See [standard responses](#standard-responses). 3312 3313 ## /wallet/changepassword [POST] 3314 > curl example 3315 3316 ```go 3317 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/wallet/changepassword?encryptionpassword=<currentpassword>&newpassword=<newpassword>" 3318 ``` 3319 3320 Changes the wallet's encryption key. 3321 3322 ### Query String Parameters 3323 #### REQUIRED 3324 **encryptionpassword** | string 3325 encryptionpassword is the wallet's current encryption password. 3326 3327 **newpassword** | string 3328 newpassword is the new password for the wallet. 3329 3330 ### Response 3331 3332 standard success or error response. See [standard responses](#standard-responses). 3333 3334 ## /wallet/init [POST] 3335 > curl example 3336 3337 ```go 3338 curl -A "Sia-Agent" -u "":<apipassword> --data "encryptionpassword=<password>&force=false" "localhost:9980/wallet/init" 3339 ``` 3340 3341 Initializes the wallet. After the wallet has been initialized once, it does not need to be initialized again, and future calls to /wallet/init will return an error. The encryption password is provided by the api call. If the password is blank, then the password will be set to the same as the seed. 3342 3343 ### Query String Parameters 3344 #### OPTIONAL WALLET PARAMETERS 3345 **encryptionpassword** | string 3346 Password that will be used to encrypt the wallet. All subsequent calls should use this password. If left blank, the seed that gets returned will also be the encryption password. 3347 3348 **dictionary** | string 3349 Name of the dictionary that should be used when encoding the seed. 'english' is the most common choice when picking a dictionary. 3350 3351 **force** | boolean 3352 When set to true /wallet/init will Reset the wallet if one exists instead of returning an error. This allows API callers to reinitialize a new wallet. 3353 3354 ### JSON Response 3355 > JSON Response Example 3356 3357 ```go 3358 { 3359 "primaryseed": "hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello" 3360 } 3361 ``` 3362 **primaryseed** 3363 Wallet seed used to generate addresses that the wallet is able to spend. 3364 3365 ## /wallet/init/seed [POST] 3366 > curl example 3367 3368 ```go 3369 curl -A "Sia-Agent" -u "":<apipassword> --data "seed=<seed>&encryptionpassword=<password>&force=false" "localhost:9980/wallet/init/seed" 3370 ``` 3371 3372 Initializes the wallet using a preexisting seed. After the wallet has been initialized once, it does not need to be initialized again, and future calls to /wallet/init/seed will return an error. The encryption password is provided by the api call. If the password is blank, then the password will be set to the same as the seed. Note that loading a preexisting seed requires scanning the blockchain to determine how many keys have been generated from the seed. For this reason, /wallet/init/seed can only be called if the blockchain is synced. 3373 3374 ### Query String Parameters 3375 #### REQUIRED WALLET PARAMETERS 3376 **seed** | string 3377 Dictionary-encoded phrase that corresponds to the seed being used to initialize the wallet. 3378 3379 #### OPTIONAL 3380 [Optional Wallet Parameters](#optional-wallet-parameters) 3381 3382 ### Response 3383 3384 standard success or error response. See [standard responses](#standard-responses). 3385 3386 ## /wallet/seed [POST] 3387 > curl example 3388 3389 ```go 3390 curl -A "Sia-Agent" -u "":<apipassword> --data "seed=<seed>" "localhost:9980/wallet/seed" 3391 ``` 3392 3393 Gives the wallet a seed to track when looking for incoming transactions. The wallet will be able to spend outputs related to addresses created by the seed. The seed is added as an auxiliary seed, and does not replace the primary seed. Only the primary seed will be used for generating new addresses. 3394 3395 ### Query String Parameters 3396 #### REQUIRED 3397 [Required Wallet Parameters](#required-wallet-parameters) 3398 3399 #### OPTIONAL | string 3400 [Optional Wallet Parameters](#optional-wallet-parameters) 3401 3402 ### Response 3403 3404 standard success or error response. See [standard responses](#standard-responses). 3405 3406 ## /wallet/seeds [GET] 3407 > curl example 3408 3409 ```go 3410 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/wallet/seeds" 3411 ``` 3412 3413 Returns the list of seeds in use by the wallet. The primary seed is the only seed that gets used to generate new addresses. This call is unavailable when the wallet is locked. 3414 3415 ### Query String Parameters 3416 #### REQUIRED 3417 **dictionary** | string 3418 Name of the dictionary that should be used when encoding the seed. 'english' is the most common choice when picking a dictionary. 3419 3420 ### JSON Response 3421 > JSON Response Example 3422 3423 ```go 3424 { 3425 "primaryseed": "hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello", 3426 "addressesremaining": 2500, 3427 "allseeds": [ 3428 "hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello", 3429 "foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo", 3430 ] 3431 } 3432 ``` 3433 **primaryseed** 3434 Seed that is actively being used to generate new addresses for the wallet. 3435 3436 **addressesremaining** 3437 Number of addresses that remain in the primary seed until exhaustion has been reached. Once exhaustion has been reached, new addresses will continue to be generated but they will be more difficult to recover in the event of a lost wallet file or encryption password. 3438 3439 **allseeds** 3440 Array of all seeds that the wallet references when scanning the blockchain for outputs. The wallet is able to spend any output generated by any of the seeds, however only the primary seed is being used to generate new addresses. 3441 3442 ## /wallet/siacoins [POST] 3443 > curl example 3444 3445 ```go 3446 curl -A "Sia-Agent" -u "":<apipassword> --data "amount=1000&destination=c134a8372bd250688b36867e6522a37bdc391a344ede72c2a79206ca1c34c84399d9ebf17773" "localhost:9980/wallet/siacoins" 3447 ``` 3448 3449 Sends siacoins to an address or set of addresses. The outputs are arbitrarily selected from addresses in the wallet. If 'outputs' is supplied, 'amount' and 'destination' must be empty. 3450 3451 ### Query String Parameters 3452 #### REQUIRED 3453 Amount and Destination or Outputs are required 3454 3455 **amount** | hastings 3456 Number of hastings being sent. A hasting is the smallest unit in Sia. There are 10^24 hastings in a siacoin. 3457 3458 **destination** | address 3459 Address that is receiving the coins. 3460 3461 **OR** 3462 3463 **outputs** 3464 JSON array of outputs. The structure of each output is: {"unlockhash": "<destination>", "value": "<amount>"} 3465 3466 ### JSON Response 3467 > JSON Response Example 3468 3469 ```go 3470 { 3471 "transactionids": [ 3472 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 3473 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3474 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 3475 ] 3476 } 3477 ``` 3478 **transactionids** 3479 Array of IDs of the transactions that were created when sending the coins. The last transaction contains the output headed to the 'destination'. Transaction IDs are 64 character long hex strings. 3480 3481 ## /wallet/siafunds [POST] 3482 > curl example 3483 3484 ```go 3485 curl -A "Sia-Agent" -u "":<apipassword> --data "amount=10&destination=c134a8372bd250688b36867e6522a37bdc391a344ede72c2a79206ca1c34c84399d9ebf17773" "localhost:9980/wallet/siafunds" 3486 ``` 3487 3488 Sends siafunds to an address. The outputs are arbitrarily selected from addresses in the wallet. Any siacoins available in the siafunds being sent (as well as the siacoins available in any siafunds that end up in a refund address) will become available to the wallet as siacoins after 144 confirmations. To access all of the siacoins in the siacoin claim balance, send all of the siafunds to an address in your control (this will give you all the siacoins, while still letting you control the siafunds). 3489 3490 ### Query String Parameters 3491 #### REQUIRED 3492 **amount** | siafunds 3493 Number of siafunds being sent. 3494 3495 **destination** | address 3496 Address that is receiving the funds. 3497 3498 ### JSON Response 3499 > JSON Response Example 3500 3501 ```go 3502 { 3503 "transactionids": [ 3504 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 3505 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3506 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 3507 ] 3508 } 3509 ``` 3510 **transactionids** 3511 Array of IDs of the transactions that were created when sending the coins. The last transaction contains the output headed to the 'destination'. Transaction IDs are 64 character long hex strings. 3512 3513 ## /wallet/siagkey [POST] 3514 > curl example 3515 3516 ```go 3517 curl -A "Sia-Agent" -u "":<apipassword> --data "encryptionpassword=<password>&keyfiles=/file1,/home/file2" "localhost:9980/wallet/siagkey" 3518 ``` 3519 3520 Loads a key into the wallet that was generated by siag. Most siafunds are currently in addresses created by siag. 3521 3522 ### Query String Parameters 3523 #### REQUIRED 3524 **encryptionpassword** 3525 Key that is used to encrypt the siag key when it is imported to the wallet. 3526 3527 **keyfiles** 3528 List of filepaths that point to the keyfiles that make up the siag key. There should be at least one keyfile per required signature. The filenames need to be commna separated (no spaces), which means filepaths that contain a comma are not allowed. 3529 3530 ### Response 3531 3532 standard success or error response. See [standard responses](#standard-responses). 3533 3534 ## /wallet/sign [POST] 3535 > curl example 3536 3537 ```go 3538 curl -A "Sia-Agent" -u "":<apipassword> --data "<requestbody>" "localhost:9980/wallet/sign" 3539 ``` 3540 3541 Signs a transaction. The wallet will attempt to sign each input specified. The transaction's TransactionSignatures should be complete except for the Signature field. If `tosign` is provided, the wallet will attempt to fill in signatures for each TransactionSignature specified. If `tosign` is not provided, the wallet will add signatures for every TransactionSignature that it has keys for. 3542 3543 ### Request Body 3544 > Request Body Example 3545 3546 ```go 3547 { 3548 // Unsigned transaction 3549 "transaction": { 3550 "siacoininputs": [ 3551 { 3552 "parentid": "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584", 3553 "unlockconditions": { 3554 "timelock": 0, 3555 "publickeys": [ "ed25519:8b845bf4871bcdf4ff80478939e508f43a2d4b2f68e94e8b2e3d1ea9b5f33ef1" ], 3556 "signaturesrequired": 1 3557 } 3558 } 3559 ], 3560 "siacoinoutputs": [ 3561 { 3562 "value": "5000000000000000000000000", 3563 "unlockhash": "17d25299caeccaa7d1598751f239dd47570d148bb08658e596112d917dfa6bc8400b44f239bb" 3564 }, 3565 { 3566 "value": "299990000000000000000000000000", 3567 "unlockhash": "b4bf662170622944a7c838c7e75665a9a4cf76c4cebd97d0e5dcecaefad1c8df312f90070966" 3568 } 3569 ], 3570 "minerfees": [ "1000000000000000000000000" ], 3571 "transactionsignatures": [ 3572 { 3573 "parentid": "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584", 3574 "publickeyindex": 0, 3575 "coveredfields": {"wholetransaction": true} 3576 } 3577 ] 3578 }, 3579 3580 // Optional IDs to sign; each should correspond to a parentid in the transactionsignatures. 3581 "tosign": [ 3582 "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584" 3583 ] 3584 } 3585 ``` 3586 3587 ### JSON Response 3588 > JSON Response Example 3589 3590 ```go 3591 { 3592 // signed transaction 3593 "transaction": { 3594 "siacoininputs": [ 3595 { 3596 "parentid": "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584", 3597 "unlockconditions": { 3598 "timelock": 0, 3599 "publickeys": [ "ed25519:8b845bf4871bcdf4ff80478939e508f43a2d4b2f68e94e8b2e3d1ea9b5f33ef1" ], 3600 "signaturesrequired": 1 3601 } 3602 } 3603 ], 3604 "siacoinoutputs": [ 3605 { 3606 "value": "5000000000000000000000000", 3607 "unlockhash": "17d25299caeccaa7d1598751f239dd47570d148bb08658e596112d917dfa6bc8400b44f239bb" 3608 }, 3609 { 3610 "value": "299990000000000000000000000000", 3611 "unlockhash": "b4bf662170622944a7c838c7e75665a9a4cf76c4cebd97d0e5dcecaefad1c8df312f90070966" 3612 } 3613 ], 3614 "minerfees": [ "1000000000000000000000000" ], 3615 "transactionsignatures": [ 3616 { 3617 "parentid": "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584", 3618 "publickeyindex": 0, 3619 "coveredfields": {"wholetransaction": true}, 3620 "signature": "CVkGjy4The6h+UU+O8rlZd/O3Gb1xRJdyQ2vzBFEb/5KveDKDrrieCiFoNtUaknXEQbdxlrDqMujc+x3aZbKCQ==" 3621 } 3622 ] 3623 } 3624 } 3625 ``` 3626 3627 ## /wallet/sweep/seed [POST] 3628 > curl example 3629 3630 ```go 3631 curl -A "Sia-Agent" -u "":<apipassword> --data "seed=<seed>" "localhost:9980/wallet/sweep/seed" 3632 ``` 3633 3634 Scans the blockchain for outputs belonging to a seed and send them to an address owned by the wallet. 3635 3636 ### Query String Parameters 3637 #### REQUIRED 3638 **seed** | string 3639 Dictionary-encoded phrase that corresponds to the seed being added to the wallet. 3640 3641 #### OPTIONAL 3642 **dictionary** | string 3643 Name of the dictionary that should be used when decoding the seed. 'english' is the most common choice when picking a dictionary. 3644 3645 ### JSON Response 3646 > JSON Response Example 3647 ```go 3648 { 3649 "coins": "123456", // hastings, big int 3650 "funds": "1", // siafunds, big int 3651 } 3652 ``` 3653 **coins** | hastings, big int 3654 Number of siacoins, in hastings, transferred to the wallet as a result of the sweep. 3655 3656 **funds** | siafunds, big int 3657 Number of siafunds transferred to the wallet as a result of the sweep. 3658 3659 ## /wallet/lock [POST] 3660 > curl example 3661 3662 ```go 3663 curl -A "Sia-Agent" -u "":<apipassword> -X POST "localhost:9980/wallet/lock" 3664 ``` 3665 3666 Locks the wallet, wiping all secret keys. After being locked, the keys are encrypted. Queries for the seed, to send siafunds, and related queries become unavailable. Queries concerning transaction history and balance are still available. 3667 3668 ### Response 3669 3670 standard success or error response. See [standard responses](#standard-responses). 3671 3672 ## /wallet/transaction/:*id* [GET] 3673 > curl example 3674 3675 ```go 3676 curl -A "Sia-Agent" "localhost:9980/wallet/transaction/22e8d5428abc184302697929f332fa0377ace60d405c39dd23c0327dc694fae7" 3677 ``` 3678 3679 Gets the transaction associated with a specific transaction id. 3680 3681 ### Path Parameters 3682 #### REQUIRED 3683 **id** | hash 3684 ID of the transaction being requested. 3685 3686 ### JSON Response 3687 > JSON Response Example 3688 3689 ```go 3690 { 3691 "transaction": { 3692 "transaction": { 3693 // See types.Transaction in https://gitlab.com/NebulousLabs/Sia/blob/master/types/transactions.go 3694 }, 3695 "transactionid": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 3696 "confirmationheight": 50000, 3697 "confirmationtimestamp": 1257894000, 3698 "inputs": [ 3699 { 3700 "parentid": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 3701 "fundtype": "siacoin input", 3702 "walletaddress": false, 3703 "relatedaddress": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 3704 "value": "1234", // hastings or siafunds, depending on fundtype, big int 3705 } 3706 ], 3707 "outputs": [ 3708 { 3709 "id": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 3710 "fundtype": "siacoin output", 3711 "maturityheight": 50000, 3712 "walletaddress": false, 3713 "relatedaddress": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3714 "value": "1234", // hastings or siafunds, depending on fundtype, big int 3715 } 3716 ] 3717 } 3718 } 3719 ``` 3720 **transaction** 3721 Raw transaction. The rest of the fields in the resposne are determined from this raw transaction. It is left undocumented here as the processed transaction (the rest of the fields in this object) are usually what is desired. 3722 3723 See types.Transaction in https://gitlab.com/NebulousLabs/Sia/blob/master/types/transactions.go 3724 3725 **transactionid** 3726 ID of the transaction from which the wallet transaction was derived. 3727 3728 **confirmationheight** 3729 Block height at which the transaction was confirmed. If the transaction is unconfirmed the height will be the max value of an unsigned 64-bit integer. 3730 3731 **confirmationtimestamp** 3732 Time, in unix time, at which a transaction was confirmed. If the transaction is unconfirmed the timestamp will be the max value of an unsigned 64-bit integer. 3733 3734 **inputs** 3735 Array of processed inputs detailing the inputs to the transaction. 3736 3737 **parentid** 3738 The id of the output being spent. 3739 3740 **fundtype** 3741 Type of fund represented by the input. Possible values are 'siacoin input' and 'siafund input'. 3742 3743 **walletaddress** | Boolean 3744 true if the address is owned by the wallet. 3745 3746 **relatedaddress** 3747 Address that is affected. For inputs (outgoing money), the related address is usually not important because the wallet arbitrarily selects which addresses will fund a transaction. 3748 3749 **value** | hastings or siafunds, depending on fundtype, big int 3750 Amount of funds that have been moved in the input. 3751 3752 **outputs** 3753 Array of processed outputs detailing the outputs of the transaction. Outputs related to file contracts are excluded. 3754 3755 **id** 3756 The id of the output that was created. 3757 3758 **fundtype** 3759 Type of fund is represented by the output. Possible values are 'siacoin output', 'siafund output', 'claim output', and 'miner payout'. Siacoin outputs and claim outputs both relate to siacoins. 3760 3761 Siafund outputs relate to siafunds. 3762 3763 Miner payouts point to siacoins that have been spent on a miner payout. Because the destination of the miner payout is determined by the block and not the transaction, the data 'maturityheight', 'walletaddress', and 'relatedaddress' areleft blank. 3764 3765 **maturityheight** 3766 Block height the output becomes available to be spent. Siacoin outputs and siafund outputs mature immediately - their maturity height will always be the confirmation height of the transaction. Claim outputs cannot be spent until they have had 144 confirmations, thus the maturity height of a claim output will always be 144 larger than the confirmation height of the transaction. 3767 3768 **walletaddress** | boolean 3769 true if the address is owned by the wallet. 3770 3771 **relatedaddress** 3772 Address that is affected. For outputs (incoming money), the related address field can be used to determine who has sent money to the wallet. 3773 3774 **value** | hastings or siafunds, depending on fundtype, big int 3775 Amount of funds that have been moved in the output. 3776 3777 ## /wallet/transactions [GET] 3778 > curl example 3779 3780 ```go 3781 curl -A "Sia-Agent" "localhost:9980/wallet/transactions" 3782 ``` 3783 3784 Returns a list of transactions related to the wallet in chronological order. 3785 3786 ### Query String Parameters 3787 #### REQUIRED 3788 **startheight** | block height 3789 // Height of the block where transaction history should begin. 3790 3791 **endheight** | block height 3792 Height of of the block where the transaction history should end. If 'endheight' is greater than the current height, or if it is '-1', all transactions up to and including the most recent block will be provided. 3793 3794 ### JSON Response 3795 > JSON Response Example 3796 3797 ```go 3798 { 3799 "confirmedtransactions": [ 3800 { 3801 // See the documentation for '/wallet/transaction/:id' for more information. 3802 } 3803 ], 3804 "unconfirmedtransactions": [ 3805 { 3806 // See the documentation for '/wallet/transaction/:id' for more information. 3807 } 3808 ] 3809 } 3810 ``` 3811 **confirmedtransactions** 3812 All of the confirmed transactions appearing between height 'startheight' and height 'endheight' (inclusive). 3813 3814 See the documentation for '/wallet/transaction/:id' for more information. 3815 3816 **unconfirmedtransactions** 3817 All of the unconfirmed transactions. 3818 3819 See the documentation for '/wallet/transaction/:id' for more information. 3820 3821 ## /wallet/transactions/:addr [GET] 3822 > curl example 3823 3824 ```go 3825 curl -A "Sia-Agent" "localhost:9980/wallet/transactions/abf1ba4ad65820ce2bd5d63466b8555d0ec9bfe5f5fa920b4fef6ad98f443e2809e5ae619b74" 3826 ``` 3827 3828 Returns all of the transactions related to a specific address. 3829 3830 ### Path Parameters 3831 #### REQUIRED 3832 **addr** | hash 3833 Unlock hash (i.e. wallet address) whose transactions are being requested. 3834 3835 ### JSON Response 3836 > JSON Response Example 3837 3838 ```go 3839 { 3840 "transactions": [ 3841 { 3842 // See the documentation for '/wallet/transaction/:id' for more information. 3843 } 3844 ] 3845 } 3846 ``` 3847 **transactions** 3848 Array of processed transactions that relate to the supplied address. 3849 3850 See the documentation for '/wallet/transaction/:id' for more information. 3851 3852 ## /wallet/unlock [POST] 3853 > curl example 3854 3855 ```go 3856 curl -A "Sia-Agent" -u "":<apipassword> --data "encryptionpassword=<password>" "localhost:9980/wallet/unlock" 3857 ``` 3858 3859 Unlocks the wallet. The wallet is capable of knowing whether the correct password was provided. 3860 3861 ### Query String Parameters 3862 #### REQUIRED 3863 **encryptionpassword** | string 3864 Password that gets used to decrypt the file. Most frequently, the encryption password is the same as the primary wallet seed. 3865 3866 ### Response 3867 3868 standard success or error response. See [standard responses](#standard-responses). 3869 3870 ## /wallet/unlockconditions/:addr [GET] 3871 > curl example 3872 3873 ```go 3874 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/wallet/unlockconditions/2d6c6d705c80f17448d458e47c3fb1a02a24e018a82d702cda35262085a3167d98cc7a2ba339" 3875 ``` 3876 3877 Returns the unlock conditions of :addr, if they are known to the wallet. 3878 3879 ### Path Parameters 3880 #### REQUIRED 3881 **addr** | hash 3882 Unlock hash (i.e. wallet address) whose transactions are being requested. 3883 3884 ### JSON Response 3885 > JSON Response Example 3886 3887 ```go 3888 { 3889 "unlockconditions": { 3890 "timelock": 0, 3891 "publickeys": [{ 3892 "algorithm": "ed25519", 3893 "key": "/XUGj8PxMDkqdae6Js6ubcERxfxnXN7XPjZyANBZH1I=" 3894 }], 3895 "signaturesrequired": 1 3896 } 3897 } 3898 ``` 3899 **timelock** 3900 The minimum blockheight required. 3901 3902 **signaturesrequired** 3903 The number of signatures required. 3904 3905 **publickeys** 3906 The set of keys whose signatures count towards signaturesrequired. 3907 3908 ## /wallet/unspent [GET] 3909 > curl example 3910 3911 ```go 3912 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/wallet/unspent" 3913 ``` 3914 3915 Returns a list of outputs that the wallet can spend. 3916 3917 ### JSON Response 3918 > JSON Response Example 3919 3920 ```go 3921 { 3922 "outputs": [ 3923 { 3924 "id": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 3925 "fundtype": "siacoin output", 3926 "confirmationheight": 50000, 3927 "unlockhash": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 3928 "value": "1234", // big int 3929 "iswatchonly": false 3930 } 3931 ] 3932 } 3933 ``` 3934 **outputs** 3935 Array of outputs that the wallet can spend. 3936 3937 **id** 3938 The id of the output. 3939 3940 **fundtype** 3941 Type of output, either 'siacoin output' or 'siafund output'. 3942 3943 **confirmationheight** 3944 Height of block in which the output appeared. To calculate the number of confirmations, subtract this number from the current block height. 3945 3946 **unlockhash** 3947 Hash of the output's unlock conditions, commonly known as the "address". 3948 3949 **value** | big int 3950 Amount of funds in the output; hastings for siacoin outputs, and siafunds for siafund outputs. 3951 3952 **iswatchonly** | Boolean 3953 Whether the output comes from a watched address or from the wallet's seed. 3954 3955 ## /wallet/verify/address/:addr [GET] 3956 > curl example 3957 3958 ```go 3959 curl -A "Sia-Agent" "localhost:9980/wallet/verify/address/75d9a7351022681ba3539d7e0c5699d143ab5a7747604998cace1299ab6c04c5ea2aa2e87aac" 3960 ``` 3961 3962 Takes the address specified by :addr and returns a JSON response indicating if the address is valid. 3963 3964 ### Path Parameters 3965 #### REQUIRED 3966 **addr** | hash 3967 Unlock hash (i.e. wallet address) whose transactions are being requested. 3968 3969 ### JSON Response 3970 > JSON Response Example 3971 3972 ```go 3973 { 3974 "valid": true 3975 } 3976 ``` 3977 **valid** 3978 valid indicates if the address supplied to :addr is a valid UnlockHash. 3979 3980 ## /wallet/watch [GET] 3981 > curl example 3982 3983 ```go 3984 curl -A "Sia-Agent" -u "":<apipassword> "localhost:9980/wallet/watch" 3985 ``` 3986 3987 Returns the set of addresses that the wallet is watching. This set only includes addresses that were explicitly requested to be watched; addresses that were generated automatically by the wallet, or by /wallet/address, are not included. 3988 3989 ### JSON Response 3990 > JSON Response Example 3991 3992 ```go 3993 { 3994 "addresses": [ 3995 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 3996 "abcdef0123456789abcdef0123456789abcd1234567890ef0123456789abcdef" 3997 ] 3998 } 3999 ``` 4000 **addresses** 4001 The addresses currently watched by the wallet. 4002 4003 ## /wallet/watch [POST] 4004 > curl example 4005 4006 ```go 4007 curl -A "Sia-Agent" -u "":<apipassword> --data "<requestbody>" "localhost:9980/wallet/watch" 4008 ``` 4009 4010 ### Request Body 4011 > Request Body Example 4012 4013 ```go 4014 { 4015 // The addresses to add or remove from the current set. 4016 "addresses": [ 4017 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 4018 "abcdef0123456789abcdef0123456789abcd1234567890ef0123456789abcdef" 4019 ], 4020 4021 // If true, remove the addresses instead of adding them. 4022 "remove": false, 4023 4024 // If true, the wallet will not rescan the blockchain. Only set this flag if 4025 // the addresses have never appeared in the blockchain. 4026 "unused": true, 4027 ``` 4028 4029 ### Response 4030 4031 standard success or error response. See [standard responses](#standard-responses). 4032 4033 # Version 4034 <<<<<<< HEAD 4035 <a href='https://sia.tech/docs/v140'>**v140** 4036 ======= 4037 <a href='https://sia.tech/docs/v140'>**v140** 4038 >>>>>>> siaprime/master