CKB Pulse
Lições

O 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.

salmansarwarr/Tranfr

Lições de salmansarwarr/Tranfr

github.com/salmansarwarr/Tranfr

Manténs este projeto? Confirma as lições dele num só issue

12 lições encontradas. Todas as lições

Comparing packed epoch valuesPráticoVista outra vez

Decode epochs into (number, index, length) before comparing them. Compare the fractional parts by cross-multiplying (index_a*length_b vs index_b*length_a), because epoch length varies and raw packed integers don't order correctly.

#Since and time locks · Fontes (2) · 2026-11-18

Cheque lock receiver path must return the cell's capacity to the senderPráticoDe uma correção

When a Cheque lock cell (RFC 0039) is spent on the receiver path, rule 1.b.ii requires the Cheque cell's CKB capacity to go back to the sender's lock. An output paying that CKB to the receiver fails with Cheque error 8 (SenderCapacityNotSame). So the Cheque lock cannot be used to deliver plain CKB to the receiver, and in this project's tests it also blocked an owner placed in the receiver role from reclaiming their own CKB.

#Testing and devnet #Capacity and cell size · Fontes (1) · 2026-11-09

Cheque lock sender withdrawal requires exact since 0xA000000000000006PráticoDe uma correção

The deployed Cheque lock (RFC 0039) accepts a sender withdrawal only when the Cheque input's since is exactly 0xA000000000000006 (relative epoch, 6 epochs after the cell was committed). A since of 0 fails with Cheque error 11 (WithdrawChequeInputSinceError), so the sender cannot reclaim for about 24h after each create or renew.

#Since and time locks #Testing and devnet · Fontes (1) · 2026-11-09

Iterating group inputs and outputs with ckb-std until IndexOutOfBoundPráticoDe uma correção

In a ckb-std script, walk the cells of a source with the high-level loaders, for example load_cell_type_hash(i, Source::GroupInput) or load_cell_lock_hash(j, Source::Output), in an index loop. Break on Err(SysError::IndexOutOfBound), and return a script error code for any other SysError. Accumulate the u64 capacities you load in a u128 so that a sum over many cells cannot overflow.

#Capacity and cell size #Cell deps and script lookup · Fontes (1) · 2026-11-08

Sign each lock group with its own placeholder length and witness shapePráticoVista outra vez

When one key controls several lock groups in a CCC transaction, call transaction.prepareSighashAllWitness(script, len, client) for each group with the final witness lock length of that lock, then getSignHashInfo and sign that group's own digest. In KeyWay's case the length is 65 bytes for secp256k1 and 85 bytes for an Omnilock owner witness holding one 65-byte signature; write the bare signature for secp256k1 and wrap it in the OmniLockWitnessLock molecule for Omnilock. A custom lock with its own witness layout needs its own length the same way.

#Witnesses and signatures #Transaction building and fees · Fontes (2) · 2026-10-23

Headless EIP-6963 test wallet for driving the CCC connector in PlaywrightPráticoDe uma correção

To drive CCC's real EIP-6963 connector and EVM/Omnilock signing in headless Playwright, inject a minimal EIP-1193 provider with page.addInitScript passed as a string, because transpiled function sources carry helpers such as __name that the page lacks. The provider answers eth_requestAccounts, eth_accounts and personal_sign, stubs on and removeListener, and announces itself on eip6963:announceProvider, also whenever eip6963:requestProvider fires. Signing runs in Node through page.exposeFunction so the key never enters the page, and personal_sign must return r‖s‖v with v = 27 + recovery id; noble-curves 2.x sign with format "recovered" yields recovery‖r‖s, so reorder it with hexFrom(bytesConcat(recovered.slice(1, 65), [recovered[0] + 27])) and check it against ccc.verifyMessageEvmPersonal.

#Testing and devnet #Witnesses and signatures · Fontes (1) · 2026-10-22

Carry type script and data into the output when spending a lock-only custody cellPráticoDe uma correção

When a custom lock's spend rebuilds an output from an input cell that may carry a type script (a UDT held in custody, say), copy cell.cellOutput.type and cell.outputData into the output and change only the lock; writing outputsData "0x" with no type burns or strands the token. Add the type script's cell deps to the transaction before signing, because the signature covers the cell deps and callers cannot append them afterwards, and refuse to build the spend if a typed cell comes without them. If the lock also constrains who gets the capacity (as Tranfr's recipient claim does today), follow that rule instead of a plain copy.

#Transaction building and fees #Cell deps and script lookup #Witnesses and signatures · Fontes (1) · 2026-10-21

Use getCellLive, not getCell, when a cell's current state matters in CCCPráticoDe uma correção

In CCC, client.getCell(outPoint) can also return a cell that has already been spent, so status checks built on it report claimed or reclaimed cells as still active. Use client.getCellLive(outPoint, true) and treat an undefined result as "not found or already spent".

#Indexer queries and cell collection · Fontes (1) · 2026-10-20

Re-zero the witness lock before recomputing the sign message with getSignHashInfoPráticoReproduzida

CCC's Transaction.getSignHashInfo hashes whatever is currently in the witness, so after a signature is filled in it no longer gives the signed message. To verify a signature (for example with ccc.recoverMessageSecp256k1), clone the tx and reset witness 0's lock to the zero placeholder of the same length that was used at signing time.

#Witnesses and signatures #Testing and devnet · Fontes (1) · 2026-10-14

Pass a config object, not a URL string, to ccc.ClientPublicTestnetPráticoReproduzida

In @ckb-ccc/core, the ClientPublicTestnet constructor takes an options object, so a custom RPC endpoint must be given as { url: rpcUrl } rather than as a bare string argument. This commit corrects the bare string calls in a deploy script to the object form.

#Network and RPC reliability · Fontes (1) · 2026-10-13

Porting the sighash_all signing message into a Rust lock scriptPráticoDe uma correção

To reproduce secp256k1_blake160_sighash_all's message in a ckb-std lock, hash with ckb blake2b: tx hash, then the first GroupInput witness parsed as WitnessArgs with its lock field zero filled (same length) and u64 LE length prefixed, then the other GroupInput witnesses, then every Source::Input witness at index >= the total input count (each length prefixed). The commit counts inputs by probing load_input_since until IndexOutOfBound.

#Witnesses and signatures · Fontes (1) · 2026-09-29

Treat an absent WitnessArgs.lock as a load failure in ckb-std lock scriptsPráticoDe uma correção

With ckb-std, `load_witness_args(0, Source::GroupInput)` can succeed while `WitnessArgs.lock` is an empty BytesOpt, so call `lock().to_opt()` and return an error on None before reading `raw_data()`. The commit's ckb-testtool tests check both a missing witness and a WitnessArgs with no lock field, and both fail with the load witness error.

#Witnesses and signatures #Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-09-25

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.