-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_payment.py
22 lines (22 loc) · 1.05 KB
/
check_payment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import rpc_pb2 as ln
import rpc_pb2 as ln, rpc_pb2_grpc as lnrpc
import grpc, os
import codecs
import time
from paramiko.client import SSHClient
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open(os.path.expanduser('~/.lnd/tls.cert'), 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
channel = grpc.secure_channel('localhost:10009', ssl_creds)
stub = lnrpc.LightningStub(channel)
request = ln.InvoiceSubscription()
for response in stub.SubscribeInvoices(request):
if response.settled:
#do something
print('starting ssh call')
client = SSHClient()
client.load_system_host_keys()
client.connect('192.168.0.104', username='pi', password='raspberry')
stdin, stdout, stderr = client.exec_command('source ~/.ludwigsbashrc && rostopic pub /roboy/control/matrix/leds/mode/simple std_msgs/Int32 \"data: 2\" --once')
time.sleep(10)
stdin, stdout, stderr = client.exec_command('source ~/.ludwigsbashrc && rostopic pub /roboy/control/matrix/leds/mode/simple std_msgs/Int32 \"data: 0\" --once')