mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #14653: rpcwallet: Add missing transaction categories to rpc helptexts
f3f6dde56e Test coinbase category in wallet rpcs (andrewtoth) e982f0b682 Add all category options to wallet rpc help (andrewtoth) Pull request description: The current helptext for `listtransactions`, `listsinceblock` and `gettransaction` only list two of the five possible options for `category`. This incorrectly implies that these are the only two options, and can cause problems if the other three options aren't accounted for. Also, some of the documentation is incorrect when specifying which options are returned for which categories. This PR updates the helptext for these RPCs and adds a functional regression test for the cases when the other three categories are returned. Tree-SHA512: 67dd7ff6269a3b0f17f5d1a61b0ae1fb1f3778f05e1c440bfbb9b3a005c9c6d740abcace20f3d597cf2bd6779c494448690f13fab0bd2340f206213bc7890b51
This commit is contained in:
parent
26ea934aef
commit
910dc0c2a6
@ -1371,10 +1371,11 @@ static UniValue listtransactions(const JSONRPCRequest& request)
|
|||||||
"move transactions (category = move)."},
|
"move transactions (category = move)."},
|
||||||
{RPCResult::Type::STR, "category", "The transaction category.\n"
|
{RPCResult::Type::STR, "category", "The transaction category.\n"
|
||||||
"\"send\" Transactions sent.\n"
|
"\"send\" Transactions sent.\n"
|
||||||
|
"\"coinjoin\" Transactions sent using CoinJoin funds.\n"
|
||||||
"\"receive\" Non-coinbase transactions received.\n"
|
"\"receive\" Non-coinbase transactions received.\n"
|
||||||
"\"move\" A local (off blockchain)\n"
|
"\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
|
||||||
"transaction between accounts, and not associated with an address,\n"
|
"\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
|
||||||
"transaction id or block..\n"},
|
"\"orphan\" Orphaned coinbase transactions received.\n"},
|
||||||
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n"
|
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n"
|
||||||
"for all other categories"},
|
"for all other categories"},
|
||||||
{RPCResult::Type::STR, "label", "A comment for the address/transaction, if any"},
|
{RPCResult::Type::STR, "label", "A comment for the address/transaction, if any"},
|
||||||
@ -1495,23 +1496,28 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
|||||||
{
|
{
|
||||||
{RPCResult::Type::OBJ, "", "", Cat<std::vector<RPCResult>>(
|
{RPCResult::Type::OBJ, "", "", Cat<std::vector<RPCResult>>(
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "address", "The dash address of the transaction. Not present for move transactions (category = move)."},
|
{RPCResult::Type::STR, "address", "The dash address of the transaction."},
|
||||||
{RPCResult::Type::STR, "category", "The transaction category. 'send' has negative amounts, 'receive' has positive amounts."},
|
{RPCResult::Type::STR, "category", "The transaction category.\n"
|
||||||
{RPCResult::Type::NUM, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the 'move' category for moves \n"
|
"\"send\" Transactions sent.\n"
|
||||||
"outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds."},
|
"\"coinjoin\" Transactions sent using CoinJoin funds.\n"
|
||||||
|
"\"receive\" Non-coinbase transactions received.\n"
|
||||||
|
"\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
|
||||||
|
"\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
|
||||||
|
"\"orphan\" Orphaned coinbase transactions received.\n"},
|
||||||
|
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n"
|
||||||
|
"for all other categories"},
|
||||||
{RPCResult::Type::NUM, "vout", "the vout value"},
|
{RPCResult::Type::NUM, "vout", "the vout value"},
|
||||||
{RPCResult::Type::NUM, "fee", "The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the 'send' category of transactions."},
|
{RPCResult::Type::NUM, "fee", "The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the 'send' category of transactions."},
|
||||||
{RPCResult::Type::NUM, "confirmations", "The number of blockchain confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n"
|
{RPCResult::Type::NUM, "confirmations", "The number of confirmations for the transaction."},
|
||||||
"When it's < 0, it means the transaction conflicted that many blocks ago."},
|
|
||||||
{RPCResult::Type::BOOL, "instantlock", "Current transaction lock state. Available for 'send' and 'receive' category of transactions."},
|
{RPCResult::Type::BOOL, "instantlock", "Current transaction lock state. Available for 'send' and 'receive' category of transactions."},
|
||||||
{RPCResult::Type::BOOL, "instantlock_internal", "Current internal transaction lock state. Available for 'send' and 'receive' category of transactions."},
|
{RPCResult::Type::BOOL, "instantlock_internal", "Current internal transaction lock state. Available for 'send' and 'receive' category of transactions."},
|
||||||
{RPCResult::Type::BOOL, "chainlock", "The state of the corresponding block chainlock."},
|
{RPCResult::Type::BOOL, "chainlock", "The state of the corresponding block chainlock."},
|
||||||
{RPCResult::Type::STR_HEX, "blockhash", "The block hash containing the transaction. Available for 'send' and 'receive' category of transactions."},
|
{RPCResult::Type::STR_HEX, "blockhash", "The block hash containing the transaction."},
|
||||||
{RPCResult::Type::NUM, "blockindex", "The index of the transaction in the block that includes it. Available for 'send' and 'receive' category of transactions."},
|
{RPCResult::Type::NUM, "blockindex", "The index of the transaction in the block that includes it."},
|
||||||
{RPCResult::Type::NUM_TIME, "blocktime", "The block time in seconds since epoch (1 Jan 1970 GMT)."},
|
{RPCResult::Type::NUM_TIME, "blocktime", "The block time in seconds since epoch (1 Jan 1970 GMT)."},
|
||||||
{RPCResult::Type::STR_HEX, "txid", "The transaction id. Available for 'send' and 'receive' category of transactions."},
|
{RPCResult::Type::STR_HEX, "txid", "The transaction id."},
|
||||||
{RPCResult::Type::NUM_TIME, "time", "The transaction time in seconds since epoch (Jan 1 1970 GMT).."},
|
{RPCResult::Type::NUM_TIME, "time", "The transaction time in seconds since epoch (Jan 1 1970 GMT).."},
|
||||||
{RPCResult::Type::NUM_TIME, "timereceived", "The time received in seconds since epoch (Jan 1 1970 GMT). Available for 'send' and 'receive' category of transactions."},
|
{RPCResult::Type::NUM_TIME, "timereceived", "The time received in seconds since epoch (Jan 1 1970 GMT)."},
|
||||||
{RPCResult::Type::BOOL, "abandoned", "'true' if the transaction has been abandoned (inputs are respendable). Only available for the 'send' category of transactions."},
|
{RPCResult::Type::BOOL, "abandoned", "'true' if the transaction has been abandoned (inputs are respendable). Only available for the 'send' category of transactions."},
|
||||||
{RPCResult::Type::STR, "comment", "If a comment is associated with the transaction."},
|
{RPCResult::Type::STR, "comment", "If a comment is associated with the transaction."},
|
||||||
{RPCResult::Type::STR, "label", "A comment for the address/transaction, if any."},
|
{RPCResult::Type::STR, "label", "A comment for the address/transaction, if any."},
|
||||||
@ -1676,7 +1682,13 @@ static UniValue gettransaction(const JSONRPCRequest& request)
|
|||||||
{RPCResult::Type::OBJ, "", "",
|
{RPCResult::Type::OBJ, "", "",
|
||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "address", "The dash address involved in the transaction."},
|
{RPCResult::Type::STR, "address", "The dash address involved in the transaction."},
|
||||||
{RPCResult::Type::STR, "category", "The category, either 'send' or 'receive'.\n"},
|
{RPCResult::Type::STR, "category", "The transaction category.\n"
|
||||||
|
"\"send\" Transactions sent.\n"
|
||||||
|
"\"coinjoin\" Transactions sent using CoinJoin funds.\n"
|
||||||
|
"\"receive\" Non-coinbase transactions received.\n"
|
||||||
|
"\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
|
||||||
|
"\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
|
||||||
|
"\"orphan\" Orphaned coinbase transactions received.\n"},
|
||||||
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT},
|
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT},
|
||||||
{RPCResult::Type::STR, "label", "A comment for the address/transaction, if any"},
|
{RPCResult::Type::STR, "label", "A comment for the address/transaction, if any"},
|
||||||
{RPCResult::Type::NUM, "vout", "the vout value"},
|
{RPCResult::Type::NUM, "vout", "the vout value"},
|
||||||
|
@ -231,6 +231,7 @@ BASE_SCRIPTS = [
|
|||||||
'rpc_platform_filter.py',
|
'rpc_platform_filter.py',
|
||||||
'feature_dip0020_activation.py',
|
'feature_dip0020_activation.py',
|
||||||
'feature_uacomment.py',
|
'feature_uacomment.py',
|
||||||
|
'wallet_coinbase_category.py',
|
||||||
'feature_filelock.py',
|
'feature_filelock.py',
|
||||||
'feature_loadblock.py',
|
'feature_loadblock.py',
|
||||||
'p2p_blockfilters.py',
|
'p2p_blockfilters.py',
|
||||||
|
59
test/functional/wallet_coinbase_category.py
Executable file
59
test/functional/wallet_coinbase_category.py
Executable file
@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright (c) 2014-2018 The Bitcoin Core developers
|
||||||
|
# Distributed under the MIT software license, see the accompanying
|
||||||
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
"""Test coinbase transactions return the correct categories.
|
||||||
|
|
||||||
|
Tests listtransactions, listsinceblock, and gettransaction.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
from test_framework.util import (
|
||||||
|
assert_array_result
|
||||||
|
)
|
||||||
|
|
||||||
|
class CoinbaseCategoryTest(BitcoinTestFramework):
|
||||||
|
def set_test_params(self):
|
||||||
|
self.num_nodes = 1
|
||||||
|
|
||||||
|
def skip_test_if_missing_module(self):
|
||||||
|
self.skip_if_no_wallet()
|
||||||
|
|
||||||
|
def assert_category(self, category, address, txid, skip):
|
||||||
|
assert_array_result(self.nodes[0].listtransactions(skip=skip),
|
||||||
|
{"address": address},
|
||||||
|
{"category": category})
|
||||||
|
assert_array_result(self.nodes[0].listsinceblock()["transactions"],
|
||||||
|
{"address": address},
|
||||||
|
{"category": category})
|
||||||
|
assert_array_result(self.nodes[0].gettransaction(txid)["details"],
|
||||||
|
{"address": address},
|
||||||
|
{"category": category})
|
||||||
|
|
||||||
|
def run_test(self):
|
||||||
|
# Generate one block to an address
|
||||||
|
address = self.nodes[0].getnewaddress()
|
||||||
|
self.nodes[0].generatetoaddress(1, address)
|
||||||
|
hash = self.nodes[0].getbestblockhash()
|
||||||
|
txid = self.nodes[0].getblock(hash)["tx"][0]
|
||||||
|
|
||||||
|
# Coinbase transaction is immature after 1 confirmation
|
||||||
|
self.assert_category("immature", address, txid, 0)
|
||||||
|
|
||||||
|
# Mine another 99 blocks on top
|
||||||
|
self.nodes[0].generate(99)
|
||||||
|
# Coinbase transaction is still immature after 100 confirmations
|
||||||
|
self.assert_category("immature", address, txid, 99)
|
||||||
|
|
||||||
|
# Mine one more block
|
||||||
|
self.nodes[0].generate(1)
|
||||||
|
# Coinbase transaction is now matured, so category is "generate"
|
||||||
|
self.assert_category("generate", address, txid, 100)
|
||||||
|
|
||||||
|
# Orphan block that paid to address
|
||||||
|
self.nodes[0].invalidateblock(hash)
|
||||||
|
# Coinbase transaction is now orphaned
|
||||||
|
self.assert_category("orphan", address, txid, 100)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
CoinbaseCategoryTest().main()
|
Loading…
Reference in New Issue
Block a user