SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 704a7a50630d63363e9dee08547d1103802b8c25
parent 80db7f981596c54870995aa38bda19a6816e974c
Author: Martin Habovstiak <martin.habovstiak@gmail.com>
Date:   Sun, 28 Mar 2021 12:10:56 +0200

Prefer invoice.macaroon, make paths configurable

Preferring invoice macaroon is much safer than admin macaroon without
any loss of features. Making paths configurable makes integration
easier.

Diffstat:
Mconfig.py | 3+++
Mpay/lnd.py | 19++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/config.py b/config.py @@ -37,8 +37,11 @@ redirect = None pay_method = "bitcoind" # Switch payment_method to lnd if you want to use lightning payments instead. And uncomment lnd_dir. #pay_method = "lnd" +# lnd_dir is only needed if you want to copy macaroon and TLS cert locally #lnd_dir = "~/.lnd/" #lnd_rpcport = "10009" +#lnd_macaroon = "invoice.macaroon" +#lnd_cert = "tls.cert" # DO NOT CHANGE THIS TO TRUE UNLESS YOU WANT ALL PAYMENTS TO AUTOMATICALLY # BE CONSIDERED AS PAID. diff --git a/pay/lnd.py b/pay/lnd.py @@ -17,7 +17,7 @@ class lnd(invoice): from lndgrpc import LNDClient - # Copy admin macaroon and tls cert to local machine + # Copy invoice macaroon and tls cert to local machine self.copy_certs() # Conect to lightning node @@ -40,8 +40,7 @@ class lnd(invoice): if test: print("Getting lnd info...") - info = self.lnd.get_info() - print(info) + self.lnd.list_invoices() print("Successfully contacted lnd.") break @@ -64,20 +63,22 @@ class lnd(invoice): # Copy tls and macaroon certs from remote machine. def copy_certs(self): - self.certs = {'tls' : 'tls.cert', 'macaroon' : 'admin.macaroon'} + self.certs = {'tls' : config.lnd_cert, 'macaroon' : config.lnd_macaroon} - if (not os.path.isfile("tls.cert")) or (not os.path.isfile("admin.macaroon")): + if (not os.path.isfile(config.lnd_cert)) or (not os.path.isfile(config.lnd_macaroon)): try: tls_file = os.path.join(config.lnd_dir, "tls.cert") macaroon_file = os.path.join( - config.lnd_dir, "data/chain/bitcoin/mainnet/admin.macaroon" + config.lnd_dir, "data/chain/bitcoin/mainnet/invoice.macaroon" ) # SSH copy if config.tunnel_host is not None: print( - "Could not find tls.cert or admin.macaroon in BTCPyment folder. \ - Attempting to download from remote lnd directory." + "Could not find {} or {} \ + Attempting to download from remote lnd directory.".format( + config.lnd_cert, config.lnd_macaroon + ) ) subprocess.run( @@ -100,7 +101,7 @@ class lnd(invoice): print(e) print("Failed to copy tls and macaroon files to local machine.") else: - print("Found tls.cert and admin.macaroon.") + print("Found tls.cert and invoice.macaroon.") return # Create lightning invoice