Skip to content

Commit ccc1cb1

Browse files
committed
btc(F-mirror F11): canonical exclude-then-append donation in payout sort
Mirror of LTC v36 commit 18dd945 onto the BTC variant. All three gentx sites (generate_share_transaction / create_local_share_v35 / create_local_share) now exclude BOTH donation scripts (COMBINED + P2PK) from per-miner payout dests and fold the COMBINED_DONATION_SCRIPT-keyed weight into the single donation-last output. Rides core/donation.hpp SSOT (FLAG6 #139). No F1 entanglement (F11 touches only the payout-sort path). Prep-branch staging; PR stays unopened until integrator dispatches the F-mirror post crossing-soak (#97). +51/-6, matches LTC F11 line counts.
1 parent 3a66006 commit ccc1cb1

1 file changed

Lines changed: 51 additions & 6 deletions

File tree

src/impl/btc/share_check.hpp

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,23 @@ uint256 generate_share_transaction(const ShareT& share, TrackerT& tracker, bool
11171117
auto gst_t2 = std::chrono::steady_clock::now(); // after amounts
11181118
// Python: sorted(dests, key=lambda a: (amounts[a], a))[-4000:]
11191119
// = ascending by (amount, script), keep last 4000 (highest amounts)
1120-
std::vector<std::pair<std::vector<unsigned char>, uint64_t>> payout_outputs(
1121-
amounts.begin(), amounts.end());
1120+
// F11: canonical exclude-then-append donation handling (p2pool data.py
1121+
// generate_transaction). The per-miner dests list excludes BOTH donation
1122+
// scripts; a COMBINED_DONATION_SCRIPT-keyed weight folds into the single
1123+
// donation-last output, and any DONATION_SCRIPT-keyed weight is dropped.
1124+
const std::vector<unsigned char> combined_donation_script(
1125+
core::donation::COMBINED_DONATION_SCRIPT.begin(), core::donation::COMBINED_DONATION_SCRIPT.end());
1126+
const std::vector<unsigned char> p2pk_donation_script(
1127+
core::donation::DONATION_SCRIPT.begin(), core::donation::DONATION_SCRIPT.end());
1128+
if (auto _dit = amounts.find(combined_donation_script); _dit != amounts.end())
1129+
donation_amount += _dit->second;
1130+
std::vector<std::pair<std::vector<unsigned char>, uint64_t>> payout_outputs;
1131+
payout_outputs.reserve(amounts.size());
1132+
for (auto& _kv : amounts) {
1133+
if (_kv.first == combined_donation_script || _kv.first == p2pk_donation_script)
1134+
continue;
1135+
payout_outputs.emplace_back(_kv.first, _kv.second);
1136+
}
11221137
std::sort(payout_outputs.begin(), payout_outputs.end(),
11231138
[](const auto& a, const auto& b) {
11241139
if (a.second != b.second) return a.second < b.second; // asc by amount
@@ -2390,8 +2405,23 @@ uint256 create_local_share_v35(
23902405
// V35: no minimum donation enforcement (unlike v36)
23912406
uint64_t donation_amount = (subsidy > sum_amounts) ? (subsidy - sum_amounts) : 0;
23922407

2393-
std::vector<std::pair<std::vector<unsigned char>, uint64_t>> payout_outputs(
2394-
amounts.begin(), amounts.end());
2408+
// F11: canonical exclude-then-append donation handling (p2pool data.py
2409+
// generate_transaction). The per-miner dests list excludes BOTH donation
2410+
// scripts; a COMBINED_DONATION_SCRIPT-keyed weight folds into the single
2411+
// donation-last output, and any DONATION_SCRIPT-keyed weight is dropped.
2412+
const std::vector<unsigned char> combined_donation_script(
2413+
core::donation::COMBINED_DONATION_SCRIPT.begin(), core::donation::COMBINED_DONATION_SCRIPT.end());
2414+
const std::vector<unsigned char> p2pk_donation_script(
2415+
core::donation::DONATION_SCRIPT.begin(), core::donation::DONATION_SCRIPT.end());
2416+
if (auto _dit = amounts.find(combined_donation_script); _dit != amounts.end())
2417+
donation_amount += _dit->second;
2418+
std::vector<std::pair<std::vector<unsigned char>, uint64_t>> payout_outputs;
2419+
payout_outputs.reserve(amounts.size());
2420+
for (auto& _kv : amounts) {
2421+
if (_kv.first == combined_donation_script || _kv.first == p2pk_donation_script)
2422+
continue;
2423+
payout_outputs.emplace_back(_kv.first, _kv.second);
2424+
}
23952425
std::sort(payout_outputs.begin(), payout_outputs.end(),
23962426
[](const auto& a, const auto& b) {
23972427
if (a.second != b.second) return a.second < b.second;
@@ -2944,8 +2974,23 @@ uint256 create_local_share(
29442974
}
29452975
}
29462976

2947-
std::vector<std::pair<std::vector<unsigned char>, uint64_t>> payout_outputs(
2948-
amounts.begin(), amounts.end());
2977+
// F11: canonical exclude-then-append donation handling (p2pool data.py
2978+
// generate_transaction). The per-miner dests list excludes BOTH donation
2979+
// scripts; a COMBINED_DONATION_SCRIPT-keyed weight folds into the single
2980+
// donation-last output, and any DONATION_SCRIPT-keyed weight is dropped.
2981+
const std::vector<unsigned char> combined_donation_script(
2982+
core::donation::COMBINED_DONATION_SCRIPT.begin(), core::donation::COMBINED_DONATION_SCRIPT.end());
2983+
const std::vector<unsigned char> p2pk_donation_script(
2984+
core::donation::DONATION_SCRIPT.begin(), core::donation::DONATION_SCRIPT.end());
2985+
if (auto _dit = amounts.find(combined_donation_script); _dit != amounts.end())
2986+
donation_amount += _dit->second;
2987+
std::vector<std::pair<std::vector<unsigned char>, uint64_t>> payout_outputs;
2988+
payout_outputs.reserve(amounts.size());
2989+
for (auto& _kv : amounts) {
2990+
if (_kv.first == combined_donation_script || _kv.first == p2pk_donation_script)
2991+
continue;
2992+
payout_outputs.emplace_back(_kv.first, _kv.second);
2993+
}
29492994
std::sort(payout_outputs.begin(), payout_outputs.end(),
29502995
[](const auto& a, const auto& b) {
29512996
if (a.second != b.second) return a.second < b.second;

0 commit comments

Comments
 (0)