docs: def btc_tx_sign_multisig_segwit(tx, idx, prevout_amount, witness_script, private_keys, hashcode=SIGHASH_ALL, hashcodes=None, native=False):
      """
      Sign a native p2wsh or p2sh-p2wsh multisig input.
  
      @tx must be a hex-encoded tx
  
      Return the signed transaction
      """
  
      from .multisig import parse_multisig_redeemscript
  
      if hashcodes is None:
          hashcodes = [hashcode] * len(private_keys)
  
      txobj = btc_tx_deserialize(str(tx))
      privs = {}
      for pk in private_keys:
          pubk = ecdsalib.ecdsa_private_key(pk).public_key().to_hex()
  
          compressed_pubkey = keylib.key_formatting.compress(pubk)
          privs[compressed_pubkey] = pk
  
      m, public_keys = parse_multisig_redeemscript(witness_script)
  
      used_keys, sigs = [], []
      for i, public_key in enumerate(public_keys):
          if public_key not in privs:
              continue
  
          if len(used_keys) == m:
              break
  
          if public_key in used_keys:
              raise ValueError('Tried to reuse key in witness script: {}'.format(public_key))
  
          pk_str = privs[public_key]
          used_keys.append(public_key)
  
          sig = btc_tx_make_input_signature_segwit(tx, idx, prevout_amount, witness_script, pk_str, hashcodes[i])
          sigs.append(sig)
  
          # print ''
  
      if len(used_keys) != m:
          raise ValueError('Missing private keys (used {}, required {})'.format(len(used_keys), m))
     
      if native: 
          # native p2wsh
          txobj['ins'][idx]['witness_script'] = btc_witness_script_serialize([None] + sigs + [witness_script]) 
  
          # print 'segwit multisig: native p2wsh: witness script {}'.format(txobj['ins'][idx]['witness_script'])
  
      else:
          # p2sh-p2wsh
          redeem_script = btc_make_p2sh_p2wsh_redeem_script(witness_script)
          txobj['ins'][idx]['script'] = redeem_script
          txobj['ins'][idx]['witness_script'] = btc_witness_script_serialize([None] + sigs + [witness_script]) 
          
          # print 'segwit multisig: p2sh p2wsh: witness script {}'.format(txobj['ins'][idx]['witness_script'])
          # print 'segwit multisig: p2sh p2wsh: redeem script {}'.format(txobj['ins'][idx]['script'])
      
      return btc_tx_serialize(txobj)