ckb-transaction-firewall-sdk 0.3.1

Off-chain pre-flight blacklist check for CKB transactions
Documentation
//! Testnet constants for the CKB Transaction Firewall.
//!
//! Enable with `features = ["testnet"]`.
//!
//! These values track the canonical CKB testnet deployment.
//!
//! Not suitable for mainnet use.

use crate::types::{DepType, HashType, OutPointLike, RegistrySpec, TransactionCellDep};

/// Testnet CKB RPC endpoint.
pub const RPC_URL: &str = "https://testnet.ckb.dev";

/// Governance threshold — number of signatures required for a governance update.
pub const GOVERNANCE_THRESHOLD: u8 = 3;

/// Number of validator entries in the testnet Merkle tree.
pub const GOVERNANCE_VALIDATOR_COUNT: u16 = 5;

/// The 5 secp256k1 compressed public keys that govern the testnet firewall.
/// Threshold is 3-of-5.
///
pub const GOVERNANCE_PUBKEYS: [[u8; 33]; 5] = [
    [
        0x03, 0xc6, 0x0a, 0xaf, 0x53, 0x51, 0x94, 0xf8, 0x0f, 0x45, 0xdc, 0x59, 0xe8, 0xe9, 0xd0,
        0xc4, 0x37, 0x35, 0xc6, 0xa1, 0xf2, 0xa3, 0x59, 0xeb, 0x9e, 0x42, 0xcf, 0xcf, 0x95, 0xab,
        0x76, 0x3d, 0xaf,
    ],
    [
        0x03, 0xdd, 0xee, 0xa1, 0x9e, 0xe4, 0x52, 0xac, 0xae, 0xc2, 0xfe, 0x23, 0xbe, 0x86, 0xdf,
        0xef, 0x14, 0x8e, 0xb0, 0x06, 0x15, 0x70, 0x2b, 0xbd, 0x4f, 0x28, 0x7d, 0xa6, 0x6a, 0x19,
        0x54, 0x24, 0x38,
    ],
    [
        0x03, 0x8f, 0x5f, 0xf1, 0xcb, 0xbb, 0x8e, 0x14, 0x00, 0x68, 0xf4, 0x9f, 0x67, 0x18, 0x3d,
        0xb9, 0x5e, 0x06, 0xba, 0xa2, 0x1c, 0xcf, 0x06, 0x97, 0x59, 0x89, 0x35, 0x0b, 0x8d, 0x4f,
        0xa9, 0xf2, 0xa0,
    ],
    [
        0x03, 0x99, 0x2a, 0xc4, 0xc9, 0x37, 0xd1, 0xe8, 0x80, 0xcb, 0x47, 0x9b, 0x55, 0x39, 0x15,
        0x85, 0xf2, 0xad, 0x88, 0x83, 0x5a, 0xa9, 0xac, 0xc7, 0xcd, 0x82, 0x2f, 0x91, 0x25, 0x62,
        0xd1, 0x63, 0x22,
    ],
    [
        0x02, 0x42, 0x93, 0x3e, 0xbb, 0x42, 0x76, 0xe5, 0x82, 0x0c, 0xab, 0xd2, 0xc0, 0x68, 0x45,
        0xa5, 0x8a, 0xcb, 0x8f, 0x98, 0x1f, 0xcd, 0x79, 0xa2, 0x78, 0x39, 0x86, 0xe5, 0x51, 0x34,
        0xc3, 0xfa, 0xc2,
    ],
];

/// Deployed contract cells on testnet.
///
pub mod contracts {
    use super::*;

    /// Returns the testnet firewall-lock code cell.
    pub fn firewall_lock() -> TransactionCellDep {
        TransactionCellDep {
            out_point: OutPointLike {
                tx_hash: [
                    0x12, 0x81, 0x93, 0xcc, 0x2d, 0x54, 0x7b, 0x22, 0x4c, 0xcf, 0x10, 0xa6, 0xe2,
                    0x99, 0xcb, 0x07, 0x49, 0xc6, 0x33, 0xc5, 0xf9, 0x35, 0x4f, 0xf5, 0xa9, 0xa5,
                    0xfd, 0x3e, 0x89, 0x43, 0x18, 0xd2,
                ],
                index: 0,
            },
            dep_type: DepType::Code,
        }
    }

    /// Returns the testnet blacklist-registry code cell.
    pub fn blacklist_registry() -> TransactionCellDep {
        TransactionCellDep {
            out_point: OutPointLike {
                tx_hash: [
                    0x41, 0x08, 0x64, 0xa6, 0x81, 0x5c, 0xec, 0x51, 0xcb, 0xc3, 0xa8, 0x6d, 0xfe,
                    0x5c, 0xf7, 0xc1, 0xff, 0x62, 0xf1, 0xc5, 0x66, 0x48, 0xea, 0x0a, 0x0b, 0xdb,
                    0x2f, 0xee, 0xb6, 0x83, 0x19, 0x73,
                ],
                index: 1,
            },
            dep_type: DepType::Code,
        }
    }

    /// Returns the testnet governance-lock code cell.
    pub fn governance_lock() -> TransactionCellDep {
        TransactionCellDep {
            out_point: OutPointLike {
                tx_hash: [
                    0x41, 0x08, 0x64, 0xa6, 0x81, 0x5c, 0xec, 0x51, 0xcb, 0xc3, 0xa8, 0x6d, 0xfe,
                    0x5c, 0xf7, 0xc1, 0xff, 0x62, 0xf1, 0xc5, 0x66, 0x48, 0xea, 0x0a, 0x0b, 0xdb,
                    0x2f, 0xee, 0xb6, 0x83, 0x19, 0x73,
                ],
                index: 0,
            },
            dep_type: DepType::Code,
        }
    }

    /// Returns the testnet spawn-aware-secp256k1 code cell (inner lock).
    pub fn spawn_aware_secp256k1() -> TransactionCellDep {
        TransactionCellDep {
            out_point: OutPointLike {
                tx_hash: [
                    0x0f, 0xe5, 0xd4, 0x76, 0x62, 0x72, 0x4a, 0x36, 0x20, 0xc0, 0x02, 0x68, 0x3d,
                    0x8c, 0x3f, 0x38, 0x10, 0x33, 0x59, 0xc7, 0xe1, 0xca, 0x69, 0x71, 0x96, 0xb3,
                    0x94, 0x42, 0x31, 0x7c, 0x70, 0x9e,
                ],
                index: 0,
            },
            dep_type: DepType::Code,
        }
    }
}

/// Returns the [`RegistrySpec`] for the current testnet registry cell.
///
pub fn registry_spec() -> RegistrySpec {
    RegistrySpec {
        code_hash: [
            0x58, 0x12, 0xb3, 0xf0, 0xf6, 0x8d, 0xed, 0x4d, 0x61, 0xe8, 0xf1, 0x21, 0x17, 0xca,
            0xa0, 0x11, 0xf2, 0x95, 0xdb, 0xe8, 0x8a, 0x29, 0xc0, 0x7b, 0x86, 0xc9, 0xca, 0xec,
            0x14, 0xbd, 0x6c, 0x55,
        ],
        hash_type: HashType::Type,
        type_id_value: [
            0xc7, 0x0a, 0x07, 0x2c, 0xdf, 0xb7, 0xd2, 0x5a, 0x5e, 0x92, 0xd2, 0x7a, 0x47, 0xf9,
            0xc8, 0xa0, 0xf3, 0x05, 0x13, 0xde, 0x68, 0x3e, 0x56, 0xe1, 0x6d, 0x55, 0xae, 0x30,
            0x77, 0x5f, 0x39, 0x51,
        ],
        required: true,
    }
}

/// Returns the live outpoint of the testnet registry data cell.
///
/// Moves after every governance update; always fetch fresh values from the RPC
/// before building transactions.
pub fn registry_cell() -> OutPointLike {
    OutPointLike {
        tx_hash: [
            0x68, 0x5d, 0xc4, 0x9b, 0xfe, 0x46, 0x6a, 0x19, 0x8a, 0x01, 0xab, 0xd9, 0x41, 0x17,
            0xf5, 0xfe, 0x7d, 0xd7, 0x9f, 0x28, 0x57, 0x0d, 0x6c, 0xeb, 0xa7, 0x44, 0x61, 0x6d,
            0x7a, 0xa5, 0x1e, 0xb4,
        ],
        index: 0,
    }
}