33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
from nacl.bindings import crypto_sign_seed_keypair
|
|
from app.core.active_config import active_config
|
|
from app.core.logger import make_log
|
|
from app.core._blockchain.ton.wallet_v3cr3 import WalletV3CR3
|
|
from os import getenv, urandom
|
|
|
|
from tonsdk.utils import Address
|
|
|
|
|
|
def load_hot_pair():
|
|
hot_seed = active_config.get('private_key')
|
|
if hot_seed is None:
|
|
make_log("HotWallet", "No seed found, generating new one", level='info')
|
|
hot_seed = urandom(32)
|
|
active_config.set('private_key', hot_seed.hex())
|
|
return load_hot_pair()
|
|
|
|
hot_seed = bytes.fromhex(hot_seed)
|
|
public_key, private_key = crypto_sign_seed_keypair(hot_seed)
|
|
return hot_seed, public_key, private_key
|
|
|
|
|
|
_extra_ton_wallet_options = {}
|
|
if getenv('TON_CUSTOM_WALLET_ADDRESS'):
|
|
_extra_ton_wallet_options['address'] = Address(getenv('TON_CUSTOM_WALLET_ADDRESS'))
|
|
|
|
hot_seed, hot_pubkey, hot_privkey = load_hot_pair()
|
|
service_wallet = WalletV3CR3(
|
|
private_key=hot_privkey,
|
|
public_key=hot_pubkey,
|
|
**_extra_ton_wallet_options
|
|
)
|