def out_lookup_invoice(r_hash): response = get_data.get_lookup_invoice(r_hash) memo = response.memo r_hash = response.r_hash r_preimage = response.r_preimage value = response.value creation_date = converters.convert_date(response.creation_date) payment_request = response.payment_request expiry = response.expiry cltv_expiry = response.cltv_expiry # Convert r_hash to 32-bit hex r_hash_hex = codecs.encode(r_hash, 'hex').decode() # Convert r_preimage to 32-bit hex r_preimage_hex = codecs.encode(r_preimage, 'hex').decode() # # Not sure why response does not include these # settled = response.settled # settle_date = response.settle_date # fallback_addr = response.fallback_addr # amt_paid_sat = response.amt_paid_sat # amt_paid_msat = response.amt_paid_msat print('\nInvoice Details:' + '\n' + '-' * 16) print("Creation Date :", creation_date) print("Memo :", memo) print("Value :", value) print("Expiry :", expiry) print("CLTV Expiry :", cltv_expiry) print("Payment Hash :", r_hash_hex) print("Payment Preimage :", r_preimage_hex) print("Payment Request :", payment_request) print('\r')
def out_list_payments(): payments = get_data.get_list_payments() payments = payments.payments if len(payments) > 0: print("\nPayments: " + str(len(payments)), '\n' + "-" * 12) payment_list = [] for payment in payments: payment_hash = payment.payment_hash create_date = converters.convert_date(payment.creation_date) value = payment.value payment_preimage = payment.payment_preimage # Setting path, but not using it in the output path = payment.path # Add this payment to the payment_list payment = [create_date, payment_hash, payment_preimage, value] payment_list.append(payment) # Build DataFrame payment_columns = [ 'Creation Date', 'Payment Hash', 'Payment Preimage', 'Value' ] payment_df = pd.DataFrame.from_records( payment_list, columns=payment_columns).to_string(index=False) print(payment_df) else: print("\nNo payments to list") print("\r")
def out_get_info(): get_info = get_data.get_info() pubkey = get_info.identity_pubkey alias = get_info.alias num_active_channels = get_info.num_active_channels num_peers = get_info.num_peers block_height = get_info.block_height block_hash = get_info.block_hash synced_to_chain = get_info.synced_to_chain best_header_timestamp = get_info.best_header_timestamp best_header_timestamp_converted = converters.convert_date( get_info.best_header_timestamp) version = get_info.version print("\nMy Lightning Node:\n" + "-" * 18) print("Public Key :", pubkey) print("Alias :", alias) print("Number of Active Channel :", num_active_channels) print("Number of Connected Peers :", num_peers) print("Block Height :", block_height) print("Block Hash :", block_hash) print("Synced to Chain :", synced_to_chain) print("Best Header Timestamp :", best_header_timestamp, "(" + str(best_header_timestamp_converted) + ")") print("LND Version :", version) print("\r")
def out_channel_info(chan_id): # Query for channel ID chan_info = get_data.get_channel_info(chan_id) channel_id = chan_info.channel_id chan_point = chan_info.chan_point last_update = chan_info.last_update node1_pub = chan_info.node1_pub node2_pub = chan_info.node2_pub capacity = chan_info.capacity # Node1 Policy node1_policy = chan_info.node1_policy node1_time_lock_delta = node1_policy.time_lock_delta node1_min_htlc = node1_policy.min_htlc node1_fee_base_msat = node1_policy.fee_base_msat node1_fee_rate_milli_msat = node1_policy.fee_rate_milli_msat # Node2 Policy node2_policy = chan_info.node2_policy node2_time_lock_delta = node2_policy.time_lock_delta node2_min_htlc = node2_policy.min_htlc node2_fee_base_msat = node2_policy.fee_base_msat node2_fee_rate_milli_msat = node2_policy.fee_rate_milli_msat # Get aliases for node_1 and node_2 node1_info = get_data.get_node_info(node1_pub) node2_info = get_data.get_node_info(node2_pub) node1_info = converters.response_to_dict(node1_info) node2_info = converters.response_to_dict(node2_info) node1_alias = node1_info['node']['alias'] node2_alias = node2_info['node']['alias'] # Channel details print("\nChannel Details:", '\n' + "-" * 16) print("Channel ID :", channel_id) print("Channel Point :", chan_point) print("Capacity :", capacity) print("Last Update :", converters.convert_date(last_update)) print('\r') # Node1 details print("Node1 Alias :", node1_alias) print("Node1 Public Key :", node1_pub) print("Node1 Policy :") print(" Time Lock Delta : ", node1_time_lock_delta) print(" Min HTLC :", node1_min_htlc) print(" Fee Base mSat :", node1_fee_base_msat) print(" Fee Rate Milli mSat :", node1_fee_rate_milli_msat) print('\r') # Node2 details print("Node2 Alias :", node2_alias) print("Node2 Public Key :", node2_pub) print("Node2 Policy :") print(" Time Lock Delta : ", node2_time_lock_delta) print(" Min HTLC :", node2_min_htlc) print(" Fee Base mSat :", node2_fee_base_msat) print(" Fee Rate Milli mSat :", node2_fee_rate_milli_msat) print('\r')
def out_list_invoices(): pd.set_option("display.max_colwidth", 65) invoices = get_data.get_list_invoices() invoices = invoices.invoices invoice_list = [] if len(invoices) > 0: print("\nInvoices: " + str(len(invoices)), '\n' + "-" * 12) for invoice in invoices: payment_preimage = codecs.encode(invoice.r_preimage, 'hex').decode() payment_hash = codecs.encode(invoice.r_hash, 'hex').decode() creation_date = converters.convert_date(invoice.creation_date) expiry = invoice.expiry cltv_expiry = invoice.cltv_expiry memo = invoice.memo value = invoice.value settled = invoice.settled settle_date = invoice.settle_date if settle_date == 0: settle_date = 'Not settled' else: settle_date = converters.convert_date(settle_date) private = invoice.private invoice = [ creation_date, memo, value, settled, settle_date, private, payment_hash, expiry, cltv_expiry ] invoice_list.append(invoice) # build df invoice_df_columns = [ 'Creation Date', 'Memo', 'Value', 'Settled', 'Settle Date', 'Private', 'Payment Hash', 'Expiry', 'CLTV' ] invoice_df = pd.DataFrame.from_records( invoice_list, columns=invoice_df_columns).to_string(index=False) print(invoice_df) else: print("\nNo invoices to list\n")
def out_decode_payreq(payment_request): response = get_data.get_decode_payreq(payment_request) destination = response.destination payment_hash = response.payment_hash num_satoshis = response.num_satoshis description = response.description timestamp = converters.convert_date(response.timestamp) expiry = response.expiry cltv_expiry = response.cltv_expiry print('\nPayment Request Details:' + '\n' + '-' * 24) print("Destination :", destination) print("Amount in Satoshis :", num_satoshis) print("Description :", description) print("Payment Hash :", payment_hash) print("Timestamp :", timestamp) print("Expiry :", expiry) print("CLTV Expiry :", cltv_expiry, '\n')
def out_txns(): txns = get_data.get_transactions() txns = txns.transactions print("\nTransactions: " + str(len(txns)) + " total \n" + "-" * 22) payment_number = 0 total_amount = 0 final_total_fees = 0 for txn in txns: tx_hash = txn.tx_hash num_confs = txn.num_confirmations block_hash = txn.block_hash block_height = txn.block_height time_stamp = converters.convert_date(txn.time_stamp) dest_addresses = txn.dest_addresses amount = txn.amount total_fees = txn.total_fees payment_number += 1 print("Payment Number :", payment_number) print("Time Stamp :", time_stamp) print("Amount :", amount) total_amount += amount print("Fee :", total_fees) final_total_fees += total_fees print("Confirmations :", num_confs) print("Block Height :", block_height) print("Block Hash :", block_hash) print("Destination Addresses :\r") for address in dest_addresses: print(" ", address) print("\r") # Print total tx amounts and fees print("Transaction Totals\n" + "-" * 18) print("Total TX Count :", payment_number) print("Total TX Amount :", total_amount) print("Total TX Fees :", final_total_fees) print('\r')
def out_node_info(pub_key): node_info = get_data.get_node_info(pub_key) node_details = node_info.node last_update = converters.convert_date(node_details.last_update) pub_key = node_details.pub_key alias = node_details.alias color = node_details.color num_channels = node_info.num_channels total_capacity = node_info.total_capacity try: addresses = node_info.addresses except: addresses = 'Unknown' print('\nNode Info') print('-' * 9) print('Alias :', alias) print('Public Key :', pub_key) print('Addresses :') print(' ', addresses) print('Color :', color) print('Last Update :', last_update) print('Nubmer of Channels :', num_channels) print('Total Capacity :', total_capacity) print('\r')