stage24-payment-variance.py
TEXT FILE949 B · Public source code for developers, search crawlers and AI agents
1def classify(expected, outputs, network, address, min_conf=1):
2 if type(expected) is not int or expected <= 0 or min_conf < 1: raise ValueError("invalid policy")
3 seen={}
4 for txid,vout,net,dest,sats,conf in outputs:
5 if net != network or dest != address: continue
6 if type(sats) is not int or sats <= 0 or type(vout) is not int or vout < 0: raise ValueError("invalid output")
7 key=(txid,vout)
8 if key in seen and seen[key] != (sats,conf): raise ValueError("conflicting evidence")
9 seen[key]=(sats,conf)
10 paid=sum(s for s,c in seen.values() if c>=min_conf)
11 return ("underpaid" if paid<expected else "overpaid" if paid>expected else "paid",paid)
12
13if __name__ == "__main__":
14 x=("fixture",0,"test","dest",500,2)
15 assert classify(1000,[x,x],"test","dest")==("underpaid",500)
16 assert classify(400,[x],"test","dest")==("overpaid",500)
17 assert classify(500,[],"test","dest")==("underpaid",0)Read-only source · Select a line number to link directly · Raw download above
