Esempio n. 1
0
 def setUpClass(cls):
     super().setUpClass()
     constants.set_testnet()
Esempio n. 2
0
    "verbosity": 3,
    # "oneserver": True,
    "noonion": True,
}

_logger = get_logger(__name__)

if __name__ == '__main__':
    passphrase = os.getenv("WALLET_PASSPHRASE")
    segwit = os.getenv("SEGWIT") == "true"

    if passphrase is None:
        raise Exception("WALLET_PASSPHRASE unset")

    if cmdline_options["testnet"]:
        constants.set_testnet()

    config = SimpleConfig(cmdline_options)
    logging.configure_logging(config)
    fd, server = daemon.get_fd_or_server(config)

    if fd is not None:
        init_plugins(config, 'cmdline')
        d = daemon.Daemon(config, fd)
        path = config.get_wallet_path()
        if os.path.exists(path) is False:
            _logger.warn(
                "Wallet doesn't exist, creating (segwit {segwit})".format(
                    segwit=segwit))
            create_new_wallet(path=path,
                              password=passphrase,
Esempio n. 3
0
import os

from electrum_ltc.simple_config import SimpleConfig
from electrum_ltc import constants
from electrum_ltc.daemon import Daemon
from electrum_ltc.storage import WalletStorage
from electrum_ltc.wallet import Wallet, create_new_wallet
from electrum_ltc.commands import Commands

config = SimpleConfig({"testnet":
                       True})  # to use ~/.electrum-ltc/testnet as datadir
constants.set_testnet()  # to set testnet magic bytes
daemon = Daemon(config, listen_jsonrpc=False)
network = daemon.network
assert network.asyncio_loop.is_running()

# get wallet on disk
wallet_dir = os.path.dirname(config.get_wallet_path())
wallet_path = os.path.join(wallet_dir, "test_wallet")
if not os.path.exists(wallet_path):
    create_new_wallet(path=wallet_path, segwit=True)

# open wallet
storage = WalletStorage(wallet_path)
wallet = Wallet(storage)
wallet.start_network(network)

# you can use ~CLI commands by accessing command_runner
command_runner = Commands(config, wallet=None, network=network)
command_runner.wallet = wallet
print("balance", command_runner.getbalance())
Esempio n. 4
0
 def setUpClass(cls):
     super().setUpClass()
     constants.set_testnet()