#!/usr/bin/env python3 """PPLNS planner for the DirectPool Bitcoin Cash shared pool (non-custodial). CashStratum runs in pool mode with the "payoutplan" option. It pays the coinbase to whatever outputs this planner lists in PLAN_FILE, so every block pays the miners directly and the pool never holds their coins. What this service does: * Reads CashStratum's share logs (logdir//.sharelog) and keeps the accepted shares of the last WINDOW_MAX_DAYS days, grouped in BUCKET_SECS buckets per address. * PPLNS window: the most recent shares whose difficulty adds up to the network difficulty times WINDOW_MULTIPLIER (same rule as the Bitcoin pool), never older than WINDOW_MAX_DAYS. * Deferred payouts, same algorithm as the Bitcoin pool: an address whose share is below MIN_PAYOUT_SATS, or beyond MAX_OUTPUTS, keeps a credit in an append-only ledger and is paid in a later block. * Every PLAN_EVERY seconds writes PLAN_FILE ("