Convert RPC server to btcjson v2.

Closes #227.
This commit is contained in:
Josh Rickmar 2015-04-17 16:05:38 -04:00
parent d050a32cb2
commit 43aef7db3c
7 changed files with 1391 additions and 469 deletions

View file

@ -0,0 +1,99 @@
// Copyright (c) 2015 Conformal Systems LLC <info@conformal.com>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//+build generate
package main
import (
"fmt"
"log"
"os"
"strings"
"github.com/btcsuite/btcd/btcjson/v2/btcjson"
"github.com/btcsuite/btcwallet/internal/rpchelp"
)
var outputFile = func() *os.File {
fi, err := os.Create("rpcserverhelp.go")
if err != nil {
log.Fatal(err)
}
return fi
}()
func writefln(format string, args ...interface{}) {
_, err := fmt.Fprintf(outputFile, format, args...)
if err != nil {
log.Fatal(err)
}
_, err = outputFile.Write([]byte{'\n'})
if err != nil {
log.Fatal(err)
}
}
func writeLocaleHelp(locale, goLocale string, descs map[string]string) {
funcName := "helpDescs" + goLocale
writefln("func %s() map[string]string {", funcName)
writefln("return map[string]string{")
for i := range rpchelp.Methods {
m := &rpchelp.Methods[i]
helpText, err := btcjson.GenerateHelp(m.Method, descs, m.ResultTypes...)
if err != nil {
log.Fatal(err)
}
writefln("%q: %q,", m.Method, helpText)
}
writefln("}")
writefln("}")
}
func writeLocales() {
writefln("var localeHelpDescs = map[string]func() map[string]string{")
for _, h := range rpchelp.HelpDescs {
writefln("%q: helpDescs%s,", h.Locale, h.GoLocale)
}
writefln("}")
}
func writeUsage() {
usageStrs := make([]string, len(rpchelp.Methods))
var err error
for i := range rpchelp.Methods {
usageStrs[i], err = btcjson.MethodUsageText(rpchelp.Methods[i].Method)
if err != nil {
log.Fatal(err)
}
}
usages := strings.Join(usageStrs, "\n")
writefln("var requestUsages = %q", usages)
}
func main() {
defer outputFile.Close()
writefln("// AUTOGENERATED by internal/rpchelp/genrpcserverhelp.go; do not edit.")
writefln("")
writefln("package main")
writefln("")
for _, h := range rpchelp.HelpDescs {
writeLocaleHelp(h.Locale, h.GoLocale, h.Descs)
writefln("")
}
writeLocales()
writefln("")
writeUsage()
}

View file

@ -0,0 +1,399 @@
// Copyright (c) 2015 Conformal Systems LLC <info@conformal.com>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//+build !generate
package rpchelp
var helpDescsEnUS = map[string]string{
// AddMultisigAddressCmd help.
"addmultisigaddress--synopsis": "Generates and imports a multisig address and redeeming script to the 'imported' account.",
"addmultisigaddress-account": "DEPRECATED -- Unused (all imported addresses belong to the imported account)",
"addmultisigaddress-keys": "Pubkeys and/or pay-to-pubkey-hash addresses to partially control the multisig address",
"addmultisigaddress-nrequired": "The number of signatures required to redeem outputs paid to this address",
"addmultisigaddress--result0": "The imported pay-to-script-hash address",
// CreateMultisigCmd help.
"createmultisig--synopsis": "Generate a multisig address and redeem script.",
"createmultisig-keys": "Pubkeys and/or pay-to-pubkey-hash addresses to partially control the multisig address",
"createmultisig-nrequired": "The number of signatures required to redeem outputs paid to this address",
// CreateMultisigResult help.
"createmultisigresult-address": "The generated pay-to-script-hash address",
"createmultisigresult-redeemScript": "The script required to redeem outputs paid to the multisig address",
// DumpPrivKeyCmd help.
"dumpprivkey--synopsis": "Returns the private key in WIF encoding that controls some wallet address.",
"dumpprivkey-address": "The address to return a private key for",
"dumpprivkey--result0": "The WIF-encoded private key",
// GetAccountCmd help.
"getaccount--synopsis": "DEPRECATED -- Lookup the account name that some wallet address belongs to.",
"getaccount-address": "The address to query the account for",
"getaccount--result0": "The name of the account that 'address' belongs to",
// GetAccountAddressCmd help.
"getaccountaddress--synopsis": "DEPRECATED -- Returns the most recent external payment address for an account that has not been seen publicly.\n" +
"A new address is generated for the account if the most recently generated address has been seen on the blockchain or in mempool.",
"getaccountaddress-account": "The account of the returned address",
"getaccountaddress--result0": "The unused address for 'account'",
// GetAddressesByAccountCmd help.
"getaddressesbyaccount--synopsis": "DEPRECATED -- Returns all addresses strings controlled by a single account.",
"getaddressesbyaccount-account": "Account name to fetch addresses for",
"getaddressesbyaccount--result0": "All addresses controlled by 'account'",
// GetBalanceCmd help.
"getbalance--synopsis": "Calculates and returns the balance of one or all accounts.",
"getbalance-minconf": "Minimum number of block confirmations required before an unspent output's value is included in the balance",
"getbalance-account": "DEPRECATED -- The account name to query the balance for, or '*' to consider all accounts",
"getbalance--condition0": "account!=*",
"getbalance--condition1": "account=*",
"getbalance--result0": "The balance of 'account' valued in bitcoin",
"getbalance--result1": "The balance of all accounts valued in bitcoin",
// GetBestBlockHashCmd help.
"getbestblockhash--synopsis": "Returns the hash of the newest block in the best chain that wallet has finished syncing with.",
"getbestblockhash--result0": "The hash of the most recent synced-to block",
// GetBlockCountCmd help.
"getblockcount--synopsis": "Returns the blockchain height of the newest block in the best chain that wallet has finished syncing with.",
"getblockcount--result0": "The blockchain height of the most recent synced-to block",
// GetInfoCmd help.
"getinfo--synopsis": "Returns a JSON object containing various state info.",
// InfoWalletResult help.
"infowalletresult-version": "The version of the server",
"infowalletresult-protocolversion": "The latest supported protocol version",
"infowalletresult-blocks": "The number of blocks processed",
"infowalletresult-timeoffset": "The time offset",
"infowalletresult-connections": "The number of connected peers",
"infowalletresult-proxy": "The proxy used by the server",
"infowalletresult-difficulty": "The current target difficulty",
"infowalletresult-testnet": "Whether or not server is using testnet",
"infowalletresult-relayfee": "The minimum relay fee for non-free transactions in BTC/KB",
"infowalletresult-errors": "Any current errors",
"infowalletresult-paytxfee": "The increment used each time more fee is required for an authored transaction",
"infowalletresult-balance": "The balance of all accounts calculated with one block confirmation",
"infowalletresult-walletversion": "The version of the address manager database",
"infowalletresult-unlocked_until": "Unset",
"infowalletresult-keypoolsize": "Unset",
"infowalletresult-keypoololdest": "Unset",
// GetNewAddressCmd help.
"getnewaddress--synopsis": "Generates and returns a new payment address.",
"getnewaddress-account": "DEPRECATED -- Account name the new address will belong to",
"getnewaddress--result0": "The payment address",
// GetRawChangeAddressCmd help.
"getrawchangeaddress--synopsis": "Generates and returns a new internal payment address for use as a change address in raw transactions.",
"getrawchangeaddress-account": "Account name the new internal address will belong to",
"getrawchangeaddress--result0": "The internal payment address",
// GetReceivedByAccountCmd help.
"getreceivedbyaccount--synopsis": "DEPRECATED -- Returns the total amount received by addresses of some account, including spent outputs.",
"getreceivedbyaccount-account": "Account name to query total received amount for",
"getreceivedbyaccount-minconf": "Minimum number of block confirmations required before an output's value is included in the total",
"getreceivedbyaccount--result0": "The total received amount valued in bitcoin",
// GetReceivedByAddressCmd help.
"getreceivedbyaddress--synopsis": "Returns the total amount received by a single address, including spent outputs.",
"getreceivedbyaddress-address": "Payment address which received outputs to include in total",
"getreceivedbyaddress-minconf": "Minimum number of block confirmations required before an output's value is included in the total",
"getreceivedbyaddress--result0": "The total received amount valued in bitcoin",
// GetTransactionCmd help.
"gettransaction--synopsis": "Returns a JSON object with details regarding a transaction relevant to this wallet.",
"gettransaction-txid": "Hash of the transaction to query",
"gettransaction-includewatchonly": "Also consider transactions involving watched addresses",
// HelpCmd help.
"help--synopsis": "Returns a list of all commands or help for a specified command.",
"help-command": "The command to retrieve help for",
"help--condition0": "no command provided",
"help--condition1": "command specified",
"help--result0": "List of commands",
"help--result1": "Help for specified command",
// GetTransactionResult help.
"gettransactionresult-amount": "The total amount this transaction credits to the wallet, valued in bitcoin",
"gettransactionresult-fee": "The total input value minus the total output value, or 0 if 'txid' is not a sent transaction",
"gettransactionresult-confirmations": "The number of block confirmations of the transaction",
"gettransactionresult-blockhash": "The hash of the block this transaction is mined in, or the empty string if unmined",
"gettransactionresult-blockindex": "Unset",
"gettransactionresult-blocktime": "The Unix time of the block header this transaction is mined in, or 0 if unmined",
"gettransactionresult-txid": "The transaction hash",
"gettransactionresult-walletconflicts": "Unset",
"gettransactionresult-time": "The earliest Unix time this transaction was known to exist",
"gettransactionresult-timereceived": "The earliest Unix time this transaction was known to exist",
"gettransactionresult-details": "Additional details for each recorded wallet credit and debit",
"gettransactionresult-hex": "The transaction encoded as a hexadecimal string",
// GetTransactionDetailsResult help.
"gettransactiondetailsresult-account": "DEPRECATED -- Unset",
"gettransactiondetailsresult-address": "The address an output was paid to, or the empty string if the output is nonstandard or this detail is regarding a transaction input",
"gettransactiondetailsresult-category": `The kind of detail: "send" for sent transactions, "immature" for immature coinbase outputs, "generate" for mature coinbase outputs, or "recv" for all other received outputs`,
"gettransactiondetailsresult-amount": "The amount of a received output",
"gettransactiondetailsresult-fee": "The included fee for a sent transaction",
// ImportPrivKeyCmd help.
"importprivkey--synopsis": "Imports a WIF-encoded private key to the 'imported' account.",
"importprivkey-privkey": "The WIF-encoded private key",
"importprivkey-label": "Unused (all imported addresses belong to the imported account)",
"importprivkey-rescan": "Rescan the blockchain (since the genesis block) for outputs controlled by the imported key",
// KeypoolRefillCmd help.
"keypoolrefill--synopsis": "DEPRECATED -- This request does nothing since no keypool is maintained.",
"keypoolrefill-newsize": "Unused",
// ListAccountsCmd help.
"listaccounts--synopsis": "DEPRECATED -- Returns a JSON object of all accounts and their balances.",
"listaccounts-minconf": "Minimum number of block confirmations required before an unspent output's value is included in the balance",
"listaccounts--result0--desc": "JSON object with account names as keys and bitcoin amounts as values",
"listaccounts--result0--key": "The account name",
"listaccounts--result0--value": "The account balance valued in bitcoin",
// ListLockUnspentCmd help.
"listlockunspent--synopsis": "Returns a JSON array of outpoints marked as locked (with lockunspent) for this wallet session.",
// TransactionInput help.
"transactioninput-txid": "The transaction hash of the referenced output",
"transactioninput-vout": "The output index of the referenced output",
// ListReceivedByAccountCmd help.
"listreceivedbyaccount--synopsis": "DEPRECATED -- Returns a JSON array of objects listing all accounts and the total amount received by each account.",
"listreceivedbyaccount-minconf": "Minimum number of block confirmations required before a transaction is considered",
"listreceivedbyaccount-includeempty": "Unused",
"listreceivedbyaccount-includewatchonly": "Unused",
// ListReceivedByAccountResult help.
"listreceivedbyaccountresult-account": "The name of the account",
"listreceivedbyaccountresult-amount": "Total amount received by payment addresses of the account valued in bitcoin",
"listreceivedbyaccountresult-confirmations": "Number of block confirmations of the most recent transaction relevant to the account",
// ListReceivedByAddressCmd help.
"listreceivedbyaddress--synopsis": "Returns a JSON array of objects listing wallet payment addresses and their total received amounts.",
"listreceivedbyaddress-minconf": "Minimum number of block confirmations required before a transaction is considered",
"listreceivedbyaddress-includeempty": "Unused",
"listreceivedbyaddress-includewatchonly": "Unused",
// ListReceivedByAddressResult help.
"listreceivedbyaddressresult-account": "DEPRECATED -- Unset",
"listreceivedbyaddressresult-address": "The payment address",
"listreceivedbyaddressresult-amount": "Total amount received by the payment address valued in bitcoin",
"listreceivedbyaddressresult-confirmations": "Number of block confirmations of the most recent transaction relevant to the address",
"listreceivedbyaddressresult-txids": "Transaction hashes of all transactions involving this address",
"listreceivedbyaddressresult-involvesWatchonly": "Unset",
// ListSinceBlockCmd help.
"listsinceblock--synopsis": "Returns a JSON array of objects listing details of wallet transactions after some block.",
"listsinceblock-blockhash": "Hash of the parent block of the first block to consider transactions from",
"listsinceblock-targetconfirmations": "Minimum number of block confirmations required before a transaction is considered",
"listsinceblock-includewatchonly": "Unused",
// ListSinceBlockResult help.
"listsinceblockresult-transactions": "JSON array of objects containing verbose details of the each transaction",
"listsinceblockresult-lastblock": "Hash of the latest-synced block to be used in later calls to listsinceblock",
// ListTransactionsResult help.
"listtransactionsresult-account": "DEPRECATED -- Unset",
"listtransactionsresult-address": "Payment address for a transaction output",
"listtransactionsresult-category": `The kind of transaction: "send" for sent transactions, "immature" for immature coinbase outputs, "generate" for mature coinbase outputs, or "recv" for all other received outputs. Note: A single output may be included multiple times under different categories`,
"listtransactionsresult-amount": "The value of the transaction output valued in bitcoin",
"listtransactionsresult-fee": "The total input value minus the total output value for sent transactions",
"listtransactionsresult-confirmations": "The number of block confirmations of the transaction",
"listtransactionsresult-generated": "Whether the transaction output is a coinbase output",
"listtransactionsresult-blockhash": "The hash of the block this transaction is mined in, or the empty string if unmined",
"listtransactionsresult-blockindex": "Unset",
"listtransactionsresult-blocktime": "The Unix time of the block header this transaction is mined in, or 0 if unmined",
"listtransactionsresult-txid": "The hash of the transaction",
"listtransactionsresult-walletconflicts": "Unset",
"listtransactionsresult-time": "The earliest Unix time this transaction was known to exist",
"listtransactionsresult-timereceived": "The earliest Unix time this transaction was known to exist",
"listtransactionsresult-comment": "Unset",
"listtransactionsresult-otheraccount": "Unset",
// ListTransactionsCmd help.
"listtransactions--synopsis": "Returns a JSON array of objects containing verbose details for wallet transactions.",
"listtransactions-account": "DEPRECATED -- Unused",
"listtransactions-count": "Maximum number of transactions to create results from",
"listtransactions-from": "Number of transactions to skip before results are created",
"listtransactions-includewatchonly": "Unused",
// ListUnspentCmd help.
"listunspent--synopsis": "Returns a JSON array of objects representing unlocked unspent outputs controlled by wallet keys.",
"listunspent-minconf": "Minimum number of block confirmations required before a transaction output is considered",
"listunspent-maxconf": "Maximum number of block confirmations required before a transaction output is excluded",
"listunspent-addresses": "If set, limits the returned details to unspent outputs received by any of these payment addresses",
// ListUnspentResult help.
"listunspentresult-txid": "The transaction hash of the referenced output",
"listunspentresult-vout": "The output index of the referenced output",
"listunspentresult-address": "The payment address that received the output",
"listunspentresult-account": "The account associated with the receiving payment address",
"listunspentresult-scriptPubKey": "The output script encoded as a hexadecimal string",
"listunspentresult-redeemScript": "Unset",
"listunspentresult-amount": "The amount of the output valued in bitcoin",
"listunspentresult-confirmations": "The number of block confirmations of the transaction",
// LockUnspentCmd help.
"lockunspent--synopsis": "Locks or unlocks an unspent output.\n" +
"Locked outputs are not chosen for transaction inputs of authored transactions and are not included in 'listunspent' results.\n" +
"Locked outputs are volatile and are not saved across wallet restarts.\n" +
"If unlock is true and no transaction outputs are specified, all locked outputs are marked unlocked.",
"lockunspent-unlock": "True to unlock outputs, false to lock",
"lockunspent-transactions": "Transaction outputs to lock or unlock",
"lockunspent--result0": "The boolean 'true'",
// SendFromCmd help.
"sendfrom--synopsis": "DEPRECATED -- Authors, signs, and sends a transaction that outputs some amount to a payment address.\n" +
"A change output is automatically included to send extra output value back to the original account.",
"sendfrom-fromaccount": "Account to pick unspent outputs from",
"sendfrom-toaddress": "Address to pay",
"sendfrom-amount": "Amount to send to the payment address valued in bitcoin",
"sendfrom-minconf": "Minimum number of block confirmations required before a transaction output is eligible to be spent",
"sendfrom-comment": "Unused",
"sendfrom-commentto": "Unused",
"sendfrom--result0": "The transaction hash of the sent transaction",
// SendManyCmd help.
"sendmany--synopsis": "Authors, signs, and sends a transaction that outputs to many payment addresses.\n" +
"A change output is automatically included to send extra output value back to the original account.",
"sendmany-fromaccount": "DEPRECATED -- Account to pick unspent outputs from",
"sendmany-amounts": "Pairs of payment addresses and the output amount to pay each",
"sendmany-amounts--desc": "JSON object using payment addresses as keys and output amounts valued in bitcoin to send to each address",
"sendmany-amounts--key": "Address to pay",
"sendmany-amounts--value": "Amount to send to the payment address valued in bitcoin",
"sendmany-minconf": "Minimum number of block confirmations required before a transaction output is eligible to be spent",
"sendmany-comment": "Unused",
"sendmany--result0": "The transaction hash of the sent transaction",
// SendToAddressCmd help.
"sendtoaddress--synopsis": "Authors, signs, and sends a transaction that outputs some amount to a payment address.\n" +
"Unlike sendfrom, outputs are always chosen from the default account.\n" +
"A change output is automatically included to send extra output value back to the original account.",
"sendtoaddress-address": "Address to pay",
"sendtoaddress-amount": "Amount to send to the payment address valued in bitcoin",
"sendtoaddress-comment": "Unused",
"sendtoaddress-commentto": "Unused",
"sendtoaddress--result0": "The transaction hash of the sent transaction",
// SetTxFeeCmd help.
"settxfee--synopsis": "Modify the increment used each time more fee is required for an authored transaction.",
"settxfee-amount": "The new fee increment valued in bitcoin",
"settxfee--result0": "The boolean 'true'",
// SignMessageCmd help.
"signmessage--synopsis": "Signs a message using the private key of a payment address.",
"signmessage-address": "Payment address of private key used to sign the message with",
"signmessage-message": "Message to sign",
"signmessage--result0": "The signed message encoded as a base64 string",
// SignRawTransactionCmd help.
"signrawtransaction--synopsis": "Signs transaction inputs using private keys from this wallet and request.\n" +
"The valid flags options are ALL, NONE, SINGLE, ALL|ANYONECANPAY, NONE|ANYONECANPAY, and SINGLE|ANYONECANPAY.",
"signrawtransaction-rawtx": "Unsigned or partially unsigned transaction to sign encoded as a hexadecimal string",
"signrawtransaction-inputs": "Additional data regarding inputs that this wallet may not be tracking",
"signrawtransaction-privkeys": "Additional WIF-encoded private keys to use when creating signatures",
"signrawtransaction-flags": "Sighash flags",
// SignRawTransactionResult help.
"signrawtransactionresult-hex": "The resulting transaction encoded as a hexadecimal string",
"signrawtransactionresult-complete": "Whether all input signatures have been created",
// ValidateAddressCmd help.
"validateaddress--synopsis": "Verify that an address is valid.\n" +
"Extra details are returned if the address is controlled by this wallet.\n" +
"The following fields are valid only when the address is controlled by this wallet (ismine=true): isscript, pubkey, iscompressed, account, addresses, hex, script, and sigsrequired.\n" +
"The following fields are only valid when address has an associated public key: pubkey, iscompressed.\n" +
"The following fields are only valid when address is a pay-to-script-hash address: addresses, hex, and script.\n" +
"If the address is a multisig address controlled by this wallet, the multisig fields will be left unset if the wallet is locked since the redeem script cannot be decrypted.",
"validateaddress-address": "Address to validate",
// ValidateAddressWalletResult help.
"validateaddresswalletresult-isvalid": "Whether or not the address is valid",
"validateaddresswalletresult-address": "The payment address (only when isvalid is true)",
"validateaddresswalletresult-ismine": "Whether this address is controlled by the wallet (only when isvalid is true)",
"validateaddresswalletresult-iswatchonly": "Unset",
"validateaddresswalletresult-isscript": "Whether the payment address is a pay-to-script-hash address (only when isvalid is true)",
"validateaddresswalletresult-pubkey": "The associated public key of the payment address, if any (only when isvalid is true)",
"validateaddresswalletresult-iscompressed": "Whether the address was created by hashing a compressed public key, if any (only when isvalid is true)",
"validateaddresswalletresult-account": "The account this payment address belongs to (only when isvalid is true)",
"validateaddresswalletresult-addresses": "All associated payment addresses of the script if address is a multisig address (only when isvalid is true)",
"validateaddresswalletresult-hex": "The redeem script ",
"validateaddresswalletresult-script": "The class of redeem script for a multisig address",
"validateaddresswalletresult-sigsrequired": "The number of required signatures to redeem outputs to the multisig address",
// VerifyMessageCmd help.
"verifymessage--synopsis": "Verify a message was signed with the associated private key of some address.",
"verifymessage-address": "Address used to sign message",
"verifymessage-signature": "The signature to verify",
"verifymessage-message": "The message to verify",
"verifymessage--result0": "Whether the message was signed with the private key of 'address'",
// WalletLockCmd help.
"walletlock--synopsis": "Lock the wallet.",
// WalletPassphraseCmd help.
"walletpassphrase--synopsis": "Unlock the wallet.",
"walletpassphrase-passphrase": "The wallet passphrase",
"walletpassphrase-timeout": "The number of seconds to wait before the wallet automatically locks",
// WalletPassphraseChangeCmd help.
"walletpassphrasechange--synopsis": "Change the wallet passphrase.",
"walletpassphrasechange-oldpassphrase": "The old wallet passphrase",
"walletpassphrasechange-newpassphrase": "The new wallet passphrase",
// CreateNewAccountCmd help.
"createnewaccount--synopsis": "Creates a new account.\n" +
"The wallet must be unlocked for this request to succeed.",
"createnewaccount-account": "Name of the new account",
// ExportWatchingWalletCmd help.
"exportwatchingwallet--synopsis": "Creates and returns a duplicate of the wallet database without any private keys to be used as a watching-only wallet.",
"exportwatchingwallet-account": "Unused",
"exportwatchingwallet-download": "Unused",
"exportwatchingwallet--result0": "The watching-only database encoded as a base64 string",
// GetBestBlockCmd help.
"getbestblock--synopsis": "Returns the hash and height of the newest block in the best chain that wallet has finished syncing with.",
// GetBestBlockResult help.
"getbestblockresult-hash": "The hash of the block",
"getbestblockresult-height": "The blockchain height of the block",
// GetUnconfirmedBalanceCmd help.
"getunconfirmedbalance--synopsis": "Calculates the unspent output value of all unmined transaction outputs for an account.",
"getunconfirmedbalance-account": "The account to query the unconfirmed balance for",
"getunconfirmedbalance--result0": "Total amount of all unmined unspent outputs of the account valued in bitcoin.",
// ListAddressTransactionsCmd help.
"listaddresstransactions--synopsis": "Returns a JSON array of objects containing verbose details for wallet transactions pertaining some addresses.",
"listaddresstransactions-addresses": "Addresses to filter transaction results by",
"listaddresstransactions-account": "Unused",
// ListAllTransactionsCmd help.
"listalltransactions--synopsis": "Returns a JSON array of objects in the same format as 'listtransactions' without limiting the number of returned objects.",
"listalltransactions-account": "Unused",
// RenameAccountCmd help.
"renameaccount--synopsis": "Renames an account.",
"renameaccount-oldaccount": "The old account name to rename",
"renameaccount-newaccount": "The new name for the account",
// WalletIsLockedCmd help.
"walletislocked--synopsis": "Returns whether or not the wallet is locked.",
"walletislocked--result0": "Whether the wallet is locked",
}

View file

@ -0,0 +1,89 @@
// Copyright (c) 2015 Conformal Systems LLC <info@conformal.com>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//+build !generate
package rpchelp
import "github.com/btcsuite/btcd/btcjson/v2/btcjson"
// Common return types.
var (
returnsBool = []interface{}{(*bool)(nil)}
returnsNumber = []interface{}{(*float64)(nil)}
returnsString = []interface{}{(*string)(nil)}
returnsStringArray = []interface{}{(*[]string)(nil)}
returnsLTRArray = []interface{}{(*[]btcjson.ListTransactionsResult)(nil)}
)
// Contains all methods and result types that help is generated for, for every
// locale.
var Methods = []struct {
Method string
ResultTypes []interface{}
}{
{"addmultisigaddress", returnsString},
{"createmultisig", []interface{}{(*btcjson.CreateMultiSigResult)(nil)}},
{"dumpprivkey", returnsString},
{"getaccount", returnsString},
{"getaccountaddress", returnsString},
{"getaddressesbyaccount", returnsStringArray},
{"getbalance", append(returnsNumber, returnsNumber[0])},
{"getbestblockhash", returnsString},
{"getblockcount", returnsNumber},
{"getinfo", []interface{}{(*btcjson.InfoWalletResult)(nil)}},
{"getnewaddress", returnsString},
{"getrawchangeaddress", returnsString},
{"getreceivedbyaccount", returnsNumber},
{"getreceivedbyaddress", returnsNumber},
{"gettransaction", []interface{}{(*btcjson.GetTransactionResult)(nil)}},
{"help", append(returnsString, returnsString[0])},
{"importprivkey", nil},
{"keypoolrefill", nil},
{"listaccounts", []interface{}{(*map[string]float64)(nil)}},
{"listlockunspent", []interface{}{(*[]btcjson.TransactionInput)(nil)}},
{"listreceivedbyaccount", []interface{}{(*[]btcjson.ListReceivedByAccountResult)(nil)}},
{"listreceivedbyaddress", []interface{}{(*[]btcjson.ListReceivedByAddressResult)(nil)}},
{"listsinceblock", []interface{}{(*btcjson.ListSinceBlockResult)(nil)}},
{"listtransactions", returnsLTRArray},
{"listunspent", []interface{}{(*btcjson.ListUnspentResult)(nil)}},
{"lockunspent", returnsBool},
{"sendfrom", returnsString},
{"sendmany", returnsString},
{"sendtoaddress", returnsString},
{"settxfee", returnsBool},
{"signmessage", returnsString},
{"signrawtransaction", []interface{}{(*btcjson.SignRawTransactionResult)(nil)}},
{"validateaddress", []interface{}{(*btcjson.ValidateAddressWalletResult)(nil)}},
{"verifymessage", returnsBool},
{"walletlock", nil},
{"walletpassphrase", nil},
{"walletpassphrasechange", nil},
{"createnewaccount", nil},
{"exportwatchingwallet", returnsString},
{"getbestblock", []interface{}{(*btcjson.GetBestBlockResult)(nil)}},
{"getunconfirmedbalance", returnsNumber},
{"listaddresstransactions", returnsLTRArray},
{"listalltransactions", returnsLTRArray},
{"renameaccount", nil},
{"walletislocked", returnsBool},
}
var HelpDescs = []struct {
Locale string // Actual locale, e.g. en_US
GoLocale string // Locale used in Go names, e.g. EnUS
Descs map[string]string
}{
{"en_US", "EnUS", helpDescsEnUS}, // helpdescs_en_US.go
}

109
rpchelp_test.go Normal file
View file

@ -0,0 +1,109 @@
// Copyright (c) 2015 Conformal Systems LLC <info@conformal.com>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package main
import (
"strings"
"testing"
"github.com/btcsuite/btcd/btcjson/v2/btcjson"
"github.com/btcsuite/btcwallet/internal/rpchelp"
)
func serverMethods() map[string]struct{} {
m := make(map[string]struct{})
for method, handlerData := range rpcHandlers {
if !handlerData.noHelp {
m[method] = struct{}{}
}
}
return m
}
// TestRPCMethodHelpGeneration ensures that help text can be generated for every
// method of the RPC server for every supported locale.
func TestRPCMethodHelpGeneration(t *testing.T) {
needsGenerate := false
defer func() {
if needsGenerate && !t.Failed() {
t.Error("Generated help texts are out of date: run 'go generate'")
return
}
if t.Failed() {
t.Log("Regenerate help texts with 'go generate' after fixing")
}
}()
for i := range rpchelp.HelpDescs {
svrMethods := serverMethods()
locale := rpchelp.HelpDescs[i].Locale
generatedDescs := localeHelpDescs[locale]()
for _, m := range rpchelp.Methods {
delete(svrMethods, m.Method)
helpText, err := btcjson.GenerateHelp(m.Method, rpchelp.HelpDescs[i].Descs, m.ResultTypes...)
if err != nil {
t.Errorf("Cannot generate '%s' help for method '%s': missing description for '%s'",
locale, m.Method, err)
continue
}
if !needsGenerate && helpText != generatedDescs[m.Method] {
needsGenerate = true
}
}
for m := range svrMethods {
t.Errorf("Missing '%s' help for method '%s'", locale, m)
}
}
}
// TestRPCMethodUsageGeneration ensures that single line usage text can be
// generated for every supported request of the RPC server.
func TestRPCMethodUsageGeneration(t *testing.T) {
needsGenerate := false
defer func() {
if needsGenerate && !t.Failed() {
t.Error("Generated help usages are out of date: run 'go generate'")
return
}
if t.Failed() {
t.Log("Regenerate help usage with 'go generate' after fixing")
}
}()
svrMethods := serverMethods()
usageStrs := make([]string, 0, len(rpchelp.Methods))
for _, m := range rpchelp.Methods {
delete(svrMethods, m.Method)
usage, err := btcjson.MethodUsageText(m.Method)
if err != nil {
t.Errorf("Cannot generate single line usage for method '%s': %v",
m.Method, err)
}
if !t.Failed() {
usageStrs = append(usageStrs, usage)
}
}
if !t.Failed() {
usages := strings.Join(usageStrs, "\n")
needsGenerate = usages != requestUsages
}
}

File diff suppressed because it is too large Load diff

59
rpcserverhelp.go Normal file
View file

@ -0,0 +1,59 @@
// AUTOGENERATED by internal/rpchelp/genrpcserverhelp.go; do not edit.
package main
func helpDescsEnUS() map[string]string {
return map[string]string{
"addmultisigaddress": "addmultisigaddress nrequired [\"key\",...] (account=\"\")\n\nGenerates and imports a multisig address and redeeming script to the 'imported' account.\n\nArguments:\n1. nrequired (numeric, required) The number of signatures required to redeem outputs paid to this address\n2. keys (array of string, required) Pubkeys and/or pay-to-pubkey-hash addresses to partially control the multisig address\n3. account (string, optional, default=\"\") DEPRECATED -- Unused (all imported addresses belong to the imported account)\n\nResult:\n\"value\" (string) The imported pay-to-script-hash address\n",
"createmultisig": "createmultisig nrequired [\"key\",...]\n\nGenerate a multisig address and redeem script.\n\nArguments:\n1. nrequired (numeric, required) The number of signatures required to redeem outputs paid to this address\n2. keys (array of string, required) Pubkeys and/or pay-to-pubkey-hash addresses to partially control the multisig address\n\nResult:\n{\n \"address\": \"value\", (string) The generated pay-to-script-hash address\n \"redeemScript\": \"value\", (string) The script required to redeem outputs paid to the multisig address\n} \n",
"dumpprivkey": "dumpprivkey \"address\"\n\nReturns the private key in WIF encoding that controls some wallet address.\n\nArguments:\n1. address (string, required) The address to return a private key for\n\nResult:\n\"value\" (string) The WIF-encoded private key\n",
"getaccount": "getaccount \"address\"\n\nDEPRECATED -- Lookup the account name that some wallet address belongs to.\n\nArguments:\n1. address (string, required) The address to query the account for\n\nResult:\n\"value\" (string) The name of the account that 'address' belongs to\n",
"getaccountaddress": "getaccountaddress \"account\"\n\nDEPRECATED -- Returns the most recent external payment address for an account that has not been seen publicly.\nA new address is generated for the account if the most recently generated address has been seen on the blockchain or in mempool.\n\nArguments:\n1. account (string, required) The account of the returned address\n\nResult:\n\"value\" (string) The unused address for 'account'\n",
"getaddressesbyaccount": "getaddressesbyaccount \"account\"\n\nDEPRECATED -- Returns all addresses strings controlled by a single account.\n\nArguments:\n1. account (string, required) Account name to fetch addresses for\n\nResult:\n[\"value\",...] (array of string) All addresses controlled by 'account'\n",
"getbalance": "getbalance (account=\"*\" minconf=1)\n\nCalculates and returns the balance of one or all accounts.\n\nArguments:\n1. account (string, optional, default=\"*\") DEPRECATED -- The account name to query the balance for, or '*' to consider all accounts\n2. minconf (numeric, optional, default=1) Minimum number of block confirmations required before an unspent output's value is included in the balance\n\nResult (account!=*):\nn.nnn (numeric) The balance of 'account' valued in bitcoin\n\nResult (account=*):\nn.nnn (numeric) The balance of all accounts valued in bitcoin\n",
"getbestblockhash": "getbestblockhash\n\nReturns the hash of the newest block in the best chain that wallet has finished syncing with.\n\nArguments:\nNone\n\nResult:\n\"value\" (string) The hash of the most recent synced-to block\n",
"getblockcount": "getblockcount\n\nReturns the blockchain height of the newest block in the best chain that wallet has finished syncing with.\n\nArguments:\nNone\n\nResult:\nn.nnn (numeric) The blockchain height of the most recent synced-to block\n",
"getinfo": "getinfo\n\nReturns a JSON object containing various state info.\n\nArguments:\nNone\n\nResult:\n{\n \"version\": n, (numeric) The version of the server\n \"protocolversion\": n, (numeric) The latest supported protocol version\n \"walletversion\": n, (numeric) The version of the address manager database\n \"balance\": n.nnn, (numeric) The balance of all accounts calculated with one block confirmation\n \"blocks\": n, (numeric) The number of blocks processed\n \"timeoffset\": n, (numeric) The time offset\n \"connections\": n, (numeric) The number of connected peers\n \"proxy\": \"value\", (string) The proxy used by the server\n \"difficulty\": n.nnn, (numeric) The current target difficulty\n \"testnet\": true|false, (boolean) Whether or not server is using testnet\n \"keypoololdest\": n, (numeric) Unset\n \"keypoolsize\": n, (numeric) Unset\n \"unlocked_until\": n, (numeric) Unset\n \"paytxfee\": n.nnn, (numeric) The increment used each time more fee is required for an authored transaction\n \"relayfee\": n.nnn, (numeric) The minimum relay fee for non-free transactions in BTC/KB\n \"errors\": \"value\", (string) Any current errors\n} \n",
"getnewaddress": "getnewaddress (account=\"\")\n\nGenerates and returns a new payment address.\n\nArguments:\n1. account (string, optional, default=\"\") DEPRECATED -- Account name the new address will belong to\n\nResult:\n\"value\" (string) The payment address\n",
"getrawchangeaddress": "getrawchangeaddress (account=\"\")\n\nGenerates and returns a new internal payment address for use as a change address in raw transactions.\n\nArguments:\n1. account (string, optional, default=\"\") Account name the new internal address will belong to\n\nResult:\n\"value\" (string) The internal payment address\n",
"getreceivedbyaccount": "getreceivedbyaccount \"account\" (minconf=1)\n\nDEPRECATED -- Returns the total amount received by addresses of some account, including spent outputs.\n\nArguments:\n1. account (string, required) Account name to query total received amount for\n2. minconf (numeric, optional, default=1) Minimum number of block confirmations required before an output's value is included in the total\n\nResult:\nn.nnn (numeric) The total received amount valued in bitcoin\n",
"getreceivedbyaddress": "getreceivedbyaddress \"address\" (minconf=1)\n\nReturns the total amount received by a single address, including spent outputs.\n\nArguments:\n1. address (string, required) Payment address which received outputs to include in total\n2. minconf (numeric, optional, default=1) Minimum number of block confirmations required before an output's value is included in the total\n\nResult:\nn.nnn (numeric) The total received amount valued in bitcoin\n",
"gettransaction": "gettransaction \"txid\" (includewatchonly=false)\n\nReturns a JSON object with details regarding a transaction relevant to this wallet.\n\nArguments:\n1. txid (string, required) Hash of the transaction to query\n2. includewatchonly (boolean, optional, default=false) Also consider transactions involving watched addresses\n\nResult:\n{\n \"amount\": n.nnn, (numeric) The total amount this transaction credits to the wallet, valued in bitcoin\n \"fee\": n.nnn, (numeric) The total input value minus the total output value, or 0 if 'txid' is not a sent transaction\n \"confirmations\": n, (numeric) The number of block confirmations of the transaction\n \"blockhash\": \"value\", (string) The hash of the block this transaction is mined in, or the empty string if unmined\n \"blockindex\": n, (numeric) Unset\n \"blocktime\": n, (numeric) The Unix time of the block header this transaction is mined in, or 0 if unmined\n \"txid\": \"value\", (string) The transaction hash\n \"walletconflicts\": [\"value\",...], (array of string) Unset\n \"time\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"timereceived\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"details\": [{ (array of object) Additional details for each recorded wallet credit and debit\n \"account\": \"value\", (string) DEPRECATED -- Unset\n \"address\": \"value\", (string) The address an output was paid to, or the empty string if the output is nonstandard or this detail is regarding a transaction input\n \"category\": \"value\", (string) The kind of detail: \"send\" for sent transactions, \"immature\" for immature coinbase outputs, \"generate\" for mature coinbase outputs, or \"recv\" for all other received outputs\n \"amount\": n.nnn, (numeric) The amount of a received output\n \"fee\": n.nnn, (numeric) The included fee for a sent transaction\n },...], \n \"hex\": \"value\", (string) The transaction encoded as a hexadecimal string\n} \n",
"help": "help (\"command\")\n\nReturns a list of all commands or help for a specified command.\n\nArguments:\n1. command (string, optional) The command to retrieve help for\n\nResult (no command provided):\n\"value\" (string) List of commands\n\nResult (command specified):\n\"value\" (string) Help for specified command\n",
"importprivkey": "importprivkey \"privkey\" (label=\"\" rescan=true)\n\nImports a WIF-encoded private key to the 'imported' account.\n\nArguments:\n1. privkey (string, required) The WIF-encoded private key\n2. label (string, optional, default=\"\") Unused (all imported addresses belong to the imported account)\n3. rescan (boolean, optional, default=true) Rescan the blockchain (since the genesis block) for outputs controlled by the imported key\n\nResult:\nNothing\n",
"keypoolrefill": "keypoolrefill (newsize=100)\n\nDEPRECATED -- This request does nothing since no keypool is maintained.\n\nArguments:\n1. newsize (numeric, optional, default=100) Unused\n\nResult:\nNothing\n",
"listaccounts": "listaccounts (minconf=1)\n\nDEPRECATED -- Returns a JSON object of all accounts and their balances.\n\nArguments:\n1. minconf (numeric, optional, default=1) Minimum number of block confirmations required before an unspent output's value is included in the balance\n\nResult:\n{\n \"The account name\": The account balance valued in bitcoin, (object) JSON object with account names as keys and bitcoin amounts as values\n ...\n}\n",
"listlockunspent": "listlockunspent\n\nReturns a JSON array of outpoints marked as locked (with lockunspent) for this wallet session.\n\nArguments:\nNone\n\nResult:\n[{\n \"txid\": \"value\", (string) The transaction hash of the referenced output\n \"vout\": n, (numeric) The output index of the referenced output\n},...]\n",
"listreceivedbyaccount": "listreceivedbyaccount (minconf=1 includeempty=false includewatchonly=false)\n\nDEPRECATED -- Returns a JSON array of objects listing all accounts and the total amount received by each account.\n\nArguments:\n1. minconf (numeric, optional, default=1) Minimum number of block confirmations required before a transaction is considered\n2. includeempty (boolean, optional, default=false) Unused\n3. includewatchonly (boolean, optional, default=false) Unused\n\nResult:\n[{\n \"account\": \"value\", (string) The name of the account\n \"amount\": n.nnn, (numeric) Total amount received by payment addresses of the account valued in bitcoin\n \"confirmations\": n, (numeric) Number of block confirmations of the most recent transaction relevant to the account\n},...]\n",
"listreceivedbyaddress": "listreceivedbyaddress (minconf=1 includeempty=false includewatchonly=false)\n\nReturns a JSON array of objects listing wallet payment addresses and their total received amounts.\n\nArguments:\n1. minconf (numeric, optional, default=1) Minimum number of block confirmations required before a transaction is considered\n2. includeempty (boolean, optional, default=false) Unused\n3. includewatchonly (boolean, optional, default=false) Unused\n\nResult:\n[{\n \"account\": \"value\", (string) DEPRECATED -- Unset\n \"address\": \"value\", (string) The payment address\n \"amount\": n.nnn, (numeric) Total amount received by the payment address valued in bitcoin\n \"confirmations\": n, (numeric) Number of block confirmations of the most recent transaction relevant to the address\n \"txids\": [\"value\",...], (array of string) Transaction hashes of all transactions involving this address\n \"involvesWatchonly\": true|false, (boolean) Unset\n},...]\n",
"listsinceblock": "listsinceblock (\"blockhash\" targetconfirmations=1 includewatchonly=false)\n\nReturns a JSON array of objects listing details of wallet transactions after some block.\n\nArguments:\n1. blockhash (string, optional) Hash of the parent block of the first block to consider transactions from\n2. targetconfirmations (numeric, optional, default=1) Minimum number of block confirmations required before a transaction is considered\n3. includewatchonly (boolean, optional, default=false) Unused\n\nResult:\n{\n \"transactions\": [{ (array of object) JSON array of objects containing verbose details of the each transaction\n \"account\": \"value\", (string) DEPRECATED -- Unset\n \"address\": \"value\", (string) Payment address for a transaction output\n \"category\": \"value\", (string) The kind of transaction: \"send\" for sent transactions, \"immature\" for immature coinbase outputs, \"generate\" for mature coinbase outputs, or \"recv\" for all other received outputs. Note: A single output may be included multiple times under different categories\n \"amount\": n.nnn, (numeric) The value of the transaction output valued in bitcoin\n \"fee\": n.nnn, (numeric) The total input value minus the total output value for sent transactions\n \"confirmations\": n, (numeric) The number of block confirmations of the transaction\n \"generated\": true|false, (boolean) Whether the transaction output is a coinbase output\n \"blockhash\": \"value\", (string) The hash of the block this transaction is mined in, or the empty string if unmined\n \"blockindex\": n, (numeric) Unset\n \"blocktime\": n, (numeric) The Unix time of the block header this transaction is mined in, or 0 if unmined\n \"txid\": \"value\", (string) The hash of the transaction\n \"walletconflicts\": [\"value\",...], (array of string) Unset\n \"time\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"timereceived\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"comment\": \"value\", (string) Unset\n \"otheraccount\": \"value\", (string) Unset\n },...], \n \"lastblock\": \"value\", (string) Hash of the latest-synced block to be used in later calls to listsinceblock\n} \n",
"listtransactions": "listtransactions (\"account\" count=10 from=0 includewatchonly=false)\n\nReturns a JSON array of objects containing verbose details for wallet transactions.\n\nArguments:\n1. account (string, optional) DEPRECATED -- Unused\n2. count (numeric, optional, default=10) Maximum number of transactions to create results from\n3. from (numeric, optional, default=0) Number of transactions to skip before results are created\n4. includewatchonly (boolean, optional, default=false) Unused\n\nResult:\n[{\n \"account\": \"value\", (string) DEPRECATED -- Unset\n \"address\": \"value\", (string) Payment address for a transaction output\n \"category\": \"value\", (string) The kind of transaction: \"send\" for sent transactions, \"immature\" for immature coinbase outputs, \"generate\" for mature coinbase outputs, or \"recv\" for all other received outputs. Note: A single output may be included multiple times under different categories\n \"amount\": n.nnn, (numeric) The value of the transaction output valued in bitcoin\n \"fee\": n.nnn, (numeric) The total input value minus the total output value for sent transactions\n \"confirmations\": n, (numeric) The number of block confirmations of the transaction\n \"generated\": true|false, (boolean) Whether the transaction output is a coinbase output\n \"blockhash\": \"value\", (string) The hash of the block this transaction is mined in, or the empty string if unmined\n \"blockindex\": n, (numeric) Unset\n \"blocktime\": n, (numeric) The Unix time of the block header this transaction is mined in, or 0 if unmined\n \"txid\": \"value\", (string) The hash of the transaction\n \"walletconflicts\": [\"value\",...], (array of string) Unset\n \"time\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"timereceived\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"comment\": \"value\", (string) Unset\n \"otheraccount\": \"value\", (string) Unset\n},...]\n",
"listunspent": "listunspent (minconf=1 maxconf=9999999 [\"address\",...])\n\nReturns a JSON array of objects representing unlocked unspent outputs controlled by wallet keys.\n\nArguments:\n1. minconf (numeric, optional, default=1) Minimum number of block confirmations required before a transaction output is considered\n2. maxconf (numeric, optional, default=9999999) Maximum number of block confirmations required before a transaction output is excluded\n3. addresses (array of string, optional) If set, limits the returned details to unspent outputs received by any of these payment addresses\n\nResult:\n{\n \"txid\": \"value\", (string) The transaction hash of the referenced output\n \"vout\": n, (numeric) The output index of the referenced output\n \"address\": \"value\", (string) The payment address that received the output\n \"account\": \"value\", (string) The account associated with the receiving payment address\n \"scriptPubKey\": \"value\", (string) The output script encoded as a hexadecimal string\n \"redeemScript\": \"value\", (string) Unset\n \"amount\": n.nnn, (numeric) The amount of the output valued in bitcoin\n \"confirmations\": n, (numeric) The number of block confirmations of the transaction\n} \n",
"lockunspent": "lockunspent unlock [{\"txid\":\"value\",\"vout\":n},...]\n\nLocks or unlocks an unspent output.\nLocked outputs are not chosen for transaction inputs of authored transactions and are not included in 'listunspent' results.\nLocked outputs are volatile and are not saved across wallet restarts.\nIf unlock is true and no transaction outputs are specified, all locked outputs are marked unlocked.\n\nArguments:\n1. unlock (boolean, required) True to unlock outputs, false to lock\n2. transactions (array of object, required) Transaction outputs to lock or unlock\n[{\n \"txid\": \"value\", (string) The transaction hash of the referenced output\n \"vout\": n, (numeric) The output index of the referenced output\n},...]\n\nResult:\ntrue|false (boolean) The boolean 'true'\n",
"sendfrom": "sendfrom \"fromaccount\" \"toaddress\" amount (minconf=1 \"comment\" \"commentto\")\n\nDEPRECATED -- Authors, signs, and sends a transaction that outputs some amount to a payment address.\nA change output is automatically included to send extra output value back to the original account.\n\nArguments:\n1. fromaccount (string, required) Account to pick unspent outputs from\n2. toaddress (string, required) Address to pay\n3. amount (numeric, required) Amount to send to the payment address valued in bitcoin\n4. minconf (numeric, optional, default=1) Minimum number of block confirmations required before a transaction output is eligible to be spent\n5. comment (string, optional) Unused\n6. commentto (string, optional) Unused\n\nResult:\n\"value\" (string) The transaction hash of the sent transaction\n",
"sendmany": "sendmany \"fromaccount\" {\"address\":amount,...} (minconf=1 \"comment\")\n\nAuthors, signs, and sends a transaction that outputs to many payment addresses.\nA change output is automatically included to send extra output value back to the original account.\n\nArguments:\n1. fromaccount (string, required) DEPRECATED -- Account to pick unspent outputs from\n2. amounts (object, required) Pairs of payment addresses and the output amount to pay each\n{\n \"Address to pay\": Amount to send to the payment address valued in bitcoin, (object) JSON object using payment addresses as keys and output amounts valued in bitcoin to send to each address\n ...\n}\n3. minconf (numeric, optional, default=1) Minimum number of block confirmations required before a transaction output is eligible to be spent\n4. comment (string, optional) Unused\n\nResult:\n\"value\" (string) The transaction hash of the sent transaction\n",
"sendtoaddress": "sendtoaddress \"address\" amount (\"comment\" \"commentto\")\n\nAuthors, signs, and sends a transaction that outputs some amount to a payment address.\nUnlike sendfrom, outputs are always chosen from the default account.\nA change output is automatically included to send extra output value back to the original account.\n\nArguments:\n1. address (string, required) Address to pay\n2. amount (numeric, required) Amount to send to the payment address valued in bitcoin\n3. comment (string, optional) Unused\n4. commentto (string, optional) Unused\n\nResult:\n\"value\" (string) The transaction hash of the sent transaction\n",
"settxfee": "settxfee amount\n\nModify the increment used each time more fee is required for an authored transaction.\n\nArguments:\n1. amount (numeric, required) The new fee increment valued in bitcoin\n\nResult:\ntrue|false (boolean) The boolean 'true'\n",
"signmessage": "signmessage \"address\" \"message\"\n\nSigns a message using the private key of a payment address.\n\nArguments:\n1. address (string, required) Payment address of private key used to sign the message with\n2. message (string, required) Message to sign\n\nResult:\n\"value\" (string) The signed message encoded as a base64 string\n",
"signrawtransaction": "signrawtransaction \"rawtx\" ([{\"txid\":\"value\",\"vout\":n,\"scriptpubkey\":\"value\",\"redeemscript\":\"value\"},...] [\"privkey\",...] flags=\"ALL\")\n\nSigns transaction inputs using private keys from this wallet and request.\nThe valid flags options are ALL, NONE, SINGLE, ALL|ANYONECANPAY, NONE|ANYONECANPAY, and SINGLE|ANYONECANPAY.\n\nArguments:\n1. rawtx (string, required) Unsigned or partially unsigned transaction to sign encoded as a hexadecimal string\n2. inputs (array of object, optional) Additional data regarding inputs that this wallet may not be tracking\n3. privkeys (array of string, optional) Additional WIF-encoded private keys to use when creating signatures\n4. flags (string, optional, default=\"ALL\") Sighash flags\n\nResult:\n{\n \"hex\": \"value\", (string) The resulting transaction encoded as a hexadecimal string\n \"complete\": true|false, (boolean) Whether all input signatures have been created\n} \n",
"validateaddress": "validateaddress \"address\"\n\nVerify that an address is valid.\nExtra details are returned if the address is controlled by this wallet.\nThe following fields are valid only when the address is controlled by this wallet (ismine=true): isscript, pubkey, iscompressed, account, addresses, hex, script, and sigsrequired.\nThe following fields are only valid when address has an associated public key: pubkey, iscompressed.\nThe following fields are only valid when address is a pay-to-script-hash address: addresses, hex, and script.\nIf the address is a multisig address controlled by this wallet, the multisig fields will be left unset if the wallet is locked since the redeem script cannot be decrypted.\n\nArguments:\n1. address (string, required) Address to validate\n\nResult:\n{\n \"isvalid\": true|false, (boolean) Whether or not the address is valid\n \"address\": \"value\", (string) The payment address (only when isvalid is true)\n \"ismine\": true|false, (boolean) Whether this address is controlled by the wallet (only when isvalid is true)\n \"iswatchonly\": true|false, (boolean) Unset\n \"isscript\": true|false, (boolean) Whether the payment address is a pay-to-script-hash address (only when isvalid is true)\n \"pubkey\": \"value\", (string) The associated public key of the payment address, if any (only when isvalid is true)\n \"iscompressed\": true|false, (boolean) Whether the address was created by hashing a compressed public key, if any (only when isvalid is true)\n \"account\": \"value\", (string) The account this payment address belongs to (only when isvalid is true)\n \"addresses\": [\"value\",...], (array of string) All associated payment addresses of the script if address is a multisig address (only when isvalid is true)\n \"hex\": \"value\", (string) The redeem script \n \"script\": \"value\", (string) The class of redeem script for a multisig address\n \"sigsrequired\": n, (numeric) The number of required signatures to redeem outputs to the multisig address\n} \n",
"verifymessage": "verifymessage \"address\" \"signature\" \"message\"\n\nVerify a message was signed with the associated private key of some address.\n\nArguments:\n1. address (string, required) Address used to sign message\n2. signature (string, required) The signature to verify\n3. message (string, required) The message to verify\n\nResult:\ntrue|false (boolean) Whether the message was signed with the private key of 'address'\n",
"walletlock": "walletlock\n\nLock the wallet.\n\nArguments:\nNone\n\nResult:\nNothing\n",
"walletpassphrase": "walletpassphrase \"passphrase\" timeout\n\nUnlock the wallet.\n\nArguments:\n1. passphrase (string, required) The wallet passphrase\n2. timeout (numeric, required) The number of seconds to wait before the wallet automatically locks\n\nResult:\nNothing\n",
"walletpassphrasechange": "walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n\nChange the wallet passphrase.\n\nArguments:\n1. oldpassphrase (string, required) The old wallet passphrase\n2. newpassphrase (string, required) The new wallet passphrase\n\nResult:\nNothing\n",
"createnewaccount": "createnewaccount \"account\"\n\nCreates a new account.\nThe wallet must be unlocked for this request to succeed.\n\nArguments:\n1. account (string, required) Name of the new account\n\nResult:\nNothing\n",
"exportwatchingwallet": "exportwatchingwallet (account=\"\" download=false)\n\nCreates and returns a duplicate of the wallet database without any private keys to be used as a watching-only wallet.\n\nArguments:\n1. account (string, optional, default=\"\") Unused\n2. download (boolean, optional, default=false) Unused\n\nResult:\n\"value\" (string) The watching-only database encoded as a base64 string\n",
"getbestblock": "getbestblock\n\nReturns the hash and height of the newest block in the best chain that wallet has finished syncing with.\n\nArguments:\nNone\n\nResult:\n{\n \"hash\": \"value\", (string) The hash of the block\n \"height\": n, (numeric) The blockchain height of the block\n} \n",
"getunconfirmedbalance": "getunconfirmedbalance (account=\"\")\n\nCalculates the unspent output value of all unmined transaction outputs for an account.\n\nArguments:\n1. account (string, optional, default=\"\") The account to query the unconfirmed balance for\n\nResult:\nn.nnn (numeric) Total amount of all unmined unspent outputs of the account valued in bitcoin.\n",
"listaddresstransactions": "listaddresstransactions [\"address\",...] (account=\"\")\n\nReturns a JSON array of objects containing verbose details for wallet transactions pertaining some addresses.\n\nArguments:\n1. addresses (array of string, required) Addresses to filter transaction results by\n2. account (string, optional, default=\"\") Unused\n\nResult:\n[{\n \"account\": \"value\", (string) DEPRECATED -- Unset\n \"address\": \"value\", (string) Payment address for a transaction output\n \"category\": \"value\", (string) The kind of transaction: \"send\" for sent transactions, \"immature\" for immature coinbase outputs, \"generate\" for mature coinbase outputs, or \"recv\" for all other received outputs. Note: A single output may be included multiple times under different categories\n \"amount\": n.nnn, (numeric) The value of the transaction output valued in bitcoin\n \"fee\": n.nnn, (numeric) The total input value minus the total output value for sent transactions\n \"confirmations\": n, (numeric) The number of block confirmations of the transaction\n \"generated\": true|false, (boolean) Whether the transaction output is a coinbase output\n \"blockhash\": \"value\", (string) The hash of the block this transaction is mined in, or the empty string if unmined\n \"blockindex\": n, (numeric) Unset\n \"blocktime\": n, (numeric) The Unix time of the block header this transaction is mined in, or 0 if unmined\n \"txid\": \"value\", (string) The hash of the transaction\n \"walletconflicts\": [\"value\",...], (array of string) Unset\n \"time\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"timereceived\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"comment\": \"value\", (string) Unset\n \"otheraccount\": \"value\", (string) Unset\n},...]\n",
"listalltransactions": "listalltransactions (account=\"\")\n\nReturns a JSON array of objects in the same format as 'listtransactions' without limiting the number of returned objects.\n\nArguments:\n1. account (string, optional, default=\"\") Unused\n\nResult:\n[{\n \"account\": \"value\", (string) DEPRECATED -- Unset\n \"address\": \"value\", (string) Payment address for a transaction output\n \"category\": \"value\", (string) The kind of transaction: \"send\" for sent transactions, \"immature\" for immature coinbase outputs, \"generate\" for mature coinbase outputs, or \"recv\" for all other received outputs. Note: A single output may be included multiple times under different categories\n \"amount\": n.nnn, (numeric) The value of the transaction output valued in bitcoin\n \"fee\": n.nnn, (numeric) The total input value minus the total output value for sent transactions\n \"confirmations\": n, (numeric) The number of block confirmations of the transaction\n \"generated\": true|false, (boolean) Whether the transaction output is a coinbase output\n \"blockhash\": \"value\", (string) The hash of the block this transaction is mined in, or the empty string if unmined\n \"blockindex\": n, (numeric) Unset\n \"blocktime\": n, (numeric) The Unix time of the block header this transaction is mined in, or 0 if unmined\n \"txid\": \"value\", (string) The hash of the transaction\n \"walletconflicts\": [\"value\",...], (array of string) Unset\n \"time\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"timereceived\": n, (numeric) The earliest Unix time this transaction was known to exist\n \"comment\": \"value\", (string) Unset\n \"otheraccount\": \"value\", (string) Unset\n},...]\n",
"renameaccount": "renameaccount \"oldaccount\" \"newaccount\"\n\nRenames an account.\n\nArguments:\n1. oldaccount (string, required) The old account name to rename\n2. newaccount (string, required) The new name for the account\n\nResult:\nNothing\n",
"walletislocked": "walletislocked\n\nReturns whether or not the wallet is locked.\n\nArguments:\nNone\n\nResult:\ntrue|false (boolean) Whether the wallet is locked\n",
}
}
var localeHelpDescs = map[string]func() map[string]string{
"en_US": helpDescsEnUS,
}
var requestUsages = "addmultisigaddress nrequired [\"key\",...] (account=\"\")\ncreatemultisig nrequired [\"key\",...]\ndumpprivkey \"address\"\ngetaccount \"address\"\ngetaccountaddress \"account\"\ngetaddressesbyaccount \"account\"\ngetbalance (account=\"*\" minconf=1)\ngetbestblockhash\ngetblockcount\ngetinfo\ngetnewaddress (account=\"\")\ngetrawchangeaddress (account=\"\")\ngetreceivedbyaccount \"account\" (minconf=1)\ngetreceivedbyaddress \"address\" (minconf=1)\ngettransaction \"txid\" (includewatchonly=false)\nhelp (\"command\")\nimportprivkey \"privkey\" (label=\"\" rescan=true)\nkeypoolrefill (newsize=100)\nlistaccounts (minconf=1)\nlistlockunspent\nlistreceivedbyaccount (minconf=1 includeempty=false includewatchonly=false)\nlistreceivedbyaddress (minconf=1 includeempty=false includewatchonly=false)\nlistsinceblock (\"blockhash\" targetconfirmations=1 includewatchonly=false)\nlisttransactions (\"account\" count=10 from=0 includewatchonly=false)\nlistunspent (minconf=1 maxconf=9999999 [\"address\",...])\nlockunspent unlock [{\"txid\":\"value\",\"vout\":n},...]\nsendfrom \"fromaccount\" \"toaddress\" amount (minconf=1 \"comment\" \"commentto\")\nsendmany \"fromaccount\" {\"address\":amount,...} (minconf=1 \"comment\")\nsendtoaddress \"address\" amount (\"comment\" \"commentto\")\nsettxfee amount\nsignmessage \"address\" \"message\"\nsignrawtransaction \"rawtx\" ([{\"txid\":\"value\",\"vout\":n,\"scriptpubkey\":\"value\",\"redeemscript\":\"value\"},...] [\"privkey\",...] flags=\"ALL\")\nvalidateaddress \"address\"\nverifymessage \"address\" \"signature\" \"message\"\nwalletlock\nwalletpassphrase \"passphrase\" timeout\nwalletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\ncreatenewaccount \"account\"\nexportwatchingwallet (account=\"\" download=false)\ngetbestblock\ngetunconfirmedbalance (account=\"\")\nlistaddresstransactions [\"address\",...] (account=\"\")\nlistalltransactions (account=\"\")\nrenameaccount \"oldaccount\" \"newaccount\"\nwalletislocked"

View file

@ -30,7 +30,7 @@ import (
"time"
"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcjson/v2/btcjson"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
@ -1115,7 +1115,7 @@ func (s creditSlice) Swap(i, j int) {
// contained within it will be considered. If we know nothing about a
// transaction an empty array will be returned.
func (w *Wallet) ListUnspent(minconf, maxconf int32,
addresses map[string]bool) ([]*btcjson.ListUnspentResult, error) {
addresses map[string]struct{}) ([]*btcjson.ListUnspentResult, error) {
syncBlock := w.Manager.SyncedTo()
@ -1184,7 +1184,7 @@ func (w *Wallet) ListUnspent(minconf, maxconf int32,
}
include:
result := &btcjson.ListUnspentResult{
TxId: output.OutPoint.Hash.String(),
TxID: output.OutPoint.Hash.String(),
Vout: output.OutPoint.Index,
Account: acctName,
ScriptPubKey: hex.EncodeToString(output.PkScript),