electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 42da407ee16784eb6e2d1f1c644f77d97d7c3007
parent c64da9448fb521ce5433c2d63f826afe1fc42b33
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue, 25 Aug 2020 16:22:59 +0200

scripts: update quick_start.py to work with 4.0.x internals

fixes #6453

Diffstat:
Melectrum/scripts/quick_start.py | 21+++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/electrum/scripts/quick_start.py b/electrum/scripts/quick_start.py @@ -1,12 +1,19 @@ +#!/usr/bin/env python3 + import os +import asyncio from electrum.simple_config import SimpleConfig from electrum import constants from electrum.daemon import Daemon from electrum.storage import WalletStorage from electrum.wallet import Wallet, create_new_wallet +from electrum.wallet_db import WalletDB from electrum.commands import Commands +from electrum.util import create_and_start_event_loop, log_exceptions + +loop, stopping_fut, loop_thread = create_and_start_event_loop() config = SimpleConfig({"testnet": True}) # to use ~/.electrum/testnet as datadir constants.set_testnet() # to set testnet magic bytes @@ -21,18 +28,20 @@ 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 = daemon.load_wallet(wallet_path, password=None, manual_upgrades=False) 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")) +print("balance", network.run_from_another_thread(command_runner.getbalance(wallet=wallet))) +print("addr", network.run_from_another_thread(command_runner.getunusedaddress(wallet=wallet))) +print("gettx", network.run_from_another_thread( + command_runner.gettransaction("bd3a700b2822e10a034d110c11a596ee7481732533eb6aca7f9ca02911c70a4f"))) + # but you might as well interact with the underlying methods directly print("balance", wallet.get_balance()) print("addr", wallet.get_unused_address()) print("gettx", network.run_from_another_thread(network.get_transaction("bd3a700b2822e10a034d110c11a596ee7481732533eb6aca7f9ca02911c70a4f"))) + +stopping_fut.set_result(1) # to stop event loop