wallet, rpc: add v3 transaction creation and wallet support #32896

pull ishaanam wants to merge 9 commits into bitcoin:master from ishaanam:wallet_v3_txs changing 17 files +514 −11
  1. ishaanam commented at 8:13 pm on July 7, 2025: contributor

    This PR Implements the following:

    • If creating a v3 transaction, AvailableCoins doesn’t return unconfirmed v2 utxos (and vice versa)
    • AvailableCoins doesn’t return an unconfirmed v3 utxo if its transaction already has a child
    • If a v3 transaction is kicked out of the mempool by a sibling, mark the sibling as a mempool conflict
    • Throw an error if pre-selected inputs are of the wrong transaction version
    • Allow setting version to 3 manually in createrawtransaction (uses commits from #31936)
    • Limits a v3 transaction weight in coin selection

    Closes #31348

    To-Do:

    • Test a v3 sibling conflict kicking out one of our transactions from the mempool
    • Implement separate size limit for TRUC children
    • Test that we can’t fund a v2 transaction when everything is v3 unconfirmed
    • Test a v3 sibling conflict being removed from the mempool
    • Test limiting v3 transaction weight in coin selection
    • Simplify tests
    • Add documentation
  2. DrahtBot commented at 8:14 pm on July 7, 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/32896.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK glozow

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #32523 (wallet: Remove isminetypes by achow101)
    • #31936 (rpc: Support v3 raw transactions creation by Bue-von-hon)
    • #21283 (Implement BIP 370 PSBTv2 by achow101)

    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.

  3. ishaanam force-pushed on Jul 7, 2025
  4. DrahtBot added the label CI failed on Jul 7, 2025
  5. DrahtBot commented at 8:19 pm on July 7, 2025: contributor

    🚧 At least one of the CI tasks failed. Task lint: https://github.com/bitcoin/bitcoin/runs/45505893140 LLM reason (✨ experimental): The CI failure is caused by a lint error due to a file permission issue with a Python script that has a shebang line but incorrect executable permissions.

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  6. ishaanam force-pushed on Jul 8, 2025
  7. in test/functional/wallet_v3_txs.py:83 in e7b4084738 outdated
    65+
    66+        self.v3_tx_spends_unconfirmed_v2_tx()
    67+        self.v3_utxos_appear_in_listunspent()
    68+
    69+    @cleanup
    70+    def v3_tx_spends_unconfirmed_v2_tx(self):
    


    glozow commented at 5:16 pm on July 8, 2025:
    We should also check that we can’t fund a v2 transaction when everything is v3 unconfirmed

    ishaanam commented at 7:22 pm on July 8, 2025:
    Good point, I will add a test for this.
  8. in src/wallet/rpc/spend.cpp:720 in 75d606c564 outdated
    715@@ -715,6 +716,12 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
    716         coinControl.m_max_tx_weight = options["max_tx_weight"].getInt<int>();
    717     }
    718 
    719+    if (tx.version == TRUC_VERSION) {
    720+        if (!coinControl.m_max_tx_weight.has_value() || coinControl.m_max_tx_weight.value() > 40000) {
    


    glozow commented at 5:17 pm on July 8, 2025:
    Instead of magic numbers, try using TRUC_MAX_VSIZE * WITNESS_SCALE_FACTOR

    glozow commented at 5:33 pm on July 8, 2025:
    Also, there is a separate size limit for TRUC children - I don’t think that’s been implemented yet?

    ishaanam commented at 7:23 pm on July 8, 2025:
    Yes, I will look into implementing the separate size limit.
  9. in src/wallet/transaction.h:261 in 75d606c564 outdated
    257@@ -258,6 +258,9 @@ class CWalletTx
    258     // BlockConflicted.
    259     std::set<Txid> mempool_conflicts;
    260 
    261+    // Set of v3 transactions that spend from this tx
    


    glozow commented at 5:25 pm on July 8, 2025:
    Comment seems inaccurate: it mentions a set but this only allows for 1 transaction. Should also mention (1) that this is used to stop us from creating another unconfirmed child and (2) this is specifically the in mempool-sibling, as there can be multiple siblings but only 1 in mempool (unless there was a reorg).

    ishaanam commented at 7:23 pm on July 8, 2025:
    Done
  10. in src/wallet/spend.h:87 in 75d606c564 outdated
    82@@ -83,6 +83,8 @@ struct CoinFilterParams {
    83     bool include_immature_coinbase{false};
    84     // By default, skip locked UTXOs
    85     bool skip_locked{true};
    86+    // Whether or not to care about the tx version
    87+    bool track_version{true}; // only used by AvailableCoinsListUnspent
    


    glozow commented at 5:37 pm on July 8, 2025:
    A more descriptive name may be exclude_version3.

    ishaanam commented at 7:26 pm on July 8, 2025:
    I’m not sure if that name would be accurate, because this boolean is set to true even when we are trying to create a v3 transaction, in which case we are technically not excluding version 3.
  11. glozow commented at 5:41 pm on July 8, 2025: member
    Nice, concept ACK! Saw that these tests fail on #31936, which is helpful for showing its issues. Ultimately, I think the wallet commits should be introduced before the RPC ones.
  12. ishaanam force-pushed on Jul 8, 2025
  13. ishaanam force-pushed on Jul 8, 2025
  14. ishaanam force-pushed on Jul 8, 2025
  15. in test/functional/test_framework/messages.py:84 in 7fdff3ff7c outdated
    79@@ -80,6 +80,9 @@
    80 
    81 DEFAULT_MEMPOOL_EXPIRY_HOURS = 336  # hours
    82 
    83+TX_MIN_STANDARD_VERSION = 1
    84+TX_MAX_STANDARD_VERSION = 3
    


    maflcko commented at 6:25 am on July 9, 2025:
    there’s also test/functional/feature_taproot.py:TX_MAX_STANDARD_VERSION = 3

    ishaanam commented at 8:28 pm on July 9, 2025:
    I’ve changed this test to import TX_MAX_STANDARD_VERSION instead.
  16. in src/rpc/rawtransaction_util.cpp:161 in 7fdff3ff7c outdated
    154@@ -154,6 +155,13 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
    155         rawTx.nLockTime = nLockTime;
    156     }
    157 
    158+    if (!version.isNull()) {
    159+        uint32_t nVersion = version.getInt<uint32_t>();
    160+        if (nVersion < TX_MIN_STANDARD_VERSION || nVersion > TX_MAX_STANDARD_VERSION)
    161+            throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, version out of range(") + util::ToString(TX_MIN_STANDARD_VERSION) + "~" + util::ToString(TX_MAX_STANDARD_VERSION) + ")");
    


    maflcko commented at 6:26 am on July 9, 2025:
    could use strprintf for shorter code? Also missing {} around body of the if?

    ishaanam commented at 8:29 pm on July 9, 2025:
    Done
  17. ishaanam force-pushed on Jul 9, 2025
  18. ishaanam force-pushed on Jul 9, 2025
  19. wallet: unconfirmed ancestors and descendants are always truc 5541d6d889
  20. wallet: don't include unconfirmed v3 txs with children in available coins 1e860bd35b
  21. wallet: throw error at conflicting tx versions in pre-selected inputs 9937af31a1
  22. ishaanam force-pushed on Jul 9, 2025
  23. wallet: mark unconfirmed v3 siblings as mempool conflicts c1af179a38
  24. ishaanam force-pushed on Jul 10, 2025
  25. wallet: limit v3 tx weight in coin selection d6a33ee40a
  26. rpc: Add version parameter for transaction 5694c3b159
  27. rpc: Add current version parameter for transaction f8bf7296c6
  28. rpc: Support v3 raw transactions creation
    Added support for creating v3 raw transaction:
    - Overloaded  to include additional parameter
    
    Co-authored-by: chungeun-choi <cucuridas@gmail.com>
    Co-authored-by: dongwook-chan <dongwook.chan@gmail.com>
    Co-authored-by: sean-k1 <uhs2000@naver.com>
    4232b645d8
  29. ishaanam force-pushed on Jul 10, 2025
  30. test: add transaction version 3 wallet tests 7ded135089
  31. ishaanam force-pushed on Jul 10, 2025

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-07-11 12:13 UTC

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