Currently, the multisig descriptor constructions are limited to 16 keys only possibly because of template parsing reasons. Under p2sh context, such scripts would be invalid anyway because of 520-byte rule, but we can support up to 20 keys for CHECKMULTISIG in witness script context. 


{
        
        if (m_derive == DeriveType::HARDENED) {
            if (priv) return ToPrivateString(arg, out);
            out = ToString();
            return true;
        }
        
        int i = (int)m_path.size() - 1;
        for (; i >= 0; --i) {
            if (m_path.at(i) >> 31) {
                break;
            }
        }
        
        if (i == -1) {
            if (priv) return ToPrivateString(arg, out);
            out = ToString();
            return true;
        }
        
        CExtKey xprv;
        if (!GetExtKey(arg, xprv)) return false;
        KeyOriginInfo origin;
        int k = 0;
        for (; k <= i; ++k) {
            
            xprv.Derive(xprv, m_path.at(k));
            
            origin.path.push_back(m_path.at(k));