Created
January 6, 2025 19:55
-
-
Save imaginator/e7350561454d5f0410c93bb3f14924f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_bolt12_payment(bolt12_offer: str, amount_sats: int): | |
ross_bolt12 = "lno1zrxq8pjw7qjlm68mtp7e3yvxee4y5xrgjhhyf2fxhlphpckrvevh50u0qtn2mq3gzvt8mkq4fy7vgt34s3kkdpllgshz3ak3d8st0texhm2hqqszvedh6tvvyt2zyvcl39chzqja08y3zu27f8jjl7mgyyp2kw5da6cqqvc3naftwk24xr90uqhwqv2p2znatq2tgh63ny3vd4slykgcx87ftuh28jwpvygshf34gfc8ywnkxlw89dh2qvmz9da8dw6nx5gty895tllv3t2lzk02l7vzna3m9dnpphjftncwvqqs4zrs72t38qscfe49vnwwmucwhg" | |
try: | |
optional_amount = PayAmount.RECEIVER(amount_sats) | |
print(bolt12_offer) | |
print(amount_sats) | |
prepare_req = PrepareSendRequest(destination=ross_bolt12, amount=optional_amount) | |
prepare_res = sdk_services.prepare_send_payment(prepare_req) | |
logging.info(f"Prepared to send {amount_sats} to {bolt12_offer}. Estimated fees: {prepare_res.fees_sat} sats") | |
send_req = SendPaymentRequest(prepare_res) | |
print(send_req) | |
send_res = sdk_services.send_payment(send_req) | |
print("SEND REQUEST", send_res) | |
logging.info(f"Payment sent successfully. Payment Hash: {send_res.payment}") | |
return send_res.payment | |
except Exception as e: | |
logging.error(f"Error creating PayAmount: {e}") | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment