Implement gambling
This commit is contained in:
@@ -9,8 +9,8 @@ def get_transaction(s, i):
|
||||
try:
|
||||
while True:
|
||||
msg, sender = s.recvfrom(4096)
|
||||
if sender[0:2] == ("::1", 62039) and len(msg) == 155 and msg[0:5] == b"\0\0\0\0\x06" and msg[5:7] == i.to_bytes(2, "big"):
|
||||
return msg[7:155]
|
||||
if sender[0:2] == ("::1", 62039) and len(msg) == 156 and msg[0:5] == b"\0\0\0\0\x06" and msg[5:7] == i.to_bytes(2, "big"):
|
||||
return msg[7:156]
|
||||
except TimeoutError:
|
||||
pass
|
||||
return None
|
||||
@@ -32,13 +32,25 @@ def main():
|
||||
if transaction is None:
|
||||
print("- no response from local node -", file=sys.stderr)
|
||||
exit(1)
|
||||
if transaction == 148 * b"\0":
|
||||
if transaction == 149 * b"\0":
|
||||
return
|
||||
sender = format_addr(transaction[4:36])
|
||||
receiver = format_addr(transaction[36:68])
|
||||
amount = format_amount(transaction[68:76])
|
||||
fee = format_amount(transaction[76:84])
|
||||
print(f"{sender} {receiver} {amount:>13} {fee:>10}")
|
||||
if transaction[0] == 1:
|
||||
sender = format_addr(transaction[5:37])
|
||||
receiver = format_addr(transaction[37:69])
|
||||
amount = format_amount(transaction[69:77])
|
||||
fee = format_amount(transaction[77:85])
|
||||
elif transaction[0] == 2:
|
||||
sender = format_addr(transaction[5:37])
|
||||
receiver = "(gambling)" + 33 * " "
|
||||
amount = format_amount(transaction[37:45])
|
||||
fee = format_amount(transaction[45:53])
|
||||
elif transaction[0] == 3:
|
||||
print("- reveal transaction -")
|
||||
sender = None
|
||||
else:
|
||||
sender = None
|
||||
if sender is not None:
|
||||
print(f"{sender} {receiver} {amount:>13} {fee:>10}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user