Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live BTC UTXO service #638

Closed
Sven-TBD opened this issue Apr 29, 2024 · 8 comments
Closed

Live BTC UTXO service #638

Sven-TBD opened this issue Apr 29, 2024 · 8 comments
Assignees
Labels

Comments

@Sven-TBD
Copy link
Contributor

Sven-TBD commented Apr 29, 2024

This issue is used to track the service of live BTC RGB++ UTXO which is also a key indicator of this issue. Meanwhile, this indicator will serve for other CKB team.

@Daryl-L
Copy link

Daryl-L commented Apr 29, 2024

设计草案

数据库

使用 KV 存储每个 BTC 区块被消耗的 utxo,其中
key: vin
value: block number
expiration: 1 day

流程

  1. 每个 BTC 的区块同步一次被消费的且 op return 与 commitment 规则相同的 vin,将其存入 kv 中
  2. 每个 CKB 区块同步 CKB 的交易
  3. 如果交易中 input cell 中存在有 RGB++ Cell,则从 kv 中删除对应的 vin
  4. 在下一个 BTC 区块开始后,将上一个区块中 kv 还存在的记录,同步给浏览器,确认是否解绑

初始化

鉴于目前 RGB++ Cell 量较少,一次性查询每个 Cell 对应的 utxo 是否被消费

@Keith-CY
Copy link
Member

设计草案

数据库

使用 KV 存储每个 BTC 区块被消耗的 utxo,其中 key: vin value: block number expiration: 1 day

流程

  1. 每个 BTC 的区块同步一次被消费的且 op return 与 commitment 规则相同的 vin,将其存入 kv 中
  2. 每个 CKB 区块同步 CKB 的交易
  3. 如果交易中 input cell 中存在有 RGB++ Cell,则从 kv 中删除对应的 vin
  4. 在下一个 BTC 区块开始后,将上一个区块中 kv 还存在的记录,同步给浏览器,确认是否解绑

初始化

鉴于目前 RGB++ Cell 量较少,一次性查询每个 Cell 对应的 utxo 是否被消费

不需要存储 vin, 以及校验 OP_RETURN, commitment. 流程可以简化如下

  1. 在 BTC 出块前, 同步 CKB 的 RGB++ Live Cells, 存下 RGB++ Lock, 通过 Indexer 可以做到, 也可以从浏览器 API 获取;
  2. 在 BTC 出块后, 遍历其 vin, 查看是否命中 RGB++ Lock 里的 args
  3. 将命中的 [RGB++ Lock, vin] 批量发给浏览器

这个服务是探测 BTC UTXO 是否消费, 无需订阅 CKB 节点

@Daryl-L
Copy link

Daryl-L commented May 6, 2024

设计草案

数据库

使用 KV 存储每个 BTC 区块被消耗的 utxo,其中 key: vin value: block number expiration: 1 day

流程

  1. 每个 BTC 的区块同步一次被消费的且 op return 与 commitment 规则相同的 vin,将其存入 kv 中
  1. 每个 CKB 区块同步 CKB 的交易
  1. 如果交易中 input cell 中存在有 RGB++ Cell,则从 kv 中删除对应的 vin
  1. 在下一个 BTC 区块开始后,将上一个区块中 kv 还存在的记录,同步给浏览器,确认是否解绑

初始化

鉴于目前 RGB++ Cell 量较少,一次性查询每个 Cell 对应的 utxo 是否被消费

不需要存储 vin, 以及校验 OP_RETURN, commitment. 流程可以简化如下

  1. 在 BTC 出块前, 同步 CKB 的 RGB++ Live Cells, 存下 RGB++ Lock, 通过 Indexer 可以做到, 也可以从浏览器 API 获取;

  2. 在 BTC 出块后, 遍历其 vin, 查看是否命中 RGB++ Lock 里的 args

  3. 将命中的 [RGB++ Lock, vin] 批量发给浏览器

这个服务是探测 BTC UTXO 是否消费, 无需订阅 CKB 节点

我之前这么考虑,每一次都全量匹配的话,未来 CKB 的 RGB++ Lock 数量越来越多,消耗也会越来越大

@rabbitz
Copy link

rabbitz commented May 9, 2024

Verify output cell utxo binding status

# api
POST /api/v2/bitcoin_vouts/verify

# params
{
  "outpoint": {
    "tx_hash": xxx,
    "index": xxx, 
  },
  "consumed_by": {
    "txid": xxx,
    "vin": {
      "txid": xxx,
      "index": xxx
    }
  }
}

outpoint: 用于定位需要校验的 output cell
consumed_by: 消费 utxo  btc txid  vout 对应的 index

@Daryl-L
Copy link

Daryl-L commented May 9, 2024

Verify output cell utxo binding status

# api
POST /api/v2/bitcoin_vouts/verify

# params
{
  "pointer": {
    "tx_hash": xxx,
    "index": xxx, 
  },
  "txid": xxx, 
  "consumed_by_txid": xxx
}

pointer: 用于定位需要校验的 output cell
txid: output cell lock script args 中绑定的 utxo txid
consumed_by_txid: 消费 utxo  btc txid

I think it is much better to rename the pointer to outpoint.

@rabbitz
Copy link

rabbitz commented May 10, 2024

@Daryl-L
Copy link

Daryl-L commented May 15, 2024

https://github.com/Magickbase/bitcoin-service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

5 participants