全部经验 · CCC (TypeScript SDK) · 从这里开始 · 术语表
completeFeeBy adds change instead of shrinking outputs, breaking output bound proofs实践来自一次修复
来自一次修复 · 核对结果:正确 · 核对于 2026-11-19
When a lock script commits to output 0's exact bytes (capacity included), the capacity must be decided before proving and must equal what the transaction ships. In CCC, tx.completeFeeBy(signer) pays the fee by pulling in the signer's cells and adding a change output, so output 0 keeps its capacity and the fee is then paid from extra inputs, which breaks the binding if the proof assumed inputCapacity minus fee. Instead compute the fee from tx.toBytes().length with the witness already at its final length, build output 0 at inputCapacity minus that fee, and check before sending that the fee recomputed on the real transaction equals the planned one.
为什么重要: The context was computed for output 0 at inputCapacity minus fee, but completeFeeBy left output 0 at inputCapacity and added a change output, so every bound unlock was rejected on chain with ContextMismatch.
代码模式
await tx.completeFeeBy(signer);摘自提交,已缩短。
同一提交中改动了测试
它与修复在一起,我们没有运行它。
- CECILIA-MULANDI/zk-Lock:
sdk/ts/test/bound.test.ts
已由测试复现
一个公开的测试在 @ckb-ccc/core 1.23.1 上运行这条经验所说的内容,无需节点。任何人都可以运行。 它覆盖了这条经验的一部分: what completeFeeBy does to the transaction, not the lock that commits to output 0.
tests/ccc/complete-fee-by-adds-change.test.mjs
- 概念
- Transaction building and fees, Witnesses and signatures, Capacity and cell size
- 证据
- 来自一次修复: 来自一个项目,已对照其提交核对
- 首次出现
- 2026-11-04
- 最近改动
- 2026-11-04
- 最近核对
- 2026-11-19
- 对照提交的核对结果
- 正确:这条经验出自该提交,并且在今天的代码中仍然成立
来源(1)
- 2026-11-04 · CECILIA-MULANDI/zk-Lock · 这个项目的更多经验
更多关于CCC (TypeScript SDK)
- Deriving minimum cell capacity with ccc.CellOutput.from and output data
- Reserve co-signer witness space before completeFeeBy in multi-signer CCC transactions
- Sign each lock group with its own placeholder length and witness shape
引用这条经验
LusoCryptoLabs, "completeFeeBy adds change instead of shrinking outputs, breaking output bound proofs", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/completefeeby-adds-change-instead-of-shrinking-outputs-break, CC BY 4.0, last changed 2026-11-04.