Skip to content

Commit 4dca277

Browse files
Lightspark Engjklein24
Lightspark Eng
authored andcommitted
Project import generated by Copybara.
GitOrigin-RevId: 4d4133c681420c2ca658ede5bd8e2e6e62e3ca5c
1 parent 85e6287 commit 4dca277

28 files changed

+662
-106
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22

3+
# v1.1.0
4+
5+
- Adding the ability to manage wallets tied to the current account. See `Account.get_wallets()` and the `Wallet` object.
6+
37
# v1.0.0
8+
49
- Added ability to create amp invoice.
510
- Fixed request_withdrawal.
611

Pipfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ name = "pypi"
55

66
[packages]
77
cryptography = "*"
8+
pyjwt = "*"
89
requests = "*"
910

1011
[dev-packages]
1112
black = "*"
12-
flask = "*"
13+
flask = "<2.3"
1314
importlib_metadata = "*"
1415
isort = "==5.11.4"
1516
pylint = "*"

Pipfile.lock

+76-76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Lightspark Python SDK - v1.0.0
1+
# Lightspark Python SDK - v1.1.0
22

33
The Lightspark Python SDK provides a convenient way to interact with the Lightspark services from applications written in the Python language.
44

copy.bara.sky

+28-2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,34 @@ core.workflow(
129129
],
130130
)
131131

132+
core.workflow(
133+
name = "swift-wallet-sdk-push",
134+
origin = git.github_origin(
135+
url = "https://github.com/lightsparkdev/webdev.git",
136+
ref = "main",
137+
),
138+
destination = git.github_destination(
139+
url = "https://github.com/lightsparkdev/swift-wallet-sdk.git",
140+
push = "main",
141+
),
142+
# Switch to ITERATIVE mode to import each commit separately.
143+
mode = "SQUASH",
144+
145+
origin_files = glob(
146+
["iosdev/lightspark-wallet-swift/**", "copy.bara.sky"],
147+
),
148+
149+
authoring = authoring.pass_thru("Lightspark Eng <[email protected]>"),
150+
transformations = [
151+
metadata.restore_author("ORIGINAL_AUTHOR", search_all_changes = True),
152+
metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
153+
core.todo_replace(
154+
mode = 'SCRUB_NAMES'
155+
),
156+
core.move("iosdev/lightspark-wallet-swift/", "")
157+
],
158+
)
159+
132160
core.workflow(
133161
name = "python-sdk-push",
134162
origin = git.github_origin(
@@ -157,5 +185,3 @@ core.workflow(
157185
core.move("python-sdk/", "")
158186
],
159187
)
160-
161-
# TODO: Add python-sdk-push after reworking the directory structure a bit.

examples/example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
print("")
245245

246246
# Withdraw funds!
247-
# TODO: Uncomment when withrawals are wroking again.
247+
# TODO: Uncomment when withrawals are working again.
248248
# withdrawal = client.request_withdrawal(
249249
# node_id=node_id,
250250
# amount_sats=1000,

lightspark/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
from lightspark.objects.AccountToTransactionsConnection import (
1212
AccountToTransactionsConnection,
1313
)
14+
from lightspark.objects.AccountToWalletsConnection import AccountToWalletsConnection
1415
from lightspark.objects.ApiToken import ApiToken
16+
from lightspark.objects.Balances import Balances
1517
from lightspark.objects.BitcoinNetwork import BitcoinNetwork
1618
from lightspark.objects.BlockchainBalance import BlockchainBalance
1719
from lightspark.objects.Channel import Channel
@@ -101,6 +103,7 @@
101103
from lightspark.objects.TransactionFailures import TransactionFailures
102104
from lightspark.objects.TransactionStatus import TransactionStatus
103105
from lightspark.objects.TransactionType import TransactionType
106+
from lightspark.objects.Wallet import Wallet
104107
from lightspark.objects.WebhookEventType import WebhookEventType
105108
from lightspark.objects.Withdrawal import Withdrawal
106109
from lightspark.objects.WithdrawalMode import WithdrawalMode

lightspark/__tests__/test_jwt.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from uuid import uuid4
4+
5+
import jwt
6+
7+
from lightspark import LightsparkSyncClient
8+
9+
PUBLIC_KEY = """
10+
-----BEGIN PUBLIC KEY-----
11+
MEMwBQYDK2VxAzoA5nZmdwgDoQuVF5sZlx26RdheC0JwXi1PNtnm6EaoffqFBxYO
12+
ksn8HvmMQIeDYL1Tyl/FOpOUIlIA
13+
-----END PUBLIC KEY-----
14+
"""
15+
16+
PRIVATE_KEY = """
17+
-----BEGIN PRIVATE KEY-----
18+
MEcCAQAwBQYDK2VxBDsEOaHk7Bad3cUQvHFZH3W8GHEMLcUnWIl/HD7qgndZnHfe
19+
6ZA+QXYswQmvz+ulvOwRBO1c2S46JKJMJA==
20+
-----END PRIVATE KEY-----
21+
"""
22+
23+
24+
class TestJWT:
25+
def test_generate_key(self):
26+
client = LightsparkSyncClient("", "")
27+
public, private = client.generate_jwt_key()
28+
assert "BEGIN PUBLIC KEY" in public
29+
assert "BEGIN PRIVATE KEY" in private
30+
31+
def test_create_jwt(self):
32+
client = LightsparkSyncClient("", "")
33+
user_id = str(uuid4())
34+
token = client.generate_wallet_jwt(PRIVATE_KEY, user_id)
35+
payload = jwt.decode(
36+
token,
37+
PUBLIC_KEY,
38+
algorithms=["EdDSA"],
39+
audience="https://api.lightspark.com",
40+
options={"require": ["exp", "iat", "sub"]},
41+
)
42+
assert payload["sub"] == user_id
43+
assert payload["exp"] > payload["iat"]

0 commit comments

Comments
 (0)