def instance(cls) -> 'RPCClient':
     if cls._instance is None:
         cls._instance = cls.__new__(cls)
         cls.node_url = Config.instance().node_url
         cls.connector = aiohttp.TCPConnector(
             family=0, resolver=aiohttp.AsyncResolver())
         cls.session = aiohttp.ClientSession(connector=cls.connector,
                                             json_serialize=json.dumps)
     return cls._instance
 async def is_alive(self) -> bool:
     """Returns whether or not the remote node is alive"""
     # We could use 'block_count' or something simple
     # But some nodes may not whitelist actions like that,
     # so we test with an essential action like account_balance
     test_action = {
         'action':
         'account_balance',
         'account':
         'ban_1tipbotgges3ss8pso6xf76gsyqnb69uwcxcyhouym67z7ofefy1jz7kepoy'
         if Config.instance().banano else
         'nano_3o7uzba8b9e1wqu5ziwpruteyrs3scyqr761x7ke6w1xctohxfh5du75qgaj'
     }
     respjson = await self.make_request(test_action)
     if 'error' in respjson or 'balance' in respjson:
         return True
     return False
Ejemplo n.º 3
0
# Create sample file if not exists
config_dir = Utils.get_project_root()
sample_file = config_dir.joinpath(pathlib.PurePath('sample.config.yaml'))
real_file = config_dir.joinpath(pathlib.PurePath('config.yaml'))
if (not os.path.isfile(sample_file)
        and not os.path.isfile(real_file)) or options.generate_config:
    ref_file = pathlib.Path(__file__).parent.joinpath(
        pathlib.PurePath('sample.config.yaml'))
    shutil.copyfile(ref_file, sample_file)
    print(f"Sample configuration created at: {sample_file}")
    if options.generate_config:
        exit(0)

# Configuration
config = Config.instance()

# Set and patch nanopy
import nanopy
nanopy.account_prefix = 'ban_' if config.banano else 'nano_'
if config.banano:
    nanopy.standard_exponent = 29
    nanopy.work_difficulty = 'fffffe0000000000'

# Setup logger
if config.debug:
    logging.basicConfig(level=logging.DEBUG)
elif config.stdout:
    logging.basicConfig(level=logging.INFO)
else:
    root = logging.getLogger('aiohttp.server')
Ejemplo n.º 4
0
 def instance(cls) -> 'RPCClient':
     if cls._instance is None:
         cls._instance = cls.__new__(cls)
         cls.node_url = Config.instance().node_url
         cls.session = aiohttp.ClientSession(json_serialize=json.dumps)
     return cls._instance
Ejemplo n.º 5
0
from pippin.db.models.wallet import Wallet, WalletLocked, WalletNotFound
from pippin.db.tortoise_config import DBConfig
from tortoise import Tortoise
from tortoise.transactions import in_transaction
from pippin.util.crypt import AESCrypt, DecryptionError
from pippin.util.random import RandomUtil
from pippin.util.validators import Validators
from pippin.version import __version__

from pippin.config import Config
import os

# Set and patch nanopy
import nanopy
nanopy.account_prefix = 'ban_' if Config.instance().banano else 'nano_'
if Config.instance().banano:
    nanopy.standard_exponent = 29
    nanopy.work_difficulty = 'fffffe0000000000'

parser = argparse.ArgumentParser(description=f'Pippin v{__version__}')
subparsers = parser.add_subparsers(title='available commands', dest='command')

wallet_parser = subparsers.add_parser('wallet_list')

wallet_create_parser = subparsers.add_parser('wallet_create')
wallet_create_parser.add_argument('--seed', type=str, help='Seed for wallet (optional)', required=False)

wallet_change_seed_parser = subparsers.add_parser('wallet_change_seed')
wallet_change_seed_parser.add_argument('--wallet', type=str, help='ID of wallet to change seed for', required=True)
wallet_change_seed_parser.add_argument('--seed', type=str, help='New seed for wallet (optional)', required=False)