forked from wusimpl/atommical-js-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathord-tool.bat
280 lines (223 loc) · 8.06 KB
/
ord-tool.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
@echo off
setlocal enabledelayedexpansion
chcp 65001 > nul
::*****************作者个人信息***************************
:: author : wusimpl ::
:: date : 2023.11.11 ::
:: version: v0.9 ::
:: contact: https://twitter.com/wusimpl ::
::********************************************************
::*******************************可改动区域*******************************************************
rem 比特币全节点数据目录
set BITCOIN_DATA_DIR=D:\bitcoin\blockdata
rem ord索引目录(index.redb所在目录)
set ORDDATA_DIR=C:\ordindex
rem 比特币节点cookie文件的路径(一般在比特币全节点根目录下)
rem set COOKIE_PATH=C:\Users\wusimpl\bitcoin_index_data\.cookie
rem ord命令行工具的目录(尾部请不要加\)
set ORD_CLI_DIR=D:\bitcoin\ord-0.10.0
rem 连接比特币节点的rpc url
rem set RPC_URL=--rpc-url http://localhost:8332
set RPC_URL=--rpc-url http://10.110.87.78:8332
rem 除了cookie的第二种认证方式,任选一种,另外一种留空就行
set AUTH=--bitcoin-rpc-pass 80308400 --bitcoin-rpc-user wusimpl
::**************************************************************************************************
::*************************必看的说明****************************
:: 第三个功能【显示地址】需要有python环境,没有python的自己安装
:: python下载地址:https://www.python.org/downloads/
::****************************************************************
set COOKIE=--cookie-file %COOKIE_PATH%
if NOT "%COOKIE_PATH%"=="" (
set ORD_BASE_CMD=ord --bitcoin-data-dir %BITCOIN_DATA_DIR% --data-dir %ORDDATA_DIR% %RPC_URL% %COOKIE%
) else (
set ORD_BASE_CMD=ord --bitcoin-data-dir %BITCOIN_DATA_DIR% --data-dir %ORDDATA_DIR% %RPC_URL% %AUTH%
)
echo %ORD_BASE_CMD%
:menu
rem cls
echo *************************************************************************
echo * *
echo * Ord管理工具 *
echo * *
echo * *
echo * [1] 创建钱包 [2] 导入钱包 [3] 显示地址 *
echo * *
echo * [4] mint BRC20铭文 [5] 查看铭文 [6] 发送铭文 *
echo * *
echo * [7] 查看待处理交易 [8] 查看钱包余额 [0] 退出 *
echo * *
echo * [9] 以文件方式mint Ordinals *
echo * *
echo * *
echo *************************************************************************
echo.
set /p choice=请输入选项数字:
if "%choice%"=="1" goto create_wallet
if "%choice%"=="2" goto import_wallet
if "%choice%"=="3" goto generate_address
if "%choice%"=="4" goto create_inscription
if "%choice%"=="5" goto view_inscriptions
if "%choice%"=="6" goto send_inscription
if "%choice%"=="7" goto view_transactions
if "%choice%"=="8" goto view_ord_balance
if "%choice%"=="9" goto mint_ordinals
if "%choice%"=="0" exit
echo 无效选项,请重新输入。
rem pause
goto menu
:create_wallet
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
%ORD_BASE_CMD% --wallet %WALLET_NAME% wallet create
pause
goto menu
:import_wallet
set /p seed_phrase=请输入BIP39种子短语:
set /p wallet_name=请为钱包命名:
%ORD_BASE_CMD% --wallet %wallet_name% wallet restore "%seed_phrase%"
pause
goto menu
:generate_address
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
set json_address_full_path=%ORD_CLI_DIR%\address.json
%ORD_BASE_CMD% --wallet %WALLET_NAME% wallet receive > %json_address_full_path%
type %json_address_full_path%
for /f "delims=" %%i in ('echo %btc_address% ^| python %ORD_CLI_DIR%\get_address.py %json_address_full_path%') do set ADDRESS=%%i
pip install qrcode > nul 2>&1
pip install pillow > nul 2>&1
pip install qrcode-terminal > nul 2>&1
python -c "import qrcode_terminal; qrcode_terminal.draw('%ADDRESS%')"
pause
goto menu
:create_inscription
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
set /p tick=tick:
set /p amt=amount(留空则默认1000):
if "%amt%"=="" (
set amt=1000
)
set token_file={"p":"brc20","op":"mint","tick":"%tick%","amt":"%amt%"}
echo 铭文文件信息:%token_file%
echo %token_file% > token.txt
set /p repeat_mint=重复mint的数量(留空则默认只打1张):
if "%repeat_mint%"=="" (
set repeat_mint=1
)
call :fetch_fees
set /p fee_rate=请指定fee_rate:
if "%fee_rate%"=="" (
set fee_rate=20
)
echo.
set ORD_CMD=%ORD_BASE_CMD% --wallet %WALLET_NAME% wallet inscribe --file token.txt --fee-rate %fee_rate%
echo 执行命令:%ORD_CMD%
echo.
echo.
set counter=1
:mint_loop
if %counter% leq %repeat_mint% (
echo 正在mint第%counter%张...
set /a counter=%counter% + 1
call %ORD_CMD%
goto mint_loop
)
pause
rem del token.txt ;no need to delete this file actually
goto menu
:mint_ordinals
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
set /p file_path=文件路径(最好是全路径):
set /p repeat_mint=重复mint的数量(留空则默认只打1张):
if "%repeat_mint%"=="" (
set repeat_mint=1
)
call :fetch_fees
set /p fee_rate=请指定fee_rate:
if "%fee_rate%"=="" (
set fee_rate=20
)
echo.
set ORD_CMD=%ORD_BASE_CMD% --wallet %WALLET_NAME% wallet inscribe --file %file_path% --fee-rate %fee_rate%
echo 执行命令:%ORD_CMD%
echo.
echo.
set counter=1
:mint_loop
if %counter% leq %repeat_mint% (
echo 正在mint第%counter%张...
set /a counter=%counter% + 1
call %ORD_CMD%
goto mint_loop
)
pause
rem del token.txt ;no need to delete this file actually
goto menu
:view_inscriptions
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
%ORD_BASE_CMD% --wallet %WALLET_NAME% wallet inscriptions
pause
goto menu
:send_inscription
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
set /p fee_rate=请指定fee_rate:
if "%fee_rate%"=="" (
set fee_rate=20
)
set /p address=请输入接收地址:
call :fetch_fees
set /p inscription_id=请输入铭文ID:
%ORD_BASE_CMD% wallet send --fee-rate %fee_rate% %address% %inscription_id%
pause
goto menu
:view_transactions
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
%ORD_BASE_CMD% --wallet %WALLET_NAME% wallet transactions
pause
goto menu
:view_ord_balance
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
echo **********************************
%ORD_BASE_CMD% --wallet %WALLET_NAME% wallet balance
echo 提示:该余额不包含铭文中所携带的聪
echo **********************************
pause
goto menu
:view_sats_balance
set /p wallet_name=请输入钱包名称(留空则为ord):
if "%wallet_name%"=="" (
set wallet_name=ord
)
%ORD_BASE_CMD% --wallet %WALLET_NAME% wallet sats
pause
goto menu
:: 获取费率函数
:fetch_fees
echo 正在获取链上gas price...
for /f "delims=" %%a in ('curl -sSL "https://mempool.space/api/v1/fees/recommended"') do set fees=%%a
echo.
echo 当前链上费率(sats/vB):%fees%
echo.
goto:eof