aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/rawtransaction.cpp
AgeCommit message (Collapse)Author
2022-05-20Merge bitcoin/bitcoin#25168: refactor: Avoid passing params where not neededMacroFake
fa1b76aeb064b315a3767a8f59836ca18aeb117e Do not call global Params() when chainman is in scope (MacroFake) fa30234be81b6f49ae8150478a9255daa1611083 Do not pass CChainParams& to PeerManager::make (MacroFake) fafe5c0ca2927642cbcec63ac73994737e1653d6 Do not pass CChainParams& to BlockAssembler constructor (MacroFake) faf012b438b451dced785e7f031e07c0c55665e1 Do not pass Consensus::Params& to Chainstate helpers (MacroFake) fa4ee53dca5ccf1b87f019f372ffc10528add943 Do not pass time getter to Chainstate helpers (MacroFake) Pull request description: It seems confusing to pass chain params, consensus params, or a time function around when it is not needed. Fix this by: * Inlining the passed time getter function. I don't see a use case why this should be mockable. * Using `chainman.GetConsensus()` or `chainman.GetParams()`, where possible. ACKs for top commit: promag: Code review ACK fa1b76aeb064b315a3767a8f59836ca18aeb117e. vincenzopalazzo: ACK https://github.com/bitcoin/bitcoin/pull/25168/commits/fa1b76aeb064b315a3767a8f59836ca18aeb117e Tree-SHA512: 1abff5cba4b4871d97f17dbcdf67bc9255ff21fa4150a79a74e39b28f0610eab3e7dee24d56872dd6e111f003b55e288958cdd467e6218368d896f191e4ec9cd
2022-05-18scripted-diff: Use getInt<T> over get_int/get_int64MacroFake
-BEGIN VERIFY SCRIPT- sed -i 's|\<get_int64\>|getInt<int64_t>|g' $(git grep -l get_int ':(exclude)src/univalue') sed -i 's|\<get_int\>|getInt<int>|g' $(git grep -l get_int ':(exclude)src/univalue') -END VERIFY SCRIPT-
2022-05-18Do not call global Params() when chainman is in scopeMacroFake
2022-05-04refactor: Change * to & in MutableTransactionSignatureCreatorMarcoFalke
2022-04-25Remove not needed clang-format off commentsMarcoFalke
Can be reviewed with --word-diff-regex=. --ignore-all-space
2022-04-16util/check: Add CHECK_NONFATAL identity function, NONFATAL_UNREACHABLE AND ↵Aurèle Oulès
UNREACHABLE macros
2022-03-31doc: Use DecodeTxDoc helperMarcoFalke
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-03-31Merge bitcoin/bitcoin#24716: rpc: Fix documentation assertion for ↵MarcoFalke
`getrawtransaction` 71038a151e3136c22449e1a5cb1f386e8474c32d rpc: Fix documentation assertion for `getrawtransaction` (laanwj) Pull request description: When `getrawtransaction` is successfully used on a coinbase transaction, there is an assertion error. This is very unlikely but happens in the `interface_usdt_utxocache.py` test in #24358. This does the following: - Add missing "coinbase" documentation. - Synchronize documentation between `getrawtransaction` and `decoderawtransaction`, the two users of `TxToUniv` that have detailed documentation. `decodepsbt` and `getblock` also uses it but fortunately elides this block. - Change "vout[].amount" to `STR_AMOUNT` for consistency. - Add maintainer comment to keep the two places synchronized. It might be possible to get smarter with deduplication, but there are some extra fields that prevent the obvious way. ACKs for top commit: jonatack: ACK 71038a151e3136c22449e1a5cb1f386e8474c32d Tree-SHA512: 962236130455d805190ff9a5c971e4e25c17db35614a90ce340264ec953b0ad7fb814eb33ae430b5073955a8a350f72bdd67ba93e35f9c70e5175b836a767a35
2022-03-30refactor: use named args when ScriptToUniv or TxToUniv are invokedMichael Dietz
2022-03-30refactor: merge ScriptPubKeyToUniv & ScriptToUniv into one functionMichael Dietz
2022-03-30rpc: Fix documentation assertion for `getrawtransaction`laanwj
When `getrawtransaction` is successfully used on a coinbase transaction, there is an assertion error. This is very unlikely but happens in the test in #24358. This does the following: - Add missing "coinbase" documentation. - Synchronize documentation between `getrawtransaction` and `decoderawtransaction`, the two users of `TxToUniv` that have detailed documentation. `decodepsbt` also uses it but fortunately elides this block. - Change "vout[].amount" to `STR_AMOUNT` for consistency. - Add maintainer comment to keep the two places synchronized. It might be possible to get smarter with deduplication, but there are some extra fields that prevent the obvious way.
2022-03-28Merge bitcoin/bitcoin#24656: refactor: Move mempool RPCs to rpc/mempoolMarcoFalke
fac5a51c47fba21678fb35805e40d00fe7c891a0 Move mempool RPCs to rpc/mempool (MarcoFalke) fa0f666dd7b55a5a0250c5e35d2c3dfd565463b7 style: Add static keyword where possible in rpc/mempool (MarcoFalke) Pull request description: This moves the remaining mempool RPCs to `rpc/mempool`. Previously all mempool RPCs from the `blockchain` category have been moved. This patch moves the ones from the `rawtransactions` category. In the future, as a follow-up to this refactoring patch, it could be considered whether a new `mempool` category should be introduced. Beside a clearer code organization, this pull request should also reduce the compile time and space of the `rawtransactions.cpp` file. ACKs for top commit: promag: Code review ACK fac5a51c47fba21678fb35805e40d00fe7c891a0. Tree-SHA512: 5578b894b68d0595869a9b03ed8dceebe3366f73dec5f090ccc36ff4002b1bc4d58af77546c2d71537c1be03694d9a28c4b1bfbb3569560997879293c5c0301e
2022-03-24Merge bitcoin/bitcoin#24636: rpc: Exclude descriptor when address is excludedfanquake
faf37c217a408114224f91b7ada3fb6ff29b0c0a rpc: Exclude descriptor when address is excluded (MarcoFalke) Pull request description: I don't think output descriptors should be used to describe redeem scripts and witness scripts. Fix this by excluding them when it doesn't make sense. This should only affect the `decodepsbt` RPC. Found by https://github.com/bitcoin/bitcoin/pull/23083 ACKs for top commit: achow101: ACK faf37c217a408114224f91b7ada3fb6ff29b0c0a jonatack: ACK faf37c217a408114224f91b7ada3fb6ff29b0c0a Tree-SHA512: ebd581ad639e70080e26028723fed287caa3fa4d7b836936645020d6cd9b7586585d7113b043442c444a9dc90c23b93efd7f8b8a7d6cf5db1e42137b67c497c3
2022-03-24Move mempool RPCs to rpc/mempoolMarcoFalke
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-03-23rpc: Exclude descriptor when address is excludedMarcoFalke
2022-03-17Move txoutproof RPCs to txoutproof.cppMarcoFalke
2022-03-09refactor: more const annotations for uses of CBlockIndex*Anthony Towns
2022-02-22Merge bitcoin/bitcoin#24367: User-facing content and codebase doc fixups ↵laanwj
from transifex translator feedback 48742693acc9de837735674057c9aae2fe90bd1d Replace "can not" with "cannot" in docs, user messages, and tests (Jon Atack) e670edd43441ecb6e5978d65348501c57d856030 User-facing content fixups from transifex translator feedback (Jon Atack) Pull request description: Closes #24366. ACKs for top commit: laanwj: Code review re-ACK 48742693acc9de837735674057c9aae2fe90bd1d hebasto: re-ACK 48742693acc9de837735674057c9aae2fe90bd1d, only suggested change since my previous [review](https://github.com/bitcoin/bitcoin/pull/24367#pullrequestreview-885938219). Tree-SHA512: 4dcdcb417251a413e65fab6070515e13a1267c8e0dbcf521386b842511391f24c84a0c2168fe13458c977682034466509bf2a3453719d4d94d3c568fd9f4adb4
2022-02-21Replace "can not" with "cannot" in docs, user messages, and testsJon Atack
2022-02-14Move `GetAllOutputTypes` function from `rpc/rawtransaction.cpp` to ↵Kiminuo
`rpc/util.{h|cpp}`
2022-01-27Merge bitcoin/bitcoin#22932: Add CBlockIndex lock annotations, guard ↵laanwj
nStatus/nFile/nDataPos/nUndoPos by cs_main 6ea56827842b9b2bd730edc38f3a7b1f46f6247b Guard CBlockIndex::nStatus/nFile/nDataPos/nUndoPos by cs_main (Jon Atack) 5d59ae0ba88849b1eb0d7350871bc19fcd5ef601 Remove/inline ReadRawBlockFromDisk(block_data, pindex, message_start) (Hennadii Stepanov) eaeeb88768db529b5241ccd42f1e87579908b4df Require IsBlockPruned() to hold mutex cs_main (Jon Atack) ca47b005770f71aa229ecc1f7b8146a96ff02151 Require CBlockIndex::IsValid() to hold cs_main (Vasil Dimov) e9f3aa5f6a7b39e8d5f2069617e5e382798d8d60 Require CBlockIndex::RaiseValidity() to hold cs_main (Vasil Dimov) 8ef457cb83fac796f8b6a56977b1016193fc1185 Require CBlockIndex::IsAssumedValid() to hold cs_main (Vasil Dimov) 572393448b4d32f91b92edc84b4200ab52d62422 Require CBlockIndex::GetUndoPos() to hold mutex cs_main (Jon Atack) 2e557ced2830fc54476e598d52225f1679205e7d Require WriteUndoDataForBlock() to hold mutex cs_main (Jon Atack) 6fd4341c10b319399c58d71c4ddeae4417e337d7 Require CBlockIndex::GetBlockPos() to hold mutex cs_main (Jon Atack) Pull request description: Issues: - `CBlockIndex` member functions `GetBlockPos()`, `GetUndoPos()`, `IsAssumedValid()`, `RaiseValidity()`, and `IsValid()` and block storage functions `WriteUndoDataForBlock()` and `IsBlockPruned()` are missing thread safety lock annotations to help ensure that they are called with mutex cs_main to avoid bugs like #22895. Doing this also enables the next step: - `CBlockIndex::nStatus` may be racy, i.e. potentially accessed by multiple threads, see #17161. A solution is to guard it by cs_main, along with fellow data members `nFile`, `nDataPos` and `nUndoPos`. This pull: - adds thread safety lock annotations for the functions listed above - guards `CBlockIndex::nStatus`, `nFile`, `nDataPos` and `nUndoPos` by cs_main How to review and test: - debug build with clang and verify there are no `-Wthread-safety-analysis` warnings - review the code to verify each annotation or lock is necessary and sensible, or if any are missing - look for whether taking a lock can be replaced by a lock annotation instead - for more information about Clang thread safety analysis, see - https://clang.llvm.org/docs/ThreadSafetyAnalysis.html - https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#lockingmutex-usage-notes - https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#threads-and-synchronization Mitigates/potentially closes #17161. ACKs for top commit: laanwj: Code review ACK 6ea56827842b9b2bd730edc38f3a7b1f46f6247b Tree-SHA512: 3ebf429c8623c51f944a7245a2e48d2aa088dec4c4914b40aa6049e89856c1ee8586f6e2e3b65195190566637a33004468b51a781e61a082248748015167569b
2022-01-26transaction decoding infer output descriptorsGregory Sanders
2022-01-25Guard CBlockIndex::nStatus/nFile/nDataPos/nUndoPos by cs_mainJon Atack
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
2022-01-06Add src/node/* code to node:: namespaceRussell Yanofsky
2022-01-04doc: Mark proprietary array optionalMarcoFalke
Also, remove not needed '\n's. Can be reviewed with --word-diff-regex=.
2021-12-30scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: * 2020: fa0074e2d82928016a43ca408717154a1c70a4db * 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2021-12-15Merge bitcoin/bitcoin#22674: validation: mempool validation and submission ↵W. J. van der Laan
for packages of 1 child + parents 046e8ff264be6b888c0f9a9d822e32aa74e19b78 [unit test] package submission (glozow) e12fafda2dfbbdf63f125e5af797ecfaa6488f66 [validation] de-duplicate package transactions already in mempool (glozow) 8310d942e046c5a9b6bd90afdcd3af68dd91e081 [packages] add sanity checks for package vs mempool limits (glozow) be3ff151a1f9665720cdf70d072b098a2f9726a9 [validation] full package accept + mempool submission (glozow) 144a29099a865ac1dc3e5291d9529fbcca9c83a4 [policy] require submitted packages to be child-with-unconfirmed-parents (glozow) d59ddc5c3d1c035474d7bc9fa9f8a0eeb1c8498c [packages/doc] define and document package rules (glozow) ba26169f6035c238378a3c9647213328a006fa23 [unit test] context-free package checks (glozow) 9b2fdca7f03911ac40fe0f8a0b5da534bee4554b [packages] add static IsChildWithParents function (glozow) Pull request description: This is 1 chunk of [Package Mempool Accept](https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a); it restricts packages to 1 child with its parents, doesn't allow conflicts, and doesn't have CPFP (yet). Future PRs (see #22290) will add RBF and CPFP within packages. ACKs for top commit: laanwj: Code review ACK 046e8ff264be6b888c0f9a9d822e32aa74e19b78 Tree-SHA512: 37dbba37d527712f8efef71ee05c90a8308992615af35f5e0cfeafc60d859cc792737d125aac526e37742fe7683ac8c155ac24af562426213904333c01260c95
2021-12-11rpc: output all hash preimages in 'decodepsbt'Antoine Poinsot
2021-12-10Merge global xpubs in joinpsbts and combinepsbtsAndrew Chow
2021-12-10Add global_xpubs to decodepsbtAndrew Chow
2021-12-10Output proprietary type info in decodepsbtAndrew Chow
2021-12-10Output psbt version in decodepsbtAndrew Chow
2021-12-10Merge bitcoin/bitcoin#22514: psbt: Actually use SIGHASH_DEFAULT for PSBT signingMarcoFalke
c0405ee27fa23a9868f04c052bdc94d7accc57e2 rpc: Document that DEFAULT is for Taproot, ALL for everything else (Andrew Chow) d3992669df826899a3de78a77a366dab46028026 psbt: Actually use SIGHASH_DEFAULT (Andrew Chow) eb9a1a2c595a03475fd4275b104676b7e2200f07 psbt: Make sighash_type std::optional<int> (Andrew Chow) Pull request description: Make the behavior align with the help text by actually using SIGHASH_DEFAULT as the default sighash for signing PSBTs. ACKs for top commit: Sjors: re-utACK c0405ee27fa23a9868f04c052bdc94d7accc57e2 Tree-SHA512: 5199fb41de416b2f10ac451f824e7c94b428ba11fdb9e50f0027c692e959ce5813a340c34a4e52d7aa128e12008303d80939a693eff36a869720e45442119828
2021-12-08rpc: Document that DEFAULT is for Taproot, ALL for everything elseAndrew Chow
2021-12-08psbt: Make sighash_type std::optional<int>Andrew Chow
It is better to ues an optional to determine whether the sighash type is set rather than using 0 as a magic number.
2021-12-08scripted-diff: Use named args in RPC docsMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i -e 's|, /\* optional \*/ true,|, /*optional=*/true,|g' $( git grep -l ', /\* optional \*/ true,' ) -END VERIFY SCRIPT-
2021-12-08Merge bitcoin/bitcoin#20295: rpc: getblockfrompeerMarcoFalke
dce8c4c38111556ca480aa0e63c46b71f66b508f rpc: getblockfrompeer (Sjors Provoost) b884ababc29ce963826d8a4327ed6a5e629ff175 rpc: move Ensure* helpers to server_util.h (Sjors Provoost) Pull request description: This adds an RPC method to fetch a block directly from a peer. This can used to fetch stale blocks with lower proof of work that are normally ignored by the node (`headers-only` in `getchaintips`). Usage: ``` bitcoin-cli getblockfrompeer HASH peer_n ``` Closes #20155 Limitations: * you have to specify which peer to fetch the block from * the node must already have the header ACKs for top commit: jnewbery: ACK dce8c4c38111556ca480aa0e63c46b71f66b508f fjahr: re-ACK dce8c4c38111556ca480aa0e63c46b71f66b508f Tree-SHA512: 843ba2b7a308f640770d624d0aa3265fdc5c6ea48e8db32269b96a082b7420f7953d1d8d1ef2e6529392c7172dded9d15639fbc9c24e7bfa5cfb79e13a5498c8
2021-12-06rpc: Only allow specific types to be P2(W)SH wrapped in decodescriptMarcoFalke
2021-12-02Merge bitcoin/bitcoin#23642: refactor: Call type-solver earlier in decodescriptMarcoFalke
33330702081f67cb05fd86e00b252f6355249513 refactor: Call type-solver earlier in decodescript (MarcoFalke) fab0d998f4bf0f3f09afa51845d91408dd484408 style: Remove whitespace (MarcoFalke) Pull request description: The current logic is a bit confusing. First creating the `UniValue` return dict, then parsing it again to get the type as `std::string`. Clean this up by using a strong type `TxoutType`. Also, remove whitespace. ACKs for top commit: shaavan: ACK 33330702081f67cb05fd86e00b252f6355249513 theStack: Code-review ACK 33330702081f67cb05fd86e00b252f6355249513 Tree-SHA512: 49db7bc614d2491cd3ec0177d21ad1e9924dbece1eb5635290cd7fd18cb30adf4711b891daf522e7c4f6baab3033b66393bbfcd1d4726f24f90a433124f925d6
2021-12-02rpc: move Ensure* helpers to server_util.hSjors Provoost
2021-12-01doc: Extract CreateTxDoc in rawtransactionfanquake
For the fields: inputs, outputs, locktime, replaceable
2021-12-01refactor: Call type-solver earlier in decodescriptMarcoFalke
Also, remove std::string type.
2021-12-01style: Remove whitespaceMarcoFalke
Can be reviewed via --ignore-all-space
2021-11-29[validation] de-duplicate package transactions already in mempoolglozow
As node operators are free to set their mempool policies however they please, it's possible for package transaction(s) to already be in the mempool. We definitely don't want to reject the entire package in that case (as that could be a censorship vector). We should still return the successful result to the caller, so add another result type to MempoolAcceptResult.
2021-11-17doc: Fix incorrect C++ named argsMarcoFalke
2021-11-10Merge bitcoin/bitcoin#23173: Add `ChainstateManager::ProcessTransaction`MarcoFalke
0fdb619aaf1d62598263361a6082d182be1af792 [validation] Always call mempool.check() after processing a new transaction (John Newbery) 2c64270bbe523ef87e7225c351464e7c716f0b3e [refactor] Don't call AcceptToMemoryPool() from outside validation.cpp (John Newbery) 92a3aeecf6a82e9cbc9fda11022b0548efd24d05 [validation] Add CChainState::ProcessTransaction() (John Newbery) 36167faea92c97ddea7403280a5074073c8e5f90 [logging/documentation] Remove reference to AcceptToMemoryPool from error string (John Newbery) 4c24142b1ec121623f81ba644d77341bc1bd88dd [validation] Remove comment about AcceptToMemoryPool() (John Newbery) 5759fd12b8d5937e9187fa33489a95b1d8e6d1e5 [test] Don't set bypass_limits to true in txvalidation_tests.cpp (John Newbery) 497c9e29640858bb3beb20089c2d4f9e133c7e42 [test] Don't set bypass_limits to true in txvalidationcache_tests.cpp (John Newbery) Pull request description: Similarly to how #18698 added `ProcessNewBlock()` and `ProcessNewBlockHeaders()` methods to the `ChainstateManager` class, this PR adds a new `ProcessTransaction()` method. Code outside validation no longer calls `AcceptToMemoryPool()` directly, but calls through the higher-level `ProcessTransaction()` method. Advantages: - The interface is simplified. Calling code no longer needs to know about the active chainstate or mempool object, since `AcceptToMemoryPool()` can only ever be called for the active chainstate, and that chainstate knows which mempool it's using. We can also remove the `bypass_limits` argument, since that can only be used internally in validation. - responsibility for calling `CTxMemPool::check()` is removed from the callers, and run automatically by `ChainstateManager` every time `ProcessTransaction()` is called. ACKs for top commit: lsilva01: tACK 0fdb619 on Ubuntu 20.04 theStack: Code-review ACK 0fdb619aaf1d62598263361a6082d182be1af792 ryanofsky: Code review ACK 0fdb619aaf1d62598263361a6082d182be1af792. Only changes since last review: splitting & joining commits, adding more explanations to commit messages, tweaking MEMPOOL_ERROR string, fixing up argument name comments. Tree-SHA512: 0b395c2e3ef242f0d41d47174b1646b0a73aeece38f1fe29349837e6fb832f4bf8d57e1a1eaed82a97c635cfd59015a7e07f824e0d7c00b2bee4144e80608172
2021-11-03[refactor] Don't call AcceptToMemoryPool() from outside validation.cppJohn Newbery
2021-10-28[validation/rpc] cache + use vsize calculated in PreChecksglozow
This is not only cleaner but also helps make sure we are always using the virtual size measure that includes the sigop weight heuristic (which is the vsize the mempool would return).
2021-09-30[MOVEONLY] consensus: move amount.h into consensusfanquake
Move amount.h to consensus/amount.h. Renames, adds missing and removes uneeded includes.
2021-09-24refactor: minor styling, prefer snake case and same line ifMichael Dietz