Skip to content

Transaction » Default Outputs Validator

Quake Wang edited this page Sep 28, 2021 · 8 revisions

Before v0.100.0

RPC send_transaction Default Outputs Validator

Outputs validator prevents improperly formed transactions from entering the tx-pool, in most cases the leading cause of client sending these transactions is simply because of bug code or misusing SDK, which results in a none-unlockable transaction.

Implementation details

CKB provides two built-in validators, default and passthrough. Only ckb v0.28.0 uses default as the default validator and other versions use passthrough.

For default validator, these checks should conform to the pseudocode described below

transaction.outputs.all{ |output|
    script = output.script
    (script.code_hash == secp256k1_blake160_sighash_all && script.hash_type == "type" && script.args.size == 20) ||
    (script.code_hash == secp256k1_blake160_multisig_all && script.hash_type == "type" && (script.args.size == 20 || (script.args.size == 28 && script.args[20..28].is_valid_since_format))
}
transaction.outputs.all{ |output|
    script = output.type
    script.is_null || script.code_hash == dao && script.hash_type == "type"
}

For passthrough validator, it will skip validation.

Since v0.100.0, including its rc and beta versions

RPC send_transaction Default Outputs Validator

Outputs validator prevents improperly formed transactions from entering the tx-pool, in most cases the leading cause of client sending these transactions is simply because of bug code or misusing SDK, which results in a none-unlockable transaction.

Implementation details

CKB provides two built-in validators, well_known_scripts_only and passthrough. When no validator is specified, well_known_scripts_only is used.

For well_known_scripts_only validator, these checks should conform to the pseudocode described below

transaction.outputs.all{ |output|
    script = output.script
    (script.code_hash == secp256k1_blake160_sighash_all && script.hash_type == "type" && script.args.size == 20) ||
    (script.code_hash == secp256k1_blake160_multisig_all && script.hash_type == "type" && (script.args.size == 20 || (script.args.size == 28 && script.args[20..28].is_valid_since_format))
}
transaction.outputs.all{ |output|
    script = output.type
    script.is_null || script.code_hash == dao && script.hash_type == "type"
}

Please refer to well known scripts list: https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0024-ckb-system-script-list/0024-ckb-system-script-list.md

User can add additional well known scripts to the configuration file ckb.toml, or use passthrough validator to skip outputs validation.

[[rpc.extra_well_known_lock_scripts]]
code_hash = "0x9799bee251b975b82c45a02154ce28cec89c5853ecc14d12b7b8cccfc19e0af4"
hash_type = "type"
args = "0x"

[[rpc.extra_well_known_lock_scripts]]
code_hash = "0x43400de165f0821abf63dcac299bbdf7fd73898675ee4ddb099b0a0d8db63bfb"
hash_type = "type"
args = "0x"

[[rpc.extra_well_known_type_scripts]]
code_hash = "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8"
hash_type = "type"
args = "0x"