quick and dirty Python graph scan for lightning nodes that support simple taproot channels
There was 93 nodes in my graph that support lightning, up from 3 the last time I checked!
```
import json
import subprocess
def get_pubkeys_from_lnd():
command = ["lncli", "describegraph"]
try:
output = subprocess.check_output(command, universal_newlines=True)
graph_data = json.loads(output)
# Extract the public keys from the nodes in the graph data
return [node['pub_key'] for node in graph_data.get('nodes', [])]
except subprocess.CalledProcessError as e:
print(f"Error running lncli describegraph: {e}")
return []
except json.JSONDecodeError as e:
print(f"Error decoding JSON output: {e}")
return []
def get_taproot_nodes():
taproot_nodes = []
pubkeys = get_pubkeys_from_lnd()
print(f"Got {len(pubkeys)} pubkeys. Scanning them for taproot support now.")
for pubkey in pubkeys:
try:
output = subprocess.check_output(
["lncli", "getnodeinfo", pubkey],
universal_newlines=True
)
node_info = json.loads(output)
# Check if feature "181" (taproot) is known
if node_info.get('node', {}).get('features', {}).get('181', {}).get('is_known'):
taproot_nodes.append(pubkey)
except subprocess.CalledProcessError as e:
print(f"Error processing pubkey {pubkey}: {e}")
except json.JSONDecodeError as e:
print(f"Error decoding JSON for pubkey {pubkey}: {e}")
# Write the final array of taproot-enabled pubkeys to a file
with open('results.txt', 'w') as result_file:
for node in taproot_nodes:
result_file.write(node + '\n')
print("Taproot nodes have been written to results.txt")
get_taproot_nodes()
```