rpc: add “ischange: true” to decoded tx outputs in wallet gettransaction response #32517

pull pinheadmz wants to merge 3 commits into bitcoin:master from pinheadmz:wallet-gettransaction-ischange changing 7 files +78 −50
  1. pinheadmz commented at 3:40 pm on May 15, 2025: member

    This change is motivated by external RBF clients like https://github.com/CardCoins/additive-rbf-batcher/. It saves the user a redundant re-looping of tx outputs, calling getaddressinfo on each one, looking for the change output in order to adjust the fee.

    The field "ischange" only appears when gettransaction is called on a wallet, and is either true or not present at all. I chose not to include ischange: false because it is confusing to see that on received transactions.

    Example of the new field:

     0    "vout": [
     1      {
     2        "value": 1.00000000,
     3        "n": 0,
     4        "scriptPubKey": {
     5          "asm": "0 5483235e05c76273b3b50af62519738781aff021",
     6          "desc": "addr(bcrt1q2jpjxhs9ca388va4ptmz2xtns7q6lupppkw7wu)#d42g84j6",
     7          "hex": "00145483235e05c76273b3b50af62519738781aff021",
     8          "address": "bcrt1q2jpjxhs9ca388va4ptmz2xtns7q6lupppkw7wu",
     9          "type": "witness_v0_keyhash"
    10        }
    11      },
    12      {
    13        "value": 198.99859000,
    14        "n": 1,
    15        "scriptPubKey": {
    16          "asm": "0 870ab1ab58632b05a417d5295f4038500e407592",
    17          "desc": "addr(bcrt1qsu9tr26cvv4stfqh65547spc2q8yqavj7fnlju)#tgapemkv",
    18          "hex": "0014870ab1ab58632b05a417d5295f4038500e407592",
    19          "address": "bcrt1qsu9tr26cvv4stfqh65547spc2q8yqavj7fnlju",
    20          "type": "witness_v0_keyhash"
    21        },
    22        "ischange": true
    23      }
    24    ]
    
  2. rpc: add "ischange: true" in wallet gettransaction decoded tx output bef143cc28
  3. DrahtBot commented at 3:40 pm on May 15, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32517.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #31252 (rpc: print P2WSH and P2SH redem Script in getrawtransaction by polespinasa)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. DrahtBot added the label RPC/REST/ZMQ on May 15, 2025
  5. in src/rpc/rawtransaction.cpp:121 in bef143cc28 outdated
    117@@ -118,6 +118,7 @@ static std::vector<RPCResult> DecodeTxDoc(const std::string& txid_field_doc)
    118                 {RPCResult::Type::STR_AMOUNT, "value", "The value in " + CURRENCY_UNIT},
    119                 {RPCResult::Type::NUM, "n", "index"},
    120                 {RPCResult::Type::OBJ, "scriptPubKey", "", ScriptPubKeyDoc()},
    121+                {RPCResult::Type::BOOL, "ischange", /*optional=*/true, "Output script is change (only if wallet transaction and true for selected rpcwallet)"},
    


    maflcko commented at 4:12 pm on May 15, 2025:

    nit: Not sure about making this optional out of convenience and then write the rule in the description string.

    It would be better to just pass down a std::optionl<RPCResult> (or std::vector<RPCResult>) here, and then use Cat() to concatenate it?


    pinheadmz commented at 4:39 pm on May 15, 2025:
    Not sure what you mean here – help gettransaction doesn’t list this at all, it just tells the user to check decoderawtransaction

    maflcko commented at 5:04 pm on May 15, 2025:
    Hmm, looks like you are right. Though, that doesn’t seem very machine readable. It is a bit unrelated, but I can try to fix it, if you don’t want to include it here.

    pinheadmz commented at 5:43 pm on May 15, 2025:
    Ill give it a shot in this branch

    pinheadmz commented at 2:16 pm on May 16, 2025:
    done
  6. [move only] move DecodeTxDoc() to a common util file for sharing 23d779dcf5
  7. rpc: add decoded tx details to gettransaction with extra wallet fields f6517df210

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-25 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me