CKB Pulse

Todas as lições · CKB node, RPC and indexer · Começa aqui · Glossário

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

De uma correção · Verificação: certa · Verificada em 2026-11-19

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.

Porque importa: Without the exact molecule layout, a tool cannot confirm the node's reported packed transaction size from RPC JSON. The cross-check against the measured node wire bytes would then fail or be skipped.

Padrão

Preferir
return 12 + raw_size + dynamic([4 + len(raw(v)) for v in tx['witnesses']])

Tirado do commit, encurtado.

Conceitos
Data encoding (molecule, hex, bigints), Transaction building and fees
Evidência
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-10-10
Última mudança
2026-10-10
Última verificação
2026-11-19
Verificação contra o commit
certa: a lição sai do commit e continua a valer no código de hoje

Fontes (1)

Mais sobre CKB node, RPC and indexer

Ver as 45 deste tema

Manténs um projeto de onde esta lição veio? Confirma ou corrige

Citar esta lição
LusoCryptoLabs, "Computing a transaction's molecule packed size from RPC JSON", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/computing-a-transaction-s-molecule-packed-size-from-rpc-json, CC BY 4.0, last changed 2026-10-10.

Tiradas de commits públicos e verificadas contra o commit de onde cada uma veio e o código de hoje do projeto. Lê a fonte antes de confiar numa. Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. Queres que uma lição seja mudada ou retirada? Abre um issue.