diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 850acee833b..e96a19b467f 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -1023,9 +1023,7 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const }}; if (const auto* text = std::get_if(&m_opts.print_elision)) { - if (!text->empty()) { - sections.PushSection({indent + "..." + maybe_separator, *text}); - } + sections.PushSection({indent + "..." + maybe_separator, *text}); return; } if (std::holds_alternative(m_opts.print_elision)) { @@ -1077,7 +1075,7 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const } CHECK_NONFATAL(!m_inner.empty()); CHECK_NONFATAL(elision_has_description(m_inner)); - if (m_type == Type::ARR && m_inner.back().m_type != Type::ELISION) { + if (m_type == Type::ARR && m_inner.back().m_type != Type::ELISION && !std::holds_alternative(m_inner.back().m_opts.print_elision)) { sections.PushSection({indent_next + "...", ""}); } else { // Remove final comma, which would be invalid JSON diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index f69082e1e96..77af932ea68 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -523,6 +523,33 @@ RPCMethod listtransactions() }; } +static std::vector ListSinceBlockTxFields() +{ + return Cat>( + { + {RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address of the transaction (not returned if the output does not have an address, e.g. OP_RETURN null data)."}, + {RPCResult::Type::STR, "category", "The transaction category.\n" + "\"send\" Transactions sent.\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."}, + {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::STR_AMOUNT, "fee", /*optional=*/true, "The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the\n" + "'send' category of transactions."}, + }, + Cat( + TransactionDescriptionString(), + std::vector{ + {RPCResult::Type::BOOL, "abandoned", "'true' if the transaction has been abandoned (inputs are respendable)."}, + {RPCResult::Type::STR, "label", /*optional=*/true, "A comment for the address/transaction, if any"}, + } + ) + ); +} + RPCMethod listsinceblock() { return RPCMethod{ @@ -544,30 +571,13 @@ RPCMethod listsinceblock() { {RPCResult::Type::ARR, "transactions", "", { - {RPCResult::Type::OBJ, "", "", Cat(Cat>( - { - {RPCResult::Type::STR, "address", /*optional=*/true, "The bitcoin address of the transaction (not returned if the output does not have an address, e.g. OP_RETURN null data)."}, - {RPCResult::Type::STR, "category", "The transaction category.\n" - "\"send\" Transactions sent.\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."}, - {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::STR_AMOUNT, "fee", /*optional=*/true, "The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the\n" - "'send' category of transactions."}, - }, - TransactionDescriptionString()), - { - {RPCResult::Type::BOOL, "abandoned", "'true' if the transaction has been abandoned (inputs are respendable)."}, - {RPCResult::Type::STR, "label", /*optional=*/true, "A comment for the address/transaction, if any"}, - })}, + {RPCResult::Type::OBJ, "", "", ListSinceBlockTxFields()}, }}, {RPCResult::Type::ARR, "removed", /*optional=*/true, "\n" - "Note: transactions that were re-added in the active chain will appear as-is in this array, and may thus have a positive confirmation count." - , {{RPCResult::Type::ELISION, "", ""},}}, + "Note: transactions that were re-added in the active chain will appear as-is in this array, and may thus have a positive confirmation count.", + { + {RPCResult::Type::OBJ, "", "", ListSinceBlockTxFields(), {.print_elision = std::string{}}}, + }}, {RPCResult::Type::STR_HEX, "lastblock", "The hash of the block (target_confirmations-1) from the best block on the main chain, or the genesis hash if the referenced block does not exist yet. This is typically used to feed back into listsinceblock the next time you call it. So you would generally use a target_confirmations of say 6, so you will be continually re-notified of transactions until they've reached 6 confirmations plus any new ones"}, } },