Fiber Funding Lock 约束Fiber Funding Lock Constraints

来源:nervosnetwork/fiber-scripts / contracts/funding-lock/src/main.rs · 部署:nervosnetwork/fiber config/mainnet|testnet/config.yml · mainnet 0xe45b…f4f1 / testnet 0x6c67…6d7c (type)Source: nervosnetwork/fiber-scripts / contracts/funding-lock/src/main.rs · deployments: nervosnetwork/fiber config/mainnet|testnet/config.yml · mainnet 0xe45b…f4f1 / testnet 0x6c67…6d7c (type)
Lock 脚本Lock script支付通道 / FiberPayment channel / Fiber主网Mainnet测试网Testnet开源Open sourceNervos 官方Nervos

A通道资金 → 承诺交易(双方 2-of-2 Schnorr 聚合签名)Channel funding → commitment tx (2-of-2 aggregated Schnorr)

Inputs 输入Inputs
funding cell(唯一 group 输入)funding cell (the only group input)Cell{ lock: { codeHash: FUNDING_LOCK, args: pubkey_hash 20B }, type: xUDT?, capacity }
➜
Outputs 输出Outputs
commitment cellcommitment cellCell{ lock: COMMITMENT_LOCK(...) }
args 字节布局args byte layout
pubkey_hash20B
  • pubkey_hash 20B blake160(双方 x-only 聚合公钥)blake160(x-only aggregated pubkey of both parties) ckb-auth 比对checked by ckb-auth (8)
witness 字节布局(112 字节,非 WitnessArgs)witness byte layout (112 bytes, not WitnessArgs)
empty_witness_args16B
pubkey32B
signature64B
  • empty_witness_args 16B 空 WitnessArgs 占位,兼容 xUDTempty WitnessArgs placeholder for xUDT compatibility = 0x10000000…10000000= 0x10000000…10000000 (7)
  • pubkey 32B x-only 聚合公钥(Schnorr 无法恢复公钥)x-only aggregated pubkey (Schnorr cannot recover it) blake160 = argsblake160 = args (8)
  • signature 64B MuSig2 聚合签名MuSig2 aggregated signature 覆盖 blake2b(raw tx 去掉 cell_deps)over blake2b(raw tx without cell_deps) (8)

限制Constraints

  • inputs:: group 中只能有 1 个输入exactly 1 input in the group (5)
  • witness:: 长度恰为 112 = 16 + 32 + 64length exactly 112 = 16 + 32 + 64 (6)
  • witness[0..16] = 空 WitnessArgs 占位= empty WitnessArgs placeholder (7)
  • signature:: exec ckb-auth(Schnorr,算法 7),消息 = blake2b(raw tx 去掉 cell_deps)(未检查)exec ckb-auth (Schnorr, algorithm 7), message = blake2b(raw tx without cell_deps) (not checked) (8)
部署与来源Deployments & source 未核验unverified
源码source nervosnetwork/fiber-scripts@e7e1c9ba · contracts/funding-lock/src/main.rs (commit read when writing this spec)
二进制核验binary check 未核验unverified hash appears in the repo only as a deployment record or doc, which does not prove the recorded commit builds this binary (reproducible build not attempted)
0x17b1910fbc…67716e47: listed in deployment/mainnet/migrations/2026-01-14-030304.json; listed in deployment/testnet/migrations/2025-11-25-060540.json
网络networkcode_hashcell_deptype_id args数据哈希data hash部署交易deploy tx
mainnet0xe45b1f8f21bff23137035a3ab751d75b36a981deec3e7820194b9c042967f4f1 type0x95006eee7b…c720b9d6:1 code0x64818d82a3…dc2433940x17b1910fbc…67716e470x95006eee7b…c720b9d6 #18372567
testnet0x6c67887fe201ee0c7853f1682c0b77c0e6214044c156c7558269390a8afa6d7c type0x12c569a258…79dd14a7:1 code0x3cb7c0304f…569f10f60x17b1910fbc…67716e470x12c569a258…79dd14a7 #19249889
链上数据核对于 on-chain data checked 2026-10-20
错误码(main.rs Error):1 IndexOutOfBound · 2 ItemMissing · 3 LengthNotEnough · 4 Encoding · 5 MultipleInputs · 6 WitnessLenError · 7 EmptyWitnessArgsError · 8 AuthErrorError codes (main.rs Error): 1 IndexOutOfBound · 2 ItemMissing · 3 LengthNotEnough · 4 Encoding · 5 MultipleInputs · 6 WitnessLenError · 7 EmptyWitnessArgsError · 8 AuthError
消息不含 cell_deps,因此可在不重签的情况下替换依赖(例如合约升级后)The message omits cell_deps, so deps can be swapped without re-signing (e.g. after an upgrade)
GitHub · gpBlockchain/ckb-contract-flow-html