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.

“Transaction building and fees”

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

Página 2 de 5

Clear the CCC client cache after a sent transaction loses a double spend racePráticoDe uma correção

A CCC client caches the outputs of every transaction it sent, so when that transaction loses a race for the same input and never commits, its change cells still look usable to later builds. This campaign calls client.cache.clear() on every client before rebuilding and confirms candidate cells with getCellLiveNoCache rather than trusting cached state.

#Indexer queries and cell collection #Transaction building and fees · Fontes (1) · 2026-10-29

A rejected or unknown get_transaction status does not make a signed transaction deadPráticoDe uma correção

A node reporting a transaction you sent as rejected or unknown does not prove it is dead: one node's answer is not proof, and while all its inputs are live the signed bytes could still be rebroadcast by someone and commit. Only release its reserved inputs if a later transaction is guaranteed to conflict with it (here a shared pool cell every later action must spend, so at most one can commit), and also require that every input is still live, that the status is still rejected or unknown when rechecked after the input reads, and that the submission is old enough (2 minutes here), behind an explicit confirmation.

#Transaction building and fees #Network and RPC reliability · Fontes (1) · 2026-10-26

Release a stuck signed transaction's inputs only after one input is spent elsewherePráticoDe uma correção

A signed CKB transaction that is not committed (not pending, proposed or sent) is still valid and can be broadcast by anyone while all its inputs are live, so do not release its input reservations yet. Release them only after a committed-state live-cell check shows at least one input spent (a spend still in the tx pool does not count), and a second status check confirms the transaction still has not committed. A conflicting spend can still be reorganized away, so require the operator to acknowledge that risk.

#Transaction building and fees #Indexer queries and cell collection #Network and RPC reliability · Fontes (2) · 2026-10-22

Computing a transaction's molecule packed size from RPC JSONAvançadoDe uma correção

A CKB Transaction's packed size (the length of get_transaction with verbosity 0) can be computed from its RPC JSON without serializing it. It is 12 (table header) + RawTransaction + witnesses. RawTransaction is 28 (table header) + 4 (version) + cell_deps (4 + 37 each) + header_deps (4 + 32 each) + inputs (4 + 44 each) + outputs + outputs_data. Each CellOutput is 16 + 8 + lock size, plus the type script size only when a type is present. Each Script is 53 + len(args). A dynvec costs 4 + 4 * count + the sum of its item sizes, and every Bytes item in outputs_data and witnesses costs 4 + len.

#Data encoding (molecule, hex, bigints) #Transaction building and fees · Fontes (1) · 2026-10-10

Use JsonRpcTransformers.transactionFrom to serialize CCC transactions for CKB/Fiber RPCPráticoReproduzida

Serializing a ccc.Transaction with ccc.stringify keeps cached input fields (cellOutput, outputData) that a native RPC such as Fiber submitSignedFundingTx does not expect. JsonRpcTransformers.transactionFrom from @ckb-ccc/core/advanced emits snake_case hex with inputs containing only previous_output and since, while keeping the tx hash and witnesses unchanged, as the commit's tests check.

#Data encoding (molecule, hex, bigints) #Transaction building and fees · Fontes (1) · 2026-09-28

ckb-cli needs --skip-check to sign and send transactions with custom locksPráticoDe uma correção

ckb-cli refuses transactions whose inputs or outputs use a lock it cannot classify (for example a custom type script based lock with 1 byte of args). `tx sign-inputs` then signs nothing, reporting `invalid lock script ... args.length` and leaving the signatures map and witness empty, and `tx send` refuses the file. Pass `--skip-check` to both sign-inputs and send; otherwise send fails with -2 ERROR_ENCODING because the secp lock reads an empty witness. Since this disables ckb-cli's own checks, run your own verifier on the signed file between sign-inputs and send.

Joined with toastmanAu/daowow@6f4cb48641.

#Witnesses and signatures #Transaction building and fees · Fontes (2) · 2026-09-26

Split CCC signTransaction from sendTransaction to retry on consumed inputsPráticoDe uma correção

When several clients race to spend the same shared cell, sign with signer.signTransaction and send with signer.client.sendTransaction as two steps instead of signer.sendTransaction. The dead-input rejection only appears at broadcast, so wrapping just the send in the retry catch lets you tell contention (re-read the live cell, rebuild, sign again) from a wallet refusal or a script verification failure, which must not be retried. Cap the attempts, because each retry costs another signature.

#Transaction building and fees #Network and RPC reliability · Fontes (1) · 2026-09-23

Persist the transaction hash before broadcasting itPráticoDe uma correção

A CKB transaction hash covers the raw transaction but not the witnesses, so after fee completion ccc tx.hash() already gives the final hash before signing. Save that hash to a durable journal before broadcasting, and assert that the hash returned by send equals it. Also assert that signing and preparation did not change the hash, so a rerun after a lost RPC reply waits for the recorded transaction instead of building and sending a duplicate.

#Transaction building and fees #Network and RPC reliability · Fontes (1) · 2026-09-18

Saving local state after the first step of a multi-step flowPráticoDe uma correção

In flows like Create followed by Arm, save local state right after the first transaction is sent. If you wait until the whole flow finishes, a failure in a later step leaves an on-chain object the user cannot find or cancel. Add the extra fields, such as the descriptor, once the later steps succeed.

#Transaction building and fees #Other · Fontes (1) · 2026-11-16

Witnesses do not follow reordered inputsPráticoDe uma correção

Witnesses are matched to inputs by position: witness i belongs to input i, and a script reading GroupInput witnesses sees the witnesses at its group's input positions. Reordering inputs does not move the witnesses, so after reordering, check and rebuild the witness list so each input's position again holds the intended witness.

#Witnesses and signatures #Transaction building and fees · Fontes (1) · 2026-11-16

Occupied capacity minimum for every outputBásicoDe uma correção

Every output must hold at least its occupied capacity: (8 for the capacity field + 33 + lock args length, plus 33 + type args length if a type script is present, plus data length) × 10^8 shannons. That is 61 CKB for a plain secp256k1 lock with 20 byte args and 63 CKB for a JoyID lock. A fixed payout or fee output set below the recipient lock's minimum is rejected, so choose a constant at or above the largest minimum among the locks you accept.

#Capacity and cell size #Transaction building and fees · Fontes (2) · 2026-11-15

Witness data in input_type and folding sub-minimum changePráticoDe uma correção

Put the type script's witness data in WitnessArgs.input_type of each input it guards (the type script reads the first witness of its own input group), so the lock field stays free for the wallet's signature and one signature can cover several such inputs. If the change left after a fixed fee is below a plain cell's minimum occupied capacity, add it to an existing output whose scripts accept extra capacity; if there is no such output, refuse the build instead of creating a cell that cannot exist.

#Witnesses and signatures #Transaction building and fees #Capacity and cell size · Fontes (1) · 2026-11-14

Página 2 de 5

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.