decred.org/dcrwallet/v3@v3.1.0/rpc/documentation/api.md (about) 1 # RPC API Specification 2 3 Version: 7.13.x 4 5 **Note:** This document assumes the reader is familiar with gRPC concepts. 6 Refer to the [gRPC Concepts documentation](https://www.grpc.io/docs/guides/concepts.html) 7 for any unfamiliar terms. 8 9 **Note:** The naming style used for autogenerated identifiers may differ 10 depending on the language being used. This document follows the naming style 11 used by Google in their Protocol Buffers and gRPC documentation as well as this 12 project's `.proto` files. That is, CamelCase is used for services, methods, and 13 messages, lower_snake_case for message fields, and SCREAMING_SNAKE_CASE for 14 enums. 15 16 This document is the authoritative source on the RPC API's definitions and 17 semantics. Any divergence from this document is an implementation error. API 18 fixes and additions require a version increase according to the rules of 19 [Semantic Versioning 2.0.0](https://semver.org/). 20 21 Only optional proto3 message fields are used (the `required` keyword is never 22 used in the `.proto` file). If a message field must be set to something other 23 than the default value, or any other values are invalid, the error must occur in 24 the application's message handling. This prevents accidentally introducing 25 parsing errors if a previously optional field is missing or a new required field 26 is added. 27 28 Functionality is grouped into gRPC services. Depending on what functions are 29 currently callable, different services will be running. As an example, the 30 server may be running without a loaded wallet, in which case the Wallet service 31 is not running and the Loader service must be used to create a new or load an 32 existing wallet. 33 34 - [`VersionService`](#versionservice) 35 - [`WalletLoaderService`](#walletloaderservice) 36 - [`WalletService`](#walletservice) 37 - [`SeedService`](#seedservice) 38 - [`TicketBuyerService`](#ticketbuyerservice) 39 - [`TicketBuyerV2Service`](#ticketbuyerv2service) 40 - [`AgendaService`](#agendaservice) 41 - [`VotingService`](#votingservice) 42 - [`MessageVerificationService`](#messageverificationservice) 43 - [`DecodeMessageService`](#decodemessageservice) 44 - [`NetworkService`](#networkservice) 45 46 ## `VersionService` 47 48 The `VersionService` service provides the caller with versioning information 49 regarding the RPC server. It has no dependencies and is always running. 50 51 **Methods:** 52 53 - [`Version`](#version) 54 55 ### Methods 56 57 #### `Version` 58 59 The `Version` method returns the RPC server version. Versioning follows the 60 rules of Semantic Versioning (SemVer) 2.0.0. 61 62 **Request:** `VersionRequest` 63 64 **Response:** `VersionResponse` 65 66 - `string version_string`: The version encoded as a string. 67 68 - `uint32 major`: The SemVer major version number. 69 70 - `uint32 minor`: The SemVer minor version number. 71 72 - `uint32 patch`: The SemVer patch version number. 73 74 - `string prerelease`: The SemVer pre-release version identifier, if any. 75 76 - `string build_metadata`: Extra SemVer build metadata, if any. 77 78 **Expected errors:** None 79 80 **Stability:** Stable: This service will never introduce a breaking change even 81 in future major versions of the API. It is suitable and recommended to use as 82 a runtime compatibility check. 83 84 ## `WalletLoaderService` 85 86 The `WalletLoaderService` service provides the caller with functions related to 87 the management of the wallet and its connection to the Decred network. It has 88 no dependencies and is always running. 89 90 **Methods:** 91 92 - [`WalletExists`](#walletexists) 93 - [`CreateWallet`](#createwallet) 94 - [`CreateWatchingOnlyWallet`](#createwatchingonlywallet) 95 - [`OpenWallet`](#openwallet) 96 - [`CloseWallet`](#closewallet) 97 - [`RescanPoint`](#rescanpoint) 98 - [`SpvSync`](#spvsync) 99 - [`RpcSync`](#rpcsync) 100 101 **Shared messages:** 102 103 - [`BlockDetails`](#blockdetails) 104 - [`DetachedBlockDetails`](#detachedblockdetails) 105 - [`TransactionDetails`](#transactiondetails) 106 - [`DecodedTransaction`](#decodedtransaction) 107 108 ### Methods 109 110 #### `WalletExists` 111 112 The `WalletExists` method returns whether a file at the wallet database's file 113 path exists. Clients that must load wallets with this service are expected to 114 call this RPC to query whether `OpenWallet` should be used to open an existing 115 wallet, or `CreateWallet` to create a new wallet. 116 117 **Request:** `WalletExistsRequest` 118 119 **Response:** `WalletExistsResponse` 120 121 - `bool exists`: Whether the wallet file exists. 122 123 **Expected errors:** None 124 125 ___ 126 127 #### `CreateWallet` 128 129 The `CreateWallet` method is used to create a wallet that is protected by two 130 levels of encryption: the public passphrase (for data that is made public on the 131 blockchain) and the private passphrase (for private keys). Since the seed is 132 not saved in the wallet database and clients should make their users backup the 133 seed, it needs to be passed as part of the request. 134 135 After creating a wallet, the `WalletService` service begins running. 136 137 Since API version 3.0.0, creating the wallet no longer automatically 138 synchronizes the wallet to the consensus server if it was previously loaded. 139 140 **Request:** `CreateWalletRequest` 141 142 - `bytes public_passphrase`: The passphrase used for the outer wallet 143 encryption. This passphrase protects data that is made public on the 144 blockchain. If this passphrase has zero length, an insecure default is used 145 instead. 146 147 - `bytes private_passphrase`: The passphrase used for the inner wallet 148 encryption. This is the passphrase used for data that must always remain 149 private, such as private keys. The length of this field must not be zero. 150 151 - `bytes seed`: The BIP0032 seed used to derive all wallet keys. The length of 152 this field must be between 16 and 64 bytes, inclusive. 153 154 **Response:** `CreateWalletReponse` 155 156 **Expected errors:** 157 158 - `FailedPrecondition`: The wallet is currently open. 159 160 - `AlreadyExists`: A file already exists at the wallet database file path. 161 162 - `InvalidArgument`: A private passphrase was not included in the request, or 163 the seed is of incorrect length. 164 165 ___ 166 167 #### `CreateWatchingOnlyWallet` 168 169 The `CreateWatchingOnlyWallet` method is used to create a watching only wallet. 170 After creating a wallet, the `WalletService` service begins running. 171 172 **Request:** `CreateWatchingOnlyWalletRequest` 173 174 - `string extended_public_key`: The extended public key of the wallet. 175 176 - `bytes public_passphrase`: The passphrase used for the outer wallet 177 encryption. This passphrase protects data that is made public on the 178 blockchain. If this passphrase has zero length, an insecure default is used 179 instead. 180 181 **Response:** `CreateWatchingOnlyWalletReponse` 182 183 **Expected errors:** 184 185 - `FailedPrecondition`: The wallet is currently open. 186 187 - `AlreadyExists`: A file already exists at the wallet database file path. 188 189 ___ 190 191 #### `OpenWallet` 192 193 The `OpenWallet` method is used to open an existing wallet database. If the 194 wallet is protected by a public passphrase, it can not be successfully opened if 195 the public passphrase parameter is missing or incorrect. 196 197 After opening a wallet, the `WalletService` service begins running. 198 199 Since API version 3.0.0, creating the wallet no longer automatically 200 synchronizes the wallet to the consensus server if it was previously loaded. 201 202 **Request:** `OpenWalletRequest` 203 204 - `bytes public_passphrase`: The passphrase used for the outer wallet 205 encryption. This passphrase protects data that is made public on the 206 blockchain. If this passphrase has zero length, an insecure default is used 207 instead. 208 209 **Response:** `OpenWalletResponse` 210 211 **Expected errors:** 212 213 - `FailedPrecondition`: The wallet is currently open. 214 215 - `NotFound`: The wallet database file does not exist. 216 217 - `InvalidArgument`: The public encryption passphrase was missing or incorrect. 218 219 ___ 220 221 #### `CloseWallet` 222 223 The `CloseWallet` method is used to cleanly stop all wallet operations on a 224 loaded wallet and close the database. After closing, the `WalletService` 225 service will remain running but any operations that require the database will be 226 unusable. 227 228 **Request:** `CloseWalletRequest` 229 230 **Response:** `CloseWalletResponse` 231 232 **Expected errors:** 233 234 - `FailedPrecondition`: The wallet is not currently open. 235 236 ___ 237 238 #### `RescanPoint` 239 240 The `RescanPoint` returns the block hash at which a rescan should begin 241 (inclusive), or null when no rescan is necessary. A non-null rescan point 242 indicates that blocks currently in the main chain must be checked for address 243 usage and relevant transactions. 244 245 **Request:** `RescanPointRequest` 246 247 **Response:** `RescanPointResponse` 248 249 - `bytes rescan_point`: The current hash of the rescan point. 250 251 **Expected Errors:** 252 253 - `FailedPrecondition`: The wallet or consensus RPC server has not been opened. 254 255 ___ 256 257 #### `SpvSync` 258 259 The `SpvSync` method begins the spv syncing process. It will 260 stream back progress to provide feedback on the current state of the wallet 261 loading/bringup. This is a long lived RPC and only end when canceled 262 or upon received an error. 263 264 **Request:** `SpvSyncRequest` 265 266 - `bool discover_accounts`: Whether or not the wallet should attempt to 267 discover accounts during discovery. This requires the private passphrase to 268 be set as well and will error otherwise. 269 270 - `bytes private_passphrase`: The current private passphrase for the wallet. 271 This is only required if discover_accounts is set to true and will error 272 otherwise. 273 274 - `repeated string spv_connect`: When given a list of addresses, the wallet in 275 spv mode will no longer attempt to use DNS address discovery to seek out other 276 persistent peers and instead use the ones specified here as persistent peers. 277 278 **Response:** `stream SpvSyncResponse` 279 280 - `bool synced`: This streamed update response denotes whether the wallet is 281 synced or not. 282 283 - `SyncNotificationType notification_type`: This denotes what type of 284 notification has been sent by the wallet. 285 286 - `FetchHeadersNotification fetch_headers`: This contains all the information 287 for a fetch headers notification response. In any other case it will be 288 set to nil. 289 290 - `FetchMissingCFiltersNotification fetch_missing_cfilters`: This contains all 291 the information for a fetch missing cfilters notification response. In any 292 other case it will be set to nil. 293 294 - `RescanProgressNotifiction rescan_progress`: This contains all the information 295 for a rescan progress notification. In any other case it will be set to nil. 296 297 - `PeerNotification peer_information`: This contains information about the 298 current state of the wallet's peers. 299 300 **Expected Errors:** 301 302 - `FailedPrecondition`: The wallet or consensus RPC server has not been opened. 303 The private passphrase does not successfully unlock the wallet. The string 304 provided to spv_connect is not a valid address or port. 305 306 - `InvalidArgument`: The private passphrase is incorrect. 307 308 ___ 309 310 #### `RpcSync` 311 312 The `RpcSync` method begins the syncing process via rpc connection to a daemon. 313 It will stream back progress to provide feedback on the current state of the 314 wallet loading/bringup. This is a long lived RPC and only end when canceled 315 or upon received an error. 316 317 **Request:** `RpcSyncRequest` 318 319 - `string network_address`: The host/IP and optional port of the RPC server to 320 connect to. IP addresses may be IPv4 or IPv6. If the port is missing, a 321 default port is chosen corresponding to the default dcrd RPC port of the 322 active Decred network. 323 324 - `string username`: The RPC username required to authenticate to the RPC 325 server. 326 327 - `bytes password`: The RPC password required to authenticate to the RPC server. 328 329 - `bytes certificate`: The consensus RPC server's TLS certificate. If this 330 field has zero length and the network address describes a loopback connection 331 (`localhost`, `127.0.0.1`, or `::1`) TLS will be disabled. 332 333 - `bool discover_accounts`: Whether or not the wallet should attempt to 334 discover accounts during discovery. This requires the private passphrase to 335 be set as well and will error otherwise. 336 337 - `bytes private_passphrase`: The current private passphrase for the wallet. 338 This is only required if discover_accounts is set to true and will error 339 otherwise. 340 341 - `repeated string spv_connect`: When given a list of addresses, the wallet in 342 spv mode will no longer attempt to use DNS address discovery to seek out other 343 persistent peers and instead use the ones specified here as persistent peers. 344 345 **Response:** `stream RpcSyncResponse` 346 347 - `bool synced`: This streamed update response denotes whether the wallet is 348 synced or not. 349 350 - `SyncNotificationType notification_type`: This denotes what type of 351 notification has been sent by the wallet. 352 353 - `FetchHeadersNotification fetch_headers`: This contains all the information 354 for a fetch headers notification response. In any other case it will be 355 set to nil. 356 357 - `FetchMissingCFiltersNotification fetch_missing_cfilters`: This contains all 358 the information for a fetch missing cfilters notification response. In any 359 other case it will be set to nil. 360 361 - `RescanProgressNotifiction rescan_progress`: This contains all the information 362 for a rescan progress notification. In any other case it will be set to nil. 363 364 - `SyncingStatus syncing_status`: Various properties to describe the current 365 state of syncing the wallet is currently performing. Once synced, this will 366 be set to nil. 367 368 **Expected Errors:** 369 370 - `InvalidArgument`: The network address is ill-formatted or does not contain a 371 valid IP address. 372 373 - `InvalidArgument`: The private passphrase is not supplied, but discoveraccounts 374 is requested. 375 376 - `InvalidArgument`: The username, password, or certificate are invalid. This 377 condition may not be return `Unauthenticated` as that refers to the client not 378 having the credentials to call this method. 379 380 - `Unavailable`: The consensus RPC server is unreachable. 381 382 - `FailedPrecondition`: A consensus RPC client is already active. 383 384 - `FailedPrecondition`: The wallet or consensus RPC server has not been opened. 385 386 - `FailedPrecondition`: The private passphrase does not successfully unlock the 387 wallet. 388 389 ## `WalletService` 390 391 The WalletService service provides RPCs for the wallet itself. The service 392 depends on a loaded wallet and does not run when the wallet has not been created 393 or opened yet. 394 395 The service provides the following methods: 396 397 - [`Ping`](#ping) 398 - [`Network`](#network) 399 - [`AccountNumber`](#accountnumber) 400 - [`Accounts`](#accounts) 401 - [`Balance`](#balance) 402 - [`BlockInfo`](#blockinfo) 403 - [`GetTransaction`](#gettransaction) 404 - [`GetTransactions`](#gettransactions) 405 - [`GetTicket`](#getticket) 406 - [`GetTickets`](#gettickets) 407 - [`ChangePassphrase`](#changepassphrase) 408 - [`RenameAccount`](#renameaccount) 409 - [`Rescan`](#rescan) 410 - [`NextAccount`](#nextaccount) 411 - [`NextAddress`](#nextaddress) 412 - [`ImportPrivateKey`](#importprivatekey) 413 - [`ImportScript`](#importscript) 414 - [`ImportVotingAccountFromSeed`](#importvotingaccountfromseed) 415 - [`FundTransaction`](#fundtransaction) 416 - [`UnspentOutputs`](#unspentoutputs) 417 - [`ConstructTransaction`](#constructtransaction) 418 - [`SignTransaction`](#signtransaction) 419 - [`SignTransactions`](#signtransactions) 420 - [`CreateSignature`](#createsignature) 421 - [`PublishTransaction`](#publishtransaction) 422 - [`PublishUnminedTransactions`](#publishunminedtransactions) 423 - [`TicketPrice`](#ticketprice) 424 - [`StakeInfo`](#stakeinfo) 425 - [`PurchaseTickets`](#purchasetickets) 426 - [`RevokeTickets`](#revoketickets) 427 - [`LoadActiveDataFilters`](#loadactivedatafilters) 428 - [`SignMessage`](#signmessage) 429 - [`SignMessages`](#signmessages) 430 - [`ValidateAddress`](#validateaddress) 431 - [`AbandonTransaction`](#abandontransaction) 432 - [`TransactionNotifications`](#transactionnotifications) 433 - [`AccountNotifications`](#accountnotifications) 434 - [`ConfirmationNotifications`](#confirmationnotifications) 435 - [`CommittedTickets`](#committedtickets) 436 - [`BestBlock`](#bestblock) 437 - [`SweepAccount`](#sweepaccount) 438 - [`SignHashes`](#signhashes) 439 - [`GetCFilters`](#GetCFilters) 440 - [`UnlockWallet`](#UnlockWallet) 441 - [`LockWallet`](#LockWallet) 442 - [`UnlockAccount`](#UnlockAccount) 443 - [`LockAccount`](#LockAccount) 444 - [`GetTrackedVSPTickets`](#GetTrackedVSPTickets) 445 - [`Address`](#Address) 446 - [`DumpPrivateKey`](#DumpPrivateKey) 447 448 #### `Ping` 449 450 The `Ping` method checks whether the service is active. 451 452 **Request:** `PingRequest` 453 454 **Response:** `PingResponse` 455 456 **Expected errors:** None 457 458 ___ 459 460 #### `Network` 461 462 The `Network` method returns the network identifier constant describing the 463 server's active network. 464 465 **Request:** `NetworkRequest` 466 467 **Response:** `NetworkResponse` 468 469 - `uint32 active_network`: The network identifier. 470 471 **Expected errors:** None 472 473 ___ 474 475 #### `CoinType` 476 477 The `CoinType` method returns the coin type identifier constant describing the 478 wallet's coin type. 479 480 **Request:** `CoinTypeRequest` 481 482 **Response:** `CoinTypeResponse` 483 484 - `uint32 coin_type`: The wallet's coin type identifier. 485 486 **Expected errors:** 487 488 - `WatchingOnly`: Watching-only wallet, coin type keys are not saved. 489 490 ___ 491 492 #### `AccountNumber` 493 494 The `AccountNumber` method looks up a BIP0044 account number by an account's 495 unique name. 496 497 **Request:** `AccountNumberRequest` 498 499 - `string account_name`: The name of the account being queried. 500 501 **Response:** `AccountNumberResponse` 502 503 - `uint32 account_number`: The BIP0044 account number. 504 505 **Expected errors:** 506 507 - `Aborted`: The wallet database is closed. 508 509 - `NotFound`: No accounts exist by the name in the request. 510 511 ___ 512 513 #### `Accounts` 514 515 The `Accounts` method returns the current properties of all accounts managed in 516 the wallet. 517 518 **Request:** `AccountsRequest` 519 520 **Response:** `AccountsResponse` 521 522 - `repeated Account accounts`: Account properties grouped into `Account` nested 523 message types, one per account, ordered by increasing account numbers. 524 525 **Nested message:** `Account` 526 527 - `uint32 account_number`: The BIP0044 account number. 528 529 - `string account_name`: The name of the account. 530 531 - `int64 total_balance`: The total (zero-conf and immature) balance, counted 532 in Atoms. 533 534 - `uint32 external_key_count`: The number of derived keys in the external 535 key chain. 536 537 - `uint32 internal_key_count`: The number of derived keys in the internal 538 key chain. 539 540 - `uint32 imported_key_count`: The number of imported keys. 541 542 - `bytes current_block_hash`: The hash of the block wallet is considered to 543 be synced with. 544 545 - `int32 current_block_height`: The height of the block wallet is considered 546 to be synced with. 547 548 **Expected errors:** 549 550 - `Aborted`: The wallet database is closed. 551 552 ___ 553 554 #### `Balance` 555 556 The `Balance` method queries the wallet for an account's balance. Balances are 557 returned as combination of total, spendable (by consensus and request policy), 558 and unspendable immature coinbase balances. 559 560 **Request:** `BalanceRequest` 561 562 - `uint32 account_number`: The account number to query. 563 564 - `int32 required_confirmations`: The number of confirmations required before an 565 unspent transaction output's value is included in the spendable balance. This 566 may not be negative. 567 568 **Response:** `BalanceResponse` 569 570 - `int64 total`: The total (zero-conf and immature) balance, counted in 571 Atoms. 572 573 - `int64 spendable`: The spendable balance, given some number of required 574 confirmations, counted in Atoms. This equals the total balance when the 575 required number of confirmations is zero and there are no immature coinbase 576 outputs. 577 578 - `int64 immature_reward`: The total value of all immature coinbase outputs, 579 counted in Atoms. 580 581 - `int64 immature_stake_generation`: The total value of all immature stakebase outputs, 582 or any revocations, counted in Atoms. 583 584 - `int64 locked_by_tickets`: The total value of all tickets that are currently locked, 585 and awaiting vote. 586 587 - `int64 voting_authority`: The total value of all tickets that the account has voting 588 authority over. 589 590 - `int64 unconfirmed`: The total value of all unconfirmed transactions with 591 with reference to the minimum number of confirmations for a transaction 592 (minconf). If minconf is 0 unconfirmed will be 0, otherwise unconfirmed 593 will be the total balance of transactions that do fulfill the requested 594 minconf. 595 596 **Expected errors:** 597 598 - `InvalidArgument`: The required number of confirmations is negative. 599 600 - `Aborted`: The wallet database is closed. 601 602 - `NotFound`: The account does not exist. 603 604 ___ 605 606 #### `BlockInfo` 607 608 The `BlockInfo` method queries for info pertaining to blocks that are recorded 609 by the wallet. Blocks are queried using either the block hash or height as an 610 identifier. Any block currently or previously in the main chain can be queried, 611 but not all sidechain blocks may be known by the wallet. 612 613 **Request:** `BlockInfoRequest` 614 615 - `bytes block_hash`: The hash of the block being queried, or null to lookup 616 blocks by their height. 617 618 - `int32 block_height`: The height of the block being queried. Height lookup 619 only returns results of blocks in the main chain. 620 621 **Response:** `BlockInfoResponse` 622 623 - `bytes block_hash`: The hash of the queried block. 624 625 - `int32 block_height`: The height of the queried block. This is the height 626 recorded in the block header and will be the height in the sidechain for any 627 reorged blocks. 628 629 - `int32 confirmations`: The number of block confirmations of all transactions 630 in the block. If the block is not currently in the main chain, this field is 631 set to zero. 632 633 - `int64 timestamp`: The unix timestamp of the block. 634 635 - `bytes block_header`: The serialized block header. 636 637 - `bool stake_invalidated`: Whether the queried block is in the main chain and 638 the next main chain block has stake invalidated the queried block. 639 640 - `bool approves_parent`: Whether this block stake validates its parent block. 641 642 **Expected errors:** 643 644 - `InvalidArgument`: The block hash and height were each set to non-default 645 values. 646 647 - `Aborted`: The wallet database is closed. 648 649 - `NotFound`: The block is not recorded by the wallet in the current main chain 650 or any old sidechain. 651 652 ___ 653 654 #### `GetAccountExtendedPubKey` 655 656 The `GetAccountExtendedPubKey` method queries the wallet for an account pubkey. 657 658 **Request:** `GetAccountExtendedPubKeyRequest` 659 660 - `uint32 account_number`: The number of the account to retrieve the pubkey. 661 662 **Response:** `GetAccountExtendedPubKeyResponse` 663 664 - `string acc_extended_pub_key`: The account's extended key. 665 666 **Expected errors:** 667 668 - `NotFound`: The account does not exist. 669 670 ___ 671 672 #### `GetAccountExtendedPrivKey` 673 674 The `GetAccountExtendedPrivKey` method queries the wallet for an account privkey. 675 676 **Request:** `GetAccountExtendedPrivKeyRequest` 677 678 - `uint32 account_number`: The number of the account to retrieve the privkey. 679 680 - `bytes passphrase`: The passphrase to unlock the wallet and retrieve the 681 account private key. 682 683 **Response:** `GetAccountExtendedPrivKeyResponse` 684 685 - `string acc_extended_priv_key`: The account's extended private key. 686 687 **Expected errors:** 688 689 - `NotFound`: The account does not exist. 690 691 - `InvalidArgument`: The private passphrase is incorrect. 692 ___ 693 694 #### `GetTransaction` 695 696 The `GetTransaction` method queries the wallet for a relevant transaction by its 697 hash. 698 699 **Request:** `GetTransactionRequest` 700 701 - `bytes transaction_hash`: The hash of the transaction being queried. 702 703 **Response:** ` GetTransactionResponse` 704 705 - `TransactionDetails transaction`: Wallet details regarding the transaction. 706 707 The `TransactionDetails` message is used by other methods and is documented 708 [here](#transactiondetails). 709 710 - `int32 confirmations`: The number of block confirmations of the transaction in 711 the main chain. If the transaction was mined in a stake-invalidated block and 712 pushed back to mempool to be mined again, or was mined again after being stake 713 invalidated, the latest number of confirmations is used (not the confirmations 714 of an invalidated block). 715 716 - `bytes block_hash`: The block hash the transaction is most recently mined in, 717 or null if unmined. 718 719 **Expected errors:** 720 721 - `InvalidArgument`: The transaction hash is of incorrect length. 722 723 - `Aborted`: The wallet database is closed. 724 725 - `NotFound`: The transaction is not recorded by the wallet. 726 727 ___ 728 729 #### `GetTransactions` 730 731 The `GetTransactions` method queries the wallet for relevant transactions. The 732 query set may be specified using a block range, inclusive, with the heights or 733 hashes of the minimum and maximum block. Transaction results are grouped 734 by the block they are mined in, or grouped together with other unmined 735 transactions. 736 737 To avoid exceeding the maximum message size with the return result, a stream is 738 used to break up the response into several messages. A single message will have 739 results of a single block and no unmined transactions, or only unmined 740 transactions (and no mined transactions). 741 742 **Request:** `GetTransactionsRequest` 743 744 - `bytes starting_block_hash`: The block hash of the block to begin including 745 transactions from. If this field is set to the default, the 746 `starting_block_height` field is used instead. If changed, the byte array 747 must have length 32 and `starting_block_height` must be zero. 748 749 - `sint32 starting_block_height`: The block height to begin including 750 transactions from. If this field is non-zero, `starting_block_hash` must be 751 set to its default value to avoid ambiguity. If positive, the field is 752 interpreted as a block height. If negative, the height is subtracted from the 753 block wallet considers itself in sync with. 754 755 - `bytes ending_block_hash`: The block hash of the last block to include 756 transactions from. If this default is set to the default, the 757 `ending_block_height` field is used instead. If changed, the byte array must 758 have length 32 and `ending_block_height` must be zero. 759 760 - `int32 ending_block_height`: The block height of the last block to include 761 transactions from. If non-zero, the `ending_block_hash` field must be set to 762 its default value to avoid ambiguity. If both this field and 763 `ending_block_hash` are set to their default values, no upper block limit is 764 used and transactions through the best block and all unmined transactions are 765 included. 766 767 - `int32 target_transaction_count`: Try to return at most this amount of 768 transactions. Both mined and unmined transactions count towards this limit. 769 Note that as transactions are returned on a per-block basis, **more** than 770 this amount of transactions may be returned in total, to prevent transactions 771 from not being seen. The caller is responsible for further clipping of the 772 dataset if it has a hard requirement on the number of total transactions it 773 manages. 774 775 **Response:** `stream GetTransactionsResponse` 776 777 - `BlockDetails mined_transactions`: All mined transactions, organized 778 by blocks in the order they appear in the blockchain. 779 780 The `BlockDetails` message is used by other methods and is documented 781 [here](#blockdetails). 782 783 - `repeated TransactionDetails unmined_transactions`: All unmined transactions. 784 The ordering is unspecified. 785 786 The `TransactionDetails` message is used by other methods and is documented 787 [here](#transactiondetails). 788 789 **Expected errors:** 790 791 - `InvalidArgument`: A non-default block hash field did not have the correct length. 792 793 - `Aborted`: The wallet database is closed. 794 795 - `NotFound`: A block, specified by its height or hash, is unknown to the 796 wallet. 797 798 ___ 799 800 #### `GetTicket` 801 802 The `GetTicket` method queries the wallet for the provided ticket. 803 804 **Request:** `GetTicketRequest` 805 806 - `bytes ticket_hash`: The hash of the ticket being queried. 807 808 **Response:** `GetTicketsResponse` 809 810 Refer to [GetTickets](#gettickets) response documentation. 811 812 **Expected errors:** 813 814 - `InvalidArgument`: The ticket hash field did not have the correct length. 815 816 - `NotFound`: The specified transaction is not known by the wallet. 817 ___ 818 819 #### `GetTickets` 820 821 The `GetTickets` method queries the wallet for relevant tickets. The 822 query set may be specified using a block range, inclusive, with the heights or 823 hashes of the minimum and maximum block. 824 825 To avoid exceeding the maximum message size with the return result, a stream is 826 used to break up the response into several messages. A single message will have 827 results of a single ticket. 828 829 **Request:** `GetTicketsRequest` 830 831 - `bytes starting_block_hash`: The block hash of the block to begin including 832 tickets from. If this field is set to the default, the 833 `starting_block_height` field is used instead. If changed, the byte array 834 must have length 32 and `starting_block_height` must be zero. 835 836 - `sint32 starting_block_height`: The block height to begin including 837 tickets from. If this field is non-zero, `starting_block_hash` must be 838 set to its default value to avoid ambiguity. If positive, the field is 839 interpreted as a block height. If negative, the height is subtracted from the 840 block wallet considers itself in sync with. 841 842 - `bytes ending_block_hash`: The block hash of the last block to include 843 tickets from. If this default is set to the default, the 844 `ending_block_height` field is used instead. If changed, the byte array must 845 have length 32 and `ending_block_height` must be zero. 846 847 - `int32 ending_block_height`: The block height of the last block to include 848 tickets from. If non-zero, the `ending_block_hash` field must be set to 849 its default value to avoid ambiguity. If both this field and 850 `ending_block_hash` are set to their default values, no upper block limit is 851 used and transactions through the best block and all unmined transactions are 852 included. 853 854 - `int32 target_ticket_count`: Try to return at most this amount of tickets. 855 Both mined and unmined tickets count towards this limit. Note that the number 856 of tickets returned may be higher or lower than this specified target and 857 callers are responsible for further clipping of the dataset if required. 858 859 **Response:** `stream GetTicketsResponse` 860 861 - `TicketDetails tickets`: A given ticket's details. 862 863 **Nested Message** `TicketDetails` 864 865 - `TransactionDetails ticket`: The transaction details of a given ticket. 866 867 - `TransactionDetails spender`: The transaction details of the ticket's 868 spender if applicable (otherwise empty). 869 870 The `TransactionDetails` message is used by other methods and is documented 871 [here](#transactiondetails). 872 873 - `TicketStatus ticket_status`: The observed status of the given ticket. 874 875 **Nested enum:** `TicketStatus` 876 877 - `UNKNOWN`: A ticket whose status was unable to be determined. 878 879 - `UNMINED`: A ticket that has yet to be mined into a block. 880 881 - `IMMATURE`: A ticket that has not yet matured enough to be live. 882 883 - `LIVE`: A currently live ticket that is waiting to be voted. 884 885 - `VOTED`: A ticket that has been voted. 886 887 - `EXPIRED`: A ticket that is expired but not yet revoked. 888 889 - `MISSED`: A ticket that was missed but not yet revoked. 890 891 - `REVOKED`: A ticket that has been revoked. 892 893 - `BlockDetails block`: The block the ticket was mined. It is null if the 894 ticket hasn't been mined yet. 895 896 **Nested Message** `BlockDetails` 897 898 - `bytes hash`: The binary hash of the block. 899 900 - `int32 height`: The block height. 901 902 - `int64 timestamp`: The timestamp the block was mined. 903 904 905 **Expected errors:** 906 907 - `InvalidArgument`: A non-default block hash field did not have the correct length. 908 909 - `InvalidArgument`: A negative target value was provided. 910 911 - `Aborted`: The wallet database is closed. 912 913 - `NotFound`: A block, specified by its height or hash, is unknown to the 914 wallet. 915 916 ___ 917 918 #### `ChangePassphrase` 919 920 The `ChangePassphrase` method requests a change to either the public (outer) or 921 private (inner) encryption passphrases. 922 923 **Request:** `ChangePassphraseRequest` 924 925 - `Key key`: The key being changed. 926 927 **Nested enum:** `Key` 928 929 - `PRIVATE`: The request specifies to change the private (inner) encryption 930 passphrase. 931 932 - `PUBLIC`: The request specifies to change the public (outer) encryption 933 passphrase. 934 935 - `bytes old_passphrase`: The current passphrase for the encryption key. This 936 is the value being modified. If the public passphrase is being modified and 937 this value is the default value, an insecure default is used instead. 938 939 - `bytes new_passphrase`: The replacement passphrase. This field may only have 940 zero length if the public passphrase is being changed, in which case an 941 insecure default will be used instead. 942 943 **Response:** `ChangePassphraseResponse` 944 945 **Expected errors:** 946 947 - `InvalidArgument`: A zero length passphrase was specified when changing the 948 private passphrase, or the old passphrase was incorrect. 949 950 - `Aborted`: The wallet database is closed. 951 952 ___ 953 954 #### `RenameAccount` 955 956 The `RenameAccount` method requests a change to an account's name property. 957 958 **Request:** `RenameAccountRequest` 959 960 - `uint32 account_number`: The number of the account being modified. 961 962 - `string new_name`: The new name for the account. 963 964 **Response:** `RenameAccountResponse` 965 966 **Expected errors:** 967 968 - `Aborted`: The wallet database is closed. 969 970 - `InvalidArgument`: The new account name is a reserved name. 971 972 - `NotFound`: The account does not exist. 973 974 - `AlreadyExists`: An account by the same name already exists. 975 976 ___ 977 978 #### `Rescan` 979 980 The `Rescan` method begins a rescan for all relevant transactions involving all 981 active addresses and watched outpoints. Rescans can be time consuming depending 982 on the amount of data that must be checked, and the size of the blockchain. If 983 transactions being scanned for are known to only exist after some height, the 984 request can specify which block height to begin scanning from. This RPC returns 985 a stream of block heights the rescan has completed through. 986 987 **Request:** `RescanRequest` 988 989 - `int32 begin_height`: The block height to begin the rescan at (inclusive). 990 991 **Response:** `stream RescanResponse` 992 993 - `int32 rescanned_through`: The block height the rescan has completed through 994 (inclusive). 995 996 **Expected errors:** 997 998 - `FailedPrecondition`: There is no consensus server associated with the wallet. 999 1000 - `InvalidArgument`: The begin height is negative. 1001 1002 - `NotFound`: There is no known block in the main chain at the begin height. 1003 1004 ___ 1005 1006 #### `NextAccount` 1007 1008 The `NextAccount` method generates the next BIP0044 account for the wallet. 1009 1010 **Request:** `NextAccountRequest` 1011 1012 - `bytes passphrase`: The private passphrase required to derive the next 1013 account's key. 1014 1015 - `string account_name`: The name to give the new account. 1016 1017 **Response:** `NextAccountResponse` 1018 1019 - `uint32 account_number`: The number of the newly-created account. 1020 1021 **Expected errors:** 1022 1023 - `Aborted`: The wallet database is closed. 1024 1025 - `InvalidArgument`: The private passphrase is incorrect. 1026 1027 - `InvalidArgument`: The new account name is a reserved name. 1028 1029 - `AlreadyExists`: An account by the same name already exists. 1030 1031 ___ 1032 1033 #### `NextAddress` 1034 1035 The `NextAddress` method generates the next deterministic address for the 1036 wallet. 1037 1038 **Request:** `NextAddressRequest` 1039 1040 - `uint32 account`: The number of the account to derive the next address for. 1041 1042 - `Kind kind`: The type of address to generate. 1043 1044 **Nested enum:** `Kind` 1045 1046 - `BIP0044_EXTERNAL`: The request specifies to generate the next address for 1047 the account's BIP0044 external key chain. 1048 1049 - `BIP0044_INTERNAL`: The request specifies to generate the next address for 1050 the account's BIP0044 internal key chain. 1051 1052 - `GapPolicy gap_policy`: The policy to use when the BIP0044 unused address gap 1053 limit would be violated. 1054 1055 **Nested enum:** `GapPolicy` 1056 1057 - `GAP_POLICY_UNSPECIFIED`: Do not specify any policy in particular. This 1058 will default to using the erroring policy unless otherwise changed in the 1059 wallet's settings. 1060 1061 - `GAP_POLICY_ERROR`: Override any other specified gap policy in the wallet 1062 settings. If the gap limit would be violated, return an error. 1063 1064 - `GAP_POLICY_IGNORE`: Override any other specified gap policy in the wallet 1065 settings. Ignore any gap limit violations and return the next child address 1066 anyways. 1067 1068 - `GAP_POLICY_WRAP`: Override any other specified gap policy in the wallet 1069 settings. If the gap limit would be violated, wrap around to the child 1070 index after the last used address. 1071 1072 **Response:** `NextAddressResponse` 1073 1074 - `string address`: The payment address string. 1075 1076 - `string public_key`: The public key encoded as a string in the Decred encoding 1077 format. 1078 1079 **Expected errors:** 1080 1081 - `Aborted`: The wallet database is closed. 1082 1083 - `NotFound`: The account does not exist. 1084 1085 ___ 1086 1087 #### `ImportPrivateKey` 1088 1089 The `ImportPrivateKey` method imports a private key in Wallet Import Format 1090 (WIF) encoding to a wallet account. A rescan may optionally be started to 1091 search for transactions involving the private key's associated payment address. 1092 1093 **Request:** `ImportPrivateKeyRequest` 1094 1095 - `bytes passphrase`: The wallet's private passphrase. 1096 1097 - `uint32 account`: The account number to associate the imported key with. 1098 1099 - `string private_key_wif`: The private key, encoded using WIF. 1100 1101 - `bool rescan`: Whether or not to perform a blockchain rescan for the imported 1102 key. 1103 1104 **Response:** `ImportPrivateKeyResponse` 1105 1106 **Expected errors:** 1107 1108 - `InvalidArgument`: The private passphrase is incorrect. 1109 1110 - `InvalidArgument`: The private key WIF string is not a valid WIF encoding. 1111 1112 - `InvalidArgument`: A rescan height was specified, but the rescan option was 1113 not set. 1114 1115 - `InvalidArgument`: A negative rescan height was passed. 1116 1117 - `Aborted`: The wallet database is closed. 1118 1119 - `NotFound`: The account does not exist. 1120 1121 ___ 1122 1123 #### `ImportScript` 1124 1125 The `ImportScript` method imports a script into the wallet. A rescan may 1126 optionally be started to search for transactions involving the script, either 1127 as an output or in a P2SH input. 1128 1129 **Request:** `ImportScriptRequest` 1130 1131 - `bytes passphrase`: The wallet's private passphrase. This parameter is 1132 deprecated and ignored. 1133 1134 - `bytes script`: The raw script. 1135 1136 - `bool rescan`: Whether or not to perform a blockchain rescan for the imported 1137 script. 1138 1139 - `int32 scan_from`: The block height to begin a rescan from. 1140 1141 - `bool require_redeemable`: The script must be a multisig script where all of 1142 the keys necessary to redeem the script are available to the wallet. 1143 1144 **Response:** `ImportScriptResponse` 1145 1146 - `string p2sh_address`: The pay-to-script-hash address for the imported script. 1147 1148 - `bool redeemable`: Whether the imported script is a multisig script and all 1149 of the keys necessary to redeem the script are available to the wallet. 1150 1151 **Expected errors:** 1152 1153 - `InvalidArgument`: A rescan height was specified, but the rescan option was 1154 not set. 1155 1156 - `InvalidArgument`: A negative rescan height was passed. 1157 1158 - `Aborted`: The wallet database is closed. 1159 1160 - `NotFound`: The account does not exist. 1161 1162 - `FailedPrecondition`: A multisig script was required to be redeemable by the 1163 wallet but is not without additional secrets. 1164 1165 ___ 1166 1167 #### `ImportVotingAccountFromSeed` 1168 The `ImportVotingAccountFromSeed` method imports bytes that become the master 1169 seed for a hierarchical deterministic private key that is imported into the 1170 wallet with the supplied name and locked with the supplied password. Addresses 1171 derived from this account MUST NOT be sent any funds. They are solely for the 1172 use of creating stake submission scripts. A rescan may optionally be started to 1173 search for tickets using submission scripts derived from this account. 1174 1175 **Request:** `ImportVotingAccountFromSeedRequest` 1176 1177 - `bytes seed`: The bytes to be used in the master seed. 1178 1179 - `bytes passphrase`: The wallet's private passphrase. 1180 1181 - `string name`: A name to use for the account. Must be unique. 1182 1183 - `bool rescan`: Whether or not to perform a blockchain rescan for the imported 1184 key. 1185 1186 - `int32 scan_from`: The block height to begin a rescan from. Default will scan from 0. 1187 1188 - `bool discover_usage`: Whether or not to perform discover usage. 1189 1190 - `int32 discover_from`: The block height to begin discovering usage from. Default is 0. 1191 1192 - `int32 discover_gap_limit`: The gap limit used when discovering usage. Dafaults to wallet config defaults. 1193 1194 **Response:** `ImportPrivateKeyResponse` 1195 1196 - `uint32 account`: The account number of the account. 1197 1198 **Expected errors:** 1199 1200 - `InvalidArgument`: Passphrase not supplied. 1201 1202 - `InvalidArgument`: The seed supplied is invalid. 1203 1204 - `InvalidArgument`: Duplicate name. 1205 1206 - `InvalidArgument`: A rescan height was specified, but the rescan option was 1207 not set. 1208 1209 - `InvalidArgument`: A negative rescan or discover height or gap limit was passed. 1210 1211 - `InvalidArgument`: A discover height or gap limit was specified, but the 1212 discover usage option was not set. 1213 ___ 1214 1215 #### `FundTransaction` 1216 1217 The `FundTransaction` method queries the wallet for unspent transaction outputs 1218 controlled by some account. Results may be refined by setting a target output 1219 amount and limiting the required confirmations. The selection algorithm is 1220 unspecified. 1221 1222 Output results are always created even if a minimum target output amount could 1223 not be reached. This allows this method to behave similar to the `Balance` 1224 method while also including the outputs that make up that balance. 1225 1226 Change outputs can optionally be returned by this method as well. This can 1227 provide the caller with everything necessary to construct an unsigned 1228 transaction paying to already known addresses or scripts. 1229 1230 **Request:** `FundTransactionRequest` 1231 1232 - `uint32 account`: Account number containing the keys controlling the output 1233 set to query. 1234 1235 - `int64 target_amount`: If positive, the service may limit output results to 1236 those that sum to at least this amount (counted in Atoms). If zero, all 1237 outputs not excluded by other arguments are returned. This may not be 1238 negative. 1239 1240 - `int32 required_confirmations`: The minimum number of block confirmations 1241 needed to consider including an output in the return set. This may not be 1242 negative. 1243 1244 - `bool include_immature_coinbases`: If true, immature coinbase outputs will 1245 also be included. 1246 1247 - `bool include_change_script`: If true, a change script is included in the 1248 response object. 1249 1250 **Response:** `FundTransactionResponse` 1251 1252 - `repeated PreviousOutput selected_outputs`: The output set returned as a list 1253 of `PreviousOutput` nested message objects. 1254 1255 **Nested message:** `PreviousOutput` 1256 1257 - `bytes transaction_hash`: The hash of the transaction this output originates 1258 from. 1259 1260 - `uint32 output_index`: The output index of the transaction this output 1261 originates from. 1262 1263 - `int64 amount`: The output value (counted in Atoms) of the unspent 1264 transaction output. 1265 1266 - `bytes pk_script`: The output script of the unspent transaction output. 1267 1268 - `int64 receive_time`: The earliest Unix time the wallet became aware of the 1269 transaction containing this output. 1270 1271 - `bool from_coinbase`: Whether the output is a coinbase output. 1272 1273 - `int32 tree`: The tree the output belongs to. This can take on the values 1274 `-1` (invalid), `0` (regular), and `1` (stake). 1275 1276 - `int64 total_amount`: The sum of all returned output amounts. This may be 1277 less than a positive target amount if there were not enough eligible outputs 1278 available. 1279 1280 - `bytes change_pk_script`: A transaction output script used to pay the 1281 remaining amount to a newly-generated change address for the account. This is 1282 null if `include_change_script` was false or the target amount was not 1283 exceeded. 1284 1285 **Expected errors:** 1286 1287 - `InvalidArgument`: The target amount is negative. 1288 1289 - `InvalidArgument`: The required confirmations is negative. 1290 1291 - `Aborted`: The wallet database is closed. 1292 1293 - `NotFound`: The account does not exist. 1294 1295 ___ 1296 1297 #### `UnspentOutputs` 1298 1299 The `UnspentOutputs` method queries the wallet for unspent transaction outputs 1300 controlled by some account. Results may be refined by setting a target output 1301 amount and limiting the required confirmations. The selection algorithm is 1302 unspecified. 1303 1304 Output results are always created even if a minimum target output amount could 1305 not be reached. This allows this method to behave similar to the `Balance` 1306 method while also including the outputs that make up that balance. 1307 1308 **Request:** `UnspentOutputsRequest` 1309 1310 - `uint32 account`: Account number containing the keys controlling the output 1311 set to query. 1312 1313 - `int64 target_amount`: If positive, the service may limit output results to 1314 those that sum to at least this amount (counted in Atoms). This may not be 1315 negative. 1316 1317 - `int32 required_confirmations`: The minimum number of block confirmations 1318 needed to consider including an output in the return set. This may not be 1319 negative. 1320 1321 - `bool include_immature_coinbases`: If true, immature coinbase outputs will 1322 also be included. 1323 1324 **Response:** `stream UnspentOutputResponse` 1325 1326 - `bytes transaction_hash`: The hash of the transaction this output originates 1327 from. 1328 1329 - `uint32 output_index`: The output index of the transaction this output 1330 originates from. 1331 1332 - `int64 amount`: The output value (counted in atoms) of the unspent 1333 transaction output. 1334 1335 - `bytes pk_script`: The output script of the unspent transaction output. 1336 1337 - `int64 receive_time`: The earliest Unix time the wallet became aware of the 1338 transaction containing this output. 1339 1340 - `bool from_coinbase`: Whether the output is a coinbase output. 1341 1342 - `int32 tree`: The tree the output belongs to. This can take on the values 1343 `-1` (invalid), `0` (regular), and `1` (stake). 1344 1345 - `int64 amount_sum`: The rolling sum of all streamed output amounts including 1346 the current response. This may be less than a positive target amount if 1347 there were not enough eligible outputs available. 1348 1349 **Expected errors:** 1350 1351 - `InvalidArgument`: The target amount is negative. 1352 1353 - `InvalidArgument`: The required confirmations is negative. 1354 1355 - `Aborted`: The wallet database is closed. 1356 1357 - `NotFound`: The account does not exist. 1358 1359 ___ 1360 1361 #### `ConstructTransaction` 1362 1363 The `ConstructTransaction` method constructs an unsigned transaction based on 1364 the request parameters, referencing unspent outputs from a wallet account. If a 1365 change output is added, it is inserted at a random output position. 1366 1367 **Request:** `ConstructTransactionRequest` 1368 1369 - `uint32 source_account`: The account to select outputs from. 1370 1371 - `int32 required_confirmations`: The number of block confirmations required 1372 before an output is considered spendable. 1373 1374 - `int32 fee_per_kb`: The transaction relay fee per kB. If zero, the default 1375 mempool policy relay fee is used. 1376 1377 - `OutputSelectionAlgorithm output_selection_algorithm`: The algorithm used when 1378 selecting transaction outputs. 1379 1380 **Nested enum:** `OutputSelectionAlgorithm` 1381 1382 - `UNSPECIFIED`: An unspecified selection algorithm is used. At time of 1383 writing the wallet only has one selection algorithm but it is not 1384 optimized for any particular use case. This will never use the `ALL` 1385 algorithm, but as other algorithms are introduced, it may become an alias 1386 for one of them. 1387 1388 - `ALL`: All spendable outputs from the account are used as inputs 1389 1390 - `repeated Output non_change_outputs`: Non-change outputs to include in the 1391 transaction. Outputs are not guaranteed to appear in the same order as they 1392 are in this repeated field. 1393 1394 **Nested message:** `Output` 1395 1396 - `OutputDestination destination`: The output destination (address, script, 1397 etc.). 1398 1399 - `int64 amount`: The value created by the output. 1400 1401 **Nested message**: `OutputDestination` 1402 1403 - `string address`: Address string to use as the output destination. If null 1404 or the empty string, this is skipped and the next destination kind is 1405 checked. 1406 1407 - `bytes script`: The script bytes to use in the output script. Only checked 1408 if none of the previous destination kinds were set. 1409 1410 - `uint32 script_version`: When the output destination is a script, this 1411 specifies the script version to use in the output. 1412 1413 - `OutputDestination change_destination`: Optional destination to use for any 1414 transaction change. If null and a change output is needed, an internal change 1415 address is created for the wallet. 1416 1417 **Response:** `ConstructTransactionResponse` 1418 1419 - `bytes unsigned_transaction`: The raw serialized transaction. 1420 1421 - `int64 total_previous_output_amount`: The total previous output amount 1422 consumed by the transaction's inputs. 1423 1424 - `int64 total_output_amount`: The total output value produced by the 1425 transaction's outputs. 1426 1427 - `uint32 estimated_signed_size`: An estimated size of the transaction once the 1428 transaction is signed. 1429 1430 - `int32 change_index`: The index of the change output or -1 if no change 1431 output was created. 1432 1433 **Expected errors:** 1434 1435 - `InvalidArgument`: An output destination address could not be decoded. 1436 1437 - `InvalidArgument`: No output destinations (change or non-change) were provided. 1438 1439 - `NotFound`: The account does not exist. 1440 1441 - `ResourceExhausted`: There was not enough available input value to construct 1442 the transaction. 1443 1444 ___ 1445 1446 #### `SignTransaction` 1447 1448 The `SignTransaction` method adds transaction input signatures to a serialized 1449 transaction using a wallet private keys. 1450 1451 **Request:** `SignTransactionRequest` 1452 1453 - `bytes passphrase`: The wallet's private passphrase. 1454 1455 - `bytes serialized_transaction`: The transaction to add input signatures to. 1456 1457 - `repeated AdditionalScript additional_scripts`: Additional output scripts of 1458 previous outputs spent by the transaction that the wallet may not be aware of. 1459 Offline signing may require previous outputs to be provided to the wallet. 1460 1461 **Nested message:** `AdditionalScript` 1462 1463 - `bytes transaction_hash`: The transaction hash of the previous output. 1464 1465 - `uint32 output_index`: The output index of the previous output. 1466 1467 - `int32 tree`: The transaction tree the previous transaction belongs to. 1468 1469 - `bytes pk_script`: The output script of the previous output. 1470 1471 **Response:** `SignTransactionResponse` 1472 1473 - `bytes transaction`: The serialized transaction with added input scripts. 1474 1475 - `repeated uint32 unsigned_input_indexes`: The indexes of every input that an 1476 input script could not be created for. 1477 1478 **Expected errors:** 1479 1480 - `Aborted`: The wallet database is closed. 1481 1482 - `InvalidArgument`: The private passphrase is incorrect. 1483 1484 - `InvalidArgument`: The serialized transaction can not be decoded. 1485 1486 ___ 1487 1488 #### `SignTransactions` 1489 1490 The `SignTransactions` method adds transaction input signatures to a set of 1491 serialized transactions using a wallet private keys. 1492 1493 **Request:** `SignTransactionsRequest` 1494 1495 - `bytes passphrase`: The wallet's private passphrase. 1496 1497 - `repeated UnsignedTransaction unsigned_transaction`: - The unsigned transactions set. 1498 1499 **Nested message:** `UnsignedTransaction` 1500 1501 - `bytes serialized_transaction`: The transaction to add input signatures to. 1502 1503 - `repeated AdditionalScript additional_scripts`: Additional output scripts of 1504 previous outputs spent by the transaction that the wallet may not be aware of. 1505 Offline signing may require previous outputs to be provided to the wallet. 1506 1507 **Nested message:** `AdditionalScript` 1508 1509 - `bytes transaction_hash`: The transaction hash of the previous output. 1510 1511 - `uint32 output_index`: The output index of the previous output. 1512 1513 - `int32 tree`: The transaction tree the previous transaction belongs to. 1514 1515 - `bytes pk_script`: The output script of the previous output. 1516 1517 **Response:** `SignTransactionsResponse` 1518 1519 - `repeated SignedTransaction transactions`: The signed transaction set. 1520 1521 **Nested message:** `SignedTransaction` 1522 1523 - `bytes transaction`: The serialized transaction with added input scripts. 1524 1525 **Expected errors:** 1526 1527 - `Aborted`: The wallet database is closed. 1528 1529 - `InvalidArgument`: A serialized transaction can not be decoded. 1530 1531 - `InvalidArgument`: The private passphrase is incorrect. 1532 1533 ___ 1534 1535 #### `CreateSignature` 1536 1537 The `CreateSignature` method creates a raw signature created by the private key 1538 of a wallet address for transaction input script. The serialized compressed 1539 public key of the address is also returned. The raw signature and public key 1540 are useful when creating custom input scripts. 1541 1542 **Request:** `CreateSignatureRequest` 1543 1544 - `bytes passphrase`: The wallet's private passphrase. 1545 1546 - `string address`: The address of the private key to use to create the 1547 signature. 1548 1549 - `bytes serialized_transaction`: The transaction to add input signatures to. 1550 1551 - `uint32 input_index`: The index of the transaction input to sign. 1552 1553 - `SigHashType hash_type`: The signature hash flags to use. 1554 1555 **Nested enum:** `SigHashType` 1556 1557 - `SIGHASH_OLD` 1558 - `SIGHASH_ALL` 1559 - `SIGHASH_NONE` 1560 - `SIGHASH_SINGLE` 1561 - `SIGHASH_ALLVALUE` 1562 - `SIGHASH_ANYONECANPAY` 1563 1564 - `bytes previous_pk_script`: The previous output script or P2SH redeem script. 1565 1566 **Response:** `CreateSignatureResponse` 1567 1568 - `bytes signature`: The raw signature. 1569 1570 - `bytes public_key`: The serialized compressed pubkey of the address. 1571 1572 **Expected errors:** 1573 1574 - `InvalidArgument`: The private passphrase is incorrect. 1575 1576 - `InvalidArgument`: The address can not be decoded. 1577 1578 - `NotFound`: The address is unknown by the wallet. 1579 1580 - `InvalidArgument`: The serialized transaction can not be decoded. 1581 1582 - `InvalidArgument`: The input index does not exist in the transaction. 1583 1584 ___ 1585 1586 #### `PublishTransaction` 1587 1588 The `PublishTransaction` method publishes a signed, serialized transaction to 1589 the Decred network. If the transaction spends any of the wallet's unspent 1590 outputs or creates a new output controlled by the wallet, it is saved by the 1591 wallet and republished later if it or a double spend are not mined. 1592 1593 **Request:** `PublishTransactionRequest` 1594 1595 - `bytes signed_transaction`: The signed transaction to publish. 1596 1597 **Response:** `PublishTransactionResponse` 1598 1599 - `bytes transaction_hash`: The hash of the published transaction. 1600 1601 **Expected errors:** 1602 1603 - `InvalidArgument`: The serialized transaction can not be decoded or is missing 1604 input scripts. 1605 1606 - `Aborted`: The wallet database is closed. 1607 1608 ___ 1609 1610 #### `PublishUnminedTransactions` 1611 1612 The `PublishTransactions` method re-broadcasts all unmined transactions 1613 to the consensus RPC server so it can be propagated to other nodes 1614 and eventually mined. 1615 1616 **Request:** `PublishUnminedTransactionsRequest` 1617 1618 **Response:** `PublishUnminedTransactionsResponse` 1619 1620 **Expected errors:**: None 1621 1622 ___ 1623 1624 #### `TicketPrice` 1625 1626 The `TicketPrice` method returns the price of a ticket for the next block, also 1627 known as the stake difficulty. May be incorrect if the daemon is currently 1628 syncing. 1629 1630 **Request:** `TicketPriceRequest` 1631 1632 **Response:** `TicketPriceResponse` 1633 1634 - `int64 ticket_price`: The stake difficulty for the next block. 1635 1636 - `int32 height`: The block height for this query. 1637 1638 **Expected errors:** None 1639 1640 ___ 1641 1642 #### `SignHashes` 1643 1644 The `SignHashes` method creates signatures of multiple hash values using the 1645 provided private keys and addresses. 1646 1647 **Request:** `SignHashesRequest` 1648 1649 - `bytes passphrase`: The wallet's private passphrase. 1650 1651 - `string address`: The address of the private key to use to create the 1652 signature. 1653 1654 - `repeated bytes hashes`: Hash values to sign. 1655 1656 **Response:** `SignHashesResponse` 1657 1658 - `bytes public_key`: The serialized compressed pubkey of the address. 1659 1660 - `repeated bytes signature`: Raw signatures. The index of each signature 1661 corresponds to the index of an incoming hash. 1662 1663 **Expected errors:** 1664 1665 - `InvalidArgument`: The private passphrase is incorrect. 1666 1667 **Stability:** Unstable: this method may require API changes to support 1668 signature algorithms other than secp256k1. 1669 1670 ___ 1671 1672 #### `StakeInfo` 1673 1674 The `StakeInfo` method returns various statistics about the wallet in relation 1675 to tickets owned fully or completely by the wallet, such as number of tickets 1676 owned and votes cast. 1677 1678 **Request:** `StakeInfoRequest` 1679 1680 **Response:** `StakeInfoResponse` 1681 1682 - `uint32 pool_size`: The current size of the ticket pool. 1683 1684 - `uint32 all_mempool_tix`: The number of tickets in the mempool. 1685 1686 - `uint32 own_mempool_tix`: The number of tickets in the mempool owned by this 1687 wallet. 1688 1689 - `uint32 immature`: The number of tickets in the blockchain that are not yet 1690 mature (can't yet be used to vote on blocks). 1691 1692 - `uint32 live`: The number of active tickets owned by the user. 1693 1694 - `uint32 voted`: The number of successful votes cast by the user. 1695 1696 - `uint32 missed`: The number of votes that were missed by the user. 1697 1698 - `uint32 revoked`: The number of revocations for missed votes cast by the user. 1699 1700 - `uint32 expired`: The number of expired tickets owned by the user. 1701 1702 - `int64 total_subsidy`: The total subsidy received by the user for proof-of-stake voting. 1703 1704 - `uint32 unspent`: The number of unspent tickets. This could include live, missed or expired tickets. 1705 1706 **Expected errors:** None 1707 1708 ___ 1709 1710 #### `PurchaseTickets` 1711 1712 The `PurchaseTickets` method is used to purchase tickets. It can use a specified 1713 address for voting rights, and can additionally be used in conjunction with a 1714 stake pool. An expiration value can be set for the tickets. Expired tickets are 1715 pruned from the wallet and funds and then restored to the user. The following 1716 fields can be left unset, and unset (empty or zero) behavior is given below: 1717 ticker_address, pool_address, expiry, tx_fee, ticket_fee. 1718 1719 **Request:** `PurchaseTicketsRequest` 1720 1721 - `bytes passphrase`: The wallet's private passphrase. 1722 1723 - `uint32 account`: The account to use to purchase the tickets. 1724 1725 - `int64 spend_limit`: The maximum amount to pay for a single ticket. If the 1726 current stake difficulty is above this amount, the wallet will return an error. 1727 1728 - `uint32 required_confirmations`: The number of required confirmations for 1729 funds used to purchase a ticket. If set to zero, it will use unconfirmed and 1730 confirmed outputs to purchase tickets. 1731 1732 - `string ticket_address`: The address to give voting rights to. If it is set 1733 to an empty string, an internal address will be used from the wallet. 1734 1735 - `uint32 num_tickets`: The number of tickets to purchase. It must be set and 1736 at least 1. 1737 1738 - `string pool_address`: The address of the stake pool used. Pool mode will 1739 be disabled if an empty string is passed. 1740 1741 - `double pool_fees`: The stake pool fees amount. This must be set to a positive 1742 value in the allowed range of 0.01 to 100.00 to be valid. It must be set when 1743 the pool_address is also set. 1744 1745 - `uint32 expiry`: The height at which the tickets expire and can no longer enter 1746 the blockchain. It defaults to 0 (no expiry). 1747 1748 - `int64 tx_fee`: Fees per kB to use for the transaction generating outputs to use 1749 for buying tickets. If 0 is passed, the global value for a transaction fee 1750 will be used. 1751 1752 - `int64 ticket_fee`: Fees per kB to use for all purchased tickets. If 0 is 1753 passed, the global value for a ticket fee will be used. This option is 1754 deprecated and ignored; use `tx_fee` instead. 1755 1756 - `bool dont_sign_tx`: If the tickets tx should be signed or not. 1757 1758 - `string cspp_server`: The cspp server to use. 1759 1760 - `uint32 mixed_account`: The mixed account. 1761 1762 - `uint32 mixed_account_branch`: The mixed account branch. 1763 1764 - `uint32 mixed_split_account`: The mixed split account. 1765 1766 - `uint32 change_account`: The change account. 1767 1768 - `string vsp_host`: The vsp host. 1769 1770 - `string vsp_pubkey`: The vsp pubkey. 1771 1772 - `bool use_voting_account`: Whether to force use of the voting account to 1773 derive submission scripts. 1774 1775 - `uint32 voting_account`: The account to derive submission scripts from. 1776 1777 **Response:** `PurchaseTicketsResponse` 1778 1779 - `repeated bytes ticket_hashes`: The transaction hashes of the generated tickets. 1780 1781 - `repeated bytes unsigned_tickets`: The unsigned tickets bytes when dont_sign_tx is true. 1782 1783 - `repeated bytes split_tx`: The split tx bytes when dont_sign_tx is true. 1784 1785 ___ 1786 1787 **Expected errors:** 1788 1789 - `InvalidArgument`: The private passphrase is incorrect. 1790 1791 - `InvalidArgument`: The spent limit was negative. 1792 1793 - `InvalidArgument`: An invalid number of tickets was specified. 1794 1795 - `InvalidArgument`: An invalid ticket address was specified. 1796 1797 - `InvalidArgument`: An invalid pool address was specified. 1798 1799 - `InvalidArgument`: Pool address was specified, but pool fees were not. 1800 1801 - `InvalidArgument`: Pool address was not specified, but pool fees were. 1802 1803 - `InvalidArgument`: And invalid pool fees amount was given, either too large or 1804 small. 1805 1806 - `InvalidArgument`: A negative fees per kB was set. 1807 1808 - `FailedPrecondition`: The wallet balance was not enough to buy tickets. 1809 1810 ___ 1811 1812 #### `RevokeTickets` 1813 1814 The `RevokeTickets` method creates revocations for any missed or expired tickets 1815 that have not yet been revoked. 1816 1817 **Request:** `RevokeTicketsRequest` 1818 1819 - `bytes passphrase`: The wallet's private passphrase. 1820 1821 **Response:** `RevokeTicketsResponse` 1822 1823 **Expected errors:** 1824 1825 - `InvalidArgument`: The private passphrase is incorrect. 1826 1827 ___ 1828 1829 #### `LoadActiveDataFilters` 1830 1831 The `LoadActiveDataFilters` method loads a transaction filter with the 1832 associated consensus RPC server for all active addresses and watched outpoints. 1833 1834 **Request:** `LoadActiveDataFiltersRequest` 1835 1836 **Response:** `LoadActiveDataFiltersResponse` 1837 1838 **Expected errors:** 1839 1840 - `FailedPrecondition`: There is no consensus server associated with the wallet. 1841 1842 ___ 1843 1844 #### `SignMessage` 1845 1846 The `SignMessage` method creates a signature of a message using the private key 1847 of an address. 1848 1849 **Request:** `SignMessageRequest` 1850 1851 - `string address`: The associated address of the private key to use to sign the 1852 message. Must be P2PKH or P2PK. 1853 1854 - `string message`: The message to sign. 1855 1856 - `bytes passphrase`: The wallet's private passphrase. 1857 1858 **Response:** `SignMessageResponse` 1859 1860 - `bytes signature`: The signature of the message. 1861 1862 **Expected errors:** 1863 1864 - `InvalidArgument`: The address cannot be decoded, is for the wrong network, or 1865 is not P2PKH or P2PK. 1866 1867 - `InvalidArgument`: The private passphrase is incorrect. 1868 1869 ___ 1870 1871 #### `SignMessages` 1872 1873 The `SignMessages` method creates a signature of multiple messages using the 1874 provided private keys and addresses. 1875 1876 **Request:** `SignMessagesRequest` 1877 1878 - `bytes passphrase`: The wallet's private passphrase. 1879 1880 - `repeated Message messages`: Message that needs to be signed. 1881 1882 **Nested message:** `Message` 1883 1884 - `string address`: The associated address of the private key to use to sign 1885 the message. Must be P2PKH or P2PK. 1886 1887 - `string message`: The message to sign. 1888 1889 **Response:** `SignMessageResponse` 1890 1891 - `repeated SignReply replies`: Replies of all signing operations. Caller 1892 must check the error field. The index of reply is identical to the incoming 1893 messages. 1894 1895 **Nested message:** `SignReply` 1896 1897 - `bytes signature`: The signature of the message. 1898 1899 - `string error`: Human readable error if the signature command failed. 1900 "" indicates success. 1901 1902 **Expected errors:** 1903 1904 - `InvalidArgument`: The private passphrase is incorrect. 1905 1906 ___ 1907 1908 #### `ValidateAddress` 1909 1910 The `ValidateAddress` method verifies if an address is valid. 1911 1912 **Request:** `ValidateAddressRequest` 1913 1914 - `string address`: The address to be validated. 1915 1916 **Response:** `ValidateAddressResponse` 1917 1918 - `bool is_valid`: True if valid, false if not. 1919 1920 - `bool is_mine`: True if the address is an address of the querying wallet, false if not. 1921 1922 - `uint32 account_number`: The account number of the wallet. For watch-only 1923 wallets this will always be 0. 1924 1925 - `string pub_key_addr`: The public key address. 1926 1927 - `bytes pub_key`: The serialized public key. 1928 1929 - `bool is_script`: True if the address pays to a script. 1930 1931 - `repeated string pk_script_addrs`: the address(es) being paid to by the redeem script. 1932 1933 - `ScriptType script_type`: The script type. 1934 1935 - `bytes pay_to_addr_script`: The redeem script. 1936 1937 - `uint32 sigs_required`: The number of signatures required. 1938 1939 - `bool is_internal`: True if the address is from the internal branch of the hd 1940 wallet. 1941 1942 - `index`: The child index for addresses derived from hd public keys. It will be 1943 0 for other types of addresses. 1944 1945 ___ 1946 1947 #### `CommittedTickets` 1948 1949 The `CommittedTickets` method returns the matching ticket purchase hashes and 1950 addresses for which the largest commitment is controlled by this wallet. 1951 1952 **Request:** `CommittedTicketsRequest` 1953 1954 - `repeated bytes tickets`: The hashes of tickets that are being verified. 1955 1956 **Response:** `CommittedTicketsResponse` 1957 1958 - `repeated TicketAddresses ticketAddresses`: The hashes and addresses that are 1959 controlled by this wallet. 1960 1961 **Nested message:** `TicketAddresses` 1962 1963 - `bytes Ticket`: Hash of the ticket. 1964 1965 - `string address`: Address of the largest commitment. 1966 ___ 1967 1968 #### `BestBlock` 1969 1970 The `BestBlock` method returns the block height and height of the best block on 1971 the main chain. 1972 1973 **Request:** `BestBlockRequest` 1974 1975 **Response:** `BestBlockResponse` 1976 1977 - `bytes hash`: The hash of the best block. 1978 1979 - `uint32 height`: The height of the best block. 1980 1981 ___ 1982 1983 #### `SweepAccount` 1984 1985 The `SweepAccount` method Moves as much value as possible in a transaction from 1986 an account per the request parameters. 1987 1988 **Request:** `SweepAccountRequest` 1989 - `string source_account`: The account to be swept. 1990 1991 - `string destination_address`: The destination address to pay to. 1992 1993 - `uint32 required_confirmations`: The minimum utxo confirmation requirement. 1994 1995 - `double fee_per_kb`: The minimum relay fee policy (optional). 1996 1997 **Response:** `SweepAccountResponse` 1998 - `bytes unsigned_transaction`: The unsigned transaction bytes. 1999 2000 - `int64 total_previous_output_amount`: The total transaction input amount. 2001 2002 - `int64 total_output_amount`: The total transaction output amount. 2003 2004 - `uint32 estimated_signed_size`: The estimated size of the transaction when signed. 2005 2006 ___ 2007 2008 #### `AbandonTransaction` 2009 2010 The `AbandonTransaction` method removes a pending mempool transaction from the 2011 wallet. Mined transactions may not be abandoned. 2012 2013 **Request:** `AbandonTransactionRequest` 2014 - `bytes transaction_hash`: Hash of the transaction to remove 2015 2016 **Response:** `AbandonTransactionResponse` 2017 2018 **Expected errors:** 2019 2020 - `Aborted`: The wallet database is closed. 2021 2022 - `NotFound`: The transaction does not exist. 2023 2024 ___ 2025 2026 #### `TransactionNotifications` 2027 2028 The `TransactionNotifications` method returns a stream of notifications 2029 regarding changes to the blockchain and transactions relevant to the wallet. 2030 2031 **Request:** `TransactionNotificationsRequest` 2032 2033 **Response:** `stream TransactionNotificationsResponse` 2034 2035 - `repeated BlockDetails attached_blocks`: A list of blocks attached to the main 2036 chain, sorted by increasing height. All newly mined transactions are included 2037 in these messages, in the message corresponding to the block that contains 2038 them. If this field has zero length, the notification is due to an unmined 2039 transaction being added to the wallet. 2040 2041 The `BlockDetails` message is used by other methods and is documented 2042 [here](#blockdetails). 2043 2044 - `repeated bytes detached_blocks`: The hashes of every block that was 2045 reorganized out of the main chain. These are sorted by heights in decreasing 2046 order (newest blocks first). 2047 2048 - `repeated TransactionDetails unmined_transactions`: All newly added unmined 2049 transactions. When relevant transactions are reorganized out and not included 2050 in (or double-spent by) the new chain, they are included here. 2051 2052 The `TransactionDetails` message is used by other methods and is documented 2053 [here](#transactiondetails). 2054 2055 - `repeated bytes unmined_transaction_hashes`: The hashes of every 2056 currently-unmined transaction. This differs from the `unmined_transactions` 2057 field by including every unmined transaction, rather than those newly added to 2058 the unmined set. 2059 2060 - `repeated detached_block_headers`: Details of every block that was reorganized 2061 out of the main chain. These are in the same order as `detached_blocks`. 2062 2063 The `DetachedBlockDetails` message is documented [here](#detachedblockdetails). 2064 2065 **Expected errors:** 2066 2067 - `Aborted`: The wallet database is closed. 2068 2069 ___ 2070 2071 #### `AccountNotifications` 2072 2073 The `AccountNotifications` method returns a stream of notifications for account 2074 property changes, such as name and key counts. 2075 2076 **Request:** `AccountNotificationsRequest` 2077 2078 **Response:** `stream AccountNotificationsResponse` 2079 2080 - `uint32 account_number`: The BIP0044 account being reported. 2081 2082 - `string account_name`: The current account name. 2083 2084 - `uint32 external_key_count`: The current number of BIP0032 external keys 2085 derived for the account. 2086 2087 - `uint32 internal_key_count`: The current number of BIP0032 internal keys 2088 derived for the account. 2089 2090 - `uint32 imported_key_count`: The current number of private keys imported into 2091 the account. 2092 2093 **Expected errors:** 2094 2095 - `Aborted`: The wallet database is closed. 2096 2097 ___ 2098 2099 #### `ConfirmationNotifications` 2100 2101 The `ConfirmationNotifications` method allows notifications of transaction 2102 confirmations. Transaction hashes to watch are streamed as requests and a 2103 stream of responses is returned which include the number of confirmations of 2104 each watched transaction. A response is immediately streamed that includes the 2105 current number of confirmations for all newly-watched transactions. Further 2106 responses will continue to describe the number of confirmations of each 2107 transaction until the confirmation upper limit is met or the transaction is 2108 removed from the wallet (e.g. due to a double spend). 2109 2110 **Request:** `stream ConfirmationNotificationsRequest` 2111 2112 - `repeated bytes tx_hashes`: Hashes of transactions to begin watching. 2113 2114 - `int32 stop_after`: The upper limit on how many confirmations is needed before 2115 the transaction becomes unwatched. 2116 2117 **Response:** `stream ConfirmationNotificationsResponse` 2118 2119 - `repeated TransactionConfirmations confirmations`: Hashes of watched 2120 transactions and their current number of confirmations. 2121 2122 **Nested message:** `TransactionConfirmations` 2123 2124 - `bytes tx_hash`: The hash of a watched transaction. 2125 2126 - `int32 confirmations`: The current number of confirmations of the 2127 transaction. If the transaction is unknown to the wallet or was removed due 2128 to a double spend, this value is set to `-1`. 2129 2130 - `bytes block_hash`: The hash of the block the transaction is mined in, or 2131 null if unmined. 2132 2133 - `int32 block_height`: The height of the block the transaction is mined in, 2134 or `-1` if unmined. 2135 2136 **Expected errors:** 2137 2138 - `InvalidArgument`: A transaction hash did not have the correct length. 2139 2140 - `InvalidArgument`: A negative `stop_after` was specified. 2141 2142 - `Aborted`: The wallet database is closed. 2143 2144 ___ 2145 2146 ### Shared messages 2147 2148 The following messages are used by multiple methods. To avoid unnecessary 2149 duplication, they are documented once here. 2150 2151 #### `BlockDetails` 2152 2153 The `BlockDetails` message is included in responses to report a block and the 2154 wallet's relevant transactions contained therein. 2155 2156 - `bytes hash`: The hash of the block being reported. 2157 2158 - `int32 height`: The height of the block being reported. 2159 2160 - `int64 timestamp`: The Unix time included in the block header. 2161 2162 - `repeated TransactionDetails transactions`: All transactions relevant to the 2163 wallet that are mined in this block. Transactions are sorted by their block 2164 index in increasing order. 2165 2166 The `TransactionDetails` message is used by other methods and is documented 2167 [here](#transactiondetails). 2168 2169 - `bool approves_parent`: Whether this block stake validates its parent block. 2170 2171 - `bytes prev_block`: The hash of the parent (previous) block of the block being 2172 reported. 2173 2174 2175 ___ 2176 2177 2178 #### `DetachedBlockDetails` 2179 2180 The `DetachedBlockDetails` message is included in responses to report a block 2181 detached from the wallet's main chain. 2182 2183 - `bytes hash`: The hash of the block being reported. 2184 2185 - `int32 height`: The height of the block being reported. 2186 2187 - `int64 timestamp`: The Unix time included in the block header. 2188 2189 - `bytes prev_block`: The hash of the parent (previous) block of the block being 2190 reported. 2191 2192 ___ 2193 2194 2195 #### `TransactionDetails` 2196 2197 The `TransactionDetails` message is included in responses to report transactions 2198 relevant to the wallet. The message includes details such as which previous 2199 wallet inputs are spent by this transaction, whether each output is controlled 2200 by the wallet or not, the total fee (if calculable), and the earlist time the 2201 transaction was seen. 2202 2203 - `bytes hash`: The hash of the serialized transaction. 2204 2205 - `bytes transaction`: The serialized transaction. 2206 2207 - `repeated Input debits`: Properties for every previously-unspent wallet output 2208 spent by this transaction. 2209 2210 **Nested message:** `Input` 2211 2212 - `uint32 index`: The transaction input index of the input being reported. 2213 2214 - `uint32 previous_account`: The account that controlled the now-spent output. 2215 2216 - `int64 previous_amount`: The previous output value. 2217 2218 - `repeated Output credits`: Properties for every output controlled by the wallet. 2219 2220 **Nested message:** `Output` 2221 2222 - `uint32 index`: The transaction output index of the output being reported. 2223 2224 - `uint32 account`: The account number of the controlled output. 2225 2226 - `bool internal`: Whether the output pays to an address derived from the 2227 account's internal key series. This often means the output is a change 2228 output. 2229 2230 - `int64 amount`: The amount for this output. 2231 2232 - `string address`: The address that the output paid to, if the output script 2233 can be parsed to a known address type. Otherwise this will be null or the 2234 empty string. 2235 2236 - `bytes output_script`: The output script. 2237 2238 - `int64 fee`: The transaction fee, if calculable. The fee is only calculable 2239 when every previous output spent by this transaction is also recorded by 2240 wallet. Otherwise, this field is zero. 2241 2242 - `int64 timestamp`: The Unix time of the earliest time this transaction was 2243 seen. 2244 2245 - `TransactionType transaction_type`: The observed type of transaction. 2246 2247 **Nested enum:** `TransactionType` 2248 2249 - `REGULAR`: All normal regular tx tree transactions. 2250 2251 - `TICKET_PURCHASE`: A transaction that purchases a ticket to be consumed later 2252 by a vote transaction upon random selection, or a recovation if the ticket 2253 is expired or missed. 2254 2255 - `VOTE`: A transaction that uses a ticket purchase transaction as an input 2256 and includes a stake base reward as one of the outputs. 2257 2258 - `REVOCATION`: A transaction that will free a previously locked utxos in 2259 a ticket purchase due to expiry or the ticket being missed. Just as stakebase 2260 rewards must reach maturity to be used, outputs from an revocation also must 2261 mature that same amount. 2262 2263 - `COINBASE`: A coinbase transaction in the regular tx tree. 2264 2265 ___ 2266 2267 #### `DecodedTransaction` 2268 2269 The `DecodedTransaction` message is included in responses that provide full 2270 transaction details. This message includes inputs and outputs not belonging to 2271 the wallet (in contrast with [`TransactionDetails`](#transactiondetails)). 2272 2273 - `bytes transaction_hash`: The hash of the transaction. 2274 2275 - `int32 version`: The version of the transaction. 2276 2277 - `uint32 lock_time`: The lock time field of the transaction. 2278 2279 - `uint32 expiry`: The expiry field of the transaction. 2280 2281 - `TransactionDetails.TransactionType transaction_type`: The type of the 2282 transaction. Note the available types are defined in the 2283 [`TransactionDetails`](#transactiondetails) message. 2284 2285 - `repeated Input inputs`: Information available on the inputs of the 2286 transaction. 2287 2288 **Nested message:** `Input` 2289 2290 - `bytes previous_transaction_hash`: The hash of the transaction from where 2291 this input is being spent. 2292 2293 - `uint32 previous_transaction_index`: The index of the output, on the 2294 previous transaction, from where this input is being spent. 2295 2296 - `TreeType tree`: The type of blockchain tree this input belongs to. 2297 2298 **Nested Enum** `TreeType` 2299 2300 - `REGULAR`: An input belonging to the regular chain of transactions. 2301 2302 - `UNKNOWN`: An input on an unknown chain. 2303 2304 - `STAKE`: An input belonging to the stake chain of transactions. 2305 2306 2307 - `uint32 sequence`: The sequence number of this input. 2308 2309 - `int64 amount_in`: The amount (in atoms) of the input. 2310 2311 - `uint32 block_height`: The block height field of witness inputs. 2312 2313 - `uint32 block_index`: The block index field of witness inputs. 2314 2315 - `bytes signature_script`: The serialized signature script of witness inputs. 2316 2317 - `string signature_script_asm`: The disassembled version of the signature 2318 script of witness inputs. 2319 2320 - `repeated Output outputs`: Information available on the outputs of the 2321 transaction. 2322 2323 **Nested Message** `Output` 2324 2325 - `int64 value`: The amount (in atoms) of the output. 2326 2327 - `uint32 index`: The index of the output in the transaction. 2328 2329 - `int32 version`: The version field of the output. 2330 2331 - `bytes script`: The serialized output script. 2332 2333 - `string script_asm`: The disassembled output script. 2334 2335 - `int32 required_signatures`: The number of required signatures for the 2336 output. 2337 2338 - `ScriptClass script_class`: The type of the output script. 2339 2340 **Nested Enum** `ScriptClass` 2341 - `NON_STANDARD`: A non-standard (or unidentifiable) output script. 2342 2343 - `PUB_KEY`: A Pay to PubKey script. 2344 2345 - `PUB_KEY_HASH`: A Pay to PubKey Hash script. 2346 2347 - `SCRIPT_HASH`: A Pay to Script Hash script. 2348 2349 - `MULTI_SIG`: A Multi Signature script. 2350 2351 - `NULL_DATA`: An empty data script. 2352 2353 - `STAKE_SUBMISSION`: A Stake Submission script. 2354 2355 - `STAKE_GEN`: A Stake Generation script. 2356 2357 - `STAKE_REVOCATION`: A Stake Revocation script. 2358 2359 - `STAKE_SUB_CHANGE`: Change for a Stake Submission transaction. 2360 2361 - `PUB_KEY_ALT`: Alternative Pay to PubKey script. 2362 2363 - `PUB_KEY_HASH_ALT`: Alternative Pay to PubKey Hash script. 2364 2365 - `TGEN`: A treasury generation script. 2366 2367 - `TADD`: A treasury add script. 2368 2369 - `repeated string addresses`: Addresses found when decoding the output 2370 script. 2371 2372 - `int64 commitment_amount`: Amount committed to a ticket on an SStx 2373 transaction. 2374 2375 ___ 2376 2377 #### `SyncNotificationType` 2378 2379 The `SyncNotificationType` enum contains all the various different types of 2380 notifications that can occur during the syncing process. When any notification 2381 is sent there will be a type included. 2382 2383 - `SYNCED`: When the wallet is synced to its connected peers. 2384 2385 - `UNSYNCED`: When the wallet is unsynced to its connected peers. 2386 2387 - `PEER_CONNECTED`: When a peer connects to the wallet. This is only available 2388 while using SPV. 2389 2390 - `PEER_DISCONNECTED`: When a peer disconnects from the wallet. This is only 2391 available while using SPV. 2392 2393 - `FETCHED_MISSING_CFILTERS_STARTED`: Notifies when the wallet attempts to find 2394 any missing committed filters. 2395 2396 - `FETCHED_MISSING_CFILTERS_PROGRESS`: When any missing committed filters are 2397 found and the progress is notified. 2398 2399 - `FETCHED_MISSING_CFILTERS_FINISHED`: Notifies when the wallet is finished 2400 fetching any missing committed filters. 2401 2402 - `FETCHED_HEADERS_STARTED`: Notifies when the wallet attempts to fetch headers 2403 from connected peers. 2404 2405 - `FETCHED_HEADERS_PROGRESS`: When new headers are received by the wallet, any 2406 progress is notified. 2407 2408 - `FETCHED_HEADERS_FINISHED`: Notifies when the wallet has completed fetching 2409 headers. 2410 2411 - `DISCOVER_ADDRESSES_STARTED`: Notifies when the wallet has begun the discover 2412 addresses process. 2413 2414 - `DISCOVER_ADDRESSES_FINISHED`: Notifies when the wallet has finished the 2415 discover addesses process. 2416 2417 - `RESCAN_STARTED`: When the rescan process has begun (if at all). 2418 2419 - `RESCAN_PROGRESS`: When the rescan process has any progress to update. 2420 2421 - `RESCAN_FINISHED`: When the rescan procress has finished. 2422 2423 ___ 2424 2425 #### `FetchHeadersNotification` 2426 2427 The `FetchHeadersNotification` message is used during the syncing process for 2428 any fetch headers notification updates. It contains the count of the fetched 2429 headers and the time of the last header fetched. 2430 2431 - `int32 fetched_headers_count`: The number of headers recently fetched. 2432 2433 - `int64 last_header_time`: The time (in nanoseconds) of the last header that 2434 was fetched. 2435 2436 ___ 2437 2438 #### `FetchMissingCFiltersNotification` 2439 2440 The `FetchMissingCFiltersNotification` message is used during the syncing 2441 process for any fetch missing committed filters notification updates. 2442 It may contain the starting and ending height of the filters that were found. 2443 2444 - `int32 fetched_cfilters_start_height`: The height of the first missing 2445 committed filter that was found. 2446 - `int32 fetched_cfilters_end_height`: The height of the last missing committed 2447 filter that was found. 2448 2449 ___ 2450 2451 #### `RescanProgressNotification` 2452 2453 The `RescanProgressNotification` message is used during the syncing process 2454 for any rescan progress notification updates. It will contain the height 2455 of the block that the rescan process has gotten through. 2456 2457 - `int32 rescanned_through`: The block height that rescan has progressed 2458 through. 2459 2460 ___ 2461 2462 #### `PeerNotification` 2463 2464 The `PeerNotification` message is used during the syncing process for any peer 2465 information updates. This includes peer count and possibly the address of 2466 the peer that caused a notification to be sent. 2467 2468 - `int32 peer_count`: The number of peers currently connected. 2469 2470 - `string address`: The address of the peer that caused the notification. 2471 2472 ___ 2473 2474 #### `GetCFilters` 2475 2476 The `GetCFilters` method allows callers to fetch the V2 committed filters from 2477 the wallet database. Callers can query these filters to search for the presence 2478 (as spends or new outputs) of arbitrary scripts in blocks. 2479 2480 Only blocks from the current mainchain (from the wallet's point of view) can be 2481 queried. The available filters have already been verified against the header 2482 following DCP0005 activation and are therefore safe for use. 2483 2484 2485 **Request:** `GetCFiltersRequest` 2486 2487 - `bytes starting_block_hash`: The block hash of the block to begin including 2488 cfilters from. If this field is set to the default, the 2489 `starting_block_height` field is used instead. If changed, the byte array 2490 must have length 32 and `starting_block_height` must be zero. 2491 2492 - `sint32 starting_block_height`: The block height to begin including 2493 cfilters from. If this field is non-zero, `starting_block_hash` must be 2494 set to its default value to avoid ambiguity. If positive, the field is 2495 interpreted as a block height. If negative, the height is subtracted from the 2496 block wallet considers itself in sync with. 2497 2498 - `bytes ending_block_hash`: The block hash of the last block to return 2499 cfilters from. If this default is set to the default, the 2500 `ending_block_height` field is used instead. If changed, the byte array must 2501 have length 32 and `ending_block_height` must be zero. 2502 2503 - `int32 ending_block_height`: The block height of the last block to return 2504 cfilters from. If non-zero, the `ending_block_hash` field must be set to 2505 its default value to avoid ambiguity. If both this field and 2506 `ending_block_hash` are set to their default values, no upper block limit is 2507 used and cfilters through the best block are returned. 2508 2509 2510 **Response:** `stream GetCFiltersResponse` 2511 2512 Each returned element of the stream corresponds to a single cfilter. The 2513 returned fields for each element are: 2514 2515 - `bytes key`: A byte array with the key that must be used to query the filter. 2516 This byte array will be of length 16. 2517 2518 - `bytes filter`: The serialized, version 2 committed filter. 2519 2520 - `bytes block_hash`: The block hash of the corresponding block. 2521 2522 **Expected errors:** 2523 2524 - `InvalidArgument`: When both `starting_block_hash` and `starting_block_height` 2525 are specified. 2526 2527 - `InvalidArgument`: When both `ending_block_hash` and `ending_block_height` are 2528 specified. 2529 2530 ___ 2531 2532 #### `UnlockWallet` 2533 2534 The `UnlockWallet` method allows the wallet to be persistently unlocked, until 2535 `LockWallet` is used, or an incorrect passphrase is provided later. 2536 2537 **Request:** `UnlockWalletRequest` 2538 2539 - `bytes passphrase`: The passphrase to unlock the wallet. 2540 2541 **Response:** `UnlockWalletResponse` 2542 2543 **Expected errors:** 2544 2545 - `InvalidArgument`: The private passphrase is incorrect. 2546 2547 ___ 2548 2549 #### `LockWallet` 2550 2551 The `LockWallet` request locks the wallet, preventing use of any keys protected 2552 by the private passphrase. This does not affect accounts which are encrypted 2553 with a separate passphrase. 2554 2555 **Request:** `LockWalletRequest` 2556 2557 **Response:** `LockWalletResponse` 2558 2559 **Expected errors:** None 2560 2561 ___ 2562 2563 #### `UnlockAccount` 2564 2565 The `UnlockAccount` method unlocks keys for a separately encrypted account with 2566 its own passphrase. Keys remain available until `LockAccount` is used, or an 2567 incorrect passphrase is provided later by this method. 2568 2569 **Request:** `UnlockAccountRequest` 2570 2571 - `bytes passphrase`: The passphrase to unlock an account. 2572 2573 - `uint32 account_number`: The account to unlock. 2574 2575 **Response:** `UnlockAccountResponse` 2576 2577 **Expected errors:** 2578 2579 - `FailedPrecondition`: The account is not encrypted with an individual 2580 passphrase. 2581 2582 - `InvalidArgument`: The private passphrase is incorrect. 2583 2584 ___ 2585 2586 #### `LockAccount` 2587 2588 The `LockAccount` request locks an account, preventing use of any keys protected 2589 by the private passphrase. This does not affect any other accounts. 2590 2591 **Request:** `LockAccountRequest` 2592 2593 - `uint32 account_number`: The account to lock. 2594 2595 **Response:** `LockAccountResponse` 2596 2597 **Expected errors:** 2598 2599 - `FailedPrecondition`: The account is not encrypted with an individual 2600 passphrase. 2601 2602 2603 #### `GetTrackedVSPTickets` 2604 2605 The `GetTrackedVSPTickets` request returns the list of tickets currently tracked 2606 by the VSP client inside dcrwallet. This only applies to tickets purchased 2607 following the new vspd mode. 2608 2609 **Request** `GetTrackedVSPTicketsRequest` 2610 2611 **Response** `GetTrackedVSPTicketsResponse` 2612 2613 2614 - `VSP vsps`: The list of tickets, grouped by VSP. 2615 2616 Nested message `VSP`: 2617 2618 - `string host`: URL of the VSP 2619 2620 - `repeated Ticket tickets`: List of tickets tracked for this VSP. 2621 2622 Nested message `Ticket`: 2623 2624 - `bytes ticket hash`: The transaction hash of the corresponding ticket. 2625 2626 - `string voting_address`: The voting address of the ticket. 2627 2628 - `string commitment_address`: The commitment address of the ticket. 2629 2630 - `uint32 state`: The internal state the VSP client believes the ticket to be. 2631 2632 - `int64 fee`: The amount (in atoms) paid as VSP fee in the fee transaction. 2633 2634 - `bytes fee_hash`: The hash of the fee transaction that pays to the VSP. 2635 2636 ___ 2637 2638 #### `Address` 2639 2640 The `Address` method queries the wallet for an address and public key from a 2641 certain account, branch, and index. 2642 2643 **Request:** `AddressRequest` 2644 2645 - `uint32 account`: The account number. 2646 2647 - `Kind kind`: The branch. 2648 2649 **Nested enum:** `Kind` 2650 2651 - `BIP0044_EXTERNAL`: The request specifies to use the account's BIP0044 2652 external key chain. 2653 2654 - `BIP0044_INTERNAL`: The request specifies to use the account's BIP0044 2655 internal key chain. 2656 2657 - `uint32 index`: The address index. 2658 2659 **Response:** `AddressResponse` 2660 2661 - `string address`: The address's p2pkh. 2662 2663 - `string pulic_key`: The address's pkh if available. 2664 2665 **Expected errors:** 2666 2667 - `InvalidArgument`: Kind is not 0 or 1. 2668 2669 - `NotFound`: Unknown account. 2670 2671 - `Unknown`: Index is out of range. 2672 2673 ___ 2674 2675 #### `DumpPrivateKey` 2676 2677 The `DumpPrivateKey` method returns the private key for an address. The wallet 2678 or account must be unlocked. 2679 2680 **Request:** `DumpPrivateKeyRequest` 2681 2682 - `string address`: The address to retrieve the private key for. 2683 2684 **Response:** `DumpPrivateKeyResponse` 2685 2686 - `string private_key_wif`: The address's private key in wif format. 2687 2688 **Expected errors:** 2689 2690 - `InvalidArgument`: Unable to decode address. 2691 2692 - `NotFound`: Address not found. 2693 2694 - `FailedPrecondition`: Account locked. 2695 2696 - `InvalidArgument`: Watching only wallet. 2697 2698 ## `SeedService` 2699 2700 The `SeedService` service provides RPC clients with the ability to generate 2701 secure random seeds encoded in both binary and human-readable formats, and 2702 decode any human-readable input back to binary. It has no dependencies and is 2703 always running. 2704 2705 **Methods:** 2706 2707 - [`GenerateRandomSeed`](#generaterandomseed) 2708 - [`DecodeSeed`](#decodeseed) 2709 2710 ### Methods 2711 2712 #### `GenerateRandomSeed` 2713 2714 The `GenerateRandomSeed` generates a secure random seed, returning it as binary, 2715 hexadecimal, and in a mnemonic word list format. 2716 2717 **Request:** `GenerateRandomSeedRequest` 2718 2719 - `uint32 seed_length`: The length of the seed to create. If zero, the 2720 recommended seed length is used instead. 2721 2722 **Response:** `GenerateRandomSeedResponse` 2723 2724 - `bytes seed_bytes`: The generated seed in a binary format. 2725 2726 - `string seed_hex`: The generated seed encoded as a hexadecimal string. 2727 2728 - `string seed_mnemonic`: The generated seed encoded as a mnemonic word list. 2729 2730 **Expected errors:** 2731 2732 - `InvalidArgument`: The non-zero seed length is invalid. 2733 2734 ___ 2735 2736 #### `DecodeSeed` 2737 2738 The `DecodeSeed` decodes a human-readable form of the seed back into binary. 2739 The user input can be either a hexadecimal string or a mnemonic word list. 2740 2741 **Request:** `DecodeSeedRequest` 2742 2743 - `string user_input`: The user input to decode. 2744 2745 **Response:** `DecodeSeedResponse` 2746 2747 - `bytes decoded_seed`: The seed resulting from the decoded user input. 2748 2749 **Expected errors:** 2750 2751 - `InvalidArgument`: The input is invalid. 2752 2753 ## `TicketBuyerService` 2754 2755 The `TicketBuyerService` service provides RPC clients with the ability to 2756 launch the automatic ticket buyer with given initial configuration parameters, 2757 and to stop it. It is always running but depends on the wallet to be loaded. 2758 2759 **Methods:** 2760 2761 - [`StartAutoBuyer`](#startautobuyer) 2762 - [`StopAutoBuyer`](#stopautobuyer) 2763 - [`TicketBuyerConfig`](#ticketbuyerconfig) 2764 - [`SetAccount`](#setaccount) 2765 - [`SetBalanceToMaintain`](#setbalancectomaintain) 2766 - [`SetMaxFee`](#setmaxfee) 2767 - [`SetMaxPriceRelative`](#setmaxpricerelative) 2768 - [`SetMaxPriceAbsolute`](#setmaxpriceabsolute) 2769 - [`SetVotingAddress`](#setvotingaddress) 2770 - [`SetPoolAddress`](#setpooladdress) 2771 - [`SetPoolFees`](#setpoolfees) 2772 - [`SetMaxPerBlock`](#setmaxperblock) 2773 2774 ### Methods 2775 2776 #### `StartAutoBuyer` 2777 2778 The `StartAutoBuyer` method starts an automatic ticket buyer with the given 2779 parameters. Ticket purchase requires the wallet to be unlocked thus the 2780 private passphrase must be passed as a parameter when performing this action. 2781 2782 **Request:** `StartAutoBuyerRequest` 2783 2784 - `bytes passphrase`: The private passphrase to unlock the wallet. 2785 2786 - `uint32 account`: The account number to use for purchasing tickets. 2787 2788 - `int64 balance_to_maintain`: The minimum amount of funds to never dip below when purchasing tickets. 2789 2790 - `int64 max_fee_per_kb`: The maximum ticket fee amount per KB. 2791 2792 - `double max_price_relative`: The scaling factor for setting the maximum ticket price, multiplied by the average price. 2793 2794 - `int64 max_price_absolute`: The maximum absolute ticket price. 2795 2796 - `string voting_address`: The address to delegate voting rights to. 2797 2798 - `string pool_address`: The stake pool address where ticket fees will go to. 2799 2800 - `double pool_fees`: The absolute per ticket fee mandated by the stake pool as a percent. 2801 2802 - `int64 max_per_block`: The maximum tickets per block. Negative number indicates one ticket every n blocks. 2803 2804 **Response:** `StartAutoBuyerResponse` 2805 2806 **Expected errors:** 2807 2808 - `InvalidArgument`: The private passphrase is incorrect. 2809 2810 - `NotFound`: The account does not exist. 2811 2812 - `InvalidArgument`: An invalid balance to maintain was specified. 2813 2814 - `InvalidArgument`: An invalid maximum ticket fee amount per KB was specified. 2815 2816 - `InvalidArgument`: An invalid maximum ticket price was specified. 2817 2818 - `InvalidArgument`: An invalid voting address was specified. 2819 2820 - `InvalidArgument`: An invalid pool address was specified. 2821 2822 - `InvalidArgument`: Pool address was specified, but pool fees were not. 2823 2824 - `InvalidArgument`: Pool address was not specified, but pool fees were. 2825 2826 - `InvalidArgument`: And invalid pool fees amount was given, either too large or too small. 2827 2828 - `FailedPrecondition`: Wallet has not been loaded. 2829 2830 - `FailedPrecondition`: Chain client is not available. 2831 2832 - `FailedPrecondition`: Ticket buyer is already started. 2833 2834 ___ 2835 2836 #### `StopAutoBuyer` 2837 2838 The `StopAutoBuyer` method stops the automatic ticket buyer. 2839 2840 **Request:** `StopAutoBuyerRequest` 2841 2842 **Response:** `StopAutoBuyerResponse` 2843 2844 **Expected errors:** 2845 2846 - `FailedPrecondition`: Ticket buyer is not running. 2847 2848 ___ 2849 2850 #### `TicketBuyerConfig` 2851 2852 The `TicketBuyerConfig` method returns the current configuration of the 2853 automatic ticket buyer. 2854 2855 **Request:** `TicketBuyerConfigRequest` 2856 2857 **Response:** `TicketBuyerConfigResponse` 2858 2859 - `uint32 account`: The account number to use for purchasing tickets. 2860 2861 - `string avg_price_mode` : The mode to use for calculating the average price. 2862 2863 - `int64 avg_priceVWAP_delta`: The number of blocks from the current block to use to calculate the VWAP. 2864 2865 - `int64 balance_to_maintain`: The minimum amount of funds to never dip below when purchasing tickets. 2866 2867 - `int64 blocks_to_avg`: The number of blocks to average for fees calculation. 2868 2869 - `bool dont_wait_for_tickets`: If true, wait until the last round of tickets have entered the blockchain, before attempting more purchases. 2870 2871 - `int64 expiry_delta`: The number of blocks in the future before the ticket expires. 2872 2873 - `string fee_source`: The fee source to use for ticket fee per KB (median or mean). 2874 2875 - `double fee_target_scaling`: The scaling factor for setting the ticket fee, multiplies by the average fee. 2876 2877 - `int64 min_fee`: The minimum ticket fee amount per KB 2878 2879 - `int64 max_fee`: The maximum ticket fee amount per KB. 2880 2881 - `int64 max_per_block`: The maximum tickets per block. Negative number indicates one ticket every n blocks. 2882 2883 - `int64 max_price_absolute`: The maximum absolute ticket price. 2884 2885 - `double max_price_relative`: The scaling factor for setting the maximum ticket price, multiplied by the average price. 2886 2887 - `int64 max_in_mempool`: The maximum number of own tickets in mempool before attempting more purchases. 2888 2889 - `string pool_address`: The stake pool address where ticket fees will go to. 2890 2891 - `double pool_fees`: The absolute per ticket fee mandated by the stake pool as a percent. 2892 2893 - `bool spread_ticket_purchases`: If true, spread ticket purchases evenly throughout the window. 2894 2895 - `string voting_address`: The address to delegate voting rights to. 2896 2897 - `int64 tx_fee`: The transaction fee amount per KB. 2898 2899 2900 **Expected errors:** 2901 2902 - `FailedPrecondition`: Ticket buyer is not running. 2903 2904 - `FailedPrecondition`: Wallet has not been loaded. 2905 2906 ___ 2907 2908 #### `SetAccount` 2909 2910 The `SetAccount` configures the account to use for the automatic ticket buyer. 2911 2912 **Request:** `SetAccountRequest` 2913 2914 - `uint32 account`: The account number to use for purchasing tickets. 2915 2916 **Response:** `SetAccountResponse` 2917 2918 **Expected errors:** 2919 2920 - `FailedPrecondition`: Ticket buyer is not running. 2921 2922 - `FailedPrecondition`: Wallet has not been loaded. 2923 2924 - `NotFound`: The account does not exist. 2925 2926 ___ 2927 2928 #### `SetBalanceToMaintain` 2929 2930 The `SetBalanceToMaintain` configures the balance to maintain for the automatic 2931 ticket buyer. 2932 2933 **Request:** `SetBalanceToMaintainRequest` 2934 2935 - `int64 balance_to_maintain`: The minimum amount of funds to never dip below when purchasing tickets. 2936 2937 **Response:** `SetBalanceToMaintainResponse` 2938 2939 **Expected errors:** 2940 2941 - `FailedPrecondition`: Ticket buyer is not running. 2942 2943 - `InvalidArgument`: An invalid balance to maintain was specified. 2944 2945 ___ 2946 2947 #### `SetMaxFee` 2948 2949 The `SetMaxFee` configures the maximum ticket fee per KB for the automatic 2950 ticket buyer. 2951 2952 **Request:** `SetMaxFeeRequest` 2953 2954 - `int64 max_fee_per_kb`: The maximum ticket fee amount per KB. 2955 2956 **Response:** `SetMaxFeeResponse` 2957 2958 **Expected errors:** 2959 2960 - `FailedPrecondition`: Ticket buyer is not running. 2961 2962 - `InvalidArgument`: An invalid maximum ticket fee amount per KB was specified. 2963 2964 ___ 2965 2966 #### `SetMaxPriceRelative` 2967 2968 The `SetMaxPriceRelative` configures the maximum relative ticket price for the 2969 automatic ticket buyer. 2970 2971 **Request:** `SetMaxPriceRelativeRequest` 2972 2973 - `double max_price_relative`: The scaling factor for setting the maximum ticket price, multiplied by the average price. 2974 2975 **Response:** `SetMaxPriceRelativeResponse` 2976 2977 **Expected errors:** 2978 2979 - `FailedPrecondition`: Ticket buyer is not running. 2980 2981 - `InvalidArgument`: An invalid maximum ticket price was specified. 2982 2983 ___ 2984 2985 #### `SetMaxPriceAbsolute` 2986 2987 The `SetMaxPriceAbsolute` configures the maximum absolute ticket price for the 2988 automatic ticket buyer. 2989 2990 **Request:** `SetMaxPriceAbsoluteRequest` 2991 2992 - `int64 max_price_absolute`: The maximum absolute ticket price. 2993 2994 **Response:** `SetMaxPriceAbsoluteResponse` 2995 2996 **Expected errors:** 2997 2998 - `FailedPrecondition`: Ticket buyer is not running. 2999 3000 - `InvalidArgument`: An invalid maximum ticket price was specified. 3001 3002 ___ 3003 3004 #### `SetVotingAddress` 3005 3006 The `SetVotingAddress` configures the ticket address for the automatic ticket 3007 buyer. 3008 3009 **Request:** `SetVotingAddressRequest` 3010 3011 - `string ticket_address`: The address to delegate voting rights to. 3012 3013 **Response:** `SetVotingAddressResponse` 3014 3015 **Expected errors:** 3016 3017 - `FailedPrecondition`: Voting buyer is not running. 3018 3019 - `FailedPrecondition`: Wallet has not been loaded. 3020 3021 - `InvalidArgument`: An invalid voting address was specified. 3022 3023 ___ 3024 3025 #### `SetPoolAddress` 3026 3027 The `SetPoolAddress` configures the pool address for the automatic ticket buyer. 3028 3029 **Request:** `SetPoolAddressRequest` 3030 3031 - `string pool_address`: The stake pool address where ticket fees will go to. 3032 3033 **Response:** `SetPoolAddressResponse` 3034 3035 **Expected errors:** 3036 3037 - `FailedPrecondition`: Ticket buyer is not running. 3038 3039 - `FailedPrecondition`: Wallet has not been loaded. 3040 3041 - `InvalidArgument`: Pool address was specified, but pool fees were not. 3042 3043 - `InvalidArgument`: Pool address was not specified, but pool fees were. 3044 3045 - `InvalidArgument`: An invalid pool address was specified. 3046 3047 ___ 3048 3049 #### `SetPoolFees` 3050 3051 The `SetPoolFees` configures the pool fees for the automatic ticket buyer. 3052 3053 **Request:** `SetPoolFeesRequest` 3054 3055 - `double pool_fees`: The absolute per ticket fee mandated by the stake pool as a percent. 3056 3057 **Response:** `SetPoolFeesResponse` 3058 3059 **Expected errors:** 3060 3061 - `FailedPrecondition`: Ticket buyer is not running. 3062 3063 - `InvalidArgument`: Pool address was specified, but pool fees were not. 3064 3065 - `InvalidArgument`: Pool address was not specified, but pool fees were. 3066 3067 - `InvalidArgument`: And invalid pool fees amount was given, either too large or too small. 3068 3069 ___ 3070 3071 #### `SetMaxPerBlock` 3072 3073 The `SetMaxPerBlock` configures the maximum tickets per block for the automatic 3074 ticket buyer. 3075 3076 **Request:** `SetMaxPerBlockRequest` 3077 3078 - `int64 max_per_block`: The maximum tickets per block. Negative number indicates one ticket every n blocks. 3079 3080 **Response:** `SetMaxPerBlockResponse` 3081 3082 **Expected errors:** 3083 3084 - `FailedPrecondition`: Ticket buyer is not running. 3085 3086 ## `TicketBuyerV2Service` 3087 3088 The `TicketBuyerV2Service` service provides RPC clients with the ability to 3089 launch the V2 ticket buyer. 3090 3091 **Methods:** 3092 3093 - [`RunTicketBuyer`](#runautobuyer) 3094 3095 ### Methods 3096 3097 #### `RunTicketBuyer` 3098 3099 The `RunTicketBuyer` starts a new V2 ticket buyer for the specified account. 3100 The users may specify a balance to maintain as well as various settings for purchasing tickets for stakepools. 3101 3102 **Request:** `RunTicketBuyerRequest` 3103 3104 - `bytes passphrase`: The private passphrase to unlock the wallet. 3105 3106 - `uint32 account`: The account number from which to purchase the tickets. 3107 3108 - `uint32 voting_account`: The account that will be used for the voting address (if no voting address is specified.) 3109 3110 - `int64 balance_to_maintain`: When set, the account will purchase as many tickets as possible without going under this amount. 3111 3112 - `string voting_address`: The address to give the tickets purchased voting rights. 3113 3114 - `string pool_address`: The address that will be used in any stakepool fee commitment utxos. 3115 3116 - `double pool_fees`: The percentage used to calculate the proper fee in the stakepool fee commitment utxos. 3117 3118 **Response:** `stream RunTicketBuyerResponse` 3119 3120 **Expected errors:** 3121 3122 - `FailedPrecondition`: Wallet has not been loaded. 3123 3124 - `InvalidArgument`: An invalid voting address was used. 3125 3126 - `InvalidArgument`: An invalid pool address was used. 3127 3128 - `InvalidArgument`: A negative balance to maintain given. 3129 3130 ## `AccountMixerService` 3131 3132 The `AccountMixerService` service provides RPC clients with the ability to 3133 launch the V2 ticket buyer. 3134 3135 **Methods:** 3136 3137 - [`RunAccountMixer`](#runautobuyer) 3138 3139 ### Methods 3140 3141 #### `RunAccountMixer` 3142 3143 The `RunAccountMixer` starts a new account mixer for the specified account (and branch). 3144 3145 **Request:** `RunAccountMixerRequest` 3146 3147 - `bytes passphrase`: The private passphrase to unlock the wallet. 3148 3149 - `uint32 mixed_account`: The account number to which the mixing funds should end up. 3150 3151 - `uint32 mixed_account_branch`: The branch number to which the mixing funds should end up. 3152 3153 - `uint32 change_account`: The account that will be used for any unmixed change that is waiting to be mixed. 3154 3155 - `string cspp_server`: The CSPP mixing server URL and port. 3156 3157 **Response:** `stream RunAccountMixerResponse` 3158 3159 **Expected errors:** 3160 3161 - `FailedPrecondition`: Wallet has not been loaded. 3162 3163 ## `AgendaService` 3164 3165 The `AgendaService` service provides RPC clients with the ability to query the 3166 agendas of the latest supported stake version. 3167 3168 **Methods:** 3169 3170 - [`Agendas`](#agendas) 3171 3172 ### Methods 3173 3174 #### `Agendas` 3175 3176 The `Agendas` method queries for defined agendas in the latest stake version 3177 supported by this software. 3178 3179 **Request:** `AgendasRequest` 3180 3181 **Response:** `AgendasResponse` 3182 3183 - `uint32 version`: The latest stake version supported by the software and the 3184 version of the included agendas. 3185 3186 - `repeated Agenda agendas`: All agendas defined by the latest supported stake 3187 version. 3188 3189 **Nested message:** `Agenda` 3190 3191 - `string id`: The ID for this agenda. 3192 3193 - `string description`: A description of what the agenda is voting about. 3194 3195 - `uint32 mask`: The bitmask of bits allocated to defining votes for this 3196 agenda. At the moment this is limited to 16 bits in the software, but 3197 protobuf v3 requires this field to be at least 32 bits wide. 3198 3199 - `repeated Choice choices`: All possible vote choices for the agenda. 3200 3201 - `int64 start_time`: The Unix time that the agenda voting begins. 3202 3203 - `int64 expire_time`: The Unix time that the agenda voting expires. 3204 3205 **Nested message:** `Choice` 3206 3207 - `string id`: The ID for this agenda vote choice. 3208 3209 - `string description`: A description of what this agenda vote entails. 3210 3211 - `uint32 bits`: The bitmask of bits used to vote for this choice. At the 3212 moment this is limited to 16 bits in the software, but protobuf v3 requires 3213 this field to be at least 32 bits wide. 3214 3215 - `bool is_abstain`: Whether the choice describes to abstain from the vote. 3216 3217 - `bool is_no`: Whether the choice describes to vote against all changes and 3218 keep the current consensus rules (if the vote is for a consensus change). 3219 3220 **ExpectedErrors:** None 3221 3222 ## `VotingService` 3223 3224 The `VotingService` service provides RPC clients with the ability to query and 3225 set the vote preferences of a voting wallet. 3226 3227 **Methods:** 3228 3229 - [`VoteChoices`](#votechoices) 3230 - [`SetVoteChoices`](#setvotechoices) 3231 3232 ### Methods 3233 3234 #### `VoteChoices` 3235 3236 The `VoteChoices` method queries for the current vote choices used to define 3237 vote bits of the latest supported stake version agendas. 3238 3239 **Request:** `VoteChoicesRequest` 3240 3241 - `bytes ticket_hash`: The hash of the ticket to return vote choices for. If 3242 hash is not specified or the ticket has no choices set, the default vote 3243 choices are returned. 3244 3245 **Response:** `VoteChoicesResponse` 3246 3247 - `uint32 version`: The latest stake version supported by the software and the 3248 version of the included agendas. 3249 3250 - `repeated Choice choices`: The currently configured agenda vote choices, 3251 including abstaining votes. 3252 3253 **Nested message:** `Choice` 3254 3255 - `string agenda_id`: The ID for the agenda the choice concerns. 3256 3257 - `string agenda_description`: A description of the agenda the choice 3258 concerns. 3259 3260 - `string choice_id`: The ID of the current choice for this agenda. 3261 3262 - `string choice_description`: A description of the current choice for this 3263 agenda. 3264 3265 - `uint32 votebits`: The votebits of the currently-configured choices. 3266 3267 **ExpectedErrors:** None 3268 3269 ___ 3270 3271 #### `SetVoteChoices` 3272 3273 The `SetVoteChoices` method sets choices for defined agendas in the latest stake version 3274 supported by this software. 3275 3276 **Request:** `SetVoteChoicesRequest` 3277 3278 - `repeated Choice choices`: Choices for each agenda to modify. If a choice is 3279 specified multiple times for an agenda, the last takes preference. 3280 3281 **Nested message:** `Choice` 3282 3283 - `string agenda_id`: The ID for the agenda to modify. 3284 3285 - `string choice_id`: The ID for the choice to choose. 3286 3287 - `bytes ticket_hash`: The hash of the ticket to set choices for. 3288 3289 **Response:** `SetVoteChoicesResponse` 3290 3291 - `uint32 votebits`: The votebits for the wallet after setting choices. 3292 3293 **ExpectedErrors:** 3294 3295 - `InvalidArgument`: An agenda ID or choice ID is not valid for the latest 3296 supported stake version. 3297 3298 ## `MessageVerificationService` 3299 3300 The `MessageVerificationService` service provides the caller with the ability to 3301 verify that a message was signed using the private key of a particular address. 3302 3303 **Methods:** 3304 3305 - [`VerifyMessage`](#verifymessage) 3306 3307 ### Methods 3308 3309 #### `VerifyMessage` 3310 3311 The `VerifyMessage` method verifies that a signature is a valid signature of a 3312 message and was created using the secp256k1 private key for an address. 3313 3314 **Request:** `VerifyMessageRequest` 3315 3316 - `string address`: The address to compare against a recovered public key from 3317 the signature. Must be secp256k1 P2PK or P2PKH. 3318 3319 - `string message`: The message to verify. 3320 3321 - `bytes signature`: The signature of the message. 3322 3323 **Response:** `VerifyMessageResponse` 3324 3325 - `bool valid`: The signature is valid and was signed by the private key of the 3326 address. 3327 3328 **Expected errors:** 3329 3330 - `InvalidArgument`: The address cannot be decoded or is not secp256k1 P2PK or 3331 P2PKH. 3332 3333 ## `DecodeMessageService` 3334 3335 The `DecodeMessageService` service provides the caller with the ability to 3336 decode various messages and structures given their serialized (binary) 3337 representation. 3338 3339 Unless otherwise noted, all serialized parameters on requests **MUST** belong 3340 to the same network (mainnet/testnet) as the wallet, otherwise the returned 3341 data may contain incorrect information. 3342 3343 **Methods:** 3344 3345 - [`DecodeRawTransaction`](#decoderawtransaction) 3346 3347 ### Methods 3348 3349 #### `DecodeRawTransaction` 3350 3351 The `DecodeRawTransaction` method takes a serialized transaction and decodes as 3352 much information as possible. 3353 3354 **Request:** `DecodeRawTransactionRequest` 3355 3356 - `bytes serialized_transaction`: The raw, serialized transaction. 3357 3358 **Response:** `DecodeRawTransactionResponse` 3359 3360 - `DecodedTransaction transaction`: The decoded transaction data. 3361 3362 The `DecodedTransaction` message is documented [here](#decodedtransaction). 3363 3364 **Expected errors:** 3365 3366 - `InvalidArgument`: The serialized transaction could not be decoded. 3367 3368 ## NetworkService 3369 3370 The `NetworkService` service provides the caller with the ability to query and 3371 perform actions in the P2P network related to blockchain data not necessarily 3372 tracked by the wallet. 3373 3374 In order to use this service, the wallet must have already been loaded. Most 3375 operations fail if the wallet is not connected to an underlying dcrd instance 3376 (when running in regular RPC mode) or to remote peers (when running in SPV mode). 3377 3378 **Methods** 3379 3380 - [`GetRawBlock`](#GetRawBlock) 3381 3382 ### Methods 3383 3384 #### `GetRawBlock` 3385 3386 The `GetRawBlock` method queries the network for a full blockchain block. The 3387 returned block is **not** cached by the wallet, therefore callers are advised 3388 to consider the bandwidth implications of requesting a large number of blocks. 3389 3390 **Request:** `GetRawBlockRequest` 3391 3392 - `bytes block_hash`: The hash of the desired block. If unspecified, the block 3393 is fetched by `block_height`. 3394 3395 - `sint32 block_height` The height of the (mainchain) block to fetch. The wallet 3396 must have seen this block height for the request to succeed. 3397 3398 **Response:** `GetRawBlockResponse` 3399 3400 - `bytes block`: The serialized raw block. 3401 3402 **Expected errors:** 3403 3404 - `Unavailable`: The wallet is not currently connected to the p2p network.