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 (fAnyoneCanPay)
            nInput = nIn;
        
        ::Serialize(s, txTo.vin[nInput].prevout);
        
        if (nInput != nIn)
            
            ::Serialize(s, CScript());
        else
            SerializeScriptCode(s);
        
        if (nInput != nIn && (fHashSingle || fHashNone))
            
            ::Serialize(s, (int)0);
        else
            ::Serialize(s, txTo.vin[nInput].nSequence);
    }
    
    template<typename S>
    void SerializeOutput(S &s, unsigned int nOutput) const {