Skip to content

Commit bf51905

Browse files
committed
replace python_wireguard with pywgkey
1 parent e059813 commit bf51905

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
"grpcio>=1.51.1",
2727
"bip-utils==2.9.0",
2828
"mospy-wallet @ git+https://github.com/Tkd-Alex/mospy.git@development",
29-
"python_wireguard"
29+
"pywgkey"
3030
]
3131

3232
[tool.hatch.metadata]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ sentinel-protobuf==0.3.3
22
grpcio>=1.51.1
33
bip-utils==2.9.0
44
mospy-wallet @ git+https://github.com/Tkd-Alex/mospy.git@development
5-
python_wireguard
5+
pywgkey

src/sentinel_sdk/modules/node.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from sentinel_sdk.transactor.transactor import Transactor
1919
from sentinel_sdk.types import PageRequest, TxParams, NodeType
2020

21-
from python_wireguard import Key
21+
from pywgkey import WgKey
2222

2323

2424
class NodeModule(Querier, Transactor):
@@ -164,7 +164,9 @@ def PostSession(
164164
if node_type == NodeType.WIREGUARD:
165165
# [from golang] wgPrivateKey, err = wireguardtypes.NewPrivateKey()
166166
# [from golang] key = wgPrivateKey.Public().String()
167-
_, key = Key.key_pair()
167+
wgkey = WgKey()
168+
# The private key should be used by the wireguard client
169+
key = wgkey.pubkey
168170
else: # NodeType.V2RAY
169171
# os.urandom(16)
170172
# [from golang] uid, err = uuid.GenerateRandomBytes(16)
@@ -187,7 +189,7 @@ def PostSession(
187189
signature = sk.sign(bige_session)
188190

189191
payload = {
190-
"key": f"{key}",
192+
"key": key,
191193
"signature": base64.b64encode(signature).decode("utf-8"),
192194
}
193195
return self.__post_session(

test/connect.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# pip install git+https://github.com/Tkd-Alex/mospy.git
3333
from mospy import Account, Transaction
3434
from mospy.clients import GRPCClient
35-
from python_wireguard import Key
35+
from pywgkey import WgKey
3636
from sentinel_protobuf.cosmos.base.v1beta1.coin_pb2 import Coin
3737
from sentinel_protobuf.sentinel.node.v2.msg_pb2 import MsgSubscribeRequest
3838
from sentinel_protobuf.sentinel.node.v2.querier_pb2 import QueryNodeRequest
@@ -218,7 +218,9 @@ def post_session_node(url: str, payload: dict) -> dict:
218218
break
219219

220220
# https://github.com/sentinel-official/cli-client/blob/master/cmd/connect.go#L253-L306
221-
private, public = Key.key_pair()
221+
wgkey = WgKey()
222+
private = wgkey.privkey
223+
public = wgkey.pubkey
222224

223225
prv_key = bip44_def_ctx.PrivateKey().Raw().ToBytes()
224226
sk = ecdsa.SigningKey.from_string(

0 commit comments

Comments
 (0)