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:
Richard Kiss
2026-11-05 11:38:36 -08:00
committed by GitHub
parent cc45b4a52f
commit 33c8ea904f
4 changed files with 22 additions and 17 deletions
+2 -13
View File
@@ -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:
+8 -2
View File
@@ -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
View File
@@ -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())
-1
View File
@@ -240,7 +240,6 @@ depends_on = [
"chia.init",
"chia.util",
{ path = "chia.server", deprecated = false },
{ path = "chia.cmds", deprecated = false },
{ path = "chia.wallet", deprecated = false },
{ path = "chia.plotters", deprecated = false },
]