名称解析
解析名称
解析一个 PIVX 名称,取得其关联的 PIVX 地址、证明细节、同步检查点以及注册数据。
端点
GET https://indexer.pivx.name/v1.0/resolve/{name}(仅解析名称)
POST https://indexer.pivx.name/v1.0/resolve/{name}(若需要额外参数)
路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
{name} | string | 是 | 要解析的 PIVX 名称(例如 richard.pivx)。 |
请求体
请求体必须是包含以下参数的 JSON 对象:
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
extended | boolean | false | 若为 true,则额外返回 domain_tx(域名注册的交易哈希)。 |
with_checkpoint | boolean | false | 若为 true,则返回索引器当前已同步到的检查点。 |
代码示例
- cURL
- JavaScript
- Python
- PHP
curl -X POST https://indexer.pivx.name/v1.0/resolve/richard.pivx \
-H "Content-Type: application/json" \
-d '{
"extended": true,
"with_checkpoint": true
}'
const url = 'https://indexer.pivx.name/v1.0/resolve/richard.pivx';
const data = {
extended: true,
with_checkpoint: true
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
import requests
url = "https://indexer.pivx.name/v1.0/resolve/richard.pivx"
payload = {
"extended": True,
"with_checkpoint": True
}
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
php
<?php
$url = 'https://indexer.pivx.name/v1.0/resolve/richard.pivx';
$data = [
'extended' => true,
'with_checkpoint' => true
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
?>
响应示例
{
"response": {
"domain_name": "bob.pivx",
"target_address": "ps12qtzaw6x3dh35xuukrqgk06e9ffx8szg2n2huqncwjsnj3ajczmklqgcx97kn63vwlge6gj2cmn",
"owner_pubkey": "1111111111111111111111111111111111111111111111111111111111111111",
"price": 250000000,
"nonce": 1780000002,
"smt_root": "5892c31e50ad3a4cf0407b91b3012a196d60c4e4f53e37261ac6747dea180eea",
"merkle_proof": [
"29bc98ae3a939618e50ba72e11a25ba30b37bb53a168a17463b9ef3fe90495d8",
"0000000000000000000000000000000000000000000000000000000000000000"
],
"proof_depth": 2,
"proof_terminal": "Occupied"
}
}
| 字段 | 类型 | 说明 |
|---|---|---|
domain_name | string | 已注册的名称 |
target_address | string | 目标 PIVX 地址 |
owner_pubkey | string | 名称持有者的公钥 |
price | int | 价格标签(用于市场) |
nonce | int | 递增的 nonce |
smt_root | string | 当前的默克尔树根(十六进制) |
| (当 with_checkpoint:false 时;否则请看 "checkpoint" 中的 SMT 根) | ||
merkle_proof | string[] | 十六进制的兄弟哈希;[0] 最深。长度等于 proof_depth |
proof_depth | int | 兄弟节点数量 — 请核对它等于 merkle_proof.length |
proof_terminal | string | object | "Occupied"、"Vacant" 或 {"Blocked":{…}} — 见下文 |
| extended: | ||
created_block_id | int | 域名创建时的 PIVX block_id |
updated_block_id | int | 域名最近一次更新时的 PIVX block_id |
domain_tx | string | 该名称注册所对应的 PIVX 交易哈希 |
| with_checkpoint: | "checkpoint" 内部的字段: | |
idx | int | 在锚定合约 rootChain 数组中的位置;检查点发现的续传游标 |
block_id | int | 最近生成的 SMT 证明所对应的 PIVX block_id |
smt_root | string | 当前的默克尔树根(十六进制) |
proof_terminal
描述证明路径末端是什么。正是它让「不存在」变得可证明,而不只是一句断言:
| 取值 | 含义 |
|---|---|
"Occupied" | 那里是该名称自己的叶子 — 解析成功。请拒绝任何终端节点不是它的解析结果。 |
"Vacant" | 那里是一棵空子树 — 名称未注册 |
{"Blocked": {"record": {…}}} | 该位置被另一个名称的叶子占据,因此所查询的名称未注册。阻塞记录被完整附上,好让你去验证这个说法,而不是被迫相信它。 |
以上全部内容的 Python、PHP 和 JavaScript 验证代码都在验证证明。
反向名称查询
提供一个 PIVX 地址即可进行反向解析:
GET/POST https://indexer.pivx.name/v1.0/resolve/reverse/{address}
POST 参数见上文说明。
按持有者查询名称
某个给定 Ed25519 公钥所拥有的全部名称。
GET/POST https://indexer.pivx.name/v1.0/resolve/owner/{Ed25519_public_key}
POST 参数见上文说明。