mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-11-06 12:50:52 -04:00
Move default_passphrase, using_default_passphrase to chia.util.keychain (#21636)
`chia.daemon` imported these two `Keychain` helpers from `chia.cmds.passphrase_funcs`. With `init_funcs` in `chia.init` (#21639), this was `chia.daemon`'s last use of `chia.cmds`, so the dependency is gone from tach.toml.
This commit is contained in:
@@ -11,8 +11,8 @@ import click
|
||||
import colorama
|
||||
|
||||
from chia.daemon.client import acquire_connection_to_daemon
|
||||
from chia.util.keychain import Keychain, supports_os_passphrase_storage
|
||||
from chia.util.keyring_wrapper import DEFAULT_PASSPHRASE_IF_NO_MASTER_PASSPHRASE, obtain_current_passphrase
|
||||
from chia.util.keychain import Keychain, default_passphrase, supports_os_passphrase_storage, using_default_passphrase
|
||||
from chia.util.keyring_wrapper import obtain_current_passphrase
|
||||
|
||||
SAVE_MASTER_PASSPHRASE_WARNING = (
|
||||
colorama.Fore.YELLOW
|
||||
@@ -219,17 +219,6 @@ def get_current_passphrase() -> str | None:
|
||||
return current_passphrase
|
||||
|
||||
|
||||
def default_passphrase() -> str:
|
||||
return DEFAULT_PASSPHRASE_IF_NO_MASTER_PASSPHRASE
|
||||
|
||||
|
||||
def using_default_passphrase() -> bool:
|
||||
if not Keychain.has_master_passphrase():
|
||||
return False
|
||||
|
||||
return Keychain.master_passphrase_is_valid(default_passphrase())
|
||||
|
||||
|
||||
def display_passphrase_hint() -> None:
|
||||
passphrase_hint = Keychain.get_master_passphrase_hint()
|
||||
if passphrase_hint is not None:
|
||||
|
||||
@@ -25,7 +25,6 @@ from chia_rs.sized_ints import uint32
|
||||
from typing_extensions import Protocol
|
||||
|
||||
from chia import __version__
|
||||
from chia.cmds.passphrase_funcs import default_passphrase, using_default_passphrase
|
||||
from chia.daemon.keychain_server import KeychainServer, keychain_commands
|
||||
from chia.daemon.windows_signal import kill
|
||||
from chia.init.init_funcs import check_keys, chia_init
|
||||
@@ -39,7 +38,14 @@ from chia.util.config import load_config
|
||||
from chia.util.errors import KeychainCurrentPassphraseIsInvalid
|
||||
from chia.util.harvester_config import add_plot_directory
|
||||
from chia.util.json_util import dict_to_json_str
|
||||
from chia.util.keychain import Keychain, KeyData, passphrase_requirements, supports_os_passphrase_storage
|
||||
from chia.util.keychain import (
|
||||
Keychain,
|
||||
KeyData,
|
||||
default_passphrase,
|
||||
passphrase_requirements,
|
||||
supports_os_passphrase_storage,
|
||||
using_default_passphrase,
|
||||
)
|
||||
from chia.util.lock import Lockfile, LockfileError, service_launch_lock_path
|
||||
from chia.util.log_exceptions import log_exceptions
|
||||
from chia.util.network import WebServer
|
||||
|
||||
+12
-1
@@ -27,7 +27,7 @@ from chia.util.errors import (
|
||||
)
|
||||
from chia.util.file_keyring import Key
|
||||
from chia.util.hash import std_hash
|
||||
from chia.util.keyring_wrapper import KeyringWrapper
|
||||
from chia.util.keyring_wrapper import DEFAULT_PASSPHRASE_IF_NO_MASTER_PASSPHRASE, KeyringWrapper
|
||||
from chia.util.streamable import Streamable, streamable
|
||||
|
||||
CURRENT_KEY_VERSION = "1.8"
|
||||
@@ -668,3 +668,14 @@ class Keychain:
|
||||
passphrase, as the passphrase hint is written as part of a passphrase update.
|
||||
"""
|
||||
Keychain.set_master_passphrase(current_passphrase, current_passphrase, passphrase_hint=passphrase_hint)
|
||||
|
||||
|
||||
def default_passphrase() -> str:
|
||||
return DEFAULT_PASSPHRASE_IF_NO_MASTER_PASSPHRASE
|
||||
|
||||
|
||||
def using_default_passphrase() -> bool:
|
||||
if not Keychain.has_master_passphrase():
|
||||
return False
|
||||
|
||||
return Keychain.master_passphrase_is_valid(default_passphrase())
|
||||
|
||||
Reference in New Issue
Block a user