@@ -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