CKB Pulse
经验

CKB 学到了什么

从这里开始 · 术语表 · 自测 · 订阅

经验用英文撰写,请用英文搜索。

Wallets and signing

找到 23 条经验。 全部经验

第 1 页,共 2 页

JoyID sub-key signing needs the COTA aggregator and CSP allowances实践来自一次修复

If you strip external hosts from a CCC bundle or restrict CSP connect-src, keep CCC's COTA aggregator host (cota.nervina.dev) and allow it, because the JoyID signer calls it before signing for sub-key wallets. Also allow the RPC websocket hosts your CCC client uses, such as wss://testnet.ckb.dev.

Low confidence: inferred from the commit message only. The diff showed just a rebuilt bundle.

#Witnesses and signatures #Network and RPC reliability · 来源(1) · 2026-11-16

Devnet tests need a real secp256k1 lock to exercise signing实践来自一次修复

Under an always-success lock, a test never checks that the signature covers the witnesses. That matters most when contract data shares a WitnessArgs with the signature, for example in inputType. Move the test cells to a secp256k1 lock, using its code cell and dep group from genesis, and sign with ccc.SignerCkbPrivateKey. The 20-byte lock args need 6 more CKB of capacity than the 14-byte fixture args.

#Witnesses and signatures #Testing and devnet #Capacity and cell size · 来源(1) · 2026-11-14

Do not detect DER signatures by a leading 0x30 byte实践来自一次修复

When converting secp256k1 signatures to DER for a CKB contract (here the Perun channel script, which uses k256 and expects low-S), a 64 or 65 byte compact R||S(||V) signature can begin with 0x30 because R is arbitrary. Dispatch on the fixed lengths first, and parse anything else with a full asn1.Unmarshal that has no trailing bytes, followed by a check that R and S lie in [1, n).

#Witnesses and signatures #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-11-10

Placeholder JoyID lock args are 22 bytes when quoting capacity实践来自一次修复

When quoting capacity before a wallet is connected, use a placeholder lock shaped like the wallet you expect. A JoyID lock has 22 byte args, 2 bytes more than a secp256k1 lock's 20, so every cell carrying the user's lock needs 2 CKB more occupied capacity. Pass the placeholder (for example args of 22 zero bytes) to the same quote function used after connecting, so the pre-connect total is not lower than what a JoyID user will actually commit.

#Capacity and cell size #Transaction building and fees · 来源(1) · 2026-11-10

Lock code hashes differ between testnet and mainnet for Omnilock, JoyID, ACP and PW lock实践由所有者核对

When identifying a wallet's lock by its code hash, Omnilock, JoyID, anyone-can-pay and PW lock have different code hashes on testnet and mainnet (per CCC's known scripts), while secp256k1 and multisig share one across networks. Code that compares against a single testnet hash will misclassify or fail to filter mainnet locks, so keep a hash per network (or look it up from the client's known scripts).

#Cell deps and script lookup · 来源(1) · 2026-11-08

Multisig sighash placeholder lock: script plus M zeroed signatures实践来自一次修复

When computing the signing message for a secp256k1_blake160_multisig_all input, set the first witness's WitnessArgs.lock to the multisig script bytes followed by threshold × 65 zero bytes (a single key sighash lock uses just 65 zero bytes), and keep the inputType and outputType fields, before calling CCC's tx.getSignHashInfo(script, client). The same placeholder length must be used here as in the signed witness, otherwise the message differs from what the lock script hashes on chain.

#Witnesses and signatures #Transaction building and fees · 来源(2) · 2026-11-08

secp256k1_blake160_multisig_all signature matching rules实践来自一次修复

The system multisig lock (secp256k1_blake160_multisig_all) expects the witness to carry exactly M signatures (threshold), uses each member key at most once, and requires all of the first R keys (require_first_n) to be among them. A tool collecting partial signatures should dedupe per member key and check the first R are present before finalizing, since any M valid distinct signers that include the first R form a complete set.

#Witnesses and signatures · 来源(1) · 2026-11-08

JoyID sub key signatures depend on the live CoTA cell dep holding the sub key root进阶由所有者核对

A JoyID sub key (second device) signature is checked by the JoyID lock against the sub key root held in the account's CoTA cell, which the transaction carries as a cell dep. Adding a device spends that CoTA cell and creates a new one with a new root. Two separate things follow: a transaction that still lists the old CoTA out point has a cell dep that is no longer live, and the lock run against the old root data does not accept the sub key signature.

JoyID specific: sub key root lives in the CoTA cell dep.

#Cell deps and script lookup #Witnesses and signatures · 来源(1) · 2026-11-06

One placeholder witness per input when all inputs share one lock实践来自一次修复

In this deploy builder, several funding inputs all share the owner's lock. The signing witness (WitnessArgs) goes at index 0, and every other input gets an empty "0x" witness, so the witnesses list stays as long as the inputs list. That matches the secp256k1 sighash script group layout, where the first witness of the group carries the signature and covers the rest.

#Witnesses and signatures #Transaction building and fees · 来源(1) · 2026-11-05

Binding an off-chain lock proof to the live cell deps it ran with进阶由所有者核对

When an off-chain signature proof is verified by running the lock against cell deps read live from the chain, record every out point those deps resolved to, dep group members included. Treat the resulting authorization as valid only while all of those cells are still live. A lock upgrade, a redeployment, or a key rotation or recovery in a lock that keeps its keys in a dep cell spends one of them, and the owner must prove again.

#Cell deps and script lookup #Login and authorization · 来源(1) · 2026-11-04

Count only empty, typeless lock cells as spendable balance实践来自一次修复

When computing a wallet's spendable balance from indexer cells under a lock, count only cells with empty output data and no type script as available. A cell with data or any type script (UDT, DOB, profile or attachment cells, not just your own type) holds state, so its capacity stays in the total but is reported as reserved, because spending it would destroy that state. In cemp-mobile this is `const hasData = cell.data !== "0x" && cell.data !== ""; const isProtocol = hasData || type !== null;`.

#Indexer queries and cell collection #Capacity and cell size · 来源(1) · 2026-10-31

JoyID signer prices fees with a 1,000 byte signature placeholder实践来自一次修复

With CCC and @ckb-ccc/joy-id, prepareTransaction fills the JoyID witness lock with a 1,000 byte placeholder before the fee is computed as ceil((serialized size + 4) x rate / 1000). The real signature is usually shorter (347 bytes in one testnet order), so the committed transaction is smaller and its measured rate is higher than the rate it was built at (7,278 against 5,000 shannons/KB). To recover the build rate, clone the transaction, set the JoyID witness lock back to 1,000 zero bytes, and compute the rate on that size, confirming with tx.estimateFee(rate) equal to the paid fee.

#Transaction building and fees #Witnesses and signatures · 来源(1) · 2026-10-30

第 1 页,共 2 页

文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 JSON · 想修改或撤下某条经验?请提交 issue。