"""Pure scheduled mainnet subsidy; includes genesis allowance. Not a circulating-supply audit. No network, wallet access or broadcasts. Reference: Litecoin Core v0.21.5.8 validation.cpp and chainparams.cpp. """ import argparse,json COIN=100_000_000 INTERVAL=840_000 def subsidy(height): if not isinstance(height,int) or isinstance(height,bool) or height<0:raise ValueError('Use a nonnegative integer mainnet height') e=height//INTERVAL return (50*COIN)>>e if e<33 else 0 def scheduled(height): subsidy(height) return sum(max(0,min(INTERVAL,height-e*INTERVAL+1))*((50*COIN)>>e) for e in range(33)) def ltc(units):return str(units//COIN)+'.'+str(units%COIN).zfill(8) def check(): assert subsidy(839999)==50*COIN and subsidy(840000)==25*COIN assert subsidy(3359999)==625000000 and subsidy(3360000)==312500000 assert subsidy(27719999)==1 and subsidy(27720000)==0 assert scheduled(3199297)==7774561250000000 assert scheduled(27719999)==8399999990760000 assert scheduled(3359999)==7875000000000000 assert scheduled(3360000)==7875000312500000 for e in range(1,34): h=e*INTERVAL assert scheduled(h)-scheduled(h-1)==subsidy(h) assert scheduled(h-1)-scheduled(h-2)==subsidy(h-1) if __name__=='__main__': p=argparse.ArgumentParser(description=__doc__);p.add_argument('--height',type=int,default=3199297);a=p.parse_args();check() print(json.dumps({'kind':'scheduled allowance including genesis, not circulating supply','height':a.height,'subsidy_litoshis':subsidy(a.height),'subsidy_ltc':ltc(subsidy(a.height)),'scheduled_allowance_litoshis':scheduled(a.height),'scheduled_allowance_ltc':ltc(scheduled(a.height))},indent=2))