调试
测试环境
ord env <DIRECTORY>在<DIRECTORY>中创建一个测试环境,启动bitcoind和ord server实例,打印与测试bitcoind和ord server实例交互的示例命令,等待CTRL-C,然后关闭bitcoind和ord server。
ord env尝试使用端口9000作为bitcoind的RPC接口,以及端口9001作为ord的RPC接口,但如果这些端口被占用,它将回退到随机的未使用端口。
在env目录内部,ord env将会将bitcoind的配置写入bitcoin.conf,ord的配置写入ord.yaml,以及环境配置写入env.json。
env.json包含了调用bitcoin-cli和ord wallet所需的命令,以及bitcoind和ord server正在监听的端口信息。
这些可以使用jq提取成shell命令:
bitcoin=`jq -r '.bitcoin_cli_command | join(" ")' env/env.json`
$bitcoin listunspent
ord=`jq -r '.ord_wallet_command | join(" ")' env/env.json`
$ord outputs
如果ord在$PATH中,并且环境目录是env,那么bitcoin-cli命令将会是:
bitcoin-cli -datadir=env
ord将是
ord --datadir env
测试网络
使用以下标志来指定测试网络,可以测试 Ord。有关运行比特币核心进行测试的更多信息,请参见[比特币的开发者文档](https://developer.bitcoin.org/examples/testing。
大多数在钱包 和 浏览器 中的 ord命令可以使用以下网络标志运行:
| 网络 | 标记 |
|---|---|
| 测试网 | --testnet or -t |
| Signet | --signet or -s |
| Regtest | --regtest or -r |
Regtest不需要下载区块链或者建立ord索引
示例
在regtest里运行bitcoind,使用:
bitcoind -regtest -txindex
在regtest里运行ord server,使用:
ord --regtest server
在regtest里创建钱包
ord --regtest wallet create
创建一个regtest接收地址
ord --regtest wallet receive
挖取101个区块(解锁coinbase)使用:
bitcoin-cli -regtest generatetoaddress 101 <receive address>
在regtest上铭刻
ord --regtest wallet inscribe --fee-rate 1 --file <file>
挖取铭文
bitcoin-cli -regtest generatetoaddress 1 <receive address>
By default, browsers don't support compression over HTTP. To test compressed content over HTTP, use the --decompress flag:
ord --regtest server --decompress
测试递归
测试 recursion 时,首先记下依赖项(以 p5.js 为例:
ord --regtest wallet inscribe --fee-rate 1 --file p5.js
这应该返回一个inscription_id,然后您可以在递归铭文中引用它。
然而,铭文ID在主网和测试链之间是不同的,因此在在主网上进行最终铭文之前,你必须将你铭文中的铭文ID更改为你依赖项的主网铭文ID。
现在你可以使用以下命令来铭刻你的递归铭文:
ord --regtest wallet inscribe --fee-rate 1 --file recursive-inscription.html
最终你可以挖取一些区块来开始服务器:
bitcoin-cli generatetoaddress 6 <receive address>
主网依赖
To avoid having to change dependency inscription IDs to mainnet inscription IDs, you may utilize a content proxy when testing. ord server accepts a --proxy option, which takes the URL of another ord server instance. When making a request to /content/<INSCRIPTION_ID> when a content proxy is set and the inscription is not found, ord server will forward the request to the content proxy. This allows you to run a test ord server instance with a mainnet content proxy. You can then use mainnet inscription IDs in your test inscription, which will then return the content of the mainnet inscriptions.
ord --regtest server --proxy https://ordinals.com