diff --git a/snippets/python/README.md b/snippets/python/README.md new file mode 100644 index 0000000..d0c3455 --- /dev/null +++ b/snippets/python/README.md @@ -0,0 +1,34 @@ +## Steps to run locally +1. Build a python package + - By running the publish-all-platforms CI in the breez-sdk repository (use dummy binaries) + - or by downloading from Pypi +2. Download the wheel artifact for your platform. For linux that is `python-wheel-3.8-manylinux_2_31_x86_64` +3. Unzip the artifact in the `snippets/python/packages` folder. +4. Run `pip install packages/{NAME_OF_.WHL_FILE}` +4. happy coding! + +To check the syntax: + +```bash +cd snippets/python +python3 -m compileall src +``` + +To check the snippet formatting: + +```bash +cd snippets/python/src +ruff --ignore F841 --ignore F401 --output-format=github . +``` + +To execute the snippets locally, in order to check for type correctness: + +```bash +#!/bin/bash + +export API_KEY="..." +export MNEMONIC="..." + +cd snippets/python +python main.py $API_KEY $MNEMONIC +``` \ No newline at end of file diff --git a/snippets/python_snippets/main.py b/snippets/python/main.py similarity index 100% rename from snippets/python_snippets/main.py rename to snippets/python/main.py diff --git a/snippets/python_snippets/src/buy_btc.py b/snippets/python/src/buy_btc.py similarity index 100% rename from snippets/python_snippets/src/buy_btc.py rename to snippets/python/src/buy_btc.py diff --git a/snippets/python_snippets/src/connecting_lsp.py b/snippets/python/src/connecting_lsp.py similarity index 100% rename from snippets/python_snippets/src/connecting_lsp.py rename to snippets/python/src/connecting_lsp.py diff --git a/snippets/python_snippets/src/fiat_currencies.py b/snippets/python/src/fiat_currencies.py similarity index 100% rename from snippets/python_snippets/src/fiat_currencies.py rename to snippets/python/src/fiat_currencies.py diff --git a/snippets/python_snippets/src/getting_started.py b/snippets/python/src/getting_started.py similarity index 100% rename from snippets/python_snippets/src/getting_started.py rename to snippets/python/src/getting_started.py diff --git a/snippets/python_snippets/src/list_payments.py b/snippets/python/src/list_payments.py similarity index 100% rename from snippets/python_snippets/src/list_payments.py rename to snippets/python/src/list_payments.py diff --git a/snippets/python_snippets/src/lnurl_auth.py b/snippets/python/src/lnurl_auth.py similarity index 100% rename from snippets/python_snippets/src/lnurl_auth.py rename to snippets/python/src/lnurl_auth.py diff --git a/snippets/python_snippets/src/lnurl_pay.py b/snippets/python/src/lnurl_pay.py similarity index 100% rename from snippets/python_snippets/src/lnurl_pay.py rename to snippets/python/src/lnurl_pay.py diff --git a/snippets/python_snippets/src/lnurl_withdraw.py b/snippets/python/src/lnurl_withdraw.py similarity index 100% rename from snippets/python_snippets/src/lnurl_withdraw.py rename to snippets/python/src/lnurl_withdraw.py diff --git a/snippets/python_snippets/src/receive_onchain.py b/snippets/python/src/receive_onchain.py similarity index 100% rename from snippets/python_snippets/src/receive_onchain.py rename to snippets/python/src/receive_onchain.py diff --git a/snippets/python_snippets/src/receive_payment.py b/snippets/python/src/receive_payment.py similarity index 100% rename from snippets/python_snippets/src/receive_payment.py rename to snippets/python/src/receive_payment.py diff --git a/snippets/python_snippets/src/send_onchain.py b/snippets/python/src/send_onchain.py similarity index 100% rename from snippets/python_snippets/src/send_onchain.py rename to snippets/python/src/send_onchain.py diff --git a/snippets/python_snippets/src/send_spontaneous_payment.py b/snippets/python/src/send_spontaneous_payment.py similarity index 100% rename from snippets/python_snippets/src/send_spontaneous_payment.py rename to snippets/python/src/send_spontaneous_payment.py diff --git a/snippets/python_snippets/src/static_channel_backup.py b/snippets/python/src/static_channel_backup.py similarity index 100% rename from snippets/python_snippets/src/static_channel_backup.py rename to snippets/python/src/static_channel_backup.py diff --git a/snippets/python_snippets/README.md b/snippets/python_snippets/README.md deleted file mode 100644 index 1b98ed2..0000000 --- a/snippets/python_snippets/README.md +++ /dev/null @@ -1,27 +0,0 @@ -## Steps to run locally - -To check the syntax: - -```bash -cd snippets/python_snippets -python3 -m compileall src -``` - -To check the snippet formatting: - -```bash -cd snippets/python_snippets/src -ruff --ignore F841 --ignore F401 --output-format=github . -``` - -To execute the snippets locally, in order to check for type correctness: - -```bash -#!/bin/bash - -export API_KEY="..." -export MNEMONIC="..." - -cd snippets/python_snippets -python main.py $API_KEY $MNEMONIC -``` \ No newline at end of file diff --git a/src/guide/buy_btc.md b/src/guide/buy_btc.md index ff9a1fe..d5cd290 100644 --- a/src/guide/buy_btc.md +++ b/src/guide/buy_btc.md @@ -66,7 +66,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/buy_btc.py:buy-btc}} +{{#include ../../snippets/python/src/buy_btc.py:buy-btc}} ```
diff --git a/src/guide/connecting_lsp.md b/src/guide/connecting_lsp.md index 68c9801..699eba4 100644 --- a/src/guide/connecting_lsp.md +++ b/src/guide/connecting_lsp.md @@ -61,7 +61,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/connecting_lsp.py:get-lsp-info}} +{{#include ../../snippets/python/src/connecting_lsp.py:get-lsp-info}} ```
@@ -137,7 +137,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/connecting_lsp.py:connect-lsp}} +{{#include ../../snippets/python/src/connecting_lsp.py:connect-lsp}} ```
diff --git a/src/guide/fiat_currencies.md b/src/guide/fiat_currencies.md index f9c4d8d..3071e3a 100644 --- a/src/guide/fiat_currencies.md +++ b/src/guide/fiat_currencies.md @@ -43,7 +43,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/fiat_currencies.py:list-fiat-currencies}} +{{#include ../../snippets/python/src/fiat_currencies.py:list-fiat-currencies}} ```
diff --git a/src/guide/getting_started.md b/src/guide/getting_started.md index 161ad40..d5f1a4d 100644 --- a/src/guide/getting_started.md +++ b/src/guide/getting_started.md @@ -134,7 +134,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/getting_started.py:init-sdk}} +{{#include ../../snippets/python/src/getting_started.py:init-sdk}} ```
@@ -214,7 +214,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/getting_started.py:fetch-balance}} +{{#include ../../snippets/python/src/getting_started.py:fetch-balance}} ```
diff --git a/src/guide/list_payments.md b/src/guide/list_payments.md index 5563a74..010c2b7 100644 --- a/src/guide/list_payments.md +++ b/src/guide/list_payments.md @@ -55,7 +55,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/list_payments.py:list-payments}} +{{#include ../../snippets/python/src/list_payments.py:list-payments}} ```
@@ -137,7 +137,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/list_payments.py:list-payments-filtered}} +{{#include ../../snippets/python/src/list_payments.py:list-payments-filtered}} ```
diff --git a/src/guide/lnurl_auth.md b/src/guide/lnurl_auth.md index 40e8a65..f266e7e 100644 --- a/src/guide/lnurl_auth.md +++ b/src/guide/lnurl_auth.md @@ -77,7 +77,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/lnurl_auth.py:lnurl-auth}} +{{#include ../../snippets/python/src/lnurl_auth.py:lnurl-auth}} ```
diff --git a/src/guide/lnurl_pay.md b/src/guide/lnurl_pay.md index f33af4c..157d85e 100644 --- a/src/guide/lnurl_pay.md +++ b/src/guide/lnurl_pay.md @@ -75,7 +75,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/lnurl_pay.py:lnurl-pay}} +{{#include ../../snippets/python/src/lnurl_pay.py:lnurl-pay}} ```
diff --git a/src/guide/lnurl_withdraw.md b/src/guide/lnurl_withdraw.md index ee93917..10b9fd7 100644 --- a/src/guide/lnurl_withdraw.md +++ b/src/guide/lnurl_withdraw.md @@ -79,7 +79,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/lnurl_withdraw.py:lnurl-withdraw}} +{{#include ../../snippets/python/src/lnurl_withdraw.py:lnurl-withdraw}} ```
diff --git a/src/guide/receive_onchain.md b/src/guide/receive_onchain.md index 19fe981..ccb1d04 100644 --- a/src/guide/receive_onchain.md +++ b/src/guide/receive_onchain.md @@ -63,7 +63,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/receive_onchain.py:generate-receive-onchain-address}} +{{#include ../../snippets/python/src/receive_onchain.py:generate-receive-onchain-address}} ```
@@ -139,7 +139,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/receive_onchain.py:in-progress-swap}} +{{#include ../../snippets/python/src/receive_onchain.py:in-progress-swap}} ```
@@ -221,7 +221,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/receive_onchain.py:list-refundables}} +{{#include ../../snippets/python/src/receive_onchain.py:list-refundables}} ```
@@ -306,7 +306,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/receive_onchain.py:execute-refund}} +{{#include ../../snippets/python/src/receive_onchain.py:execute-refund}} ```
@@ -384,7 +384,7 @@ do {
```python,ignore -{{#include ../../snippets/python_snippets/src/receive_onchain.py:get-channel-opening-fees}} +{{#include ../../snippets/python/src/receive_onchain.py:get-channel-opening-fees}} ```
diff --git a/src/guide/receive_payment.md b/src/guide/receive_payment.md index 6d7db0c..572b280 100644 --- a/src/guide/receive_payment.md +++ b/src/guide/receive_payment.md @@ -62,7 +62,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/receive_payment.py:receive-payment}} +{{#include ../../snippets/python/src/receive_payment.py:receive-payment}} ```
diff --git a/src/guide/send_onchain.md b/src/guide/send_onchain.md index 1d4bc66..fa313a6 100644 --- a/src/guide/send_onchain.md +++ b/src/guide/send_onchain.md @@ -61,7 +61,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/send_onchain.py:estimate-current-reverse-swap-total-fees}} +{{#include ../../snippets/python/src/send_onchain.py:estimate-current-reverse-swap-total-fees}} ```
@@ -135,7 +135,7 @@ Log.v("Breez", "Maximum amount, in sats: ${fees.max}")
```python,ignore -{{#include ../../snippets/python_snippets/src/send_onchain.py:get-current-reverse-swap-min-max}} +{{#include ../../snippets/python/src/send_onchain.py:get-current-reverse-swap-min-max}} ```
@@ -221,7 +221,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/send_onchain.py:start-reverse-swap}} +{{#include ../../snippets/python/src/send_onchain.py:start-reverse-swap}} ```
@@ -297,7 +297,7 @@ for (rs in sdk.inProgressReverseSwaps()) {
```python,ignore -{{#include ../../snippets/python_snippets/src/send_onchain.py:check-reverse-swaps-status}} +{{#include ../../snippets/python/src/send_onchain.py:check-reverse-swaps-status}} ```
diff --git a/src/guide/send_spontaneous_payment.md b/src/guide/send_spontaneous_payment.md index 628ca60..b5cba79 100644 --- a/src/guide/send_spontaneous_payment.md +++ b/src/guide/send_spontaneous_payment.md @@ -62,7 +62,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/send_spontaneous_payment.py:send-spontaneous-payment}} +{{#include ../../snippets/python/src/send_spontaneous_payment.py:send-spontaneous-payment}} ```
diff --git a/src/guide/static_channel_backup.md b/src/guide/static_channel_backup.md index 99e3b07..7eb0f62 100644 --- a/src/guide/static_channel_backup.md +++ b/src/guide/static_channel_backup.md @@ -64,7 +64,7 @@ try {
```python,ignore -{{#include ../../snippets/python_snippets/src/static_channel_backup.py:static-channel-backup}} +{{#include ../../snippets/python/src/static_channel_backup.py:static-channel-backup}} ```