github.com/fozzysec/SiaPrime@v0.0.0-20190612043147-66c8e8d11fe3/doc/api/Wallet.md (about) 1 Wallet 2 ====== 3 4 This document contains detailed descriptions of the wallet's API routes. For an 5 overview of the wallet's API routes, see [API.md#wallet](/doc/API.md#wallet). 6 For an overview of all API routes, see [API.md](/doc/API.md) 7 8 There may be functional API calls which are not documented. These are not 9 guaranteed to be supported beyond the current release, and should not be used 10 in production. 11 12 Overview 13 -------- 14 15 The wallet stores and manages siacoins and siafunds. The wallet's API endpoints 16 expose methods for creating and loading wallets, locking and unlocking, sending 17 siacoins and siafunds, and getting the wallet's balance. 18 19 You must create a wallet before you can use the wallet's API endpoints. You can 20 create a wallet with the `/wallet/init` endpoint. Wallets are always encrypted 21 on disk. Calls to some wallet API endpoints will fail until the wallet is 22 unlocked. The wallet can be unlocked with the `/wallet/unlock` endpoint. Once 23 the wallet is unlocked calls to the API endpoints will succeed until the wallet 24 is locked again with `/wallet/lock`, or Siad is restarted. The host and renter 25 require the miner to be unlocked. 26 27 Index 28 ----- 29 30 | Route | HTTP verb | 31 | ----------------------------------------------------------------------- | --------- | 32 | [/wallet](#wallet-get) | GET | 33 | [/wallet/033x](#wallet033x-post) | POST | 34 | [/wallet/address](#walletaddress-get) | GET | 35 | [/wallet/addresses](#walletaddresses-get) | GET | 36 | [/wallet/backup](#walletbackup-get) | GET | 37 | [/wallet/changepassword](#walletchangepassword-post) | POST | 38 | [/wallet/init](#walletinit-post) | POST | 39 | [/wallet/init/seed](#walletinitseed-post) | POST | 40 | [/wallet/lock](#walletlock-post) | POST | 41 | [/wallet/seed](#walletseed-post) | POST | 42 | [/wallet/seeds](#walletseeds-get) | GET | 43 | [/wallet/siacoins](#walletsiacoins-post) | POST | 44 | [/wallet/siafunds](#walletsiafunds-post) | POST | 45 | [/wallet/siagkey](#walletsiagkey-post) | POST | 46 | [/wallet/sign](#walletsign-post) | POST | 47 | [/wallet/sweep/seed](#walletsweepseed-post) | POST | 48 | [/wallet/transaction/___:id___](#wallettransactionid-get) | GET | 49 | [/wallet/transactions](#wallettransactions-get) | GET | 50 | [/wallet/transactions/___:addr___](#wallettransactionsaddr-get) | GET | 51 | [/wallet/unlock](#walletunlock-post) | POST | 52 | [/wallet/unlockconditions](#walletunlockconditions-post) | POST | 53 | [/wallet/unlockconditions/___:addr___](#walletunlockconditionsaddr-get) | GET | 54 | [/wallet/unspent](#walletunspent-get) | GET | 55 | [/wallet/verify/address/:___addr___](#walletverifyaddressaddr-get) | GET | 56 | [/wallet/watch](#walletwatch-post) | POST | 57 58 59 #### /wallet [GET] 60 61 returns basic information about the wallet, such as whether the wallet is 62 locked or unlocked. 63 64 ###### JSON Response 65 ```javascript 66 { 67 // Indicates whether the wallet has been encrypted or not. If the wallet 68 // has not been encrypted, then no data has been generated at all, and the 69 // first time the wallet is unlocked, the password given will be used as 70 // the password for encrypting all of the data. 'encrypted' will only be 71 // set to false if the wallet has never been unlocked before (the unlocked 72 // wallet is still encryped - but the encryption key is in memory). 73 "encrypted": true, 74 75 // Indicates whether the wallet is currently locked or unlocked. Some calls 76 // become unavailable when the wallet is locked. 77 "unlocked": true, 78 79 // Indicates whether the wallet is currently rescanning the blockchain. This 80 // will be true for the duration of calls to /unlock, /seeds, /init/seed, 81 // and /sweep/seed. 82 "rescanning": false, 83 84 // Number of siacoins, in hastings, available to the wallet as of the most 85 // recent block in the blockchain. 86 "confirmedsiacoinbalance": "123456", // hastings, big int 87 88 // Number of siacoins, in hastings, that are leaving the wallet according 89 // to the set of unconfirmed transactions. Often this number appears 90 // inflated, because outputs are frequently larger than the number of coins 91 // being sent, and there is a refund. These coins are counted as outgoing, 92 // and the refund is counted as incoming. The difference in balance can be 93 // calculated using 'unconfirmedincomingsiacoins' - 'unconfirmedoutgoingsiacoins' 94 "unconfirmedoutgoingsiacoins": "0", // hastings, big int 95 96 // Number of siacoins, in hastings, are entering the wallet according to 97 // the set of unconfirmed transactions. This number is often inflated by 98 // outgoing siacoins, because outputs are frequently larger than the amount 99 // being sent. The refund will be included in the unconfirmed incoming 100 // siacoins balance. 101 "unconfirmedincomingsiacoins": "789", // hastings, big int 102 103 // Number of siafunds available to the wallet as of the most recent block 104 // in the blockchain. 105 "siafundbalance": "1", // big int 106 107 // Number of siacoins, in hastings, that can be claimed from the siafunds 108 // as of the most recent block. Because the claim balance increases every 109 // time a file contract is created, it is possible that the balance will 110 // increase before any claim transaction is confirmed. 111 "siacoinclaimbalance": "9001", // hastings, big int 112 113 // Number of siacoins, in hastings per byte, below which a transaction output 114 // cannot be used because the wallet considers it a dust output 115 "dustthreshold": "1234", // hastings / byte, big int 116 } 117 ``` 118 119 #### /wallet/033x [POST] 120 121 loads a v0.3.3.x wallet into the current wallet, harvesting all of the secret 122 keys. All spendable addresses in the loaded wallet will become spendable from 123 the current wallet. An error will be returned if the given `encryptionpassword` 124 is incorrect. 125 126 ###### Query String Parameters 127 ``` 128 // Path on disk to the v0.3.3.x wallet to be loaded. 129 source 130 131 // Encryption key of the wallet. 132 encryptionpassword 133 ``` 134 135 ###### Response 136 standard success or error response. See 137 [API.md#standard-responses](/doc/API.md#standard-responses). 138 139 #### /wallet/address [GET] 140 141 gets a new address from the wallet generated by the primary seed. An error will 142 be returned if the wallet is locked. 143 144 ###### JSON Response 145 ```javascript 146 { 147 // Wallet address that can receive siacoins or siafunds. Addresses are 76 character long hex strings. 148 "address": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab" 149 } 150 ``` 151 152 #### /wallet/addresses [GET] 153 154 fetches the list of addresses from the wallet. If the wallet has not been 155 created or unlocked, no addresses will be returned. After the wallet is 156 unlocked, this call will continue to return its addresses even after the 157 wallet is locked again. 158 159 ###### JSON Response 160 ```javascript 161 { 162 // Array of wallet addresses owned by the wallet. 163 "addresses": [ 164 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 165 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 166 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 167 ] 168 } 169 ``` 170 171 #### /wallet/backup [GET] 172 173 creates a backup of the wallet settings file. Though this can easily be done 174 manually, the settings file is often in an unknown or difficult to find 175 location. The /wallet/backup call can spare users the trouble of needing to 176 find their wallet file. The destination file is overwritten if it already 177 exists. 178 179 ###### Query String Parameters 180 ``` 181 // path to the location on disk where the backup file will be saved. 182 destination 183 ``` 184 185 ###### Response 186 standard success or error response. See 187 [API.md#standard-responses](/doc/API.md#standard-responses). 188 189 #### /wallet/changepassword [POST] 190 191 changes the wallet's encryption password. 192 193 ###### Query String Parameter 194 ``` 195 // encryptionpassword is the wallet's current encryption password. 196 encryptionpassword 197 // newpassword is the new password for the wallet. 198 newpassword 199 ``` 200 201 ###### Response 202 standard success or error response. See 203 [#standard-responses](#standard-responses). 204 205 #### /wallet/init [POST] 206 207 initializes the wallet. After the wallet has been initialized once, it does not 208 need to be initialized again, and future calls to /wallet/init will return an 209 error, unless the force flag is set. The encryption password is provided by the 210 api call. If the password is blank, then the password will be set to the same 211 as the seed. 212 213 ###### Query String Parameters 214 ``` 215 // Password that will be used to encrypt the wallet. All subsequent calls 216 // should use this password. If left blank, the seed that gets returned will 217 // also be the encryption password. 218 encryptionpassword 219 220 // Name of the dictionary that should be used when encoding the seed. 'english' 221 // is the most common choice when picking a dictionary. 222 dictionary // Optional, default is english. 223 224 // boolean, when set to true /wallet/init will Reset the wallet if one exists 225 // instead of returning an error. This allows API callers to reinitialize a new 226 // wallet. 227 force 228 ``` 229 230 ###### JSON Response 231 ```javascript 232 { 233 // Wallet seed used to generate addresses that the wallet is able to spend. 234 "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" 235 } 236 ``` 237 238 #### /wallet/init/seed [POST] 239 240 initializes the wallet using a preexisting seed. After the wallet has been 241 initialized once, it does not need to be initialized again, and future calls to 242 /wallet/init/seed will return an error unless the force flag is set. The 243 encryption password is provided by the api call. If the password is blank, then 244 the password will be set to the same as the seed. Note that loading a 245 preexisting seed requires scanning the blockchain to determine how many keys 246 have been generated from the seed. For this reason, /wallet/init/seed can only 247 be called if the blockchain is synced. 248 249 ###### Query String Parameters 250 ``` 251 // Password that will be used to encrypt the wallet. All subsequent calls 252 // should use this password. If left blank, the seed that gets returned will 253 // also be the encryption password. 254 encryptionpassword 255 256 // Name of the dictionary that should be used when encoding the seed. 'english' 257 // is the most common choice when picking a dictionary. 258 dictionary // Optional, default is english. 259 260 // Dictionary-encoded phrase that corresponds to the seed being used to 261 // initialize the wallet. 262 seed 263 264 // boolean, when set to true /wallet/init will Reset the wallet if one exists 265 // instead of returning an error. This allows API callers to reinitialize a new 266 // wallet. 267 force 268 ``` 269 270 ###### Response 271 standard success or error response. See 272 [API.md#standard-responses](/doc/API.md#standard-responses). 273 274 #### /wallet/seed [POST] 275 276 gives the wallet a seed to track when looking for incoming transactions. The 277 wallet will be able to spend outputs related to addresses created by the seed. 278 The seed is added as an auxiliary seed, and does not replace the primary seed. 279 Only the primary seed will be used for generating new addresses. 280 281 ###### Query String Parameters 282 ``` 283 // Key used to encrypt the new seed when it is saved to disk. 284 encryptionpassword 285 286 // Name of the dictionary that should be used when encoding the seed. 'english' 287 // is the most common choice when picking a dictionary. 288 dictionary 289 290 // Dictionary-encoded phrase that corresponds to the seed being added to the 291 // wallet. 292 seed 293 ``` 294 295 ###### Response 296 standard success or error response. See 297 [API.md#standard-responses](/doc/API.md#standard-responses). 298 299 #### /wallet/seeds [GET] 300 301 returns a list of seeds in use by the wallet. The primary seed is the only seed 302 that gets used to generate new addresses. This call is unavailable when the 303 wallet is locked. 304 305 A seed is an encoded version of a 256 bit random seed. The output is 29 words 306 chosen from a small dictionary as indicated by the input. The most common 307 choice for the dictionary is going to be 'english'. The underlying seed is the 308 same no matter what dictionary is used for the encoding. The encoding also 309 contains a small checksum of the seed, to help catch simple mistakes when 310 copying. The library 311 [entropy-mnemonics](https://gitlab.com/SiaPrime/entropy-mnemonics) is used 312 when encoding. 313 314 ###### Query String Parameters 315 ``` 316 // Name of the dictionary that should be used when encoding the seed. 'english' 317 // is the most common choice when picking a dictionary. 318 dictionary 319 ``` 320 321 ###### JSON Response 322 ```javascript 323 { 324 // Seed that is actively being used to generate new addresses for the wallet. 325 "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", 326 327 // Number of addresses that remain in the primary seed until exhaustion has 328 // been reached. Once exhaustion has been reached, new addresses will 329 // continue to be generated but they will be more difficult to recover in the 330 // event of a lost wallet file or encryption password. 331 "addressesremaining": 2500, 332 333 // Array of all seeds that the wallet references when scanning the blockchain 334 // for outputs. The wallet is able to spend any output generated by any of 335 // the seeds, however only the primary seed is being used to generate new 336 // addresses. 337 "allseeds": [ 338 "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", 339 "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", 340 ] 341 } 342 ``` 343 344 #### /wallet/siacoins [POST] 345 346 Function: Send siacoins to an address or set of addresses. The outputs are 347 arbitrarily selected from addresses in the wallet. If 'outputs' is supplied, 348 'amount' and 'destination' must be empty. The number of outputs should not 349 exceed 400; this may result in a transaction too large to fit in the 350 transaction pool. 351 352 ###### Query String Parameters 353 ``` 354 // Number of hastings being sent. A hasting is the smallest unit in SiaPrime. There 355 // are 10^24 hastings in a siacoin. 356 amount // hastings 357 358 // Address that is receiving the coins. 359 destination // address 360 361 // JSON array of outputs. The structure of each output is: 362 // {"unlockhash": "<destination>", "value": "<amount>"} 363 outputs 364 ``` 365 366 ###### JSON Response 367 ```javascript 368 { 369 // Array of IDs of the transactions that were created when sending the coins. 370 // The last transaction contains the output headed to the 'destination'. 371 // Transaction IDs are 64 character long hex strings. 372 transactionids [ 373 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 374 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 375 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 376 ] 377 } 378 ``` 379 380 ### Examples 381 382 #### Send to single address 383 384 ###### Example POST Request 385 Use _amount_ and _destination_ parameters. 386 ``` 387 /wallet/siacoins?amount=1000000000000000000000000&destination=1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab 388 ``` 389 390 ###### Expected Response Code 391 ``` 392 200 OK 393 ``` 394 395 ###### Example Response Body 396 ```json 397 { 398 "transactionids": [ 399 "3918e4a4b4cee46b3e5b28b8a1cc41c064a6f6002d162d396f296c201e6edc13", 400 "18b85b7d20f8a87bdadacf11e135ad44db1d93efd0613d23116e8cf255502762" 401 ] 402 } 403 ``` 404 405 406 #### Send to set of addresses 407 Use _outputs_ parameter in the form of a JSON array. _amount_ and _destination_ parameters must be empty. 408 409 410 ###### Example POST Request 411 ``` 412 /wallet/siacoins?outputs=[{"unlockhash":"1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab","value":"1000000000000000000000000"},{"unlockhash":"abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab1234567890","value":"8000000000000000000000000"},{"unlockhash":"cdef0123456789abcdef0123456789abcdef0123456789ab1234567890abcdef0123456789ab","value":"5000000000000000000000000"}] 413 ``` 414 415 ###### (sample JSON request body for reference) 416 ```json 417 { 418 "outputs": [ 419 { 420 "unlockhash": 421 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 422 "value": "1000000000000000000000000" 423 }, 424 { 425 "unlockhash": 426 "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab1234567890", 427 "value": "8000000000000000000000000" 428 }, 429 { 430 "unlockhash": 431 "cdef0123456789abcdef0123456789abcdef0123456789ab1234567890abcdef0123456789ab", 432 "value": "20000000000000000000000000" 433 } 434 ] 435 } 436 437 ``` 438 439 ###### Expected Response Code 440 ``` 441 200 OK 442 ``` 443 444 ###### Example Response Body 445 ```json 446 { 447 "transactionids": [ 448 "21962e0118f3ca5d6fab0262c65bca0220fbcc828c499974d86e7cc4047a0ce5", 449 "f2471d550823f2c0616565d8476a7fea5f2b9a841612bf109923c3a54e760721" 450 ] 451 } 452 ``` 453 454 #### /wallet/siafunds [POST] 455 456 sends siafunds to an address. The outputs are arbitrarily selected from 457 addresses in the wallet. Any siacoins available in the siafunds being sent (as 458 well as the siacoins available in any siafunds that end up in a refund address) 459 will become available to the wallet as siacoins after 144 confirmations. To 460 access all of the siacoins in the siacoin claim balance, send all of the 461 siafunds to an address in your control (this will give you all the siacoins, 462 while still letting you control the siafunds). 463 464 ###### Query String Parameters 465 ``` 466 // Number of siafunds being sent. 467 amount // siafunds 468 469 // Address that is receiving the funds. 470 destination // address 471 ``` 472 473 ###### JSON Response 474 ```javascript 475 { 476 // Array of IDs of the transactions that were created when sending the coins. 477 // The last transaction contains the output headed to the 'destination'. 478 // Transaction IDs are 64 character long hex strings. 479 "transactionids": [ 480 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 481 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 482 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 483 ] 484 } 485 ``` 486 487 #### /wallet/siagkey [POST] 488 489 Function: Load a key into the wallet that was generated by siag. Most siafunds 490 are currently in addresses created by siag. 491 492 ###### Query String Parameters 493 ``` 494 // Key that is used to encrypt the siag key when it is imported to the wallet. 495 encryptionpassword 496 497 // List of filepaths that point to the keyfiles that make up the siag key. 498 // There should be at least one keyfile per required signature. The filenames 499 // need to be commna separated (no spaces), which means filepaths that contain 500 // a comma are not allowed. 501 keyfiles 502 ``` 503 504 ###### Response 505 standard success or error response. See 506 [API.md#standard-responses](/doc/API.md#standard-responses). 507 508 #### /wallet/sign [POST] 509 510 Function: Sign a transaction. The transaction's TransactionSignatures should 511 be complete except for the Signature field. If `tosign` is provided, the 512 wallet will attempt to fill in signatures for each TransactionSignature 513 specified. If `tosign` is not provided, the wallet will add signatures for 514 every TransactionSignature that it has keys for. 515 516 ###### Request Body 517 ```javascript 518 { 519 // Unsigned transaction 520 "transaction": { 521 "siacoininputs": [ 522 { 523 "parentid": "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584", 524 "unlockconditions": { 525 "timelock": 0, 526 "publickeys": [ "ed25519:8b845bf4871bcdf4ff80478939e508f43a2d4b2f68e94e8b2e3d1ea9b5f33ef1" ], 527 "signaturesrequired": 1 528 } 529 } 530 ], 531 "siacoinoutputs": [ 532 { 533 "value": "5000000000000000000000000", 534 "unlockhash": "17d25299caeccaa7d1598751f239dd47570d148bb08658e596112d917dfa6bc8400b44f239bb" 535 }, 536 { 537 "value": "299990000000000000000000000000", 538 "unlockhash": "b4bf662170622944a7c838c7e75665a9a4cf76c4cebd97d0e5dcecaefad1c8df312f90070966" 539 } 540 ], 541 "minerfees": [ "1000000000000000000000000" ], 542 "transactionsignatures": [ 543 { 544 "parentid": "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584", 545 "publickeyindex": 0, 546 "coveredfields": {"wholetransaction": true} 547 } 548 ] 549 }, 550 551 // Optional IDs to sign; each should correspond to a parentid in the transactionsignatures. 552 "tosign": [ 553 "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584" 554 ] 555 } 556 ``` 557 558 ###### Response 559 ```javascript 560 { 561 // signed transaction 562 "transaction": { 563 "siacoininputs": [ 564 { 565 "parentid": "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584", 566 "unlockconditions": { 567 "timelock": 0, 568 "publickeys": [ "ed25519:8b845bf4871bcdf4ff80478939e508f43a2d4b2f68e94e8b2e3d1ea9b5f33ef1" ], 569 "signaturesrequired": 1 570 } 571 } 572 ], 573 "siacoinoutputs": [ 574 { 575 "value": "5000000000000000000000000", 576 "unlockhash": "17d25299caeccaa7d1598751f239dd47570d148bb08658e596112d917dfa6bc8400b44f239bb" 577 }, 578 { 579 "value": "299990000000000000000000000000", 580 "unlockhash": "b4bf662170622944a7c838c7e75665a9a4cf76c4cebd97d0e5dcecaefad1c8df312f90070966" 581 } 582 ], 583 "minerfees": [ "1000000000000000000000000" ], 584 "transactionsignatures": [ 585 { 586 "parentid": "af1a88781c362573943cda006690576b150537c1ae142a364dbfc7f04ab99584", 587 "publickeyindex": 0, 588 "coveredfields": {"wholetransaction": true}, 589 "signature": "CVkGjy4The6h+UU+O8rlZd/O3Gb1xRJdyQ2vzBFEb/5KveDKDrrieCiFoNtUaknXEQbdxlrDqMujc+x3aZbKCQ==" 590 } 591 ] 592 } 593 } 594 ``` 595 596 #### /wallet/sweep/seed [POST] 597 598 Function: Scan the blockchain for outputs belonging to a seed and send them to 599 an address owned by the wallet. 600 601 ###### Query String Parameters 602 ``` 603 // Name of the dictionary that should be used when decoding the seed. 'english' 604 // is the most common choice when picking a dictionary. 605 dictionary // Optional, default is english. 606 607 // Dictionary-encoded phrase that corresponds to the seed being added to the 608 // wallet. 609 seed 610 ``` 611 612 ###### JSON Response 613 ```javascript 614 { 615 // Number of siacoins, in hastings, transferred to the wallet as a result of 616 // the sweep. 617 "coins": "123456", // hastings, big int 618 619 // Number of siafunds transferred to the wallet as a result of the sweep. 620 "funds": "1", // siafunds, big int 621 } 622 ``` 623 624 #### /wallet/lock [POST] 625 626 locks the wallet, wiping all secret keys. After being locked, the keys are 627 encrypted. Queries for the seed, to send siafunds, and related queries become 628 unavailable. Queries concerning transaction history and balance are still 629 available. 630 631 ###### Response 632 standard success or error response. See 633 [API.md#standard-responses](/doc/API.md#standard-responses). 634 635 #### /wallet/transaction/___:id___ [GET] 636 637 gets the transaction associated with a specific transaction id. 638 639 ###### Path Parameters 640 ``` 641 // ID of the transaction being requested. 642 :id 643 ``` 644 645 ###### JSON Response 646 ```javascript 647 { 648 "transaction": { 649 // Raw transaction. The rest of the fields in the resposne are determined 650 // from this raw transaction. It is left undocumented here as the processed 651 // transaction (the rest of the fields in this object) are usually what is 652 // desired. 653 "transaction": { 654 // See types.Transaction in https://gitlab.com/SiaPrime/SiaPrime/blob/master/types/transactions.go 655 }, 656 657 // ID of the transaction from which the wallet transaction was derived. 658 "transactionid": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 659 660 // Block height at which the transaction was confirmed. If the transaction 661 // is unconfirmed the height will be the max value of an unsigned 64-bit 662 // integer. 663 "confirmationheight": 50000, 664 665 // Time, in unix time, at which a transaction was confirmed. If the 666 // transaction is unconfirmed the timestamp will be the max value of an 667 // unsigned 64-bit integer. 668 "confirmationtimestamp": 1257894000, 669 670 // Array of processed inputs detailing the inputs to the transaction. 671 "inputs": [ 672 { 673 // The id of the output being spent. 674 "parentid": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 675 676 // Type of fund represented by the input. Possible values are 677 // 'siacoin input' and 'siafund input'. 678 "fundtype": "siacoin input", 679 680 // true if the address is owned by the wallet. 681 "walletaddress": false, 682 683 // Address that is affected. For inputs (outgoing money), the related 684 // address is usually not important because the wallet arbitrarily 685 // selects which addresses will fund a transaction. 686 "relatedaddress": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 687 688 // Amount of funds that have been moved in the input. 689 "value": "1234", // hastings or siafunds, depending on fundtype, big int 690 } 691 ], 692 // Array of processed outputs detailing the outputs of the transaction. 693 // Outputs related to file contracts are excluded. 694 "outputs": [ 695 { 696 // The id of the output that was created. 697 "id": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 698 699 // Type of fund is represented by the output. Possible values are 700 // 'siacoin output', 'siafund output', 'claim output', and 'miner 701 // payout'. Siacoin outputs and claim outputs both relate to siacoins. 702 // Siafund outputs relate to siafunds. Miner payouts point to siacoins 703 // that have been spent on a miner payout. Because the destination of 704 // the miner payout is determined by the block and not the transaction, 705 // the data 'maturityheight', 'walletaddress', and 'relatedaddress' are 706 // left blank. 707 "fundtype": "siacoin output", 708 709 // Block height the output becomes available to be spent. Siacoin 710 // outputs and siafund outputs mature immediately - their maturity 711 // height will always be the confirmation height of the transaction. 712 // Claim outputs cannot be spent until they have had 144 confirmations, 713 // thus the maturity height of a claim output will always be 144 larger 714 // than the confirmation height of the transaction. 715 "maturityheight": 50000, 716 717 // true if the address is owned by the wallet. 718 "walletaddress": false, 719 720 // Address that is affected. For outputs (incoming money), the related 721 // address field can be used to determine who has sent money to the 722 // wallet. 723 "relatedaddress": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 724 725 // Amount of funds that have been moved in the output. 726 "value": "1234", // hastings or siafunds, depending on fundtype, big int 727 } 728 ] 729 } 730 } 731 ``` 732 733 #### /wallet/transactions [GET] 734 735 returns a list of transactions related to the wallet. 736 737 ###### Query String Parameters 738 ``` 739 // Height of the block where transaction history should begin. 740 startheight // block height 741 742 // Height of of the block where the transaction history should end. If 743 // 'endheight' is greater than the current height, or if it is '-1', all 744 // transactions up to and including the most recent block will be provided. 745 endheight // block height 746 ``` 747 748 ###### JSON Response 749 ```javascript 750 { 751 // All of the confirmed transactions appearing between height 'startheight' 752 // and height 'endheight' (inclusive). 753 "confirmedtransactions": [ 754 { 755 // See the documentation for '/wallet/transaction/:id' for more information. 756 } 757 ], 758 759 // All of the unconfirmed transactions. 760 "unconfirmedtransactions": [ 761 { 762 // See the documentation for '/wallet/transaction/:id' for more information. 763 } 764 ] 765 } 766 ``` 767 768 #### /wallet/transactions/___:addr___ [GET] 769 770 returns all of the transactions related to a specific address. 771 772 ###### Path Parameters 773 ``` 774 // Unlock hash (i.e. wallet address) whose transactions are being requested. 775 :addr 776 ``` 777 778 ###### JSON Response 779 ```javascript 780 { 781 // Array of processed transactions that relate to the supplied address. 782 "transactions": [ 783 { 784 // See the documentation for '/wallet/transaction/:id' for more information. 785 } 786 ] 787 } 788 ``` 789 790 #### /wallet/unlock [POST] 791 792 unlocks the wallet. The wallet is capable of knowing whether the correct 793 password was provided. 794 795 ###### Query String Parameters 796 ``` 797 // Password that gets used to decrypt the file. Most frequently, the encryption 798 // password is the same as the primary wallet seed. 799 encryptionpassword string 800 ``` 801 802 ###### Response 803 standard success or error response. See 804 [API.md#standard-responses](/doc/API.md#standard-responses). 805 806 #### /wallet/unlockconditions [POST] 807 808 stores a set of unlock conditions in the wallet database. 809 810 ###### Request Body 811 ```javascript 812 { 813 "unlockconditions": { 814 // the minimum blockheight required 815 "timelock": 0, 816 // the number of signatures required 817 "signaturesrequired": 1, 818 // the set of keys whose signatures count towards signaturesrequired 819 "publickeys": [{ 820 "algorithm": "ed25519", 821 "key": "/XUGj8PxMDkqdae6Js6ubcERxfxnXN7XPjZyANBZH1I=" 822 }] 823 } 824 } 825 ``` 826 827 ###### Response 828 standard success or error response. See 829 [API.md#standard-responses](/doc/API.md#standard-responses). 830 831 #### /wallet/unlockconditions/___:addr___ [GET] 832 833 returns the unlock conditions of :addr, if they are known to the wallet. 834 835 ###### Response 836 ```javascript 837 { 838 "unlockconditions": { 839 // the minimum blockheight required 840 "timelock": 0, 841 // the number of signatures required 842 "signaturesrequired": 1, 843 // the set of keys whose signatures count towards signaturesrequired 844 "publickeys": [{ 845 "algorithm": "ed25519", 846 "key": "/XUGj8PxMDkqdae6Js6ubcERxfxnXN7XPjZyANBZH1I=" 847 }] 848 } 849 } 850 ``` 851 852 #### /wallet/unspent [GET] 853 854 returns a list of unspent outputs that the wallet is tracking. 855 856 ###### Response 857 ```javascript 858 { 859 // Array of outputs that the wallet can spend. 860 "outputs": [ 861 { 862 // The id of the output. 863 "id": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 864 865 // Type of output, either 'siacoin output' or 'siafund output'. 866 "fundtype": "siacoin output", 867 868 // Height of block in which the output appeared. To calculate the 869 // number of confirmations, subtract this number from the current 870 // block height. 871 "confirmationheight": 50000, 872 873 // Hash of the output's unlock conditions, commonly known as the "address". 874 "unlockhash": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 875 876 // Amount of funds in the output; hastings for siacoin outputs, and 877 // siafunds for siafund outputs. 878 "value": "1234", // big int 879 880 // Whether the output comes from a watched address or from the wallet's seed. 881 "iswatchonly": false 882 } 883 ] 884 } 885 ``` 886 887 #### /wallet/verify/address/___:addr___ [GET] 888 889 takes the address specified by :addr and returns a JSON response indicating if the address is valid. 890 891 ###### JSON Response 892 ```javascript 893 { 894 // valid indicates if the address supplied to :addr is a valid UnlockHash. 895 "valid": true 896 } 897 ``` 898 899 #### /wallet/watch [GET] 900 901 returns the set of addresses that the wallet is watching. This set only 902 includes addresses that were explicitly requested to be watched; addresses 903 that were generated automatically by the wallet, or by /wallet/address, are 904 not included. 905 906 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-12) 907 ```javascript 908 { 909 // The addresses currently watched by the wallet. 910 "addresses": [ 911 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 912 "abcdef0123456789abcdef0123456789abcd1234567890ef0123456789abcdef" 913 ] 914 } 915 ``` 916 917 #### /wallet/watch [POST] 918 919 updates the set of addresses watched by the wallet. 920 921 ###### Request Body 922 ``` 923 { 924 // The addresses to add or remove from the current set. 925 "addresses": [ 926 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 927 "abcdef0123456789abcdef0123456789abcd1234567890ef0123456789abcdef" 928 ], 929 930 // If true, remove the addresses instead of adding them. 931 "remove": false, 932 933 // If true, the wallet will not rescan the blockchain. Only set this flag if 934 // the addresses have never appeared in the blockchain. 935 "unused": true, 936 } 937 938 ``` 939 940 ###### Response 941 standard success or error response. See 942 [#standard-responses](#standard-responses).