Skip to content

Instantly share code, notes, and snippets.

@dgnsrekt
Last active March 16, 2019 23:08
Show Gist options
  • Save dgnsrekt/f2ba1ae2a1f6e368e4383905f5a26a3f to your computer and use it in GitHub Desktop.
Save dgnsrekt/f2ba1ae2a1f6e368e4383905f5a26a3f to your computer and use it in GitHub Desktop.
a script to replace a target link on https://lightningbutton.network/
# SYSTEM
import json
from time import sleep
from random import choice
# THIRDPARTY
from requests_html import HTMLSession
from lnd_grpc import lnd_grpc
NODE = lnd_grpc.Client()
TARGETS = ["bitcoinhex"]
PAYLOAD = [
"https://bitcoin.org/bitcoin.pdf",
"https://twitter.com/DGNSREKT/status/1107035977325953024",
"https://www.youtube.com/channel/UCGAJWjdaAh7ZbMAkunSmvpA",
]
SLEEP_TIME = 15
session = HTMLSession()
count = 0
xrf_token = ""
def check_channel_balance():
# ADD CHANNEL ARG
balance = 0
for channel in NODE.list_channels():
balance += int(channel.local_balance)
print(f"CURRENT_CHANNEL_BALANCE:{balance}")
def get_current_link():
global xrf_token
global session
if xrf_token:
session.headers["x-csrf-token"] = xrf_token
response = session.get("https://lightningbutton.network/")
javascript_variables = response.html.find("script")[-1].text.split("$")[0]
current_link = javascript_variables.split("link")[1].strip(" = ").strip("'")
if not xrf_token:
xrf_token = response.cookies["XSRF-TOKEN"]
return current_link
def link_is_target(link):
link = link.lower()
for target in TARGETS:
if target in link:
return target in link
def fire():
global xrf_token
global session
if xrf_token:
session.headers["Content-Type"] = "application/json"
session.headers["x-csrf-token"] = xrf_token
payload = {"link": choice(PAYLOAD)}
response = session.post(
"https://lightningbutton.network/invoice/getInvoice", data=json.dumps(payload)
)
invoice = response.json()["request"]
decoded_invoice = NODE.decode_pay_req(invoice)
public_key = decoded_invoice.destination
amount = decoded_invoice.num_satoshis
has_route = NODE.query_routes(pub_key=public_key, amt=amount, num_routes=2)
if has_route:
node_respose = NODE.pay_invoice(payment_request=invoice)
return True
def main():
global count
while True:
current = get_current_link()
if link_is_target(current):
print("TARGET ACQUIRED!")
print("FIRE!!!")
target_hit = fire()
if target_hit:
count += 1
print(f"TARGETS DESTROYED: {count}")
else:
print("MISSED TARGET :(")
print(
"I've giving it all she's got, Captain! If I push it any harder, the whole thing'll blow!"
)
print("SHIP NEEDS SUPPLIES!")
# ADD: NOTIFICATION SERVICE
sleep(10 * 60)
else:
print(current, "is ok")
check_channel_balance()
sleep(SLEEP_TIME)
if __name__ == "__main__":
main()
@dgnsrekt
Copy link
Author

I know its not pretty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment