LiçõesO que a CKB aprendeu
Começa aqui · Glossário · Testa-te · Feed
As lições estão escritas em inglês, por isso pesquise em inglês.
Prático ✕
174 lições encontradas. Todas as lições
AnteriorPágina 11 de 15Seguinte
To expose a remote secp256k1 key as a CCC signer, extend ccc.SignerCkbPublicKey(client, publicKey) and override signOnlyTransaction and signMessageRaw to call the backend. The address and lock come from the public key, and signMessageRaw must sign in the "Nervos Message:" format so signMessage and verifyMessage keep working. SignerCkbPublicKey also reports anyone-can-pay addresses of the key, whose cells a backend that only signs the secp256k1 lock cannot spend, so override getAddressObjs to return only the lock you can sign (ckb-keyway had to do this later).
#Witnesses and signatures · Fontes (1) · 2026-10-12
CCC's ccc-connector element emits close before it announces a newly chosen wallet, every time. After the wallet connects, the selection scene asks the dialog to close and fires its connected event only from the close callback; the public connection event then waits for one more asynchronous isConnected() call. Treating close as a cancel therefore loses the connection. On close, check whether a wallet was chosen (the example reads el.walletName and el.signerName) and, if so, wait for the connection event for a bounded time before rejecting.
Checked against the CCC source in @ckb-ccc/connector 2.3.2 (9ffef01) and 2.4.0 (e10b99d): scenes/selecting/index.ts (connectSigner) and connector/index.ts (close, handleConnected, updateSigner).
#Login and authorization · Fontes (1) · 2026-10-12
The CKB light client keeps reporting a script, with its block number, from get_scripts until you register a new script set that leaves it out. A sync poll that runs between your local delete and that set_scripts call will still see the removed script. Do not let that poll recreate local per script progress for an owner that no longer exists, and clear that progress again once the new set is registered while polling is excluded.
#Indexer queries and cell collection #Network and RPC reliability · Fontes (1) · 2026-10-11
Before consuming a deployed code cell, call indexer get_cells across the whole chain with script_search_mode "prefix" and args "0x", once as lock and once as type. Query the cell's data hash with hash_type data, data1 and data2, and for a Type ID cell also its type script hash with hash_type type. Zero results only means no live cell uses the binary right now. Consuming the cell is irreversible, and a Type ID identity cannot be recreated, so treat unused Type ID cells with extra caution.
#Cell deps and script lookup #Indexer queries and cell collection #Type ID and upgrades · Fontes (2) · 2026-10-10
A type script that checks a newly created output can read its proof from WitnessArgs.output_type, but the script decides which witness to read: tactus-o1's state proof script loads absolute witness 0 (Source::Input, index 0), not a witness matched to the output index. If that witness is also the first witness of the secp lock group, put the proof in its output_type field next to the 65 byte lock placeholder, and it is covered by the lock signature because the sighash keeps the other WitnessArgs fields and zeroes only the lock.
#Witnesses and signatures · Fontes (1) · 2026-10-10
With the CKB light client, a DAO withdrawing cell older than the script's sync start is never returned by the scan, and the phase-2 unlock output is a plain cell that does not point back at it. So absence from the scan cannot mark the position spent: retire it only when the unlock transaction is confirmed (a verified local inclusion, or getTransactionStatus reporting committed on the node), keep it shown as confirming while the unlock is in flight, and never treat an unreachable node or an unknown transaction as a spend.
#Indexer queries and cell collection #Other · Fontes (2) · 2026-10-09
A molecule table or dynvec (Script, CellOutput, WitnessArgs) is serialized as a u32 total size, then one u32 offset per field, then the fields. There is no separate count; readers derive it from the first offset. An absent Opt field takes zero bytes, so its offset equals the next offset, or the total size if it is last. A hand-rolled encoder that inserts a u32 count after the total size, as this commit's dyn_collection does, produces malformed molecule.
#Data encoding (molecule, hex, bigints) #Witnesses and signatures · Fontes (1) · 2026-10-09
When locating a Type Script group off chain, match input and output cells by the blake2b hash of the complete Script (code_hash, hash_type, args), never by code hash alone. By convention (RFC 22 for lock groups), a group's witness sits at the transaction index of its first input, or of its first output if the group has no inputs. CKB does not enforce this: the script picks which witness it reads, and which WitnessArgs field (input_type or output_type) holds the data is the protocol's own choice.
#Witnesses and signatures #Transaction building and fees · Fontes (1) · 2026-10-09
To check that a Script points at a given deployed code Cell, compare its code_hash with ckb blake2b256 of the Cell's output data when hash_type is data, data1 or data2 (0, 2, 4), and with the hash of that Cell's Type Script when hash_type is type (1). A type selection needs the code Cell to actually carry a Type Script, and other hash_type values are rejected.
#Cell deps and script lookup #Data encoding (molecule, hex, bigints) · Fontes (2) · 2026-10-09
CKB picks the VM version from the Script hash_type: data (0) runs VM0, data1 (2) runs VM1, data2 (4) runs VM2, and type (1) runs the latest activated VM. Code deployed for VM2 and pinned by data hash must be referenced with hash_type data2. The same code hash with data or data1 still resolves to the same cell but runs under an older VM, so tooling should reject those hash types for a VM2 target rather than only checking that the code hash matches.
#Cell deps and script lookup #Type ID and upgrades · Fontes (1) · 2026-10-09
With the bundled secp256k1 blake160 sighash lock, all inputs sharing the same lock form one group even when another owner's inputs sit between them. The signature goes in the witness at the group's first input index, and changing a later group witness (which leaves the tx hash unchanged) still fails verification at Inputs[first].Lock. So composed multi owner transactions must place one signature placeholder per lock group at its first input and finalize every group witness before signing.
#Witnesses and signatures #Transaction building and fees · Fontes (1) · 2026-10-09
A locally maintained index of CKB blocks can lag the node or still hold an orphaned block after a reorg, so before serving its tip as an anchor, fetch the node's tip number, wait briefly for the index to reach it, then ask the node for the canonical block hash at the indexed height and refuse (503 with NOT_SYNCED or REORGANIZING) unless it equals the indexed hash. The check narrows the window but is not atomic, so a client that signs over the anchor should also compare it with an independent source.
#Network and RPC reliability #Indexer queries and cell collection · Fontes (1) · 2026-10-08
AnteriorPágina 11 de 15Seguinte
Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. JSON · Queres que uma lição seja mudada ou retirada? Abre um issue.