Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide current syncer type in getinfo result #2305

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -1804,9 +1804,10 @@ func (s *Server) getInfo(ctx context.Context, icmd any) (any, error) {
}

n, _ := s.walletLoader.NetworkBackend()
if rpc, ok := n.(*dcrd.RPC); ok {
switch n := n.(type) {
case *dcrd.RPC:
var consensusInfo dcrdtypes.InfoChainResult
err := rpc.Call(ctx, "getinfo", &consensusInfo)
err := n.Call(ctx, "getinfo", &consensusInfo)
if err != nil {
return nil, err
}
Expand All @@ -1817,6 +1818,11 @@ func (s *Server) getInfo(ctx context.Context, icmd any) (any, error) {
info.Proxy = consensusInfo.Proxy
info.RelayFee = consensusInfo.RelayFee
info.Errors = consensusInfo.Errors
info.SyncType = "rpc"
case *spv.Syncer:
info.SyncType = "spv"
case nil:
info.SyncType = "none"
}

return info, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/rpc/jsonrpc/rpcserverhelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func helpDescsEnUS() map[string]string {
"getblock": "getblock \"hash\" (verbose=true verbosetx=false)\n\nReturns information about a block given its hash.\n\nArguments:\n1. hash (string, required) The hash of the block\n2. verbose (boolean, optional, default=true) Specifies the block is returned as a JSON object instead of hex-encoded string\n3. verbosetx (boolean, optional, default=false) Specifies that each transaction is returned as a JSON object and only applies if the verbose flag is true (dcrd extension)\n\nResult:\n{\n \"hash\": \"value\", (string) The hash of the block (same as provided)\n \"powhash\": \"value\", (string) The Proof-of-Work hash of the block (same as hash prior to DCP0011 activation)\n \"confirmations\": n, (numeric) The number of confirmations\n \"size\": n, (numeric) The size of the block\n \"height\": n, (numeric) The height of the block in the block chain\n \"version\": n, (numeric) The block version\n \"merkleroot\": \"value\", (string) Root hash of the merkle tree\n \"stakeroot\": \"value\", (string) The block's sstx hashes the were included\n \"tx\": [\"value\",...], (array of string) The transaction hashes (only when verbosetx=false)\n \"rawtx\": [{ (array of object) The transactions as JSON objects (only when verbosetx=true)\n \"hex\": \"value\", (string) Hex-encoded transaction\n \"txid\": \"value\", (string) The hash of the transaction\n \"version\": n, (numeric) The transaction version\n \"locktime\": n, (numeric) The transaction lock time\n \"expiry\": n, (numeric) The transacion expiry\n \"vin\": [{ (array of object) The transaction inputs as JSON objects\n \"coinbase\": \"value\", (string) The hex-encoded bytes of the signature script (coinbase txns only)\n \"stakebase\": \"value\", (string) The hex-encoded bytes of the signature script (vote txns only)\n \"treasurybase\": true|false, (boolean) Whether or not the input is a treasury base (treasurybase txns only)\n \"treasuryspend\": \"value\", (string) The hex-encoded bytes of the signature script (treasury spend txns only)\n \"txid\": \"value\", (string) The hash of the origin transaction (non-coinbase txns only)\n \"vout\": n, (numeric) The index of the output being redeemed from the origin transaction (non-coinbase txns only)\n \"tree\": n, (numeric) The tree of the transaction\n \"sequence\": n, (numeric) The script sequence number\n \"amountin\": n.nnn, (numeric) The amount in\n \"blockheight\": n, (numeric) The block height of the origin transaction\n \"blockindex\": n, (numeric) The block idx of the origin transaction\n \"scriptSig\": { (object) The signature script used to redeem the origin transaction as a JSON object (non-coinbase txns only)\n \"asm\": \"value\", (string) Disassembly of the script\n \"hex\": \"value\", (string) Hex-encoded bytes of the script\n }, \n },...], \n \"vout\": [{ (array of object) The transaction outputs as JSON objects\n \"value\": n.nnn, (numeric) The amount in DCR\n \"n\": n, (numeric) The index of this transaction output\n \"version\": n, (numeric) The version of the public key script\n \"scriptPubKey\": { (object) The public key script used to pay coins as a JSON object\n \"asm\": \"value\", (string) Disassembly of the script\n \"hex\": \"value\", (string) Hex-encoded bytes of the script\n \"reqSigs\": n, (numeric) The number of required signatures\n \"type\": \"value\", (string) The type of the script (e.g. 'pubkeyhash')\n \"addresses\": [\"value\",...], (array of string) The Decred addresses associated with this script\n \"commitamt\": n.nnn, (numeric) The ticket commitment value if the script is for a staking commitment\n \"version\": n, (numeric) The script version\n }, \n },...], \n \"blockhash\": \"value\", (string) The hash of the block that contains the transaction\n \"blockheight\": n, (numeric) The height of the block that contains the transaction\n \"blockindex\": n, (numeric) The index within the array of transactions contained by the block\n \"confirmations\": n, (numeric) Number of confirmations of the block\n \"time\": n, (numeric) Transaction time in seconds since 1 Jan 1970 GMT\n \"blocktime\": n, (numeric) Block time in seconds since the 1 Jan 1970 GMT\n },...], \n \"stx\": [\"value\",...], (array of string) The block's sstx hashes the were included\n \"rawstx\": [{ (array of object) The block's raw sstx hashes the were included\n \"hex\": \"value\", (string) Hex-encoded transaction\n \"txid\": \"value\", (string) The hash of the transaction\n \"version\": n, (numeric) The transaction version\n \"locktime\": n, (numeric) The transaction lock time\n \"expiry\": n, (numeric) The transacion expiry\n \"vin\": [{ (array of object) The transaction inputs as JSON objects\n \"coinbase\": \"value\", (string) The hex-encoded bytes of the signature script (coinbase txns only)\n \"stakebase\": \"value\", (string) The hex-encoded bytes of the signature script (vote txns only)\n \"treasurybase\": true|false, (boolean) Whether or not the input is a treasury base (treasurybase txns only)\n \"treasuryspend\": \"value\", (string) The hex-encoded bytes of the signature script (treasury spend txns only)\n \"txid\": \"value\", (string) The hash of the origin transaction (non-coinbase txns only)\n \"vout\": n, (numeric) The index of the output being redeemed from the origin transaction (non-coinbase txns only)\n \"tree\": n, (numeric) The tree of the transaction\n \"sequence\": n, (numeric) The script sequence number\n \"amountin\": n.nnn, (numeric) The amount in\n \"blockheight\": n, (numeric) The block height of the origin transaction\n \"blockindex\": n, (numeric) The block idx of the origin transaction\n \"scriptSig\": { (object) The signature script used to redeem the origin transaction as a JSON object (non-coinbase txns only)\n \"asm\": \"value\", (string) Disassembly of the script\n \"hex\": \"value\", (string) Hex-encoded bytes of the script\n }, \n },...], \n \"vout\": [{ (array of object) The transaction outputs as JSON objects\n \"value\": n.nnn, (numeric) The amount in DCR\n \"n\": n, (numeric) The index of this transaction output\n \"version\": n, (numeric) The version of the public key script\n \"scriptPubKey\": { (object) The public key script used to pay coins as a JSON object\n \"asm\": \"value\", (string) Disassembly of the script\n \"hex\": \"value\", (string) Hex-encoded bytes of the script\n \"reqSigs\": n, (numeric) The number of required signatures\n \"type\": \"value\", (string) The type of the script (e.g. 'pubkeyhash')\n \"addresses\": [\"value\",...], (array of string) The Decred addresses associated with this script\n \"commitamt\": n.nnn, (numeric) The ticket commitment value if the script is for a staking commitment\n \"version\": n, (numeric) The script version\n }, \n },...], \n \"blockhash\": \"value\", (string) The hash of the block that contains the transaction\n \"blockheight\": n, (numeric) The height of the block that contains the transaction\n \"blockindex\": n, (numeric) The index within the array of transactions contained by the block\n \"confirmations\": n, (numeric) Number of confirmations of the block\n \"time\": n, (numeric) Transaction time in seconds since 1 Jan 1970 GMT\n \"blocktime\": n, (numeric) Block time in seconds since the 1 Jan 1970 GMT\n },...], \n \"time\": n, (numeric) The block time in seconds since 1 Jan 1970 GMT\n \"mediantime\": n, (numeric) The median block time over the last 11 blocks\n \"nonce\": n, (numeric) The block nonce\n \"votebits\": n, (numeric) The block's voting results\n \"finalstate\": \"value\", (string) The block's finalstate\n \"voters\": n, (numeric) The number votes in the block\n \"freshstake\": n, (numeric) The number of new tickets in the block\n \"revocations\": n, (numeric) The number of revocations in the block\n \"poolsize\": n, (numeric) The size of the live ticket pool\n \"bits\": \"value\", (string) The bits which represent the block difficulty\n \"sbits\": n.nnn, (numeric) The stake difficulty of the block\n \"extradata\": \"value\", (string) Extra data field for the requested block\n \"stakeversion\": n, (numeric) Stake Version of the block\n \"difficulty\": n.nnn, (numeric) The proof-of-work difficulty as a multiple of the minimum difficulty\n \"chainwork\": \"value\", (string) The total number of hashes expected to produce the chain up to the block in hex\n \"previousblockhash\": \"value\", (string) The hash of the previous block\n \"nextblockhash\": \"value\", (string) The hash of the next block (only if there is one)\n} \n",
"getcoinjoinsbyacct": "getcoinjoinsbyacct\n\nGet coinjoin outputs by account.\n\nArguments:\nNone\n\nResult:\n{\n \"Accounts name\": Coinjoin outputs sum., (object) Return a map of account's name and its coinjoin outputs sum.\n ...\n}\n",
"getcurrentnet": "getcurrentnet\n\nGet Decred network the wallet is connected to.\n\nArguments:\nNone\n\nResult:\nn (numeric) The network identifier\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 fee per kB of the serialized tx size 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 DCR/KB\n \"errors\": \"value\", (string) Any current errors\n} \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 fee per kB of the serialized tx size 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 DCR/KB\n \"sync_type\": \"value\", (string) The current wallet syncing method (rpc, spv, or none)\n \"errors\": \"value\", (string) Any current errors\n} \n",
"getmasterpubkey": "getmasterpubkey (\"account\")\n\nRequests the master pubkey from the wallet.\n\nArguments:\n1. account (string, optional) The account to get the master pubkey for\n\nResult:\n\"value\" (string) The master pubkey for the wallet\n",
"getmultisigoutinfo": "getmultisigoutinfo \"hash\" index\n\nReturns information about a multisignature output.\n\nArguments:\n1. hash (string, required) Input hash to check.\n2. index (numeric, required) Index of input.\n\nResult:\n{\n \"address\": \"value\", (string) Script address.\n \"redeemscript\": \"value\", (string) Hex of the redeeming script.\n \"m\": n, (numeric) m (in m-of-n)\n \"n\": n, (numeric) n (in m-of-n)\n \"pubkeys\": [\"value\",...], (array of string) Associated pubkeys.\n \"txhash\": \"value\", (string) txhash\n \"blockheight\": n, (numeric) Height of the containing block.\n \"blockhash\": \"value\", (string) Hash of the containing block.\n \"spent\": true|false, (boolean) If it has been spent.\n \"spentby\": \"value\", (string) Hash of spending tx.\n \"spentbyindex\": n, (numeric) Index of spending tx.\n \"amount\": n.nnn, (numeric) Amount of coins contained.\n} \n",
"getnewaddress": "getnewaddress (\"account\" \"gappolicy\")\n\nGenerates and returns a new payment address.\n\nArguments:\n1. account (string, optional) Account name the new address will belong to (default=\"default\")\n2. gappolicy (string, optional) String defining the policy to use when the BIP0044 gap limit would be violated, may be \"error\", \"ignore\", or \"wrap\"\n\nResult:\n\"value\" (string) The payment address\n",
Expand Down
1 change: 1 addition & 0 deletions internal/rpchelp/helpdescs_en_US.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ var helpDescsEnUS = map[string]string{
"inforesult-paytxfee": "The fee per kB of the serialized tx size used each time more fee is required for an authored transaction",
"inforesult-balance": "The balance of all accounts calculated with one block confirmation",
"inforesult-walletversion": "The version of the address manager database",
"inforesult-sync_type": "The current wallet syncing method (rpc, spv, or none)",
"inforesult-unlocked_until": "Unset",
"inforesult-keypoolsize": "Unset",
"inforesult-keypoololdest": "Unset",
Expand Down
1 change: 1 addition & 0 deletions rpc/jsonrpc/types/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ type InfoResult struct {
UnlockedUntil int64 `json:"unlocked_until"`
PaytxFee float64 `json:"paytxfee"`
RelayFee float64 `json:"relayfee"`
SyncType string `json:"sync_type"`
Errors string `json:"errors"`
}

Expand Down
Loading