Skip to content

Commit b103356

Browse files
committed
bindings: call swaps info from python example
1 parent f9a4741 commit b103356

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lwk_bindings/examples/lightning.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,18 @@ def list_all_swaps(lightning_session):
323323
except Exception as e:
324324
print(f"Error listing all swaps: {e}")
325325

326+
def show_swaps_info(lightning_session):
327+
"""Show swaps info from Boltz API"""
328+
try:
329+
# Fetch swaps info from Boltz
330+
swaps_info_json = lightning_session.fetch_swaps_info()
331+
332+
# Parse and pretty print the JSON
333+
swaps_info = json.loads(swaps_info_json)
334+
print(json.dumps(swaps_info, indent=2))
335+
except Exception as e:
336+
print(f"Error fetching swaps info: {e}")
337+
326338
def main():
327339
# Get mnemonic from environment variable
328340
mnemonic_str = os.getenv('MNEMONIC')
@@ -433,6 +445,7 @@ def main():
433445
print("6) Fetch restorable reverse swaps")
434446
print("7) Fetch restorable submarine swaps")
435447
print("8) List all swaps")
448+
print("9) Show swaps info")
436449
print("q) Quit")
437450

438451
choice = input("Choose option: ").strip().lower()
@@ -472,6 +485,9 @@ def main():
472485
elif choice == '8':
473486
print("\n=== Listing All Swaps ===")
474487
list_all_swaps(lightning_session)
488+
elif choice == '9':
489+
print("\n=== Showing Swaps Info ===")
490+
show_swaps_info(lightning_session)
475491
elif choice == 'q':
476492
print("Goodbye!")
477493
break

0 commit comments

Comments
 (0)