Skip to content

Fix Python snippet callbacks and logs #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions snippets/python/src/getting_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def fetch_balance(sdk: BindingLiquidSdk):

# ANCHOR: logging
class SdkLogger(Logger):
def log(log_entry: LogEntry):
logging.debug("Received log [", log_entry.level, "]: ", log_entry.line)
def log(self, log_entry: LogEntry):
logging.debug(f"Received log [{log_entry.level}]: {log_entry.line}")

def set_logger(logger: SdkLogger):
try:
Expand All @@ -48,8 +48,8 @@ def set_logger(logger: SdkLogger):

# ANCHOR: add-event-listener
class SdkListener(EventListener):
def on_event(sdk_event: SdkEvent):
logging.debug("Received event ", sdk_event)
def on_event(self, sdk_event: SdkEvent):
logging.debug(f"Received event {sdk_event}")

def add_event_listener(sdk: BindingLiquidSdk, listener: SdkListener):
try:
Expand Down
14 changes: 7 additions & 7 deletions snippets/python/src/receive_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def prepare_receive_lightning(sdk: BindingLiquidSdk):
try:
# Fetch the lightning Receive limits
current_limits = sdk.fetch_lightning_limits()
logging.debug("Minimum amount allowed to deposit in sats ", current_limits.receive.min_sat)
logging.debug("Maximum amount allowed to deposit in sats ", current_limits.receive.max_sat)
logging.debug(f"Minimum amount allowed to deposit in sats {current_limits.receive.min_sat}")
logging.debug(f"Maximum amount allowed to deposit in sats {current_limits.receive.max_sat}")

# Set the invoice amount you wish the payer to send, which should be within the above limits
optional_amount = ReceiveAmount.BITCOIN(5_000)
Expand All @@ -17,7 +17,7 @@ def prepare_receive_lightning(sdk: BindingLiquidSdk):

# If the fees are acceptable, continue to create the Receive Payment
receive_fees_sat = prepare_response.fees_sat
logging.debug("Fees: ", receive_fees_sat, " sats")
logging.debug(f"Fees: {receive_fees_sat} sats")
return prepare_response
except Exception as error:
logging.error(error)
Expand All @@ -29,8 +29,8 @@ def prepare_receive_onchain(sdk: BindingLiquidSdk):
try:
# Fetch the onchain Receive limits
current_limits = sdk.fetch_onchain_limits()
logging.debug("Minimum amount allowed to deposit in sats ", current_limits.receive.min_sat)
logging.debug("Maximum amount allowed to deposit in sats ", current_limits.receive.max_sat)
logging.debug(f"Minimum amount allowed to deposit in sats {current_limits.receive.min_sat}")
logging.debug(f"Maximum amount allowed to deposit in sats {current_limits.receive.max_sat}")

# Set the onchain amount you wish the payer to send, which should be within the above limits
optional_amount = ReceiveAmount.BITCOIN(5_000)
Expand All @@ -39,7 +39,7 @@ def prepare_receive_onchain(sdk: BindingLiquidSdk):

# If the fees are acceptable, continue to create the Receive Payment
receive_fees_sat = prepare_response.fees_sat
logging.debug("Fees: ", receive_fees_sat, " sats")
logging.debug(f"Fees: {receive_fees_sat} sats")
return prepare_response
except Exception as error:
logging.error(error)
Expand All @@ -58,7 +58,7 @@ def prepare_receive_liquid(sdk: BindingLiquidSdk):

# If the fees are acceptable, continue to create the Receive Payment
receive_fees_sat = prepare_response.fees_sat
logging.debug("Fees: ", receive_fees_sat, " sats")
logging.debug(f"Fees: {receive_fees_sat} sats")
return prepare_response
except Exception as error:
logging.error(error)
Expand Down
6 changes: 3 additions & 3 deletions snippets/python/src/send_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def prepare_send_payment_lightning_bolt11(sdk: BindingLiquidSdk):

# If the fees are acceptable, continue to create the Send Payment
send_fees_sat = prepare_response.fees_sat
logging.debug("Fees: ", send_fees_sat, " sats")
logging.debug(f"Fees: {send_fees_sat} sats")
return prepare_response
except Exception as error:
logging.error(error)
Expand Down Expand Up @@ -43,7 +43,7 @@ def prepare_send_payment_liquid(sdk: BindingLiquidSdk):

# If the fees are acceptable, continue to create the Send Payment
send_fees_sat = prepare_response.fees_sat
logging.debug("Fees: ", send_fees_sat, " sats")
logging.debug(f"Fees: {send_fees_sat} sats")
return prepare_response
except Exception as error:
logging.error(error)
Expand All @@ -60,7 +60,7 @@ def prepare_send_payment_liquid_drain(sdk: BindingLiquidSdk):

# If the fees are acceptable, continue to create the Send Payment
send_fees_sat = prepare_response.fees_sat
logging.debug("Fees: ", send_fees_sat, " sats")
logging.debug(f"Fees: {send_fees_sat} sats")
return prepare_response
except Exception as error:
logging.error(error)
Expand Down
Loading