from lnd_grpc import Client from lnd_grpc.protos import rpc_pb2 as ln from random import randint from hashlib import sha256 from time import sleep from pathlib import Path ROOT_DIR = Path(__file__).parent LND_DIR = ROOT_DIR / ".lnd/" NETWORK = "testnet" client = Client(lnd_dir=str(LND_DIR), network=NETWORK) def create_random_hash(): n = str(randint(0, 1e32)) hash = sha256(n.encode()) return hash.digest(), n HASH, PREIMAGE = create_random_hash() MEMO = "TESTING HODL INVOICES" SATOSHIS = 10 print("HASH", HASH, type(HASH)) print("PREIMAGE", PREIMAGE) invoice = client.add_hold_invoice(memo=MEMO, hash=HASH, value=SATOSHIS) single_sub = client.subscribe_single_invoice(r_hash=HASH)
type=str, default=DEFAULT_WALLET_CONFIG, help=CONFIG_FILE_HELP) settings = parser.parse_args() settings.config = os.path.abspath(settings.config) if not os.path.exists(settings.config): sys.exit("*** can't use config: %s" % settings.config) config = ConfigParser() config.read(settings.config) logging.basicConfig(level=logging.DEBUG) lnd_dir = config['LND']['LndDir'] macaroon_path = config['LND']['MacaroonPath'] tls_cert_path = config['LND']['TlsCertPath'] network = config['LND']['Network'] grpc_host = config['LND']['GrpcHost'] grpc_port = int(config['LND']['GrpcPort']) c = Client(lnd_dir, macaroon_path, tls_cert_path, network, grpc_host, grpc_port) print(c.get_info()) lnd = Lnd(c) app = Terminus(config, lnd) app.run_app() reactor.run()
from lnd_grpc import Client from pathlib import Path from models import Invoice ROOT = Path(__file__).parent macaroon = ROOT / "admin.macaroon" tls = ROOT / "tls.cert" assert macaroon.exists() assert tls.exists() c = Client( macaroon_path=str(macaroon), tls_cert_path=str(tls), network="testnet", grpc_host="127.0.0.1", grpc_port="10009", ) MEMO = "THIS IS A MEMO" print(c.get_info()) inv = c.add_invoice(memo=MEMO, value=100) print(inv.r_hash, type(inv.r_hash)) print(inv.payment_request, type(inv.payment_request)) print(inv.add_index, type(inv.add_index)) decoded = c.decode_pay_req(pay_req=inv.payment_request) print(decoded) print(decoded.description) print(decoded.timestamp, type(decoded.timestamp))
from lnd_grpc import Client from pathlib import Path ROOT_DIR = Path(__file__).parent LND_DIR = ROOT_DIR / ".lnd/" NETWORK = "testnet" client = Client(lnd_dir=str(LND_DIR), network=NETWORK) print(client.version) print(client.get_info()) print(client.wallet_balance()) print(client.channel_balance()) print(client.list_peers()) print(client.new_address(address_type="p2wkh"))
from lnd_grpc import Client from pathlib import Path root_path = Path(__file__).parent lnd_path = root_path / ".lnd" print(lnd_path) x = Client(lnd_dir=str(lnd_path)) print(x.get_info())