refactor(scripts): 简化热钱包初始化脚本参数

- 只保留 --username, --threshold-n, --threshold-t 参数
- 移除 --host, --verbose, --help 参数(host 固定为 localhost:4000)
- username 改为必填参数
- 更新使用说明和错误提示

用法: ./init-hot-wallet.sh --username rwadurian-system-hot-wallet-01 --threshold-n 3 --threshold-t 2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-15 08:48:51 -08:00
parent fce8a919ff
commit c0e6e1f620
1 changed files with 10 additions and 35 deletions

View File

@ -6,26 +6,16 @@
# 用途: 创建系统热钱包的 MPC 密钥,用于提现转账 # 用途: 创建系统热钱包的 MPC 密钥,用于提现转账
# #
# 前提条件: # 前提条件:
# 1. mpc-system account-service 正在运行 (默认端口 4000) # 1. mpc-system account-service 正在运行 (端口 4000)
# 2. mpc-system session-coordinator 和 server-party 已启动 # 2. mpc-system session-coordinator 和 server-party 已启动
# 3. jq 已安装 (用于解析 JSON) # 3. jq 已安装 (用于解析 JSON)
# 4. curl 已安装 # 4. curl 已安装
# #
# 使用方法: # 使用方法:
# ./init-hot-wallet.sh [options] # ./init-hot-wallet.sh --username <wallet-name> --threshold-n <n> --threshold-t <t>
#
# 选项:
# -u, --username 热钱包用户名 (默认: system-hot-wallet)
# -n, --threshold-n 总 party 数量 (默认: 3)
# -t, --threshold-t 签名门限值 (默认: 2)
# -h, --host mpc-system account-service 地址 (默认: http://localhost:4000)
# -v, --verbose 显示详细调试信息
# --help 显示帮助
# #
# 示例: # 示例:
# ./init-hot-wallet.sh # ./init-hot-wallet.sh --username rwadurian-system-hot-wallet-01 --threshold-n 3 --threshold-t 2
# ./init-hot-wallet.sh -u my-hot-wallet -h http://192.168.1.111:4000
# ./init-hot-wallet.sh --username prod-hot-wallet --threshold-n 3 --threshold-t 2
# #
# ============================================================================= # =============================================================================
@ -39,12 +29,12 @@ BLUE='\033[0;34m'
CYAN='\033[0;36m' CYAN='\033[0;36m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
# 默认配置 # 配置 - 通过参数传入
USERNAME="system-hot-wallet" USERNAME=""
THRESHOLD_N=3 THRESHOLD_N=3
THRESHOLD_T=2 THRESHOLD_T=2
MPC_HOST="http://localhost:4000" MPC_HOST="http://localhost:4000"
VERBOSE=false VERBOSE=true
# 日志函数 # 日志函数
log_info() { log_info() {
@ -69,12 +59,6 @@ log_debug() {
fi fi
} }
# 显示帮助
show_help() {
head -35 "$0" | tail -30
exit 0
}
# 检查依赖 # 检查依赖
check_dependencies() { check_dependencies() {
log_info "检查依赖..." log_info "检查依赖..."
@ -145,20 +129,9 @@ parse_args() {
THRESHOLD_T="$2" THRESHOLD_T="$2"
shift 2 shift 2
;; ;;
-h|--host)
MPC_HOST="$2"
shift 2
;;
-v|--verbose)
VERBOSE=true
shift
;;
--help)
show_help
;;
*) *)
log_error "未知参数: $1" log_error "未知参数: $1"
echo "使用 --help 查看帮助" echo "用法: ./init-hot-wallet.sh --username <name> --threshold-n <n> --threshold-t <t>"
exit 1 exit 1
;; ;;
esac esac
@ -169,6 +142,9 @@ parse_args() {
validate_params() { validate_params() {
if [ -z "$USERNAME" ]; then if [ -z "$USERNAME" ]; then
log_error "用户名不能为空" log_error "用户名不能为空"
echo ""
echo "用法: ./init-hot-wallet.sh --username <name> --threshold-n <n> --threshold-t <t>"
echo "示例: ./init-hot-wallet.sh --username rwadurian-system-hot-wallet-01 --threshold-n 3 --threshold-t 2"
exit 1 exit 1
fi fi
@ -435,7 +411,6 @@ main() {
echo " 用户名: $USERNAME" echo " 用户名: $USERNAME"
echo " 门限: $THRESHOLD_T-of-$THRESHOLD_N" echo " 门限: $THRESHOLD_T-of-$THRESHOLD_N"
echo " MPC 服务: $MPC_HOST" echo " MPC 服务: $MPC_HOST"
echo " 详细模式: $VERBOSE"
echo "" echo ""
check_dependencies check_dependencies