コード例 #1
0
 def test_create_new_wallet(self):
     passphrase = 'mypassphrase'
     password = '******'
     encrypt_file = True
     d = create_new_wallet(path=self.wallet_path,
                           passphrase=passphrase,
                           password=password,
                           encrypt_file=encrypt_file,
                           gap_limit=1)
     wallet = d['wallet']  # type: Standard_Wallet
     wallet.check_password(password)
     self.assertEqual(passphrase, wallet.keystore.get_passphrase(password))
     self.assertEqual(d['seed'], wallet.keystore.get_seed(password))
     self.assertEqual(encrypt_file, wallet.storage.is_encrypted())
コード例 #2
0
ファイル: test_wallet.py プロジェクト: faircoin/electrumfair
 def test_create_new_wallet(self):
     passphrase = 'mypassphrase'
     password = '******'
     encrypt_file = True
     d = create_new_wallet(path=self.wallet_path,
                           passphrase=passphrase,
                           password=password,
                           encrypt_file=encrypt_file,
                           segwit=True)
     wallet = d['wallet']  # type: Standard_Wallet
     wallet.check_password(password)
     self.assertEqual(passphrase, wallet.keystore.get_passphrase(password))
     self.assertEqual(d['seed'], wallet.keystore.get_seed(password))
     self.assertEqual(encrypt_file, wallet.storage.is_encrypted())
コード例 #3
0
    def test_create_new_wallet(self):
        passphrase = 'mypassphrase'
        password = '******'
        encrypt_file = True
        d = create_new_wallet(path=self.wallet_path,
                              passphrase=passphrase,
                              password=password,
                              encrypt_file=encrypt_file,
                              gap_limit=1,
                              config=self.config)
        wallet = d['wallet']  # type: Standard_Wallet

        # lightning initialization
        self.assertTrue(wallet.db.get('lightning_privkey2').startswith('xprv'))

        wallet.check_password(password)
        self.assertEqual(passphrase, wallet.keystore.get_passphrase(password))
        self.assertEqual(d['seed'], wallet.keystore.get_seed(password))
        self.assertEqual(encrypt_file, wallet.storage.is_encrypted())
コード例 #4
0
ファイル: quick_start.py プロジェクト: Cessaa/electrum-auxpow
from electrum.storage import WalletStorage
from electrum.wallet import Wallet, create_new_wallet
from electrum.commands import Commands


config = SimpleConfig({"testnet": True})  # to use ~/.electrum/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())
print("addr",    command_runner.getunusedaddress())
print("gettx",   command_runner.gettransaction("bd3a700b2822e10a034d110c11a596ee7481732533eb6aca7f9ca02911c70a4f"))

# but you might as well interact with the underlying methods directly
print("balance", wallet.get_balance())
コード例 #5
0
ファイル: quick_start.py プロジェクト: mrheat/electrum-doi
from electrum.storage import WalletStorage
from electrum.wallet import Wallet, create_new_wallet
from electrum.commands import Commands


config = SimpleConfig({"testnet": True})  # to use ~/.electrum-doi/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, config=config)

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

# you can use ~CLI commands by accessing command_runner
command_runner = Commands(config=config, daemon=daemon, network=network)
command_runner.wallet = wallet
print("balance", command_runner.getbalance())
print("addr",    command_runner.getunusedaddress())
print("gettx",   command_runner.gettransaction("bd3a700b2822e10a034d110c11a596ee7481732533eb6aca7f9ca02911c70a4f"))

# but you might as well interact with the underlying methods directly
print("balance", wallet.get_balance())
コード例 #6
0
ファイル: start-electrum.py プロジェクト: openware/images
    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))
            if seed is not None:
                restore_wallet_from_text(seed,
                                     path=path,
                                     password=passphrase,
                                     encrypt_file=True)
            else:
                create_new_wallet(path=path,
                                  password=passphrase,
                                  encrypt_file=True,
                                  segwit=segwit)
        wallet = d.load_wallet(path, passphrase)
        if wallet is None:
            raise Exception("Failed to load wallet")
        d.cmd_runner.wallet = wallet
        wallet.change_gap_limit( gap_limit )
        daemon.run_hook('load_wallet', wallet, None)
        d.server.register_function(lambda: wallet.get_local_height(), 'get_local_height')
        d.join()
        sys.exit(0)
    else:
        result = server.daemon(config)