code: func putCompressedScript(target, pkScript []byte) int {
  	// Pay-to-pubkey-hash script.
  	if valid, hash := isPubKeyHash(pkScript); valid {
  		target[0] = cstPayToPubKeyHash
  		copy(target[1:21], hash)
  		return 21
  	}
  
  	// Pay-to-script-hash script.
  	if valid, hash := isScriptHash(pkScript); valid {
  		target[0] = cstPayToScriptHash
  		copy(target[1:21], hash)
  		return 21
  	}
  
  	// Pay-to-pubkey (compressed or uncompressed) script.
  	if valid, serializedPubKey := isPubKey(pkScript); valid {
  		pubKeyFormat := serializedPubKey[0]
  		switch pubKeyFormat {
  		case 0x02, 0x03:
  			target[0] = pubKeyFormat
  			copy(target[1:33], serializedPubKey[1:33])
  			return 33
  		case 0x04:
  			// Encode the oddness of the serialized pubkey into the
  			// compressed script type.
  			target[0] = pubKeyFormat | (serializedPubKey[64] & 0x01)
  			copy(target[1:33], serializedPubKey[1:33])
  			return 33
  		}
  	}
  
  	// When none of the above special cases apply, encode the unmodified
  	// script preceded by the sum of its size and the number of special
  	// cases encoded as a variable length quantity.
  	encodedSize := uint64(len(pkScript) + numSpecialScripts)
  	vlqSizeLen := putVLQ(target, encodedSize)
  	copy(target[vlqSizeLen:], pkScript)
  	return vlqSizeLen + len(pkScript)
  }
docs: // putCompressedScript compresses the passed script according to the domain
  // specific compression algorithm described above directly into the passed
  // target byte slice.  The target byte slice must be at least large enough to
  // handle the number of bytes returned by the compressedScriptSize function or
  // it will panic.