Bitcoin full node and query server

Jun 22, 2026

View in context in the libbitcoin Slack #general mirror.

evoskuil02:56
ECDSA Capture
constexpr bool script::is_pay_public_key_pattern(
    const operations& ops) NOEXCEPT
{
    return ops.size() == 2
        && is_public_key(ops[0].data())
        && ops[1].code() == opcode::checksig;
}

constexpr bool script::is_pay_key_hash_pattern(const operations& ops) NOEXCEPT
{
    return ops.size() == 5
        && ops[0].code() == opcode::dup
        && ops[1].code() == opcode::hash160
        && ops[2].data().size() == short_hash_size
        && ops[3].code() == opcode::equalverify
        && ops[4].code() == opcode::checksig;
}

constexpr bool script::is_pay_witness_key_hash_pattern(
    const operations& ops) NOEXCEPT
{
    return ops.size() == 2
        && ops[0].code() == opcode::push_size_0
        && ops[1].code() == opcode::push_size_20;
}

constexpr bool script::is_pay_multisig_standard_pattern(
    const operations& ops) NOEXCEPT
{
    if (ops.size() < 4u ||
        ops.back().code() != opcode::checkmultisig)
        return false;

    const auto& m_op = ops.front();
    const auto& n_op = ops[ops.size() - 2u];

    // Standard form is restricted to minimal encoding.
    if (!m_op.is_positive() || !n_op.is_positive())
        return false;

    const auto m = operation::opcode_to_positive(m_op.code());
    const auto n = operation::opcode_to_positive(n_op.code());

    if (is_zero(m) || is_zero(n) || (m > n) || (n > 16u) ||
        (n != ops.size() - 3u))
        return false;

    // Standard multisig requires valid public key forms.
    for (auto op = std::next(ops.begin()); op != std::prev(ops.end(), 2); ++op)
        if (!is_public_key(op->data()))
            return false;

    return true;
}