aboutsummaryrefslogtreecommitdiff
path: root/src/policy
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-10-05 19:02:02 -0400
committerAndrew Chow <github@achow101.com>2023-10-05 19:08:19 -0400
commit54bdb6e0745934ad9ae6c77628f2382a83b9a1f0 (patch)
tree7644dd0f9bee6d342b5cc9999d0fb2a3a679d289 /src/policy
parentcf553e3ab7b3827c9c1b91fcc50082856f761913 (diff)
parent5b878be742dbfcd232d949d2df1fff4743aec3d8 (diff)
Merge bitcoin/bitcoin#27609: rpc: allow submitpackage to be called outside of regtest
5b878be742dbfcd232d949d2df1fff4743aec3d8 [doc] add release note for submitpackage (glozow) 7a9bb2a2a59ba49f80519c8435229abec2432486 [rpc] allow submitpackage to be called outside of regtest (glozow) 5b9087a9a7da2602485e85e0b163dc3cbd2daf31 [rpc] require package to be a tree in submitpackage (glozow) e32ba1599c599e75b1da3393f71f633de860505f [txpackages] IsChildWithParentsTree() (glozow) b4f28cc345ef9c5261c4a8d743654a44784c7802 [doc] parent pay for child in aggregate CheckFeeRate (glozow) Pull request description: Permit (restricted topology) submitpackage RPC outside of regtest. Suggested in https://github.com/bitcoin/bitcoin/pull/26933#issuecomment-1510851570 This RPC should be safe but still experimental - interface may change, not all features (e.g. package RBF) are implemented, etc. If a miner wants to expose this to people, they can effectively use "package relay" before the p2p changes are implemented. However, please note **this is not package relay**; transactions submitted this way will not relay to other nodes if the feerates are below their mempool min fee. Users should put this behind some kind of rate limit or permissions. ACKs for top commit: instagibbs: ACK 5b878be742dbfcd232d949d2df1fff4743aec3d8 achow101: ACK 5b878be742dbfcd232d949d2df1fff4743aec3d8 dergoegge: Code review ACK 5b878be742dbfcd232d949d2df1fff4743aec3d8 ajtowns: ACK 5b878be742dbfcd232d949d2df1fff4743aec3d8 ariard: Code Review ACK 5b878be742. Though didn’t manually test the PR. Tree-SHA512: 610365c0b2ffcccd55dedd1151879c82de1027e3319712bcb11d54f2467afaae4d05dca5f4b25f03354c80845fef538d3938b958174dda8b14c10670537a6524
Diffstat (limited to 'src/policy')
-rw-r--r--src/policy/packages.cpp15
-rw-r--r--src/policy/packages.h4
2 files changed, 19 insertions, 0 deletions
diff --git a/src/policy/packages.cpp b/src/policy/packages.cpp
index fd272a2642..47a9274a31 100644
--- a/src/policy/packages.cpp
+++ b/src/policy/packages.cpp
@@ -88,3 +88,18 @@ bool IsChildWithParents(const Package& package)
return std::all_of(package.cbegin(), package.cend() - 1,
[&input_txids](const auto& ptx) { return input_txids.count(ptx->GetHash()) > 0; });
}
+
+bool IsChildWithParentsTree(const Package& package)
+{
+ if (!IsChildWithParents(package)) return false;
+ std::unordered_set<uint256, SaltedTxidHasher> parent_txids;
+ std::transform(package.cbegin(), package.cend() - 1, std::inserter(parent_txids, parent_txids.end()),
+ [](const auto& ptx) { return ptx->GetHash(); });
+ // Each parent must not have an input who is one of the other parents.
+ return std::all_of(package.cbegin(), package.cend() - 1, [&](const auto& ptx) {
+ for (const auto& input : ptx->vin) {
+ if (parent_txids.count(input.prevout.hash) > 0) return false;
+ }
+ return true;
+ });
+}
diff --git a/src/policy/packages.h b/src/policy/packages.h
index 702667b8ad..cf37857e4b 100644
--- a/src/policy/packages.h
+++ b/src/policy/packages.h
@@ -63,4 +63,8 @@ bool CheckPackage(const Package& txns, PackageValidationState& state);
*/
bool IsChildWithParents(const Package& package);
+/** Context-free check that a package IsChildWithParents() and none of the parents depend on each
+ * other (the package is a "tree").
+ */
+bool IsChildWithParentsTree(const Package& package);
#endif // BITCOIN_POLICY_PACKAGES_H