startup errors fix #1
This commit is contained in:
parent
e51bb86dc0
commit
4cca40a626
|
|
@ -12,7 +12,8 @@ RUN apt-get update && apt-get install -y \
|
|||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
lsb-release && \
|
||||
lsb-release \
|
||||
ffmpeg && \
|
||||
install -m 0755 -d /etc/apt/keyrings && \
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \
|
||||
chmod a+r /etc/apt/keyrings/docker.asc && \
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ async def s_api_v1_auth_me(request):
|
|||
WalletConnection.invalidated == False
|
||||
)
|
||||
).order_by(WalletConnection.created.desc())
|
||||
))).scalars().first()
|
||||
)).scalars().first()
|
||||
|
||||
return response.json({
|
||||
'user': request.ctx.user.json_format(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import asyncio
|
||||
from os import getenv, urandom
|
||||
import os
|
||||
|
||||
|
|
@ -6,31 +5,16 @@ from nacl.bindings import crypto_sign_seed_keypair
|
|||
from tonsdk.utils import Address
|
||||
|
||||
from app.core._blockchain.ton.wallet_v3cr3 import WalletV3CR3
|
||||
from app.core.models._config import ServiceConfig
|
||||
from app.core.storage import db_session
|
||||
from app.core.logger import make_log
|
||||
|
||||
|
||||
async def load_hot_pair_async():
|
||||
async with db_session() as session:
|
||||
service_config = ServiceConfig(session)
|
||||
hot_seed = await service_config.get('private_key')
|
||||
if hot_seed is None:
|
||||
make_log("HotWallet", "No seed found, generating new one", level='info')
|
||||
hot_seed_env = os.getenv("TON_INIT_HOT_SEED")
|
||||
if not hot_seed_env:
|
||||
hot_seed_bytes = urandom(32)
|
||||
make_log("HotWallet", f"Generated random seed")
|
||||
else:
|
||||
hot_seed_bytes = bytes.fromhex(hot_seed_env)
|
||||
make_log("HotWallet", f"Loaded seed from env")
|
||||
|
||||
await service_config.set('private_key', hot_seed_bytes.hex())
|
||||
hot_seed = hot_seed_bytes.hex()
|
||||
|
||||
hot_seed_bytes = bytes.fromhex(hot_seed)
|
||||
public_key, private_key = crypto_sign_seed_keypair(hot_seed_bytes)
|
||||
return hot_seed_bytes, public_key, private_key
|
||||
def _load_seed_from_env_or_generate() -> bytes:
|
||||
seed_hex = os.getenv("TON_INIT_HOT_SEED")
|
||||
if seed_hex:
|
||||
make_log("HotWallet", "Loaded seed from env")
|
||||
return bytes.fromhex(seed_hex)
|
||||
make_log("HotWallet", "No seed provided; generating ephemeral seed", level='info')
|
||||
return urandom(32)
|
||||
|
||||
|
||||
_extra_ton_wallet_options = {}
|
||||
|
|
@ -39,14 +23,14 @@ if getenv('TON_CUSTOM_WALLET_ADDRESS'):
|
|||
|
||||
|
||||
def _init_wallet():
|
||||
# Safe to call at import time; Sanic event loop not running yet
|
||||
hot_seed, hot_pubkey, hot_privkey = asyncio.run(load_hot_pair_async())
|
||||
hot_seed_bytes = _load_seed_from_env_or_generate()
|
||||
pub, priv = crypto_sign_seed_keypair(hot_seed_bytes)
|
||||
wallet = WalletV3CR3(
|
||||
private_key=hot_privkey,
|
||||
public_key=hot_pubkey,
|
||||
private_key=priv,
|
||||
public_key=pub,
|
||||
**_extra_ton_wallet_options
|
||||
)
|
||||
return hot_seed, hot_pubkey, hot_privkey, wallet
|
||||
return hot_seed_bytes, pub, priv, wallet
|
||||
|
||||
|
||||
hot_seed, hot_pubkey, hot_privkey, service_wallet = _init_wallet()
|
||||
|
|
|
|||
Loading…
Reference in New Issue